/** * 更新区块缓存 * * @param void * @access private * @return string */ function updateContent($isreturn = false) { $ret = ''; include_once JIEQI_ROOT_PATH . '/class/blocks.php'; $blocks_handler =& JieqiBlocksHandler::getInstance('JieqiBlocksHandler'); if (!empty($this->blockvars['bid'])) { $block = $blocks_handler->get($this->blockvars['bid']); if (is_object($block)) { switch ($block->getVar('contenttype')) { case JIEQI_CONTENT_TXT: $ret = $block->getVar('content', 's'); break; case JIEQI_CONTENT_HTML: $ret = $block->getVar('content', 'n'); break; case JIEQI_CONTENT_JS: $ret = '<script language="javascript" type="text/javascript">' . $block->getVar('content', 'n') . '</script>'; break; case JIEQI_CONTENT_MIX: $ret = $block->getVar('content', 'n'); break; case JIEQI_CONTENT_PHP: break; } $blocks_handler->saveContent($block->getVar('bid'), $block->getVar('modname'), $block->getVar('contenttype'), $ret); } else { $ret = 'block not exists! (id:' . $this->blockvars['bid'] . ')'; } } elseif (!empty($this->blockvars['filename']) && preg_match('/^\\w+$/', $this->blockvars['filename'])) { $blockpath = $this->blockvars['module'] == 'system' ? JIEQI_ROOT_PATH : $GLOBALS['jieqiModules'][$this->blockvars['module']]['path']; $blockpath .= '/templates/blocks/' . $this->blockvars['filename'] . '.html'; $ret = jieqi_readfile($blockpath); $blocks_handler->saveContent($this->blockvars['filename'], $this->blockvars['module'], JIEQI_CONTENT_HTML, $ret); } else { $ret = 'empty block id!'; } if ($isreturn) { return $ret; } }
function getContent($id) { global $jieqiConfigs; global $jieqi_file_postfix; return jieqi_readfile($this->getDir('txtdir', true, false) . '/' . $id . $jieqi_file_postfix['txt']); }
$packxml = jieqi_uploadpath($jieqiConfigs['article']['umddir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . '.xml'; } else { $packxml = jieqi_uploadpath($jieqiConfigs['article']['umddir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . '_' . $_REQUEST['vsize'] . '.xml'; } //文件不存在或者过期自动生成 if (!is_file($packxml) || filemtime($packxml) + 600 < $lastupdate) { include_once JIEQI_ROOT_PATH . '/modules/article/include/repack.php'; article_repack($_REQUEST['id'], array('makeumd' => 1), 1); } if (is_file($packxml)) { include_once JIEQI_ROOT_PATH . '/lib/xml/xmlarray.php'; $xmlarray = new XMLArray(); if ($_REQUEST['vsize'] <= 1) { $packrows[1] = $xmlarray->xml2array(jieqi_readfile($packxml)); } else { $packrows = $xmlarray->xml2array(jieqi_readfile($packxml)); } } $jieqiTpl->assign_by_ref('packrows', $packrows); $jieqiTset['jieqi_contents_template'] = $jieqiModules['article']['path'] . '/templates/packumd.html'; break; case 'txtchapter': default: $jieqiTpl->assign('type', 'txtchapter'); $jieqiConfigs['article']['maketxt'] = intval($jieqiConfigs['article']['maketxt']); if (empty($jieqiConfigs['article']['maketxt'])) { jieqi_printfail($jieqiLang['article']['down_file_notopen']); } $packsize = array(); $jieqiTpl->assign_by_ref('packsize', $packsize); $jieqiTpl->assign('vsize', 0);
/** * 获得缓存 * * @param string $name 缓存的键名(这里是文件名) * @param int $ttl 缓存时间 * @access public * @return string */ function get($name, $ttl = 0, $over = 0) { if (empty($ttl) && empty($over)) { return jieqi_readfile($name); } else { $ftime = @filemtime($name); if (!$ftime) { return false; } if ($ttl > 0 && JIEQI_NOW_TIME - $ftime > $ttl || $over > 0 && $over > $ftime) { jieqi_delfile($name); return false; } else { return jieqi_readfile($name); } } }
function jieqi_makezip($filename, $volume, $type) { if (@function_exists('gzcompress')) { include_once JIEQI_ROOT_PATH . '/lib/compress/zip.php'; $zip = new JieqiZip(); if ($type == 1) { $zipfilename = MYSQL_BACKUP_PATH . '/' . $filename . '-1' . '.zip'; if (!$zip->zipstart($zipfilename)) { return FALSE; } for ($i = 1; $i < $volume; $i++) { $sqlfilename = MYSQL_BACKUP_PATH . '/' . $filename . '-' . $i . '.sql'; if (@is_file($sqlfilename)) { $content = jieqi_readfile($sqlfilename); $zip->zipadd(basename($sqlfilename), $content); jieqi_delfile($sqlfilename); } } if ($zip->zipend()) { @chmod($zipfilename, 0777); } return TRUE; } elseif ($type == 2) { for ($i = 1; $i < $volume; $i++) { $zipfilename = MYSQL_BACKUP_PATH . '/' . $filename . '-' . $i . '.zip'; if (!$zip->zipstart($zipfilename)) { return FALSE; } $sqlfilename = MYSQL_BACKUP_PATH . '/' . $filename . '-' . $i . '.sql'; if (@is_file($sqlfilename)) { $content = jieqi_readfile($sqlfilename); $zip->zipadd(basename($sqlfilename), $content); if ($zip->zipend()) { @chmod($zipfilename, 0777); } jieqi_delfile($sqlfilename); } } return TRUE; } else { return FALSE; } } else { return FALSE; } }
$imgfile = $avatar_cut ? $base_avatar . '/' . $_REQUEST['uid'] . 's' . $prefix : $base_avatar . '/' . $_REQUEST['uid'] . $prefix; break; case 'i': $imgfile = $avatar_cut ? $base_avatar . '/' . $_REQUEST['uid'] . 'i' . $prefix : $base_avatar . '/' . $_REQUEST['uid'] . $prefix; break; case 'l': default: $imgfile = $base_avatar . '/' . $_REQUEST['uid'] . $prefix; break; } if (is_file($imgfile)) { switch ($prefix) { case '.jpg': case '.jpeg': header("Content-type: image/jpeg"); break; case '.gif': header("Content-type: image/gif"); break; case '.bmp': header("Content-type: image/bmp"); break; case '.png': default: header("Content-type: image/png"); break; } echo jieqi_readfile($imgfile); } else { exit('image file is not exists!'); }
function replace_path($articleid, $dirtype, $filetype, $idisdir = true) { global $showinfo; global $fromary; global $toary; global $jieqiLang; $dirname = jieqi_uploadpath($dirtype, 'article') . jieqi_getsubdir($articleid); if ($idisdir) { $dirname .= '/' . $articleid; } else { $dirname .= '/' . $articleid . $filetype; } if (file_exists($dirname)) { echo ' '; echo sprintf($jieqiLang['article']['replace_id_doing'], $articleid); ob_flush(); flush(); if (is_dir($dirname)) { $handle = @opendir($dirname); while ($file = @readdir($handle)) { if ($file != '.' && $file != '..') { $filename = $dirname . '/' . $file; if (is_file($filename) && is_writable($filename) && substr($filename, 0 - strlen($filetype)) == $filetype) { if (empty($_REQUEST['filesize']) || $_REQUEST['filesize'] == 'sizeunlimit' || $_REQUEST['filesize'] == 'sizeless' && filesize($filename) <= 1024 || $_REQUEST['filesize'] == 'sizemore' && filesize($filename) >= 1024) { $filedata = jieqi_readfile($filename); if ($_REQUEST['replacetype'] == 1) { $filedata = str_replace($fromary, $toary, $filedata); } else { $filedata = str_replace($_REQUEST['txtsearch'], $_REQUEST['txtreplace'], $filedata); } jieqi_writefile($filename, $filedata); } } } } } elseif (is_file($dirname)) { $filename = $dirname; if (is_file($filename) && is_writable($filename) && substr($filename, 0 - strlen($filetype)) == $filetype) { if (empty($_REQUEST['filesize']) || $_REQUEST['filesize'] == 'sizeunlimit' || $_REQUEST['filesize'] == 'sizeless' && filesize($filename) <= 1024 || $_REQUEST['filesize'] == 'sizemore' && filesize($filename) >= 1024) { $filedata = jieqi_readfile($filename); if ($_REQUEST['replacetype'] == 1) { $filedata = str_replace($fromary, $toary, $filedata); } else { $filedata = str_replace($_REQUEST['txtsearch'], $_REQUEST['txtreplace'], $filedata); } jieqi_writefile($filename, $filedata); } } } $showinfo = $jieqiLang['article']['replace_success_next']; } else { $showinfo = $jieqiLang['article']['replace_noid_next']; } }
} @chmod($dir, 0777); if ($_REQUEST['mod'] != 'system') { $dir .= '/' . $_REQUEST['mod']; if (!file_exists($dir)) { @mkdir($dir, 0777); } @chmod($dir, 0777); } $dir .= '/system.php'; if (file_exists($dir)) { @chmod($dir, 0777); } $cfgdefine = "<?php\n" . $cfgdefine . "\n?>"; jieqi_writefile($dir, $cfgdefine); $publicdata = str_replace('?><?php', '', $cfgdefine . jieqi_readfile(JIEQI_ROOT_PATH . '/lang/lang_system.php') . jieqi_readfile(JIEQI_ROOT_PATH . '/configs/groups.php')); jieqi_writefile(JIEQI_ROOT_PATH . '/configs/define.php', $publicdata); } else { $isdefine = 0; } //记录日志 include_once JIEQI_ROOT_PATH . '/class/logs.php'; $logs_handler = JieqiLogsHandler::getInstance('JieqiLogsHandler'); $logdata = array('logtype' => 2, 'logdata' => 'module:' . $_REQUEST['mod'] . ',define:' . $isdefine, 'todata' => serialize($_REQUEST)); $logs_handler->addlog($logdata); jieqi_msgwin(LANG_DO_SUCCESS, $jieqiLang['system']['edit_config_success']); } else { //显示参数 include_once JIEQI_ROOT_PATH . '/admin/header.php'; include_once JIEQI_ROOT_PATH . '/lib/html/formloader.php'; $config_form = new JieqiThemeForm($jieqiLang['system']['edit_config'], 'config', JIEQI_URL . '/admin/configs.php');
function makejar($jarfile = '', $jadfile = '') { $zip = new JieqiZip(); $zip->zipstart($jarfile); //建立ZIP文件,准备输出内容 $zip->zipadd('a.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/a.class')); $zip->zipadd('b.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/b.class')); $zip->zipadd('c.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/c.class')); $zip->zipadd('d.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/d.class')); $zip->zipadd('e.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/e.class')); $zip->zipadd('f.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/f.class')); $zip->zipadd('g.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/g.class')); $zip->zipadd('h.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/h.class')); $zip->zipadd('i.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/i.class')); $zip->zipadd('j.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/j.class')); $zip->zipadd('k.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/k.class')); $zip->zipadd('l.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/l.class')); $zip->zipadd('m.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/m.class')); $zip->zipadd('n.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/n.class')); $zip->zipadd('o.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/o.class')); $zip->zipadd('JavaBook.class', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/JavaBook.class')); $zip->zipadd('icon.png', jieqi_readfile(JIEQI_ROOT_PATH . '/lib/compress/jar/icon.png')); $maininest = 'Manifest-Version: 1.0' . "\r\n" . 'Ant-Version: Apache Ant 1.7.0' . "\r\n" . 'MicroEdition-Configuration: CLDC-1.0' . "\r\n" . 'MIDlet-Name: ' . $this->bookinfo['title'] . "\r\n" . 'MIDlet-Version: 1.0' . "\r\n" . 'MIDlet-Vendor: JIEQI CMS (www.jieqi.com)' . "\r\n" . 'MIDlet-1: ' . $this->bookinfo['title'] . ', /icon.png, JavaBook' . "\r\n" . 'MicroEdition-Profile: MIDP-1.0' . "\r\n" . 'Created-By: 10.0-b19 (Sun Microsystems Inc.)' . "\r\n"; $zip->zipadd('META-INF/MANIFEST.MF', $maininest); $index = ''; $index .= chr(0x0) . chr(0x1) . chr(0x30); $index .= $this->dechexs(strlen($this->bookinfo['title']), 2) . $this->bookinfo['title']; $chaptercount = strval(count($this->chapters)); $index .= $this->dechexs(strlen($chaptercount), 2) . $chaptercount; //增加章节 $i = 1; foreach ($this->chapters as $k => $v) { $zip->zipadd($i, $v['content']); $tmpstr = $i . ',' . strlen($v['content']) . ',' . $v['title']; $index .= $this->dechexs(strlen($tmpstr), 2) . $tmpstr; $i++; } //电子书运行后默认首页显示书的信息 $tmpvar = ''; $tmpvar .= strtoupper(JIEQI_SYSTEM_CHARSET) != 'UTF-8' ? iconv(strtoupper(JIEQI_SYSTEM_CHARSET), 'UTF-8//IGNORE', '书名:') : '书名:'; $tmpvar .= $this->bookinfo['title'] . "\r\n"; $tmpvar .= strtoupper(JIEQI_SYSTEM_CHARSET) != 'UTF-8' ? iconv(strtoupper(JIEQI_SYSTEM_CHARSET), 'UTF-8//IGNORE', '作者:') : '作者:'; $tmpvar .= $this->bookinfo['author'] . "\r\n"; $tmpvar .= strtoupper(JIEQI_SYSTEM_CHARSET) != 'UTF-8' ? iconv(strtoupper(JIEQI_SYSTEM_CHARSET), 'UTF-8//IGNORE', '制作:') : '制作:'; $tmpvar .= $this->bookinfo['publisher'] . "\r\n"; if (defined('JIEQI_MAIN_URL')) { $tmpvar .= strtoupper(JIEQI_SYSTEM_CHARSET) != 'UTF-8' ? iconv(strtoupper(JIEQI_SYSTEM_CHARSET), 'UTF-8//IGNORE', '网址:') : '网址:'; $tmpvar .= JIEQI_MAIN_URL . "\r\n"; } $tmpvar = substr($tmpvar, 0, -2); $index .= $this->dechexs(strlen($tmpvar), 4) . $tmpvar; $zip->zipadd('0', $index); $zip->setComment('create by jieqi cms (www.jieqi.com)'); //设置备注 $zip->zipend(); //输出zip文件完毕 $filesize = filesize($jarfile); $jadstr = 'Manifest-Version: 1.0' . "\r\n" . 'Ant-Version: Apache Ant 1.7.0' . "\r\n" . 'MIDlet-1: ' . $this->bookinfo['title'] . ', /icon.png, JavaBook' . "\r\n" . 'MIDlet-Jar-Size: ' . $filesize . "\r\n" . 'MIDlet-Jar-URL: ' . basename($jarfile) . "\r\n" . 'MIDlet-Name: ' . $this->bookinfo['title'] . "\r\n" . 'MIDlet-Vendor: JIEQI CMS (www.jieqi.com)' . "\r\n" . 'MIDlet-Version: 1.0' . "\r\n" . 'MicroEdition-Configuration: CLDC-1.0' . "\r\n" . 'MicroEdition-Profile: MIDP-1.0' . "\r\n"; if (empty($jadfile)) { $i = strrpos($jarfile, '.'); if ($i > 0) { $jadfile = substr($jarfile, 0, $i); } $jadfile .= '.jad'; } jieqi_writefile($jadfile, $jadstr); }
} if (!$db_query->query($sql)) { $errtext .= $jieqiLang[JIEQI_MODULE_NAME]['create_db_error'] . '<br />'; } } else { $errtext .= $jieqiLang[JIEQI_MODULE_NAME]['error_name_format'] . '<br />'; } } else { if (!mysql_select_db($_POST['mysql_name'])) { $errtext .= sprintf($jieqiLang[JIEQI_MODULE_NAME]['dbname_not_exists'], htmlspecialchars($_POST['mysql_name'])) . '<br />'; } } //保存至配置文件 if (empty($errtext)) { $file_name = JIEQI_ROOT_PATH . '/configs/define.php'; $file_content = jieqi_readfile($file_name); $file_content = str_replace('<?php', '', $file_content); $file_content = str_replace('?>', '', $file_content); $config_array = explode(';', $file_content); if (is_array($config_array) && count($config_array) > 0) { for ($i = 0; $i < count($config_array); $i++) { if (strpos($config_array[$i], 'JIEQI_URL')) { $config_array[$i] = "\r\n@define('JIEQI_URL','" . $_POST['local_root'] . "')"; } else { if (strpos($config_array[$i], 'JIEQI_DB_HOST')) { $config_array[$i] = "\r\n@define('JIEQI_DB_HOST','" . $_POST['mysql_host'] . "')"; } else { if (strpos($config_array[$i], 'JIEQI_DB_NAME')) { $config_array[$i] = "\r\n@define('JIEQI_DB_NAME','" . $_POST['mysql_name'] . "')"; } else { if (strpos($config_array[$i], 'JIEQI_DB_USER')) {
$mysql_version = @mysql_get_server_info(); $upmodules = false; unset($jieqiModules); include JIEQI_ROOT_PATH . '/configs/modules.php'; if (is_array($_POST['mod_name']) && count($_POST['mod_name']) > 0) { foreach ($_POST['mod_name'] as $v) { if (file_exists($sql_dir . '/' . $v . '/struct.sql') && file_exists($sql_dir . '/' . $v . '/data.sql')) { if (!isset($jieqiModules[$v])) { $jieqiModules[$v] = array('caption' => $v, 'dir' => '', 'path' => '', 'url' => '', 'theme' => '', 'publish' => '1'); $upmodules = true; } elseif ($jieqiModules[$v]['publish'] <= 0) { $jieqiModules[$v]['publish'] = 1; $upmodules = true; } $file_content = jieqi_readfile($sql_dir . '/' . $v . '/struct.sql'); $file_content .= jieqi_readfile($sql_dir . '/' . $v . '/data.sql'); //... $sqlary = array(); jieqi_splitsqlfile($sqlary, preg_replace(array('/DROP\\s+TABLE\\s+IF\\s+EXISTS\\s+`?jieqi_([a-z1-9_]+)`?\\s*;/isU', '/TABLE\\s+`?jieqi_([a-z1-9_]+)`?(;|\\s)/isU', '/INSERT\\s+INTO\\s+`?jieqi_([a-z1-9_]+)`?(;|\\s)/isU', '/UPDATE\\s+`?jieqi_([a-z1-9_]+)`?(;|\\s)/isU'), array('DROP TABLE IF EXISTS `' . JIEQI_DB_PREFIX . '_\\1`;', 'TABLE `' . JIEQI_DB_PREFIX . '_\\1`\\2', 'INSERT INTO `' . JIEQI_DB_PREFIX . '_\\1`\\2', 'UPDATE `' . JIEQI_DB_PREFIX . '_\\1`\\2'), $file_content)); $sqlerr = array(); foreach ($sqlary as $v) { $v = trim($v); if (!empty($v) and strlen($v) > 5) { if ($mysql_version > '4.1') { if (preg_match('/^\\s*CREATE\\s+TABLE/is', $v)) { $v = str_replace(array('TYPE=MyISAM', 'TYPE=HEAP'), array('ENGINE=MyISAM DEFAULT CHARSET=' . JIEQI_DB_CHARSET, 'TYPE=MEMORY DEFAULT CHARSET=' . JIEQI_DB_CHARSET), $v); } } $retflag = $db_query->execute($v); if (!$retflag) { $sqlerr[] = array('sql' => $v, 'error' => $db_query->db->error());
/** * 建立编译模板文件 * * @param string $resource_name 模板文件 * @param bool $isfile resource_name是文件名还是文件内容,默认文件名 * @access private * @return string */ function _compile_file(&$resource_name, $isfile = true) { $this->tplinc = ''; if ($isfile) { $str = jieqi_readfile($resource_name); } else { $str =& $resource_name; } //除去注释, PHP代码,替换程序结束符 $rep_from = array('/' . $this->left_comments . '.*' . $this->right_comments . '/isU', '/<\\?.*\\?>/isU', '/<%.*%>/isU', '/<\\s*script[^>]+language\\s*=\\s*[\'"]?php[\'"]?.*>.*<\\/\\s*script\\s*>/isU'); $rep_to = array('', '', '', ''); $str = preg_replace($rep_from, $rep_to, $str); //分离出所有模板html和语句 $htmlStrs = preg_split("/(" . $this->left_delimiter . ".*" . $this->right_delimiter . ")/isU", $str, -1, PREG_SPLIT_DELIM_CAPTURE); $str = ''; $n = count($htmlStrs); $this->unite = false; for ($i = 0; $i < $n; $i++) { if (strlen($htmlStrs[$i]) > 0) { if ($this->unite) { $str .= ".'" . $this->_addslashes($htmlStrs[$i]) . "'"; } else { $str .= "echo '" . $this->_addslashes($htmlStrs[$i]) . "'"; } $this->unite = true; } $i++; if ($i < $n) { $tmpflag = $this->unite; $tmpvar = strval($this->gettplstr($htmlStrs[$i])); if ($tmpflag == true && $this->unite == true) { $str .= "." . $tmpvar; } elseif ($tmpflag == true && $this->unite == false) { $str .= ";\r\n" . $tmpvar; } elseif ($tmpflag == false && $this->unite == true) { $str .= "echo " . $tmpvar; } elseif ($tmpflag == false && $this->unite == false) { $str .= $tmpvar; } } } if ($this->unite) { $str .= ";"; } unset($regs); unset($htmlStrs); return $str; }