Browse Source

add cache enabled optional

pull/7/head
ghost 3 years ago
parent
commit
5de0a77ccc
  1. 1
      config-default.php
  2. 10
      public/image.php

1
config-default.php

@ -9,6 +9,7 @@ error_reporting(E_ALL);
define('BASE_URL', 'https://kvazar.today'); define('BASE_URL', 'https://kvazar.today');
define('PAGE_LIMIT', 10); define('PAGE_LIMIT', 10);
define('SEF_MODE', true); define('SEF_MODE', true);
define('CACHE_ENABLED', false);
// Database // Database
define('DB_HOST', 'localhost'); define('DB_HOST', 'localhost');

10
public/image.php

@ -1,11 +1,14 @@
<?php <?php
require_once('../config.php');
require_once('../library/icon.php'); require_once('../library/icon.php');
if (isset($_GET['hash'])) { if (isset($_GET['hash'])) {
header("Content-Type: image/jpeg"); header("Content-Type: image/jpeg");
if (CACHE_ENABLED) {
$filename = dirname(__FILE__) . '/../cache/' . $_GET['hash'] . '.jpeg'; $filename = dirname(__FILE__) . '/../cache/' . $_GET['hash'] . '.jpeg';
if (!file_exists($filename)) { if (!file_exists($filename)) {
@ -16,4 +19,11 @@ if (isset($_GET['hash'])) {
} }
echo file_get_contents($filename); echo file_get_contents($filename);
} else {
$icon = new Icon();
echo $icon->generateImageResource(md5($_GET['hash']), 60, 60, false);
}
} }

Loading…
Cancel
Save