Exemplo n.º 1
0
function king_ajax_login()
{
    /**
    登录页面增加一个$act变量,做登录判断用。
    */
    global $king;
    $adminname = kc_post('adminname');
    $adminpass = kc_post('adminpass');
    $s = '<div class="k_login"><div><label>' . $king->lang->get('system/login/name') . ':</label><p><input type="text" class="k_in w150" id="adminname" name="adminname" value="' . htmlspecialchars($adminname) . '" maxlength="12" />';
    $s .= kc_check(array(array('adminname', 0, $king->lang->get('system/check/e0'), 2, 12), array('adminname', 1, $king->lang->get('system/check/e1'))));
    $s .= '</p></div>';
    $s .= '<div><label>' . $king->lang->get('system/login/pass') . ':</label><p><input type="password" class="k_in w150" id="adminpass" name="adminpass" maxlength="30" />';
    $s .= kc_check(array(array('adminpass', 0, $king->lang->get('system/check/e0'), 6, 30)));
    if ($GLOBALS['ischeck']) {
        $s .= kc_check(array(array('adminpass', 12, $king->lang->get('system/login/check'), !king_ajax_login_check($adminname, $adminpass))));
    }
    $s .= '</p></div>';
    //expire
    $array_select = array(0 => $king->lang->get('system/time/cookie'), 86400 => $king->lang->get('system/time/oneday'), 2592000 => $king->lang->get('system/time/jan'), 15768000 => $king->lang->get('system/time/halfyear'), 315360000 => $king->lang->get('system/time/forever'));
    $s .= '<div><label>' . $king->lang->get('portal/user/expire') . ':</label><p>' . kc_htm_select('expire', $array_select, 86400) . '</p></div></div>';
    $but = kc_htm_a($king->lang->get('system/common/login'), "{CMD:'login',IS:1}");
    $but .= '<a href="javascript:;" title="' . $king->lang->get('system/common/close') . '" class="k_close">' . $king->lang->get('system/common/close') . '</a>';
    //	$s.='</p>';
    if ($GLOBALS['ischeck']) {
        $_sql = "select adminlogin from %a_admin where adminname='" . $king->db->escape($adminname) . "';";
        if ($_res = $king->db->getRows_one($_sql)) {
            $_location = $_res['adminlogin'];
        }
        kc_ajax('', '', 0, "parent.location='{$_location}'");
    } else {
        kc_ajax($king->lang->get('system/login/title'), $s, $but, '', 420, 220);
        kc_error($but);
    }
}
Exemplo n.º 2
0
 /**
 	返回htm标签
 	@param string $_label       Label标签中的内容
 	@param string $_htmlcode    表单的主体内容
 	@param array  $_arraycheck  表单验证,详见kc_check()
 	@param string $_tag         表单对应的KingCMS标签
 	@param string $_help        帮助
 	@return string
 */
 public function htmForm($_label = null, $_htmlcode = null, $_arraycheck = null, $_tag = null, $_help = null)
 {
     if ($this->config('htmlframe' . $this->isMng) == 1 && !in_array($GLOBALS['action'], array('ajax', 'iframe'))) {
         //1代表的是table结构
         $s = '<tbody><tr>';
         if (!empty($_label)) {
             $s .= '<th>';
             preg_match_all("/^([^\\(]+)((\\(.*\\))?)\$/", $_label, $_label_array, PREG_PATTERN_ORDER);
             //拆分标题和提示内容
             $s .= $_label_array[1][0];
             $s .= '</th>';
         } else {
             $s .= "<th>&nbsp;</th>";
         }
         $s .= '<td>';
         $s_tag = '';
         if ($this->isMng) {
             if ($this->admin['adminmode'] == 2) {
                 if (isset($_tag[0])) {
                     $array = explode(',', $_tag);
                     $s_tag .= ' <var>';
                     foreach ($array as $val) {
                         list($prefix, $name) = substr($val, 0, 7) == 'config.' ? explode('.', $val, 2) : array($val, '');
                         /*
                         						if(substr($val,0,7)=='config.'){
                         							$kctag='{config:'.$name.'/}';
                         						}else{
                         							$kctag='{king:'.$val.'/}';
                         						}
                         */
                         $kctag = $prefix == 'config' ? '{config:' . $name . '/}' : '{king:' . $val . '/}';
                         $s_tag .= '<i title="' . $this->lang->get('system/common/tag') . ':{king:' . $val . '/}" onClick="window.clipboardData.setData(\'Text\',\'' . $kctag . '\');">' . $kctag . '</i>';
                     }
                     $s_tag .= '</var>';
                 }
             }
         }
         $s .= '<table class="k_side" cellspacing="0"><tr><td>';
         $s .= $_htmlcode;
         if ($_arraycheck) {
             $s .= kc_check($_arraycheck);
         }
         $s .= '</td>';
         $s .= isset($_help[0]) ? "<td>{$_help}</td>" : '';
         $s .= isset($s_tag[0]) ? "<td>{$s_tag}</td>" : '';
         $s .= '</tr></table>';
         $s .= '</td></tr></tbody>';
     } else {
         $s = isset($_label[0]) ? '<div class="k_htm">' : '<div class="k_htm_in">';
         if ($_label) {
             $s .= '<label>' . $_label;
         }
         if ($this->isMng && isset($_tag[0])) {
             if ($this->admin['adminmode'] == 2) {
                 $array = explode(',', $_tag);
                 $s .= ' <var>';
                 foreach ($array as $val) {
                     list($prefix, $name) = kc_explode('.', $val, 2);
                     /*
                     					strtolower($prefix)=='config'
                     						? $kctag='{const:'.$name.'/}'
                     						: $kctag='{king:'.$val.'/}';
                     */
                     $kctag = $prefix == 'config' ? '{config:' . $name . '/}' : '{king:' . $val . '/}';
                     $s .= '<i title="' . $this->lang->get('system/common/tag') . ':{king:' . $val . '/}" onClick="window.clipboardData.setData(\'Text\',\'' . $kctag . '\');">' . $kctag . '</i>';
                 }
                 $s .= '</var>';
             }
         }
         if ($_label) {
             $s .= '</label>';
         }
         $s .= '<p>';
         if (isset($_help[0])) {
             //			$s.='<table class="k_side" cellspacing="0"><tr><td>';
             $s .= $_htmlcode;
             //			$s.='</td><td>';
             $s .= "<tt>{$_help}</tt>";
             if ($_arraycheck) {
                 $s .= kc_check($_arraycheck);
             }
             //			$s.='</td></tr></table>';
         } else {
             $s .= $_htmlcode;
             if ($_arraycheck) {
                 $s .= kc_check($_arraycheck);
             }
         }
         $s .= '</p></div>';
     }
     return $s;
 }
