Esempio n. 1
0
 function static_data_refresh()
 {
     $type = jget('type');
     if (!in_array($type, array('app', 'content', 'login', 'other', 'role', 'user', 'verify'))) {
         exit('type is invalid');
     }
     $ret = array();
     $other_logic = jlogic('other');
     $func = 'get' . ucfirst($type) . 'Statistics';
     if (method_exists($other_logic, $func)) {
         $cache_id = 'misc/' . $type . '_statistics';
         cache_file('rm', $cache_id);
         if ($type == 'other') {
             cache_file('rm', 'misc/data_length');
         }
         $ret = $other_logic->{$func}();
     }
     #生成html代码
     $head_html = "<tr class='altbg1'>";
     $body_html = "<tr class='altbg2'>";
     if ($ret) {
         foreach ($ret['data'] as $k => $v) {
             $head_html .= "<td>{$v['name']}</td>";
             $body_html .= "<td>{$v['num']}</td>";
         }
     }
     $head_html .= "</tr>";
     $body_html .= "</tr>";
     echo $head_html . $body_html;
     exit;
 }
Esempio n. 2
0
 function get_sign_tag($get = 'tags')
 {
     if (false === ($rets = cache_file('get', $cache_id = $this->cache_id('list')))) {
         $rets = $this->row();
         if ($rets) {
             if ($rets['tag']) {
                 $arr = explode("\r\n", $rets['tag']);
                 $tags = array();
                 foreach ($arr as $tag) {
                     $tag = trim($tag);
                     if ($tag) {
                         $tags[$tag] = $tag;
                     }
                 }
                 $rets['tags'] = $tags;
             }
         } else {
             $rets = array();
         }
         cache_file('set', $cache_id, $rets);
     }
     if ($get && isset($rets[$get])) {
         return $rets[$get];
     }
     return $rets;
 }
Esempio n. 3
0
File: cache.php Progetto: VSG24/ccms
function cache_page($content)
{
    if (false !== ($f = @fopen(cache_file(), 'w'))) {
        gzencode(fwrite($f, $content), 9);
        fclose($f);
    }
    return $content;
}
Esempio n. 4
0
function cache_images($images)
{
    rrmdir(__DIR__ . '/img');
    mkdir(__DIR__ . '/img');
    foreach ($images as $id => $image) {
        cache_file(get_raw_url($image->path), __DIR__ . '/img/' . basename($image->path));
    }
}
function cache_page($content)
{
    $f = fopen(cache_file(), 'w');
    if (false !== $f) {
        fwrite($f, gzcompress($content));
        fclose($f);
    }
    return $content;
}
 function cache_rm($mod)
 {
     $mod = jfilter($mod, 'txt');
     if ($mod) {
         parent::cache_rm($mod);
         cache_file('rm', 'role_action/' . $mod . '-0');
         cache_file('rm', 'role_action/' . $mod . '-1');
     }
 }
Esempio n. 7
0
 function guest()
 {
     $cache_id = 'role/guest';
     if (false === ($row = cache_file('get', $cache_id))) {
         $row = $this->row(1);
         $row['uid'] = 0;
         $row['role_id'] = 1;
         $row['nickname'] = $row['role_name'] = '游客';
         $row['username'] = '******';
         cache_file('set', $cache_id, $row);
     }
     return $row;
 }
Esempio n. 8
0
 public function get_tag_by_top_topic_count($limit, $dateline = 0, $cache_time = 0)
 {
     $tags = array();
     $limit = max(0, (int) $limit);
     if ($limit > 0) {
         $dateline = max(43200, (int) $dateline);
         $cache_time = max(300, (int) $cache_time);
         $cache_id = "misc/topic-new-tag-{$limit}-{$dateline}";
         if (!$cache_time || false === ($tags = cache_file('get', $cache_id))) {
             $tags = DB::fetch_all("select `id`,`name`,`topic_count`,`last_post` from `" . TABLE_PREFIX . "tag` \r\n\t\t\t\t\twhere `last_post` > '" . (TIMESTAMP - $dateline) . "' \r\n\t\t\t\t\torder by `topic_count` desc \r\n\t\t\t\t\tlimit {$limit}");
             if ($cache_time) {
                 cache_file('set', $cache_id, $tags, $cache_time);
             }
         }
     }
     return $tags;
 }
Esempio n. 9
0
 function _memberlist($where = '', $limit = 20, $orderby = 'uid', $query_link = '')
 {
     $per_page_num = (int) $limit;
     $cache_time = 300;
     $cache_id = jtable('members')->cache_id('people-_memberlist-count-' . md5($where));
     if (false === ($total_record = cache_file('get', $cache_id))) {
         $sql = " select count(*) as `total_record` from `" . TABLE_PREFIX . "members` {$where} ";
         $total_record = DB::result_first($sql);
         cache_file('set', $cache_id, $total_record, $cache_time);
     }
     if ($total_record > 0) {
         $page_arr = page($total_record, $per_page_num, $query_link, array('return' => 'array'));
         $wherelist = " {$where} order by `{$orderby}` desc {$page_arr['limit']} ";
         $cache_id = jtable('members')->cache_id('people-_memberlist-' . md5($wherelist));
         if (false === ($members = cache_file('get', $cache_id))) {
             $members = $this->TopicLogic->GetMember($wherelist, "`uid`,`ucuid`,`media_id`,`aboutme`,`username`,`nickname`,`face_url`,`face`,`validate`,`validate_category`,`province`,`city`");
             cache_file('set', $cache_id, $members, $cache_time);
         }
         $members = buddy_follow_html($members, 'uid', 'follow_html2');
     }
     $ret_ary = array('member' => $members, 'pagearr' => $page_arr);
     return $ret_ary;
 }
Esempio n. 10
0
<?php

