示例#1
0
function decrypt($txt, $key = '')
{
    strlen($key) > 5 or $key = DT_KEY;
    $str = mycrypt(str_replace(array('-P-', '-S-', '-Z-', '-X-'), array('+', '/', '0x', '0X'), $txt), $key, 'DECODE');
    return substr($str, -3) == substr($key, 0, 3) ? substr($str, 0, -3) : '';
}
示例#2
0
文件: img.php 项目: vluo/myPoto
 function thumb()
 {
     date_default_timezone_set('UTC');
     $params = $_SERVER["QUERY_STRING"];
     $config = loader::config();
     $params = mycrypt($params, $config['img_path_key'], 'DE');
     $params = @unserialize($params);
     if (!$params['path']) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found!');
         exit;
     }
     $path = $params['path'];
     $this->realpath = get_realpath(ROOTDIR . $path);
     if (isset($params['guard']) && $params['guard']) {
         //防盗链代码,具体代码需要在插件中实现
         include_once INCDIR . 'plugin.php';
         $plugin =& loader::lib('plugin');
         $Config =& loader::config();
         if (!$Config['safemode']) {
             $plugin->init_plugins();
         }
         $plugin->trigger('output_image', $path);
     }
     $this->pathCheck();
     //不处理图片直接输出
     if (isset($params['donothing']) && $params['donothing']) {
         $this->responseImg();
         return;
     }
     $this->cache_dir = ROOTDIR . 'cache/dimgs/';
     $this->param['w'] = isset($params['w']) ? intval($params['w']) : 0;
     //intval(getGet('w',0));
     $this->param['h'] = isset($params['h']) ? intval($params['h']) : 0;
     //intval(getGet('h',0));
     $this->param['zoom'] = isset($params['zoom']) ? intval($params['zoom']) : 0;
     //getGet('zoom',0);
     $open_cache = isset($params['cache']) ? intval($params['cache']) : 0;
     $cache_key = md5($path . $this->param['w'] . $this->param['h'] . $this->param['zoom']);
     $this->cache_subdir = $this->cache_dir . substr($cache_key, 0, 2);
     $this->cache_file = $this->cache_subdir . '/' . $cache_key . '.php';
     if ($this->browserCache()) {
         //尝试浏览器缓存
         exit;
     }
     if ($open_cache) {
         //如果开启了服务器缓存
         $this->cleanCache();
         if ($this->serverCache()) {
             //尝试服务器缓存
             exit;
         }
         if (!$this->processImage()) {
             //处理图片
             exit('Process image failed!');
         }
         if ($this->writeToCache()) {
             //写入缓存
             $this->serverCache();
         }
     } else {
         if (!$this->processImage()) {
             exit('Process image failed!');
         }
         $this->outputImg();
         //直接输出图片
         $this->imgHandler->close();
     }
 }