Exemplo n.º 3
0
function king_ajax_repass()
{
    global $king;
    //adminname
    $array = array(array('readminname', 0, 2, 12), array('readminname', 1));
    $s = "<p class=\"k_htm\"><label>" . $king->lang->get('system/admin/name') . "</label><input class=\"k_in w150\" type=\"text\" value=\"" . kc_post('readminname') . "\" id=\"readminname\" name=\"readminname\"/>";
    $s .= kc_check($array);
    $s .= "</p>";
    //adminpass
    $array = array(array('readminpass', 0, 6, 30));
    $s .= "<p class=\"k_htm\"><label>" . $king->lang->get('system/admin/pass') . "</label><input class=\"k_in w150\" type=\"text\" value=\"" . kc_post('readminpass') . "\" id=\"readminpass\" name=\"readminpass\"/>";
    $s .= kc_check($array);
    $s .= "</p>";
    //but
    $but = "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:'repass',IS:1}\">" . $king->lang->get('system/common/save') . "</a>";
    if ($GLOBALS['ischeck']) {
        //POST过程或新添加的过程
        if (!$king->db->getRows_one("SELECT * FROM %a_admin where adminname='" . kc_post('readminname') . "';")) {
            $king->db->insert('%a_admin', array('adminname' => kc_post('readminname'), 'adminpass' => md5(kc_post('readminpass')), 'adminlevel' => 'admin', 'adminlanguage' => 'zh-cn', 'admineditor' => 'fckeditor', 'admindate' => time(), 'adminlogin' => '../system/manage.php'));
        } else {
            $king->db->update('%a_admin', array("adminpass" => md5(kc_post('readminpass')), 'adminlevel' => 'admin'), "adminname='" . kc_post('readminname') . "'");
        }
        kc_ajax('OK', '<p class="k_ok">' . $king->lang->get('system/ok/save') . '</p>');
    }
    kc_ajax($king->lang->get('system/install/repwd'), $s, $but, null, 250, 120 + $GLOBALS['check_num'] * 15);
}