require "system.php";
set_time_limit(30);
// Cachen von gespeicherten Übungen
if (isset($_GET['data_id'])) {
    $data = $database->query('SELECT data FROM data WHERE id = ' . intval($_GET['data_id']))->fetchColumn();
    list($url, $text) = split_data($data);
    if (!$url) {
        header("HTTP/1.1 404 Not found");
        die('<DOCTYPE HTML><h1>Not found</h1>');
    }
    try {
        $_GET['cache_id'] = cache_file($url, false, true, 3600 * 24);
    } catch (Exception $e) {
        // Geht anscheinend nicht - dann leiten wir halt weiter auf das Original
        header('Location: ' . $url);
        die;
    }
}
// Daten direkt aus dem Cache laden
$cache_id = $_GET['cache_id'];
$cache_file = $cache_dir . basename($cache_id);
$query = $database->prepare('SELECT * FROM cache WHERE id = ?');
$query->execute(array($cache_id));
$cache_object = $query->fetch(PDO::FETCH_OBJ);
if (!$cache_object || !file_exists($cache_file)) {
    header("HTTP/1.1 404 Not found");
    die('<DOCTYPE HTML><h1>Not found</h1>');
}
header('Content-disposition: attachment; filename="' . addcslashes($cache_object->filename, '"') . '"');
Esempio n. 11
0
if (is_dir('pdftk')) {
    $execute = 'LD_LIBRARY_PATH=pdftk pdftk/pdftk ';
} else {
    $execute = 'pdftk ';
}
$final_cache_id = '';
foreach ($combine as $data) {
    list($url, $title) = split_data($data['data']);
    if (!$url) {
        continue;
    }
    if (preg_match('/cache_id=([^&]+)/', $url, $match)) {
        $cache_id = basename($match[1]);
    } else {
        try {
            $cache_id = cache_file($url, false, true, 3600 * 24);
        } catch (Exception $e) {
            status_message("Dieser Dienst funktioniert nur mit PDF-Dateien");
            gotop("index.php");
        }
    }
    if (substr(get_mime_type($cache_dir . $cache_id), 0, 15) != 'application/pdf') {
        status_message("Dieser Dienst funktioniert nur mit PDF-Dateien");
        gotop("index.php");
    }
    $execute .= escapeshellarg($cache_dir . $cache_id) . ' ';
    $final_cache_id .= $cache_id;
}
$final_cache_id = sha1($final_cache_id);
$execute .= ' output ' . escapeshellarg($cache_dir . $final_cache_id);
if (!file_exists($cache_dir . $final_cache_id)) {
Esempio n. 12
0
function cache_underscore() {
    cache_file(UNDERSCOREJS_URL, UNDERSCOREJS_PATH);
}
 function get_maps()
 {
     $cache_id = $this->cache_id('get_maps', 1);
     if (false === ($rets = cache_file('get', $cache_id))) {
         $rets = $this->get(array('sql_order' => ' `id` ASC ', 'result_list_key_is_pri' => 1));
         if ($rets['list']) {
             $min = 1;
             $table_id = '';
             foreach ($rets['list'] as $k => $v) {
                 $table_id = $v['id'];
                 $v['max'] = $v['uid'];
                 $v['min'] = $min;
                 $min = $v['max'];
                 $rets['list'][$k] = $v;
             }
             $rets['table_id'] = $table_id;
         } else {
             $rets = $rets ? $rets : array();
         }
         cache_file('set', $cache_id, $rets);
     }
     return $rets;
 }
Esempio n. 14
0
                print "Pages non trouv&eacute;e";
                die;
            }
        }
    } else {
        $_GET["la_langue"] = $_GET["la_langue"] != "" ? $_GET["la_langue"] : __defaultlangueid__;
        $_GET["arbre"] = 0;
        //verification si le site est publié
        $sql = "select etat_id from " . __racinebd__ . "arbre where arbre_id=" . __defaultfather__;
        $link = query($sql);
        $tbl_etat = fetch($link);
        if ($tbl_etat["etat_id"] == $_GET["etat_id"]) {
            cache_file("tpl/index.php", array($_GET, $_POST, $_SESSION), $_SERVER["PATH_INFO"]);
        } else {
            if (file_exists($_SERVER["DOCUMENT_ROOT"] . __racine__ . "tpl/maintenance.php")) {
                cache_file("tpl/maintenance.php", array($_GET, $_POST, $_SESSION), $_SERVER["PATH_INFO"]);
            } else {
                print "Site en maintenance";
                die;
            }
        }
    }
    if ($_GET["mode"] == "view") {
        ?>
    <div style="position:absolute;top:0px;left:0px;color:red;font-family:arial;font-size:12px;background:gray;font-weight:bold;padding:5px 5px 5px 5px">PREVIEW</div>
    <?php 
    }
    if (__showtime__) {
        print "<br>" . round(microtime(true) - $starttime, 2) . " s<br>";
    }
}
Esempio n. 15
0
 function Main()
 {
     $config = jconf::get('robot');
     $order_by = $this->Get['order_by'] ? $this->Get['order_by'] : "today_times";
     $order_type = $this->Get['order_type'] ? $this->Get['order_type'] : "desc";
     $toggle_order_type = $order_type == "desc" ? "asc" : "desc";
     ${$order_by} = "order_" . $order_type;
     include_once ROOT_PATH . 'include/logic/robot.logic.php';
     $RobotRogic = new RobotLogic();
     $turnon_radio = $this->jishigou_form->YesNoRadio('config[turnon]', (int) $config['turnon'], '', 'class="radio"');
     if ($config['turnon']) {
         if (false === ($robot_list = cache_file('get', $cache_id = 'robot/list'))) {
             $sql = "SELECT * FROM " . $RobotRogic->tableName;
             $query = $this->DatabaseHandler->Query($sql);
             $robot_list = array();
             while (false != ($row = $query->GetRow())) {
                 if ($row['times'] < 10) {
                     continue;
                 }
                 $row['link'] = preg_replace("/.*?(((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k):\\/\\/)|(www\\.))([^\\[\"'\\s\\)\\(\\;]+))|([a-z0-9\\_\\-.]+@[a-z0-9]+\\.[a-z0-9\\.]{2,}))*/i", "\\1", $row['agent']);
                 if (strpos($row['link'], '@') !== false) {
                     $row['link'] = "mailto:" . $row['link'];
                 }
                 if ($row['link'] && strpos($row['link'], ":") === false) {
                     $row['link'] = "http:/" . "/" . $row['link'];
                 }
                 $row['first_visit_timestamp'] = $row['first_visit'];
                 $row['first_visit'] = my_date_format($row['first_visit']);
                 $row['last_visit_timestamp'] = $row['last_visit'];
                 $row['last_visit'] = my_date_format($row['last_visit']);
                 if ($this->ad) {
                     $show_ad = isset($config['list'][$row['name']]['show_ad']) ? (int) $config['list'][$row['name']]['show_ad'] : 1;
                     $row['show_ad_radio'] = $this->jishigou_form->YesNoRadio("config[list][{$row['name']}][show_ad]", $show_ad, '', "class='radio'");
                 }
                 $row['today_times'] = 0;
                 $row['name'] = trim($row['name']);
                 $robot_list[$row['name']] = $row;
             }
             cache_file('set', $cache_id, $robot_list, 3600);
         }
         $name_list = array();
         foreach ($robot_list as $row) {
             if ($row['last_visit_timestamp'] + 86400 > TIMESTAMP) {
                 $name_list[] = $row['name'];
             }
         }
         if (!empty($name_list) && count($name_list) >= 0) {
             $names = jimplode($name_list);
             include_once ROOT_PATH . 'include/logic/robot_log.logic.php';
             $RobotLogLogic = new RobotLogLogic("");
             $sql = "SELECT * FROM {$RobotLogLogic->tableName}\r\n\t\t\t\twhere\r\n\t\t\t\t\t`name` in({$names})\r\n\t\t\t\t\tand `date`='{$RobotLogLogic->date}'";
             $query = $this->DatabaseHandler->Query($sql);
             while ($row = $query->GetRow()) {
                 if (isset($robot_list[$row['name']])) {
                     $robot_list[$row['name']]['today_times'] = $row['times'];
                 }
             }
         }
         if (is_array($robot_list) && sizeof($robot_list) > 0) {
             foreach ($robot_list as $key => $value) {
                 $order_by_list[$key] = $value[$order_by];
             }
             array_multisort($order_by_list, constant(strtoupper("sort_" . $order_type)), $robot_list);
         }
         if (sizeof($robot_list) > 0 && false === ($robot_ip_list = cache_file('get', $cache_id = 'robot/ip_list'))) {
             $robot_ip_list = array();
             $sql = "SELECT ip,name from {$RobotRogic->tableName}_ip GROUP BY `name` order by `last_visit` DESC";
             $query = $this->DatabaseHandler->Query($sql, "SKIP_ERROR");
             if ($query != false) {
                 while ($row = $query->GetRow()) {
                     $robot_ip_list[$row['name']][] = $row['ip'];
                 }
                 if (!empty($robot_ip_list)) {
                     foreach ($robot_ip_list as $_robot => $_ip_list) {
                         if (sizeof($_ip_list) > 5) {
                             $ip_list = array();
                             $ip_list_count = 0;
                             foreach ($_ip_list as $_ip) {
                                 $ip = substr($_ip, 0, strrpos($_ip, ".")) . ".*";
                                 $ip_list[$ip] = $ip;
                                 $ip_list_count++;
                                 if ($ip_list_count > 10) {
                                     break;
                                 }
                             }
                             $robot_ip_list[$_robot] = $ip_list;
                         }
                     }
                 }
             }
             cache_file('set', $cache_id, $robot_ip_list, 3600);
         }
     }
     include template("admin/robot");
 }
