Esempio n. 1
0
 public function KC_Template_class($outTmp = '', $inTmp = '')
 {
     //读取模板 并 合并
     global $king;
     $s = kc_f_get_contents(strtolower($outTmp));
     isset($inTmp[0]) ? $s_in = kc_f_get_contents(strtolower($inTmp)) : ($s_in = '{king:inside/}');
     $s = preg_replace('/{king:inside\\s*\\/}/i', $s_in, $s, 1);
     $s = preg_replace('%(</title[^>]*>)%s', "\${1}\n<meta name=\"generator\" content=\"KingCMS\"/>\n<script type=\"text/javascript\" src=\"" . $king->config('inst') . "system/js/jquery.js\"></script>\n<script type=\"text/javascript\" src=\"" . $king->config('inst') . "system/js/jquery.kc.js\"></script>", $s, 1);
     $s = preg_replace('%(\\<(script|link|img|input|embed|object|base|area|map|table|td|th|tr|param) [^>]*(src|href|background|value)=(["\']))((\\.\\.\\/)+)(images\\/[^>]+\\4[^>]*\\>)%s', "\${1}" . $king->config('siteurl') . $king->config('inst') . "\${7}", $s);
     //过滤HTML注释<!--  -->
     if ($king->config('templatefiternote')) {
         $s = preg_replace('/<\\!--((?!-->|<\\!--).|\\n)*-->/i', '', $s);
     }
     $this->tmp = $s;
 }
Esempio n. 2
0
 /**
 	读取缓存的内容
 	@param string $path     路径
 	@param string $time     缓存文件过期时间设置
 		1  当$time==1的时候,仅读取预定的缓存时间内的内容
 */
 public function get($path, $time = null)
 {
     global $king;
     /*
     	if(empty($GLOBALS['Cache_class_array']))
     		$GLOBALS['Cache_class_array']=array();
     */
     $path = PATH_CACHE . '/' . strtolower($path) . $this->ext;
     /*
     */
     if (empty($GLOBALS['file_get_contents_array'])) {
         $GLOBALS['file_get_contents_array'] = array();
     }
     if (array_key_exists($path, $GLOBALS['file_get_contents_array'])) {
         //如果已经存在这个键值
         return $GLOBALS['file_get_contents_array'][$path];
     } else {
         //如果没有这个键值,则加入
         if (file_exists(ROOT . $path)) {
             if ($time) {
                 //如果有日期限制,则需要做比较
                 if ($time == 1) {
                     $time = time() - $king->config('cachetime');
                 }
                 $filetime = filemtime(ROOT . $path);
                 //读取文件日期
                 if ($filetime < $time) {
                     //如果文件日期小于给定的日期,则为过时
                     return false;
                 }
             }
             /**/
             //			$s=unserialize(kc_f_get_contents($path));
             $s = unserialize(substr(kc_f_get_contents($path), 49));
             /**
             			//unserialize效率竟然远远高于include??
             			$s=include(PATH_CACHE.'/'.$path.$this->ext);
             			/**/
             $GLOBALS['file_get_contents_array'][$path] = $s;
             //重写file数组
             return $s;
         } else {
             return false;
         }
     }
     /*
     */
 }
Esempio n. 3
0
 +   @Link         http://www.KingCMS.com/            +

 +   @E-Mail       KingCMS(a)Gmail.com                +

 +   Copyright (c) KingCMS.com All Rights Reserved.   +

 * ================================================== */
