Example #1
0
function king_def()
{
    global $king;
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // 过去的时间
    header("Content-type: image/png");
    $salt = kc_get('salt', 1, 1);
    $width = $king->config('verifywidth');
    //图片长度
    $height = $king->config('verifyheight');
    //图片高度
    $size = $king->config('verifysize');
    //文字大小
    $num = $king->config('verifynum');
    //文字数量
    $content = $king->config('verifycontent');
    //随机字符
    $array_content = explode('|', $content);
    $array_content = array_diff($array_content, array(null));
    $array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
    $str = '';
    $img = imageCreate($width, $height);
    //创建一个空白图像
    imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
    //写字
    for ($i = 0; $i < $num; $i++) {
        $code = $array_content[array_rand($array_content)];
        $str .= $code;
        //验证码字符
        $color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
        $font = 'verify_font/' . $array_font[array_rand($array_font)];
        //随机读取一个字体
        $left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
        imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
    }
    //画星号
    $max = $width * $height / 400;
    for ($i = 0; $i < $max; $i++) {
        imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
    }
    //画点
    $max = $width * $height / 40;
    for ($i = 0; $i < $max; $i++) {
        imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
    }
    //画线
    $max = $width * $height / 800;
    for ($i = 0; $i < $max; $i++) {
        imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
    }
    //写验证码到verify中
    $verify = new KC_Verify_class();
    $verify->Put($salt, $str);
    imagePng($img);
    imageDestroy($img);
    $verify->Clear();
}
Example #2
0
 /**
 	清理多余的临时验证码文件
 	@return void
 */
 public function Clear()
 {
     global $king;
     $array = kc_f_getdir(PATH_CACHE . '/verify', 'php');
     foreach ($array as $val) {
         $filetime = filemtime(ROOT . PATH_CACHE . '/verify/' . $val);
         //读取文件日期
         if ($filetime < time() - $king->config('verifytime')) {
             //如果文件日期小于给定的日期,则删除
             kc_f_delete(PATH_CACHE . '/verify/' . $val);
         }
     }
 }