Esempio n. 16
0
 function DoExport()
 {
     global $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
     $excepttables = array(TABLE_PREFIX . "sessions", TABLE_PREFIX . "cache");
     $time = $timestamp = time();
     $tablepre = TABLE_PREFIX;
     $this->DatabaseHandler->Query('SET SQL_QUOTE_SHOW_CREATE=1', 'SKIP_ERROR');
     $filename = get_param('filename');
     if (!$filename || preg_match("/(\\.)(exe|php|jsp|asp|aspx|cgi|fcgi|pl)(\\.|\$)/i", $filename) || !preg_match('~^[\\w\\d\\-\\_]+$~', $filename)) {
         $this->Messager("备份文件名无效");
     }
     $type = get_param('type');
     $setup = get_param('setup');
     $customtables = get_param('customtables');
     $startrow = get_param('startrow');
     $extendins = get_param('extendins');
     $usehex = get_param('usehex');
     $usezip = get_param('usezip');
     $sizelimit = get_param('sizelimit');
     $volume = (int) get_param('volume');
     $method = 'multivol';
     $sqlcharset = get_param('sqlcharset');
     $sqlcompat = get_param('sqlcompat');
     if ($type == 'all_tables') {
         $tables = $this->_array_keys2($this->_fetch_table_list($tablepre), 'Name');
     } elseif ($type == 'custom') {
         $tables = array();
         $cache_id = "tables";
         if (empty($setup)) {
             $tables = cache_file('get', $cache_id);
         } else {
             cache_file('set', $cache_id, $customtables);
             $tables =& $customtables;
         }
         if (!is_array($tables) || empty($tables)) {
             $this->Messager("没有要导出的数据表");
         }
     }
     $volume = intval($volume) + 1;
     $idstring = '# Identify: ' . base64_encode("{$timestamp}," . SYS_VERSION . ",{$type},{$method},{$volume}") . "\n";
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $this->Config['charset']);
     $setnames = $sqlcharset && $this->DatabaseHandler->GetVersion() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41') ? "SET NAMES '{$dumpcharset}';\n\n" : '';
     if ($this->DatabaseHandler->GetVersion() > '4.1') {
         if ($sqlcharset) {
             $this->DatabaseHandler->Query("SET NAMES '" . $sqlcharset . "';\n\n");
         }
         if ($sqlcompat == 'MYSQL40') {
             $this->DatabaseHandler->Query("SET SQL_MODE='MYSQL40'");
         } elseif ($sqlcompat == 'MYSQL41') {
             $this->DatabaseHandler->Query("SET SQL_MODE=''");
         }
     }
     $f = str_replace(array('/', '\\', '.'), '', $filename);
     $f = dir_safe($f);
     $backupdir = 'db/' . $f;
     $backupfilename = './data/backup/' . $backupdir . '/' . $f;
     if (!is_dir($d = dirname($backupfilename))) {
         jio()->MakeDir($d);
     }
     if ($usezip) {
         require_once ROOT_PATH . 'include/func/zip.func.php';
     }
     if ($method == 'multivol') {
         $sqldump = '';
         $tableid = intval(get_param('tableid'));
         $startfrom = intval(get_param('startfrom'));
         $complete = TRUE;
         for (; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
             $sqldump .= $this->_sql_dump_table($tables[$tableid], $startfrom, strlen($sqldump));
             if ($complete) {
                 $startfrom = 0;
             }
         }
         $dumpfile = $backupfilename . "-%s" . '.sql';
         !$complete && $tableid--;
         if (trim($sqldump)) {
             $sqldump = "{$idstring}" . "# <?php exit(); ?>\n" . "# JishiGou Multi-Volume Data Dump Vol.{$volume}\n" . "# Version: JishiGou " . SYS_VERSION . "\n" . "# Time: {$time}\n" . "# Type: {$type}\n" . "# Table Prefix: {$tablepre}\n" . "#\n" . "# JishiGou Home: http:\\/\\/www.jishigou.net\n" . "# Please visit our website for newest infomation about JishiGou\n" . "# --------------------------------------------------------\n\n\n" . "{$setnames}" . $sqldump;
             $dumpfilename = sprintf($dumpfile, $volume);
             $fp = fopen($dumpfilename, 'wb');
             flock($fp, 2);
             if (!fwrite($fp, $sqldump)) {
                 fclose($fp);
                 $this->Messager("备份文件写入失败,请检查是否有足够的权限或联系管理员");
             } else {
                 fclose($fp);
                 if ($usezip == 2) {
                     $fp = @fopen($dumpfilename, "r");
                     $content = @fread($fp, filesize($dumpfilename));
                     fclose($fp);
                     $zip = new zipfile();
                     $zip->addFile($content, basename($dumpfilename));
                     $fp = @fopen(sprintf($backupfilename . "-%s" . '.zip', $volume), 'w');
                     if (fwrite($fp, $zip->file()) !== FALSE) {
                         @unlink($dumpfilename);
                     }
                     fclose($fp);
                 }
                 unset($sqldump, $zip, $content);
                 $this->Messager("分卷备份: 数据文件 #{$volume} 成功创建,程序将自动继续。\r\n", "admin.php?mod=db&code=doexport&type=" . rawurlencode($type) . "&saveto=server&filename=" . rawurlencode($filename) . "&method=multivol&sizelimit=" . rawurlencode($sizelimit) . "&volume=" . rawurlencode($volume) . "&tableid=" . rawurlencode($tableid) . "&startfrom=" . rawurlencode($startrow) . "&extendins=" . rawurlencode($extendins) . "&sqlcharset=" . rawurlencode($sqlcharset) . "&sqlcompat=" . rawurlencode($sqlcompat) . "&exportsubmit=yes&usehex={$usehex}&usezip={$usezip}");
             }
         } else {
             $volume--;
             $filelist = '<ul>';
             if ($usezip == 1) {
                 $zip = new zipfile();
                 $zipfilename = $backupfilename . '.zip';
                 $unlinks = array();
                 for ($i = 1; $i <= $volume; $i++) {
                     $filename = sprintf($dumpfile, $i);
                     $fp = @fopen($filename, "r");
                     $content = @fread($fp, filesize($filename));
                     fclose($fp);
                     $zip->addFile($content, basename($filename));
                     $unlinks[] = $filename;
                     $filelist .= "<li><a href=\"{$filename}\">{$filename}</a></li>\n";
                 }
                 $fp = @fopen($zipfilename, 'w');
                 if (fwrite($fp, $zip->file()) !== FALSE) {
                     foreach ($unlinks as $f) {
                         jio()->DeleteFile($f);
                     }
                 } else {
                     $this->Messager('database_export_multivol_succeed');
                 }
                 unset($sqldump, $zip, $content);
                 fclose($fp);
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $zipfilename;
                 $this->Messager("数据成功备份并压缩至服务器  data/backup/db/ 目录下。<br />" . (true === JISHIGOU_FOUNDER ? $filelist : ""), null);
             } else {
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 for ($i = 1; $i <= $volume; $i++) {
                     $filename = sprintf($usezip == 2 ? $backupfilename . "-%s" . '.zip' : $dumpfile, $i);
                     $filelist .= "<li><a href=\"{$filename}\">{$filename}</a></li>\n";
                 }
                 $this->Messager("恭喜您,全部 {$volume} 个备份文件成功创建,备份完成。\r\n" . (true === JISHIGOU_FOUNDER ? $filelist : "<br />文件备份在  data/backup/db/ 目录下"), null);
             }
         }
     } else {
         $tablesstr = '';
         foreach ($tables as $table) {
             $tablesstr .= '"' . $table . '" ';
         }
         $query = $this->DatabaseHandler->Query("SHOW VARIABLES LIKE 'basedir'");
         list(, $mysql_base) = $query->GetRow('row');
         $dumpfile = addslashes(dirname(dirname(__FILE__))) . '/' . $backupfilename . '.sql';
         @unlink($dumpfile);
         $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base) . 'bin/';
         @shell_exec($mysqlbin . 'mysqldump --force --quick ' . ($this->DatabaseHandler->GetVersion() > '4.1' ? '--skip-opt --create-options' : '-all') . ' --add-drop-table' . ($extendins == 1 ? ' --extended-insert' : '') . '' . ($this->DatabaseHandler->GetVersion() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '') . ' --host="' . $this->Config['db_host'] . ($this->Config['db_port'] ? is_numeric($this->Config['db_port']) ? ' --port=' . $this->Config['db_port'] : ' --socket="' . $this->Config['db_port'] . '"' : '') . '" --user="******" --password="******" "' . $this->Config['db_name'] . '" ' . $tablesstr . ' > ' . $dumpfile);
         if (is_file($dumpfile)) {
             if ($usezip) {
                 require_once ROOT_PATH . 'include/func/zip.func.php';
                 $zip = new zipfile();
                 $zipfilename = $backupfilename . '.zip';
                 $fp = @fopen($dumpfile, "r");
                 $content = @fread($fp, filesize($dumpfile));
                 fclose($fp);
                 $zip->addFile($idstring . "# <?exit();?>\n " . $setnames . "\n #" . $content, basename($dumpfile));
                 $fp = @fopen($zipfilename, 'w');
                 fwrite($fp, $zip->file());
                 fclose($fp);
                 @unlink($dumpfile);
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $backupfilename . '.zip';
                 unset($sqldump, $zip, $content);
                 $this->Messager('database_export_zip_succeed');
             } else {
                 if (is_writeable($dumpfile)) {
                     $fp = @fopen($dumpfile, 'rb+');
                     fwrite($fp, $idstring . "# <?exit();?>\n " . $setnames . "\n #");
                     fclose($fp);
                 }
                 touch('./data/backup/' . $backupdir . '/index.htm');
                 $filename = $backupfilename . '.sql';
                 $this->Messager('database_export_succeed');
             }
         } else {
             $this->Messager('database_shell_fail');
         }
     }
 }