define('ROOT', dirname(__FILE__) . '/');
define('INC', True);
require ROOT . 'config.php';
require ROOT . 'system/core.class.php';
require ROOT . 'system/lib/func.php';
//Beta版->正式版的重大变更,自动升级config.php
if (!defined('DB_TYPE') && defined('KC_DB_TYPE')) {
    $isupdate = 1;
    $s = kc_f_get_contents('config.php');
    $s = str_replace('KC_DB_', 'DB_', $s);
    $s = str_replace('DB_ADMIN', 'KC_DB_ADMIN', $s);
    $s = str_replace('KC_CONFIG_', '', $s);
    $s = str_replace('KC_CACHE_PATH', 'PATH_CACHE', $s);
    /*
    $s=str_replace('KC_DB_TYPE','DB_TYPE',$s);
    $s=str_replace('KC_DB_CHARSET','DB_CHARSET',$s);
    $s=str_replace('KC_DB_PRE','DB_PRE',$s);
    //$s=str_replace('KC_DB_ADMIN','DB_ADMIN',$s);
    $s=str_replace('KC_DB_HOST','DB_HOST',$s);
    $s=str_replace('KC_DB_DATA','DB_DATA',$s);
    $s=str_replace('KC_DB_USER','DB_USER',$s);
    $s=str_replace('KC_DB_PASS','DB_PASS',$s);
    $s=str_replace('KC_DB_SQLITE','DB_SQLITE',$s);
    
Esempio n. 4
0
function king_ajax_config()
{
    global $king;
    //dbtype
    $dbtype = kc_post('dbtype');
    if (!in_array($dbtype, array('mysql', 'sqlite'))) {
        kc_error($king->lang->get('system/install/dbtypeerr'));
    }
    //licensed
    $license = kc_post('license');
    if ($license != 1) {
        kc_error($king->lang->get('system/install/licenseerr'));
    }
    $host = kc_post('host');
    $data = kc_post('data');
    $user = kc_post('user');
    $pass = kc_post('pass');
    $sqlitedata = kc_post('sqlitedata');
    //验证
    if ($dbtype == 'mysql') {
        //host
        if (!kc_validate($host, '/^[A-Za-z0-9\\.\\:\\/]+$/')) {
            kc_error($king->lang->get('system/install/ckhost'));
        }
        //data
        if (!kc_validate($data, '/^[A-Za-z0-9\\-\\_]+$/')) {
            kc_error($king->lang->get('system/install/ckdata'));
        }
        //user
        if (!kc_validate($user, '/^[A-Za-z0-9\\-\\_]+$/')) {
            kc_error($king->lang->get('system/install/ckuser'));
        }
    } else {
        //sqlitedata
        if (!kc_validate($sqlitedata, '/^[A-Za-z0-9\\-\\_\\.]+$/')) {
            kc_error($king->lang->get('system/install/ckdata'));
        }
    }
    //pre
    $pre = kc_post('pre');
    if (!kc_validate($pre, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckpre'));
    }
    //preadmin
    $preadmin = kc_post('preadmin');
    if (!kc_validate($preadmin, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckpreadmin'));
    }
    //adminname
    $adminname = kc_get('adminname', 1, 1);
    if (strlen($adminname) < 2 || strlen($adminname) > 12) {
        kc_error($king->lang->get('system/install/ckadminname'));
    }
    //adminpass
    $adminpass = kc_get('adminpass', 0, 1);
    if (strlen($adminpass) < 6 || strlen($adminname) > 30) {
        kc_error($king->lang->get('system/install/ckadminpass'));
    }
    //cache
    $cache = kc_post('cache');
    if (!kc_validate($cache, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckcache'));
    }
    //inst
    $inst = kc_post('inst');
    //timediff
    $timediff = kc_get('timediff', 2, 1);
    //debug
    $debug = kc_post('debug') == 1 ? 'True' : 'False';
    //isdelete
    $isdelete = kc_post('isdelete') == 1 ? 1 : 0;
    $s = kc_f_get_contents('config.php');
    $s = preg_replace("%(define\\('DB_TYPE',')([A-Za-z]+)('\\))%s", "\${1}{$dbtype}\${3}", $s);
    $s = preg_replace("%(define\\('DB_PRE',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$pre}\${3}", $s);
    $s = preg_replace("%(define\\('KC_DB_ADMIN',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$preadmin}\${3}", $s);
    //sqlite
    $s = preg_replace("%(define\\('DB_SQLITE',')([A-Za-z0-9\\-\\_\\.\\/]+)('\\))%s", "\${1}{$sqlitedata}\${3}", $s);
    //mysql
    $s = preg_replace("%(define\\('DB_HOST',')([A-Za-z0-9\\.\\:\\/]+)('\\))%s", "\${1}{$host}\${3}", $s);
    $s = preg_replace("%(define\\('DB_DATA',')([A-Za-z0-9\\-\\_]+)('\\))%s", "\${1}{$data}\${3}", $s);
    $s = preg_replace("%(define\\('DB_USER',')([A-Za-z0-9\\-\\_]+)('\\))%s", "\${1}{$user}\${3}", $s);
    $s = preg_replace("%(define\\('DB_PASS',')([^']*)('\\))%s", "\${1}{$pass}\${3}", $s);
    $s = preg_replace("%(define\\('PATH_CACHE',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$cache}\${3}", $s);
    $s = preg_replace("%(define\\('DEBUG',)(True|False)(\\))%s", "\${1}{$debug}\${3}", $s);
    if (kc_f_put_contents('config.php', $s)) {
        //写入成功
        $js = "\$.kc_ajax('{CMD:\\'install\\',adminname:\\'{$adminname}\\',adminpass:\\'{$adminpass}\\',timediff:\\'{$timediff}\\',inst:\\'{$inst}\\',isdelete:\\'{$isdelete}\\'}')";
        kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/install/crtdb') . "</p>", "<a href=\"javascript:;\">" . $king->lang->get('system/common/cancel') . "</a>", $js);
    } else {
        kc_error($king->lang->get('system/install/puterror'));
    }
    //写config.php,并输出ajax执行程序,进入下一步install
}
Esempio n. 5
0
/**
	编辑文本
*/
function king_ajax_edit()
{
    global $king;
    $king->access('webftp_edit');
    $path = kc_post('path');
    $ext = kc_f_ext($path);
    switch ($ext) {
        case 'html':
            $code = 'html';
            break;
        case 'htm':
            $code = 'html';
            break;
        case 'shtml':
            $code = 'html';
            break;
        case 'shtm':
            $code = 'html';
            break;
        case 'css':
            $code = 'css';
            break;
        case 'js':
            $code = 'js';
            break;
        case 'php':
            $code = 'php';
            break;
        case 'php3':
            $code = 'php';
            break;
        case 'php4':
            $code = 'php';
            break;
        case 'sql':
            $code = 'sql';
            break;
        case 'xml':
            $code = 'xml';
            break;
        default:
            $code = '';
    }
    if (isset($_POST['webftpcontent'])) {
        //写文件
        kc_f_put_contents($path, $_POST['webftpcontent'], 1);
        kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/ok/save') . "</p>");
    }
    if (!kc_f_isfile($path)) {
        kc_error($king->lang->get('system/error/notfile'));
    }
    $content = kc_f_get_contents($path);
    $js = "editAreaLoader.init({\r\n\t\t\tid: \"webftpcontent\"\r\n\t\t\t,start_highlight: " . (strlen($content) > 10240 ? 'false' : 'true') . "\r\n\t\t\t,allow_resize: \"both\"\r\n\t\t\t,allow_toggle: false\r\n\t\t\t,word_wrap: true\r\n\t\t\t,language: \"en\"\r\n\t\t\t,syntax: \"php\"\r\n\t\t});";
    $s = "<textarea id=\"webftpcontent\" name=\"webftpcontent\" rows=\"15\" cols=\"80\" style=\"width:870px;height:420px\">";
    $s .= htmlspecialchars($content);
    $s .= "</textarea>";
    $but = kc_htm_a($king->lang->get('system/common/save'), "{CMD:'edit',IS:1,path:'{$path}'}");
    kc_ajax($king->lang->get('system/common/edit') . ' : ' . $path, $s, $but, $js, 900, 450);
}