Example #3
0
/**

	删除文件夹/删除目录
	@papram string $path;  要删除的文件夹路径
	@return void
*/
function kc_f_rd($path, $is = 0)
{
    $path = kc_f_iconv($path, 1);
    if (!is_dir(ROOT . $path)) {
        return;
    }
    $array = kc_f_getdir($path);
    foreach ($array as $val) {
        $file = $path . '/' . $val;
        if ($val != '') {
            if (is_dir(ROOT . $file)) {
                //目录
                kc_f_rd($file, 1);
                rmdir(ROOT . $file);
            } else {
                kc_f_delete($file);
            }
        }
    }
    if (!$is && is_dir(ROOT . $path)) {
        rmdir(ROOT . $path);
    }
}
Example #4
0
    /**
    	返回mainmenu值
    	@return string
    */
    private function tag_mainMenu()
    {
        global $king;
        $cachepath = 'system/mainmenu/' . $king->admin['adminid'] . '/' . $king->admin['adminlanguage'];
        $s = $king->cache->get($cachepath);
        if ($s) {
            return $s;
        }
        if (!$king->acc('#open_setting') && !$king->acc('#open_help')) {
            return '';
        }
        $str = '';
        //language
        $_array = kc_f_getdir('system/language', 'xml');
        if (count($_array) > 1) {
            $_array = array_map('kc_f_name', $_array);
            $i = 0;
            foreach ($_array as $_value) {
                $i ? $str .= '<li>' : ($str .= '<li class="hr">');
                $str .= '<a class="k_ajax" rel="{CMD:\'language\',lang:\'' . $_value . '\',URL:\'../system/manage.php\'}">';
                $str .= '<img src="../system/images/white.gif" class="os ' . ($king->admin['adminlanguage'] == $_value ? 'n8' : '') . '"/>';
                $str .= kc_getlang($_value) . '</a></li>';
                $i++;
            }
        }
        //skins
        $_array = kc_f_getdir('system/skins/', 'dir');
        if (count($_array) > 1) {
            $i = 0;
            foreach ($_array as $_value) {
                $i ? $str .= '<li>' : ($str .= '<li class="hr">');
                $str .= '<a class="k_ajax" rel="{CMD:\'skins\',URL:\'../system/manage.php\',skins:\'' . $_value . '\'}">';
                $str .= '<img src="../system/images/white.gif" class="os ' . ($king->admin['adminskins'] == $_value ? 'n8' : '') . '"/>';
                $str .= kc_getlang($_value) . '</a></li>';
                $i++;
            }
        }
        //editor
        $_array = kc_f_getdir('system/editor/', 'dir');
        if (count($_array) > 1) {
            $i = 0;
            foreach ($_array as $_value) {
                $i ? $str .= '<li>' : ($str .= '<li class="hr">');
                $str .= '<a class="k_ajax" rel="{CMD:\'editor\',URL:\'../system/manage.php\',editor:\'' . $_value . '\'}">';
                $str .= '<img src="../system/images/white.gif" class="os ' . ($king->admin['admineditor'] == $_value ? 'n8' : '') . '"/>';
                $str .= kc_getlang($_value) . '</a></li>';
                $i++;
            }
        }
        $s = '<ul class="k_menu" id="k_mainmenu">';
        if ($king->acc('#open_setting')) {
            $s .= '<li>

				<a href="javascript:;">' . $king->lang->get('system/common/tools') . '</a>

					<ul>';
            if ($king->acc('#systemcache')) {
                $s .= '<li><a class="k_ajax" rel="{CMD:\'clearcache\',URL:\'../system/manage.php\'}"><img src="../system/images/white.gif" class="os d8"/>' . $king->lang->get('system/common/clearcache') . '</a></li>';
            }
            if ($king->acc('#systeminfo')) {
                $s .= '<li class="hr"><a href="../system/manage.php?action=config"><img src="../system/images/white.gif" class="os e7"/>' . $king->lang->get('system/title/system') . '</a></li>';
            }
            if ($king->admin['adminlevel'] == 'admin') {
                $s .= '<li><a href="../system/manage.php?action=admin"><img src="../system/images/white.gif" class="os e6"/>' . $king->lang->get('system/title/admin') . '</a></li>';
            }
            if ($king->acc('#module')) {
                $s .= '<li><a href="../system/manage.php?action=module"><img src="../system/images/white.gif" class="os m8"/>' . $king->lang->get('system/menu/module') . '</a></li>';
            }
            if ($king->acc('#conn')) {
                $s .= '<li class="hr"><a href="../system/manage.php?action=conn"><img src="../system/images/white.gif" class="os r5"/>' . $king->lang->get('system/title/conn') . '</a></li>';
            }
            if ($king->acc('#lnkclass')) {
                $s .= '<li><a href="../system/manage.php?action=lnk"><img src="../system/images/white.gif" class="os r1"/>' . $king->lang->get('system/title/lnk') . '</a></li>';
            }
            if ($king->acc('#upfile')) {
                $s .= '<li><a href="../system/manage.php?action=upfile"><img src="../system/images/white.gif" class="os m5"/>' . $king->lang->get('system/title/upfile') . '</a></li>';
            }
            /*
            				if($king->acc('#timingtask'))
            					$s.='<li><a href="../system/manage.php?action=timingtask">'.$king->lang->get('system/title/timingtask').'</a></li>';
            */
            if ($king->acc('#log')) {
                $s .= '<li class="hr"><a href="../system/manage.php?action=log"><img src="../system/images/white.gif" class="os h6"/>' . $king->lang->get('system/title/log') . '</a></li>';
            }
            if ($king->acc('#event')) {
                $s .= '<li><a href="../system/manage.php?action=event"><img src="../system/images/white.gif" class="os g9"/>' . $king->lang->get('system/title/event') . '</a></li>';
            }
            if ($king->acc('#bot')) {
                $s .= '<li><a href="../system/manage.php?action=bot"><img src="../system/images/white.gif" class="os o8"/>' . $king->lang->get('system/title/bot') . '</a></li>';
            }
            $s .= $str . '
					</ul>
			</li>';
        }
        if ($king->acc('#open_help')) {
            $s .= '
			<li>
				<a href="javascript:;">' . $king->lang->get('system/common/help') . '</a>
				<ul>
					<li><a href="http://help.kingcms.com/" target="_blank"><img src="../system/images/white.gif" class="os q9"/>' . $king->lang->get('system/common/kchelp') . '</a></li>
					<li><a href="javascript:;" class="k_ajax" rel="{URL:\'../system/manage.php\',CMD:\'faq\'}"><img src="../system/images/white.gif" class="os g6"/>' . $king->lang->get('system/common/faq') . '</a></li>
					<li class="hr"><a href="http://www.kingcms.com/" target="_blank"><img src="../system/images/white.gif" class="os b9"/>' . $king->lang->get('system/menu/official') . '</a></li>
					<li><a href="http://bbs.kingcms.com/" target="_blank"><img src="../system/images/white.gif" class="os r2"/>' . $king->lang->get('system/menu/club') . '</a></li>
					<li><a href="http://bbs.kingcms.com/forum-17-1.html" target="_blank"><img src="../system/images/white.gif" class="os r3"/>' . $king->lang->get('system/menu/bug') . '</a></li>
					<li class="hr"><a href="http://www.kingcms.com/license/" target="_blank"><img src="../system/images/white.gif" class="os r4"/>' . $king->lang->get('system/menu/license') . '</a></li>';
            /*
            					<li class="hr"><a class="k_ajax" rel="{CMD:\'about\',URL:\'../system/login.php\'}"><img src="../system/images/white.gif" class="os"/>'.$king->lang->get('system/menu/checknew').'</a></li>';
            */
            if ($king->acc('#phpinfo')) {
                $s .= '<li><a href="../system/manage.php?action=phpinfo"><img src="../system/images/white.gif" class="os a3"/>PHPINFO()</a></li>';
            }
            $s .= '<li class="hr"><a class="k_ajax" rel="{CMD:\'about\',URL:\'../system/login.php\'}"><img src="../system/images/white.gif" class="os h2"/>' . $king->lang->get("system/common/about") . '..</a></li>
				</ul>
			</li>';
        }
        $s .= '</ul>';
        $king->cache->put($cachepath, $s);
        return $s;
    }