Esempio n. 17
0
    cache_file('js' . DIR_SEP . 'jquery.js', method_retrieve("script_jquery"));
    $writing = '';
    $writing .= method_retrieve('style_default');
    $writing .= NEWLINE;
    $writing .= '$output = <<< OUTPUT';
    $writing .= NEWLINE;
    $writing .= NEWLINE;
    $writing .= method_retrieve('style_html');
    $writing .= NEWLINE;
    $writing .= NEWLINE;
    $writing .= 'OUTPUT;';
    $writing .= NEWLINE;
    $writing .= 'echo $output;';
    $writing .= NEWLINE;
    $writing .= NEWLINE;
    cache_file('style' . DIR_SEP . 'style.css', catch_output($writing));
}
include CMS_FILE_INCLUDE;
// Page load time output (won't load on Style.css stuff)
if (function_exists('br') && function_exists('isGroupMember')) {
    if (isGroupMember(1) && constant_test('SETTING_PHP_VARIABLES', 'show')) {
        echo '<div class="container-fluid">';
        echo PtimerStop();
        echo catch_output(method_retrieve('cms_verbose'));
        echo '</div>';
    }
}
// ************************** Clean **************************
// Keep the tmp folder clean of error logs
//if (file_exists(CMS_ERROR_PHP)) unlink(CMS_ERROR_PHP);
//if (file_exists(ini_get('error_log'))) unlink(ini_get('error_log'));
Esempio n. 18
0
 function Do_Reg_Follow_User()
 {
     $follow_type = $this->Post['followType'];
     $_limit = $this->Post['list_limit'] ? $this->Post['list_limit'] + 15 : '15';
     $list = array();
     if ($follow_type == 'recommend') {
         $day = 7;
         $time = $day * 86400;
         $limit = (int) $this->ShowConfig['reg_follow']['user'];
         if ($limit < 1) {
             $limit = 20;
         }
         $regfollow = jconf::get('regfollow');
         for ($i = 0; $i < count($regfollow); $i++) {
             if ($regfollow[$i] == '') {
                 unset($regfollow[$i]);
             }
         }
         if (!empty($regfollow)) {
             $count = count($regfollow);
             if ($count > $limit) {
                 $keys = array_rand($regfollow, $limit);
                 foreach ($keys as $k) {
                     $uids[] = $regfollow[$k];
                 }
             } else {
                 $uids = $regfollow;
             }
         } else {
             $cache_id = "misc/RTU-{$day}-{$limit}";
             if (false === ($uids = cache_file('get', $cache_id))) {
                 $dateline = time() - $time;
                 $sql = "SELECT DISTINCT(uid) AS uid, COUNT(tid) AS topics FROM `" . TABLE_PREFIX . "topic` WHERE dateline>={$dateline} GROUP BY uid ORDER BY topics DESC LIMIT {$limit}";
                 $query = $this->DatabaseHandler->Query($sql);
                 $uids = array();
                 while (false != ($row = $query->GetRow())) {
                     $uids[$row['uid']] = $row['uid'];
                 }
                 cache_file('set', $cache_id, $uids, 900);
             }
         }
     } elseif ($follow_type == 'huoyue') {
         $sql = "select DISTINCT(T.username) AS username , T.uid AS uid , COUNT(T.tid) AS count from `" . TABLE_PREFIX . "topic` T left join `" . TABLE_PREFIX . "members` M on T.uid=M.uid WHERE T.dateline>='" . (time() - 86400 * 7) . "' and M.face!='' GROUP BY username ORDER BY count DESC LIMIT 0,{$_limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $uids = array();
         while (false != ($row = $query->GetRow())) {
             $uids[$row['uid']] = $row['uid'];
         }
     } elseif ($follow_type == 'renqi') {
         $sql = "select DISTINCT(B.uid) AS uid, COUNT(B.touid) AS `count`\r\n\t\t\t\tFROM " . DB::table(jtable('buddy_fans')->table_name(max(1, MEMBER_ID))) . " B\r\n\t\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "members` M on (M.uid=B.uid)\r\n\t\t\t\tWHERE B.dateline>='" . (TIMESTAMP - 86400 * 7) . "' AND M.face!=''\r\n\t\t\t\tGROUP BY B.uid\r\n\t\t\t\tORDER BY `count` DESC\r\n\t\t\t\tLIMIT {$_limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $uids = array();
         while (false != ($row = $query->GetRow())) {
             $uids[$row['uid']] = $row['uid'];
         }
     } elseif ($follow_type == 'yingxiang') {
         $sql = "select DISTINCT(T.tousername) AS username ,  COUNT(T.tid) AS count, M.face ,M.username,M.uid from `" . TABLE_PREFIX . "topic` T left join `" . TABLE_PREFIX . "members` M on T.tousername=M.username WHERE M.face !='' and  T.dateline>='" . (time() - 86400 * 7) . "' and T.touid > 0  GROUP BY tousername ORDER BY count DESC LIMIT 0,{$_limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $uids = array();
         while (false != ($row = $query->GetRow())) {
             $uids[$row['uid']] = $row['uid'];
         }
     }
     if ($uids) {
         $_list = $this->TopicLogic->GetMember($uids, "`uid`,`ucuid`,`username`,`face_url`,`face`,`validate`,`nickname`,`aboutme`");
         foreach ($uids as $uid) {
             if ($uid > 0 && isset($_list[$uid]) && $uid != MEMBER_ID) {
                 $list[$uid] = $_list[$uid];
             }
         }
         $user_count = $list ? count($list) : '0';
     } else {
     }
     if ($follow_type == 'tag') {
         $sql = "select * from `" . TABLE_PREFIX . "tag_recommend` order by `id` desc limit  0,{$_limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $tag_name = array();
         while (false != ($row = $query->GetRow())) {
             $tag_name[$row['name']] = $row['name'];
         }
         if ($tag_name) {
             $query = DB::query("SELECT `id`,`name` FROM " . DB::table('tag') . " where `name` in ('" . implode("','", $tag_name) . "') order by `id` desc limit 0,{$_limit} ");
             $tag_list = array();
             while (false != ($row = DB::fetch($query))) {
                 $tag_list[] = $row;
             }
         }
         $tag_count = count($tag_list);
     }
     include template('reg_follow_user_ajax');
 }
Esempio n. 19
0
 function getajax()
 {
     $cachefile = jconf::get('channel');
     $channel_channels = is_array($cachefile['channels']) ? $cachefile['channels'] : array();
     $type = in_array($this->Post['type'], array('recommend_top', 'week_dig', 'month_dig', 'dig_user_follow', 'recommend', 'recommend20')) ? $this->Post['type'] : '';
     $itemid = jget('id', 'int', 'P');
     $uid = jget('uid', 'int', 'P');
     $num = jget('num', 'int', 'P');
     if ($itemid && $channel_channels[$itemid]) {
         $ids = implode(",", $channel_channels[$itemid]);
         $where = " AND `item_id` IN(" . jimplode($channel_channels[$itemid]) . ") ";
     } else {
         $where = "";
     }
     $time = TIMESTAMP;
     $topic_list = array();
     if ($type == 'month_dig') {
         $time = $time - 30 * 24 * 3600;
         $cache_id = 'dig-30days-top10-' . $itemid;
     } elseif ($type == 'week_dig') {
         $time = $time - 7 * 24 * 3600;
         $cache_id = 'dig-7days-top10-' . $itemid;
     } elseif ($type == 'recommend_top') {
         $cache_id = 'channel-recommend-top10-' . $itemid;
     } elseif ($type == 'dig_user_follow') {
         $cache_id = 'dig_user_follow-' . $itemid;
     } elseif ($type == 'recommend') {
         $cache_id = 'all-recommend-top10';
     } elseif ($type == 'recommend20') {
         $cache_id = 'all-recommend-top20';
     } else {
         echo '<font color=red>开发中......</font>';
         exit;
     }
     if (false === ($topic_list = cache_file('get', $cache_id))) {
         $isquery = true;
         if ($type == 'dig_user_follow') {
             $query = DB::query("SELECT uid FROM " . TABLE_PREFIX . "topic_dig WHERE tid = '" . $itemid . "'");
             while ($rs = DB::fetch($query)) {
                 $diguids[] = $rs['uid'];
             }
             $query = DB::query("SELECT tid,count(tid) as nums FROM " . TABLE_PREFIX . "topic_dig WHERE tid<>'" . $itemid . "' AND uid IN(" . jimplode($diguids) . ") group by tid ORDER BY nums DESC LIMIT 10");
             while ($rs = DB::fetch($query)) {
                 $digftids[] = $rs['tid'];
             }
             if (count($digftids) == 0) {
                 $isquery = false;
             }
             $sql = "SELECT `tid`,`content` FROM `" . TABLE_PREFIX . "topic` WHERE `type` = 'first' AND tid IN(" . jimplode($digftids) . ") ORDER BY digcounts DESC ";
         } elseif ($type == 'recommend_top') {
             $sql = "SELECT tid,r_title as content FROM `" . TABLE_PREFIX . "topic_recommend` WHERE r_title <> '' AND item = 'channel' " . $where . " and (expiration>" . time() . " OR expiration=0) ORDER BY recd DESC,dateline DESC LIMIT 10 ";
         } elseif ($type == 'recommend') {
             $sql = "SELECT tid,r_title as content FROM `" . TABLE_PREFIX . "topic_recommend` WHERE r_title <> '' AND (expiration>" . time() . " OR expiration=0) ORDER BY recd DESC,dateline DESC LIMIT 10 ";
         } elseif ($type == 'recommend20') {
             $sql = "SELECT tid,r_title as content FROM `" . TABLE_PREFIX . "topic_recommend` WHERE r_title <> '' AND (expiration>" . time() . " OR expiration=0) ORDER BY recd DESC,dateline DESC LIMIT 20 ";
         } else {
             $sql = "SELECT `tid`,`content` FROM `" . TABLE_PREFIX . "topic`\r\n\t\t\t\t\tWHERE `digcounts` > 0 AND `item` = 'channel' " . $where . " AND `dateline` >= {$time} AND `type` = 'first'\r\n\t\t\t\t\tORDER BY `digcounts` DESC, `lastdigtime` DESC LIMIT 10 ";
         }
         $topic_list = array();
         if ($isquery) {
             $query = DB::query($sql);
             while ($rs = DB::fetch($query)) {
                 if ($type == 'month_dig' || $type == 'week_dig') {
                     $userdata = $this->_getuserfortid($rs['tid']);
                     $rs['uid'] = $userdata['uid'];
                     $rs['username'] = $userdata['username'];
                     $rs['nickname'] = $userdata['nickname'];
                     $rs['face'] = $userdata['face'];
                 }
                 $rs['scontent'] = cut_str(strip_tags($rs['content']), 18);
                 $rs['lcontent'] = cut_str(strip_tags($rs['content']), 36);
                 $topic_list[$rs['tid']] = $rs;
             }
         }
         cache_file('set', $cache_id, $topic_list, 36000);
     }
     if ($type == 'month_dig' || $type == 'week_dig') {
         $html = '';
         if ($topic_list) {
             $i = 1;
             foreach ($topic_list as $rs) {
                 $html .= "<li><i class='hotlist{$i}'>{$i}</i><div class='list_face'><img onerror='javascript:faceError(this);' src='{$rs['face']}'></div><div class='list_con'><p><a href='" . jurl("index.php?mod={$rs['username']}") . "' title='点击访问【{$rs['nickname']}】的主页'>{$rs['nickname']}</a></p><p><a href='" . jurl("index.php?mod=topic&code={$rs[tid]}") . "' title='{$rs['content']}'>{$rs['scontent']}</a></p></div></li>";
                 $i++;
                 if ($i > $num) {
                     break;
                 }
             }
         } else {
             $html .= '没有找到相关' . $this->Config['changeword']["n_weibo"];
         }
     } else {
         $html = '<ul class="hot_reply_b">';
         if ($topic_list) {
             $i = 1;
             foreach ($topic_list as $rs) {
                 $html .= "<li><a href='" . jurl("index.php?mod=topic&code={$rs[tid]}") . "' title='点此查看详情' target='_blank'>{$i}.{$rs['lcontent']}</a></li>";
                 $i++;
             }
         } else {
             $html .= '没有找到相关' . $this->Config['changeword']["n_weibo"];
         }
         $html .= '</ul>';
     }
     echo $html;
 }
Esempio n. 20
0
 function _get_topic_list_3($key)
 {
     $ret = array();
     $akey = addslashes($key);
     $total_record = 0;
     $member_info = DB::fetch_first("select * from " . DB::table('members') . " where `username`='{$akey}' or `nickname`='{$akey}' limit 1");
     if (!$member_info) {
         $cache_id = 'wall/_get_topic_list_3-' . $akey;
         if (false === ($member_list = cache_file('get', $cache_id))) {
             $member_list = DB::fetch_all("SELECT `uid`, `topic_count` FROM " . DB::table('members') . "\r\n\t\t\t\t\tWHERE `username` LIKE '%{$akey}%' OR `nickname` LIKE '%{$akey}%'\r\n\t\t\t\t\tORDER BY `lastactivity` DESC\r\n\t\t\t\t\tLIMIT 10");
             cache_file('set', $cache_id, $member_list, 3600);
         }
         if (!$member_list) {
             return $ret;
         } else {
             $uids = array();
             foreach ($member_list as $row) {
                 $uids[$row['uid']] = $row['uid'];
                 $total_record += $row['topic_count'];
             }
         }
     } else {
         $uids = $member_info['uid'];
         $total_record = $member_info['topic_count'];
     }
     if ($uids && $total_record > 0) {
         $per_page_num = 20;
         $query_link = "index.php?mod=wall&code=control&type=3&key=" . urlencode($key);
         $rets = jtable('member_topic')->get_tids($uids, array('type' => array('both', 'forward', 'reply'), 'sql_order' => ' `dateline` DESC ', 'result_count' => $total_record, 'per_page_num' => $per_page_num, 'page_url' => $query_link), 1);
         if ($rets) {
             if ($member_info) {
                 $ret['member_info'] = $member_info;
             }
             $ret['total_record'] = $total_record;
             $ret['page_arr'] = $rets['page'];
             $ret['topic_list'] = $this->TopicLogic->Get($rets['ids']);
             $ret['parent_list'] = $this->TopicLogic->GetParentTopic($ret['topic_list']);
         }
     }
     return $ret;
 }
Esempio n. 21
0
 static function db($key = null, $val = null)
 {
     $ret = false;
     $type = $key;
     if (is_null($key)) {
         $key = 'core_settings';
         if ($val) {
             $val = ConfigHandler::core_settings(array(), $val, 'db');
         }
     } else {
         $key = (string) $key;
     }
     $db_prefix = defined('TABLE_PREFIX') ? TABLE_PREFIX : $GLOBALS['_J']['config']['db_table_prefix'];
     $cache_id = 'setting/' . $key;
     if (is_null($val)) {
         if (false === ($ret = cache_file('get', $cache_id))) {
             $row = array();
             $query = DB::query("select * from {$db_prefix}setting where `key`='{$key}'", 'SILENT');
             if (false == $query) {
                 $ret = array();
             } else {
                 $row = DB::fetch($query);
             }
             if ($row) {
                 $ret = unserialize(base64_decode($row['val']));
                 $ret = $ret ? $ret : array();
             } else {
                 @(include ConfigHandler::file($type));
                 $ret = is_null($type) ? $config : $config[$type];
                 $ret = $ret ? $ret : array();
                 ConfigHandler::db($type, $ret);
                 if (is_null($type) && $ret) {
                     ConfigHandler::set($ret);
                 }
             }
             cache_file('set', $cache_id, $ret);
         }
     } else {
         $ret = DB::query("replace into {$db_prefix}setting (`key`, `val`) values ('{$key}', '" . base64_encode(serialize($val)) . "')", 'SILENT');
         cache_file('rm', $cache_id);
     }
     return $ret;
 }
Esempio n. 22
0
 function visitState()
 {
     if (false === ($role_list = cache_file('get', $cache_id))) {
         $sql = "\r\n\t\t\tSELECT\r\n\t\t\t\tid,name,`type`\r\n\t\t\tFROM\r\n\t\t\t\t" . TABLE_PREFIX . 'role';
         $query = $this->DatabaseHandler->Query($sql);
         while (false != ($row = $query->getRow())) {
             $role_list[$row['type']][] = array('name' => $row['name'], 'value' => $row['id']);
         }
         cache_file('set', $cache_id, $role_list);
     }
     if ($this->Config['allowed_visit_role_list']) {
         $allowed_visit_role_list = explode(',', $this->Config['allowed_visit_role_list']);
         foreach ($allowed_visit_role_list as $k => $v) {
             $allowed_visit_role_check_list[$v] = "checked";
         }
     }
     $site_enable = @file_get_contents(ROOT_PATH . 'data/cache/site_enable.txt');
     include template('admin/visit_state');
 }
Esempio n. 23
0
 function Main()
 {
     $timestamp = time();
     $uid = MEMBER_ID;
     $member = $this->_topicLogicGetMember($uid);
     $limit = $this->ShowConfig['tag_index']['hot'];
     $cache_id = "wap-tag/tag_hot";
     if ($limit > 0 && false === ($tag_list = cache_file('get', $cache_id))) {
         $tag_ids = array();
         $tag_list = array();
         $sql = "SELECT DISTINCT(`tag_id`) AS `tag_id`, COUNT(item_id) AS `count` FROM `" . TABLE_PREFIX . "topic_tag` WHERE dateline>='" . ($timestamp - 86400 * 20) . "' GROUP BY `tag_id` ORDER BY `count` DESC LIMIT {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $tag_ids = array();
         while (false != ($row = $query->GetRow())) {
             $tag_ids[$row['tag_id']] = $row['tag_id'];
         }
         if ($tag_ids) {
             $sql = "select `id`,`name`,`topic_count`,`status`,`total_count`,`tag_count` from `" . TABLE_PREFIX . "tag` where id in('" . implode("','", $tag_ids) . "') order by `topic_count` desc";
             $query = $this->DatabaseHandler->Query($sql);
             $tag_lis = array();
             while (false != ($row = $query->GetRow())) {
                 $row['name'] = wap_iconv($row['name']);
                 $tag_list[] = $row;
             }
         }
         cache_file('set', $cache_id, $tag_list, $this->CacheConfig['tag_index']['hot']);
     }
     $limit = $this->ShowConfig['tag_index']['guanzhu'];
     $cache_id = "wap-tag/tag_guanzu";
     if ($limit > 0 && false === ($tag_guanzu = cache_file('get', $cache_id))) {
         $sql = "select `id`,`name`,`topic_count`,`tag_count` from `" . TABLE_PREFIX . "tag`  ORDER BY `tag_count` DESC LIMIT {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $tag_guanzu = array();
         while (false != ($row = $query->GetRow())) {
             $row['name'] = wap_iconv($row['name']);
             $tag_guanzu[$row['id']] = $row;
         }
         cache_file('set', $cache_id, $tag_guanzu, $this->CacheConfig['tag_index']['guanzhu']);
     }
     $limit = $this->ShowConfig['tag_index']['day7'];
     $cache_id = "wap-tag/tag_r_day7";
     if ($limit > 0 && false === ($tag_r_day7 = cache_file('get', $cache_id))) {
         $sql = "select `id`,`name`,`topic_count`,`tag_count` from `" . TABLE_PREFIX . "tag`  WHERE last_post>='" . (time() - 86400 * 7) . "' GROUP BY `topic_count` DESC LIMIT {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $tag_r_day7 = array();
         while (false != ($row = $query->GetRow())) {
             $row['name'] = wap_iconv($row['name']);
             $tag_r_day7[$row['id']] = $row;
         }
         cache_file('set', $cache_id, $tag_r_day7, $this->CacheConfig['tag_index']['day7']);
     }
     $limit = $this->ShowConfig['tag_index']['day7_guanzhu'];
     $cache_id = "wap-tag/day7_guanzhu";
     if ($limit > 0 && false === ($day7_guanzhu = cache_file('get', $cache_id))) {
         $sql = "select `id`,`name`,`topic_count`,`tag_count` from `" . TABLE_PREFIX . "tag`  WHERE `tag_count` > 0 and last_post>='" . (time() - 86400 * 7) . "' GROUP BY `tag_count` DESC LIMIT {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $day7_guanzhu = array();
         while (false != ($row = $query->GetRow())) {
             $row['name'] = wap_iconv($row['name']);
             $day7_guanzhu[$row['id']] = $row;
         }
         cache_file('set', $cache_id, $day7_guanzhu, $this->CacheConfig['tag_index']['day7_guanzhu']);
     }
     $limit = $this->ShowConfig['tag_index']['tag_tuijian'];
     $cache_id = "wap-tag/tag_tuijian";
     if ($limit > 0 && false === ($tag_tuijian = cache_file('get', $cache_id))) {
         $sql = "select `id`,`name`,`topic_count`,`tag_count` from `" . TABLE_PREFIX . "tag`  WHERE `status` = 1 order by `topic_count` desc  Limit {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $tag_tuijian = array();
         while (false != ($row = $query->GetRow())) {
             $row['name'] = wap_iconv($row['name']);
             $tag_tuijian[] = $row;
         }
         cache_file('set', $cache_id, $tag_tuijian, $this->CacheConfig['tag_index']['tag_tuijian']);
     }
     $tag_hb = 'hb';
     $this->Title = '话题榜';
     include template('tag_index');
 }
Esempio n. 24
0
 function getHotTagTop()
 {
     $code = 'hot_follow_tag';
     $limit = 10;
     $tag_guanzu = array();
     $time = strtotime("-7 day");
     $cache_id = 'hottagtop';
     if (!($tag_guanzu = cache_file('get', $cache_id))) {
         $sql = "SELECT\r\n\t\t\t\t\t    COUNT(*) AS topic_count,t.`name`,t.`tag_count`,t.id\r\n\t\t\t\t\tFROM " . TABLE_PREFIX . "topic_tag tt\r\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "tag t\r\n\t\t\t\t\t    ON t.id = tt.tag_id\r\n\t\t\t\t\tWHERE tt.dateline > '{$time}' and t.topic_count > 0\r\n\t\t\t\t\tGROUP BY tt.tag_id\r\n\t\t\t\t\tORDER BY topic_count DESC\r\n\t\t\t\t\tLIMIT {$limit} ";
         $query = $this->DatabaseHandler->Query($sql);
         while (false != ($row = $query->GetRow())) {
             $tag_guanzu[$row['id']] = $row;
         }
         cache_file('set', $cache_id, $tag_guanzu, 36000);
     }
     if (!$tag_guanzu) {
         echo "<script type='text/javascript'>";
         echo "\$('#hot_tag_top').remove()";
         echo "</script>";
         exit;
     }
     include template("topic_right_user_ajax");
 }
Esempio n. 25
0
function cache_zip_file_contents($url, $identifier = null)
{
    /*{{{*/
    global $database;
    if ($identifier === null) {
        $identifier = $url;
    }
    $cache_id = cache_file($url, false, true, 500);
    $retval = array();
    $directory = dirname($_SERVER['REQUEST_URI']);
    if (substr($directory, -1) != '/') {
        $directory .= '/';
    }
    $zip = new ZipArchive();
    if (!$zip->open($GLOBALS['cache_dir'] . '/' . $cache_id)) {
        throw new Execption("Failed to open ZIP archive from {$url}");
    }
    for ($i = 0; $i < $zip->numFiles; $i++) {
        $file_name = basename($zip->getNameIndex($i));
        if (isset($retval[$file_name])) {
            $n = 0;
            while (isset($retval[$n . '~' . $file_name])) {
                $n++;
            }
            $file_name = $n . '~' . $file_name;
        }
        $content = $zip->getFromIndex($i);
        $cache_id = sha1($identifier . '#' . $file_name);
        $cache_file = $GLOBALS['cache_dir'] . '/' . $cache_id;
        $cache_url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . $directory . 'cache.php?cache_id=' . $cache_id . '&filename=' . $file_name;
        $cache_exists = file_exists($cache_file);
        if ($content) {
            // Nur den Cache neu schreiben, wenn sich tatsächlich etwas verändert hat
            // Dadurch verhindern wir, dass Zettel immer wieder als „Neu“ zählen, weil
            // ein Webserver schlampig konfiguriert ist.
            if (!file_exists($cache_file) || sha1_file($cache_file) != sha1($content)) {
                file_put_contents($cache_file, $content);
            }
            // In der Datenbank ein Update ausführen
            // Das auch, wenn eigentlich nichts geändert wurde - weil wir nämlich durch
            // den Aufruf wissen, dass die Daten noch gebraucht werden.
            // Die hierrüber geladenen Daten ein halbes Jahr aufbewahren.
            $query = $database->prepare('SELECT COUNT(*) FROM cache WHERE id = ?');
            $query->execute(array($cache_id));
            if ($query->fetchColumn() == 0) {
                $query = $database->prepare('INSERT INTO cache (created_timestamp, max_age, filename, id) VALUES (?, ?, ?, ?)');
            } else {
                $query = $database->prepare('UPDATE cache SET created_timestamp = ?, max_age = ?, filename = ? WHERE id = ?');
            }
            $query->execute(array(time(), 3600 * 24 * 30 * 6, $file_name, $cache_id));
        }
        $retval[$zip->getNameIndex($i)] = $cache_url . ' ' . $file_name;
    }
    return $retval;
}
Esempio n. 26
0
 function getRecommendUser()
 {
     $follow_type = 'recommend';
     $this->ShowConfig = jconf::get('show');
     $day = 7;
     $time = $day * 86400;
     $limit = (int) $this->ShowConfig['reg_follow']['user'];
     if ($limit < 1) {
         $limit = 20;
     }
     $TopicLogic = jlogic('topic');
     $regfollow = jconf::get('regfollow');
     for ($i = 0; $i < count($regfollow); $i++) {
         if ($regfollow[$i] == '') {
             unset($regfollow[$i]);
         }
     }
     if (!empty($regfollow)) {
         $count = count($regfollow);
         if ($count > $limit) {
             $keys = array_rand($regfollow, $limit);
             foreach ($keys as $k) {
                 $uids[] = $regfollow[$k];
             }
         } else {
             $uids = $regfollow;
         }
     } else {
         $cache_id = "misc/RTU-{$day}-{$limit}";
         if (false === ($uids = cache_file('get', $cache_id))) {
             $dateline = time() - $time;
             $sql = "SELECT DISTINCT(uid) AS uid, COUNT(tid) AS topics FROM `" . TABLE_PREFIX . "topic` WHERE dateline>={$dateline} GROUP BY uid ORDER BY topics DESC LIMIT {$limit}";
             $query = $this->DatabaseHandler->Query($sql);
             $uids = array();
             while (false != ($row = $query->GetRow())) {
                 $uids[$row['uid']] = $row['uid'];
             }
             cache_file('set', $cache_id, $uids, 900);
         }
     }
     if (!$uids) {
         $uids[] = 1;
     }
     $list = array();
     if ($uids) {
         $list = $TopicLogic->GetMember($uids, "`uid`,`ucuid`,`username`,`face`,`validate`,`validate_category`,`nickname`");
     }
     return $list;
 }
Esempio n. 27
0
 function get_hot_qun($limit, $cache_time = 300)
 {
     $rets = array();
     $limit = max(0, (int) $limit);
     if ($limit > 0) {
         $cache_time = max(60, (int) $cache_time);
         $cache_id = 'qun/hot_qun-' . $limit;
         if (false === ($rets = cache_file('get', $cache_id))) {
             $sql = " select * from `" . TABLE_PREFIX . "qun`  where `recd` = 1 order by `member_num` desc limit {$limit}  ";
             $query = DB::query($sql);
             $rets = array();
             while (false != ($row = DB::fetch($query))) {
                 $row['icon'] = $this->qun_avatar($row['qid'], 's');
                 $rets[] = $row;
             }
             cache_file('set', $cache_id, $rets, $cache_time);
         }
     }
     return $rets;
 }
Esempio n. 28
0
 function _rm_table_cache($name = '')
 {
     $name = $name ? $name : $this->table;
     cache_file('rm', 'table/' . $name);
     cache_file('rm', 'table_status/' . $name);
 }
Esempio n. 29
0
 function getRoleStatistics()
 {
     $cache_id = 'misc/role_statistics';
     if (false === ($role_list_r = cache_file('get', $cache_id))) {
         #取得所有的角色类型
         $role_list = array();
         $sql = " select `id`,`name` from `" . TABLE_PREFIX . "role` ";
         $query = DB::query($sql);
         while ($rs = DB::fetch($query)) {
             $role_list[$rs['id']] = $rs['name'];
         }
         $role_list_r = array();
         if ($role_list) {
             $sql = " select `role_id`,count(*) as num from `" . TABLE_PREFIX . "members` GROUP BY `role_id` ";
             $query = DB::query($sql);
             while ($rs = DB::fetch($query)) {
                 $id = $rs['role_id'];
                 if ($id > 0 && $role_list[$id]) {
                     $role_list_r['data'][$rs['role_id']]['name'] = "<b>" . $role_list[$id] . "</b>";
                     $role_list_r['data'][$rs['role_id']]['num'] = '<a href="admin.php?mod=member&code=dosearch&role_ids=' . $id . '">' . $rs['num'] . '</a>';
                 }
             }
             $role_list_r['time'] = TIMESTAMP;
         }
         cache_file('set', $cache_id, $role_list_r, 3600);
     }
     return $role_list_r;
 }
Esempio n. 30
0
 function _recommendTag($day = 1, $limit = 12, $cache_time = 0)
 {
     if ($limit < 1) {
         return false;
     }
     $time = $day * 86400;
     $cache_time = $cache_time ? $cache_time : $time / 90;
     $cache_id = "misc/recommendTopicTag-{$day}-{$limit}";
     if (false === ($list = cache_file('get', $cache_id))) {
         $dateline = TIMESTAMP - $time;
         $sql = "SELECT DISTINCT(tag_id) AS tag_id, COUNT(item_id) AS item_id_count FROM `" . TABLE_PREFIX . "topic_tag` WHERE dateline>={$dateline} GROUP BY tag_id ORDER BY item_id_count DESC LIMIT {$limit}";
         $query = $this->DatabaseHandler->Query($sql);
         $ids = array();
         while (false != ($row = $query->GetRow())) {
             $ids[$row['tag_id']] = $row['tag_id'];
         }
         $list = array();
         if ($ids) {
             $sql = "select `id`,`name`,`topic_count` from `" . TABLE_PREFIX . "tag` where `id` in('" . implode("','", $ids) . "')";
             $query = $this->DatabaseHandler->Query($sql);
             $list = $query->GetAll();
         }
         cache_file('set', $cache_id, $list, $cache_time);
     }
     return $list;
 }