Example #5
0
function king_def()
{
    global $king;
    $sel_array = array('mysql' => 'MySQL', 'sqlite' => 'SQLite');
    $phpself = $_SERVER['PHP_SELF'];
    $inst = substr($phpself, 0, strlen($phpself) - 11);
    //安装目录
    $select_type = kc_htm_radio('dbtype', $sel_array, 'sqlite');
    //数据库类型
    $array_dirs = array('config.php', 'system/js');
    $array_func = array('mysql_connect', 'file_get_contents', 'file_put_contents', 'simplexml_load_file');
    //,'fsockopen'
    $s = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<title>" . $king->lang->get('system/install/title') . "</title>\r\n<link href=\"system/skins/default/style.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n<style type=\"text/css\">\r\n.k_table_form{font-size:12px;}\r\n.k_table_form th{width:200px;color:#000;font-weight:normal;text-indent:5px;padding:5px;}\r\n.k_table_form td{text-indent:5px;}\r\n</style>\r\n<meta name=\"generator\" content=\"KingCMS\"/>\r\n<script type=\"text/javascript\" src=\"system/js/jquery.js\"></script>\r\n<script type=\"text/javascript\" src=\"system/js/jquery.kc.js\"></script>\r\n<script type=\"text/javascript\" src=\"system/skins/default/fun.js\"></script>\r\n<script type=\"text/javascript\">\r\njQuery(function(\$){\r\n\r\n\t\$(\"#k_dbtype_mysql , #k_dbtype_sqlite\").click(function(){\$.ck_radio(this)});\r\n\r\n\t\$.ck_radio=function(obj){\r\n\t\tif(\$(obj).attr('id')=='k_dbtype_mysql'){\r\n\t\t\t\$('.mysql').show();\r\n\t\t\t\$('.sqlite').hide();\r\n\r\n\t\t}else{\r\n\t\t\t\$('.sqlite').show();\r\n\t\t\t\$('.mysql').hide();\r\n\t\t\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n</script>\r\n</head>\r\n<body>\r\n<div id=\"k_ajax\"></div>\r\n<div id=\"top\">\r\n\t<a id=\"logo\" href=\"http://www.kingcms.com\" target=\"_blank\"><img alt=\"KingCMS\" src=\"system/skins/default/logo.gif\"/></a>\r\n\t<ul class=\"k_menu\">\r\n\t\t<li><a href=\"INSTALL.php\">" . $king->lang->get('system/common/install') . "</a></li>\r\n\t\t<li><a href=\"javascript:;\">" . $king->lang->get('system/common/language') . "</a>\r\n\r\n\t\t\t\t<ul>";
    //language
    $array = kc_f_getdir('system/language', 'xml');
    $array = array_map('kc_f_name', $array);
    $_language = kc_cookie('language');
    foreach ($array as $val) {
        $s .= '<li><a href="javascript:;" class="k_ajax" rel="{CMD:\'language\',lang:\'' . $val . '\'}">';
        if ($_language == $val) {
            $s .= '&bull;&nbsp;';
        }
        $s .= kc_getlang($val) . '</a></li>';
    }
    $s .= "</ul>\r\n\t\t</li>\r\n\t</ul>\r\n</div>\r\n<div id=\"main\">\r\n\r\n\r\n<table class=\"w0\"><tr><td style=\"vertical-align:top;\" class=\"w10\">\r\n\t<form name=\"form_install\" id=\"form_install\">\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/install/db') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/dbtype') . "</th><td>{$select_type}</td></tr></tbody>\r\n\t\t<tr><th>" . $king->lang->get('system/install/pre') . "</th><td><input id=\"pre\" name=\"pre\" class=\"k_in w200\" value=\"king\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/preadmin') . "</th><td><input id=\"preadmin\" name=\"preadmin\" class=\"k_in w200\" value=\"kc\"/></td></tr>\r\n\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbhost') . "</th><td><input id=\"host\" name=\"host\" class=\"k_in w200\" value=\"localhost\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbdata') . "</th><td><input id=\"data\" name=\"data\" class=\"k_in w200\" value=\"test\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbuser') . "</th><td><input id=\"user\" name=\"user\" class=\"k_in w200\" value=\"root\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbpass') . "</th><td><input id=\"pass\" name=\"pass\" class=\"k_in w200\" value=\"\"/></td></tr>\r\n\r\n\t\t<tr class=\"sqlite\"><th>" . $king->lang->get('system/install/dbfile') . "</th><td><input id=\"sqlitedata\" name=\"sqlitedata\" class=\"k_in w200\" value=\"" . kc_random(12) . ".db3\"/></td></tr>\r\n\t</table>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/install/admin') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/adminname') . "</th><td><input id=\"adminname\" name=\"adminname\" class=\"k_in w200\" value=\"admin\"/></td></tr></tbody>\r\n\t\t<tr><th>" . $king->lang->get('system/install/adminpass') . "</th><td><input id=\"adminpass\" name=\"adminpass\" class=\"k_in w200\" value=\"admin888\"/></td></tr>\r\n\t</table>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/level/config') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/cache') . "</th><td><input id=\"cache\" name=\"cache\" class=\"k_in w200\" value=\"_cache\"/></td></tr></tbody>\r\n\r\n\t\t<tr><th>" . $king->lang->get('system/const/inst') . "</th><td><input id=\"inst\" name=\"inst\" class=\"k_in w100\" value=\"{$inst}\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/timediff') . "</th><td><input id=\"timediff\" name=\"timediff\" class=\"k_in w100\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/debug') . "</th><td><input id=\"debug\" value=\"1\" name=\"debug\" type=\"checkbox\" checked=\"checked\"/><label for=\"debug\">" . $king->lang->get('system/install/opendebug') . "</label></td></tr>\r\n\t</table>\r\n\r\n\t<script type=\"text/javascript\">\r\n\tvar dateObj = new Date();\r\n\tvar timediff=" . date('G', 0) . ";\r\n\t\$('#timediff').val(timediff);\r\n\t</script>\r\n\r\n\t<p>\r\n\t\t<input value=\"1\" id=\"license\" name=\"license\" type=\"checkbox\"/><label for=\"license\">" . $king->lang->get('system/install/readlicense') . "</label>\r\n\t\t[<a href=\"http://www.kingcms.com/license/\" target=\"_blank\">" . $king->lang->get('system/install/license') . "</a>]\r\n\t</p>\r\n\t\t<input value=\"1\" id=\"isdelete\" name=\"isdelete\" type=\"checkbox\" checked=\"checked\"/><label for=\"isdelete\">" . $king->lang->get('system/install/isdelete') . "</label>\r\n\t<p>\r\n\r\n\t</p>\r\n\r\n\t<p class=\"k_submit\">\r\n\r\n\t\t<input value=\"" . $king->lang->get('system/common/install') . "[S]\" class=\"k_ajax big\" rel=\"{CMD:'config',FORM:'form_install'}\" type=\"button\" accesskey=\"s\"/>\r\n\r\n\t</p>\r\n\t</form>\r\n</td><td class=\"w1\" style=\"vertical-align:top;\"></td><td>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/sys') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/obj') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/this') . "</th></tr>";
    $s .= '<tr><td>' . $king->lang->get('system/skin/os') . '</td><td>ALL</td><td>' . PHP_OS . '</td></tr>';
    $s .= '<tr><td>' . $king->lang->get('system/skin/phpver') . '</td><td>5.1.0+</td><td>' . PHP_VERSION . '</td></tr>';
    if (function_exists('disk_free_space')) {
        $s .= '<tr><td>' . $king->lang->get('system/skin/diskspace') . '</td><td>>2 Mb</td><td>' . kc_f_size(disk_free_space('./')) . '</td></tr>';
    }
    $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/writeinfo') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/filedir') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5wgfv -k07-87;[yu'pbv9io/h9;'99999\">" . $king->lang->get('system/skin/this') . "</td></tr>";
    foreach ($array_dirs as $val) {
        $s .= '<tr><td>' . $val . '</td><td>' . $king->lang->get('system/skin/write/w1') . '</td><td>' . $king->lang->get('system/skin/write/w' . (is_writable(ROOT . $val) ? 1 : 0)) . '</td></tr>';
    }
    $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/func') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/funs') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/this') . "</th></tr>";
    foreach ($array_func as $val) {
        $s .= '<tr><td>' . $val . '()</td><td>' . $king->lang->get('system/skin/fun/f1') . '</td><td>' . $king->lang->get('system/skin/fun/f' . (function_exists($val) ? 1 : 0)) . '</td></tr>';
    }
    $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/other') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t";
    $s .= "<tr><th class=\"w10 red\">" . $king->lang->get('system/skin/obj') . "</th><th class=\"w5 red\">" . $king->lang->get('system/skin/advice') . "</th><th class=\"w5 red\">" . $king->lang->get('system/skin/this') . "</th></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/browser') . "</td><td>IE 7.0</td><td>" . kc_browser() . "</td></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/safemode') . "</td><td>--</td><td>" . $king->lang->get('system/skin/open/o' . (ini_get('safe_mode') ? 1 : 0)) . "</td></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/maxetime') . "</td><td>--</td><td>" . ini_get('max_execution_time') . "s</td></tr>\r\n\t</table>\r\n\r\n\t<p><img class=\"f6 os\" src=\"system/images/white.gif\"/><a href=\"http://www.kingcms.com/\" class=\"k_ajax\" rel=\"{CMD:'repass',METHOD:'GET'}\">" . $king->lang->get('system/install/resetpass') . "</a></p>\r\n\t<p><img class=\"j2 os\" src=\"system/images/white.gif\"/><a href=\"http://www.kingcms.com/\" class=\"k_ajax\" rel=\"{CMD:'delete'}\">" . $king->lang->get('system/install/delfile') . "</a></p>\r\n\t<p><img class=\"n1 os\" src=\"system/images/white.gif\"/><a href=\"system/login.php\">" . $king->lang->get('system/install/login') . "</a></p>\r\n\r\n</td></tr></table>\r\n\r\n</div>\r\n</body>\r\n</html>";
    exit($s);
}
Example #6
0
function king_lnkedt()
{
    global $king;
    $king->access('#lnk');
    $kid = kc_get('kid', 2);
    $adminid = kc_get('adminid', 2) ? kc_get('adminid', 2, 1) : $king->admin['adminid'];
    //当提交过来的adminid和当前管理员id不同的时候,验证管理员的级别
    if ($adminid != $king->admin['adminid']) {
        $king->access('admin');
    }
    $sql = 'kname,ktitle,kpath,adminid,kimage,isblank,konclick,isflo';
    if ($GLOBALS['ismethod'] || $kid == '') {
        //POST过程或新添加的过程
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            //初始化新添加的数据
            $data['kimage'] = 'lnk.gif';
            $data['adminid'] = $adminid;
        }
    } else {
        if (!($data = $king->db->getRows_one("select {$sql} from %s_lnk where kid={$kid} limit 1;"))) {
            kc_error($king->lang->get('system/error/param') . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__);
        }
    }
    $fields = explode(',', $sql);
    $data = kc_data($fields, $data);
    $s = $king->openForm('manage.php?action=lnkedt');
    //kname
    $_array = array(array('kname', 0, 1, 20));
    $s .= $king->htmForm($king->lang->get('system/lnk/kname') . ' (1-20)', '<input class="k_in w200" type="text" name="kname" value="' . htmlspecialchars($data['kname']) . '" maxlength="20" />', $_array);
    //ktitle
    $_array = array(array('ktitle', 0, 0, 100));
    $s .= $king->htmForm($king->lang->get('system/lnk/ktitle') . ' (0-100)', '<input class="k_in w400" type="text" name="ktitle" value="' . htmlspecialchars($data['ktitle']) . '" maxlength="100" />', $_array);
    //kpath
    $_array = array(array('kpath', 0, 1, 100));
    $s .= $king->htmForm($king->lang->get('system/lnk/kpath') . ' (1-100)', '<input class="k_in w400" type="text" name="kpath" value="' . htmlspecialchars($data['kpath']) . '" maxlength="100" />', $_array);
    //konclick
    $_array = array(array('konclick', 0, 0, 255));
    $s .= $king->htmForm($king->lang->get('system/lnk/konclick') . ' (0-255)', '<input class="k_in w400" type="text" name="konclick" value="' . htmlspecialchars($data['konclick']) . '" maxlength="255" />', $_array);
    //isblank&isflo
    $array_blank = array(1 => $king->lang->get('system/lnk/blank'));
    $array_flo = array(1 => $king->lang->get('system/lnk/flo'));
    $s .= $king->htmForm($king->lang->get('system/lnk/attrib'), kc_htm_checkbox('isblank', $array_blank, $data['isblank']) . kc_htm_checkbox('isflo', $array_flo, $data['isflo']));
    //kimage
    $_array = array(array('kimage', 0, 1, 100));
    $array = kc_f_getdir('system/images/lnk', 'gif|png|jpg');
    $image = '<div id="lnksel"><p>';
    $i = 1;
    foreach ($array as $val) {
        $image .= '<a href="javascript:;" onclick="$(\'#kimage\').val(\'' . $val . '\');lnksel();"><img src="images/lnk/' . $val . '"/></a>';
        if ($i++ == 6) {
            $image .= '</p><p>';
            $i = 1;
        }
    }
    $image .= '</p></div>';
    $s .= $king->htmForm($king->lang->get('system/lnk/image'), '<table class="k_side" cellspacing="0"><tr><td><img src="images/lnk/' . htmlspecialchars($data['kimage']) . '" id="klnkimage"/></td><td>' . $image . '</td></tr></table>', $_array, null, kc_help('system/help/lnkimg'));
    $s .= kc_htm_hidden(array('adminid' => $data['adminid'], 'kimage' => htmlspecialchars($data['kimage']), 'kid' => $kid));
    $s .= '<script>function lnksel(){var kimage=$(\'#kimage\').val();$(\'#klnkimage\').attr(\'src\',\'images/lnk/\'+kimage);}</script>';
    $s .= $king->closeForm('save');
    if ($GLOBALS['ischeck']) {
        //	$sql='kname,ktitle,kpath,adminid,kimage,isblank,konclick,isflo';
        $array = array();
        foreach ($fields as $val) {
            $array[$val] = $data[$val];
        }
        $_array = array('isblank', 'isflo');
        foreach ($_array as $val) {
            $array[$val] = $data[$val] ? 1 : 0;
        }
        if ($kid) {
            //update
            $king->db->update('%s_lnk', $array, "kid={$kid}");
            $nlog = 7;
        } else {
            //insert
            $array['norder'] = $king->db->neworder('%s_lnk', "adminid={$data['adminid']}");
            $nlog = 5;
            $king->db->insert('%s_lnk', $array);
        }
        $king->cache->del('system/lnk/' . $data['adminid']);
        $king->cache->del('system/lnk/flo_' . $data['adminid']);
        //写log
        $king->log($nlog, $data['kname']);
        kc_goto($king->lang->get('system/goto/is'), 'manage.php?action=lnkedt&adminid=' . $data['adminid'], 'manage.php?action=lnk&adminid=' . $data['adminid']);
    }
    $king->skin->output($king->lang->get('system/title/lnk'), king_inc_lnk_left(), '', $s);
}
Example #7
0
/**
	双击重命名,单击编辑、下载
	创建文件
	添加编辑器
*/
function king_def()
{
    global $king;
    $king->access('webftp');
    $path = kc_post('path');
    $dirs = kc_f_getdir($path, 'dir');
    $s = "<table class=\"k_side w0\">";
    $s .= "<tr><td class=\"w200\">";
    //左侧菜单
    $s .= "<table class=\"k_table_list\" cellspacing=\"0\">";
    $s .= "<tr id=\"ftp_dir\"><th><em id=\"ftp_root\"><img src=\"../system/images/white.gif\" class=\"os b1\"/></em>";
    $s .= "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:'right'}\">" . $king->lang->get('webftp/list/dir') . "</a></th></tr>";
    //左侧
    $s .= "</table>";
    $s .= "</td><td>";
    $s .= "<table class=\"k_table_list\" cellspacing=\"0\">";
    $s .= "<tr id=\"ftp_file\"><th>" . $king->lang->get('system/common/filename') . "</th>";
    $s .= "<th class=\"w100\">" . $king->lang->get('system/common/manage') . "</th>";
    $s .= "<th class=\"w150\">" . $king->lang->get('system/common/filesize') . "</th>";
    $s .= "<th class=\"w150\">" . $king->lang->get('system/common/modifydate') . "</th>";
    $s .= "</tr>";
    //右侧内容
    $s .= "</table>";
    $s .= "</td></tr>";
    $s .= "</table>";
    $s .= "<script language=\"javascript\" type=\"text/javascript\" src=\"edit_area/edit_area_full.js\"></script>";
    $s .= "<script type=\"text/javascript\" >\r\n\r\n\t//调用右侧文件列表\r\n\t\$.kc_ajax({CMD:'right'});\r\n\t//调用左侧导航菜单\r\n\t\$.kc_ajax({CMD:'left',obj:'ftp_dir',ID:'ftp_root',IS:2});\r\n\r\n\tfunction lll(path,dir,issub,space){var spath=path+dir;var id=spath.replace(/[\\]\\[\\/\\!\\@\\#\$\\%\\^\\&\\(\\)\\~\\+\\;\\'\\,\\.\\`\\-\\=]/g,'_');\r\n\t\tvar s='<tr id=\"k_brow_obj_'+id+'\"><td>';\r\n\t\tfor(i=0;i<space;i++){s+=\$.kc_icon()};//space计算\r\n\t\t\r\n\t\t//+-展开按钮\r\n\t\ts+='<a id=\"k_brow_dir_'+id+'\" href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:\\'left\\',path:\\''+path+dir+'/\\',ID:\\'k_brow_dir_'+id+'\\',obj:\\'k_brow_obj_'+id+'\\',space:'+(space*1+1)+',IS:2}\">';\r\n\t\ts+=\$.kc_icon(issub==1?'k1':'')+'</a>';\r\n\r\n\t\t//点击后在右侧显示对应目录下面的文件\r\n\t\ts+='<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:\\'right\\',path:\\''+path+dir+'/\\'}\">'+\$.kc_icon('b1')+'<em id=\"k_brow_sub_'+id+'\">'+dir+'</em></a></td>';\r\n\t\ts+='</tr>';\r\n\t\treturn s;\r\n\t};\r\n\r\n\t//关闭展开\r\n\tfunction remove_dir(id,space){\r\n\t\t\$(\"[id^='\"+id+\"_']\").remove();\r\n\t};\r\n\r\n\t//右侧文件列表\r\n\tfunction iii(ico,path,file,size,mdate){var s;\r\n\t\tvar spath=path+file;\r\n\t\tvar id=spath.replace(/[\\]\\[\\/\\!\\@\\#\$\\%\\^\\&\\(\\)\\~\\+\\;\\'\\,\\.\\`\\-\\=]/g,'_');\r\n\t\tvar isdir=(size=='--' ? 1 : 0);\r\n\t\ts='<tr id=\"k_brow_right_'+id+'\" ondblClick=\"iRename(\\''+ico+'\\',\\''+path+'\\',\\''+file+'\\',\\''+size+'\\',\\''+encodeURI(mdate)+'\\',\\''+id+'\\')\"><td>';\r\n\t\ts+=\$.kc_list(id,file,iLink(path,file,isdir,id),0,1,ico);\r\n\t\ts+='</td>';\r\n\t\ts+='<td>';\r\n\t\t//重命名\r\n\t\ts+='<a href=\"javascript:;\" onClick=\"iRename(\\''+ico+'\\',\\''+path+'\\',\\''+file+'\\',\\''+size+'\\',\\''+encodeURI(mdate)+'\\',\\''+id+'\\')\">';\r\n\t\ts+=\$.kc_icon('l4','" . $king->lang->get('system/common/rename') . "')+'</a>';\r\n\t\t//删除\r\n\t\ts+='<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:\\'delete\\',path:\\''+path+'\\',file:\\''+file+'\\',isdir:'+isdir+',IS:2,ID:\\'ftp_root\\'}\">';\r\n\t\ts+=\$.kc_icon('j2','" . $king->lang->get('system/common/del') . "');\r\n\t\ts+='</td>';\r\n\t\ts+='<td>'+size+'</td>';\r\n\t\ts+='<td>'+mdate+'</td>';\r\n\t\ts+='</tr>';\r\n\r\n\t\treturn s;\r\n\t\r\n\t}\r\n\r\n\t//重命名文件或文件夹\r\n\tfunction iRename(ico,path,file,size,mdate,id){var s;\r\n\t\tvar isdir=(size=='--' ? 1 : 0);\r\n\t\ts='<input class=\"k_in w200\" value=\"'+file+'\" id=\"R'+id+'\"/>';\r\n\r\n\t\ts+='<a href=\"javascript:;\" class=\"k_ajax\" ';\r\n\t\ts+='rel=\"{CMD:\\'rename\\',path:\\''+path+'\\',file:\\''+file+'\\',id:\\'R'+id+'\\',VAL:\\'R'+id+'\\',isdir:'+isdir+'}\">';\r\n\t\ts+=\$.kc_icon('o7')+'</a>';\r\n\r\n\t\ts+='<a href=\"javascript:;\" onClick=\"nRename(\\''+ico+'\\',\\''+path+'\\',\\''+file+'\\',\\''+size+'\\',\\''+mdate+'\\',\\''+id+'\\')\">';\r\n\t\ts+=\$.kc_icon('m2')+'</a>';\r\n\r\n\t\t\$('#k_brow_right_'+id+'>td>label>u').html(s);\r\n\t\t\$.kc_ready('#k_brow_right_'+id+'>td>label>u');\r\n\t}\r\n\t//取消重命名\r\n\tfunction nRename(ico,path,file,size,mdate,id){\r\n\t\t\$('#k_brow_right_'+id).replaceWith(iii(ico,path,file,size,decodeURI(mdate)));\r\n\t}\r\n\r\n\t//生成链接\r\n\tfunction iLink(path,file,isdir,id){\r\n\t\tvar s;\r\n\t\tif(isdir){\r\n\t\t\ts='{CMD:\\'right\\',path:\\''+path+file+'/\\',leftopen:1}';\r\n\t\t}else{\r\n\t\t\tvar fext=file.substring(file.lastIndexOf('.') + 1);\r\n\r\n\t\t\tvar ss={php:'',html:'',htm:''};\r\n\r\n\t\t\tif(ss[fext]!=undefined){\r\n\t\t\t\ts='{CMD:\\'edit\\',path:\\''+path+file+'\\'}';\r\n\t\t\t}else{\r\n\t\t\t\ts='../'+path+file;\r\n\t\t\t}\r\n\r\n\t\t\tswitch(fext){\r\n\t\t\t\tcase 'php':\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase 'html':\r\n\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn s;\r\n\t}";
    $s .= "</script>";
    $king->skin->output($king->lang->get('webftp/title/center'), '', '', $s);
}