Пример #1
0
 function doSave()
 {
     $id = (int) $_POST['id'];
     $name = dhtmlspecialchars($_POST['name']);
     $table = dhtmlspecialchars($_POST['table']);
     $description = dhtmlspecialchars($_POST['desc']);
     $show = (int) $_POST['show'];
     $position = $_POST['position'];
     $position2 = $_POST['pos'];
     $form = dhtmlspecialchars($_POST['form']);
     $binding = isset($_POST['binding']) ? 1 : 0;
     empty($name) && javascript::alert('模块名称不能为空!');
     empty($table) && $binding && javascript::alert('模块名不能为空!');
     if (!$binding && empty($id)) {
         if (empty($table)) {
             include iPATH . 'include/cn.class.php';
             $table = CN::pinyin($name);
         }
     }
     !preg_match("/[a-zA-Z]/", $table[0]) && javascript::alert('模型表名只能以英文字母开头');
     !preg_match("/[a-zA-Z0-9_\\-~]/", $table) && javascript::alert('模型表名只能由英文字母或数字组成');
     //model::isSysTable($table) && javascript::alert('您所填写的模块表名是系统表!请重新填写.');
     if ($id) {
         iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}' and `id`!='{$id}'") && javascript::alert('该模块已经存在!请检查是否重复');
         iCMS_DB::query("UPDATE `#iCMS@__model` SET `name` = '{$name}', `table` = '{$table}', `binding` = '{$binding}', `description` = '{$description}', `show` = '{$show}', `position` = '{$position}', `position2` = '{$position2}', `form` = '{$form}' WHERE `id` = '{$id}';");
         if (!$binding) {
             $oTable = iCMS_DB::getValue("SELECT `table` FROM `#iCMS@__model` where `id` ='{$id}'");
             if ($oTable != $table) {
                 iCMS_DB::query("RENAME TABLE `#iCMS@__" . model::tbn($oTable) . "` TO `#iCMS@__" . model::tbn($table) . "`");
             }
         }
     } else {
         iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}'") && javascript::alert('该模块已经存在!请检查是否重复');
         $field = $binding ? '' : model::$defaultField;
         iCMS_DB::query("INSERT INTO `#iCMS@__model`(`name`, `table`, `field`, `binding`, `description`,`show`, `position`,`position2`,`form`, `addtime`)VALUES ('{$name}', '{$table}','{$field}', '{$binding}', '{$description}','{$show}', '{$position}','{$position2}','{$form}', '" . time() . "');");
         $id = iCMS_DB::$insert_id;
         if (!$binding) {
             //创建模块基础表
             $tableSQL = "CREATE TABLE `#iCMS@__" . model::tbn($table) . "` (\n\t\t\t\t\t   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t   `fid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `orderNum` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `title` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `clink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `editor` varchar(200) NOT NULL DEFAULT '',\n\t\t\t\t\t   `userid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `tags` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `pubdate` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `hits` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `comments` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `good` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `bad` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `vlink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `type` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `top` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `postype` tinyint(1) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `status` tinyint(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\t\t   PRIMARY KEY (`id`),\n\t\t\t\t\t   KEY `pubdate` (`pubdate`),\n\t\t\t\t\t   KEY `comment` (`comments`),\n\t\t\t\t\t   KEY `hit` (`hits`),\n\t\t\t\t\t   KEY `order` (`orderNum`),\n\t\t\t\t\t   KEY `sortid` (`fid`,`id`),\n\t\t\t\t\t   KEY `topord` (`top`,`orderNum`),\n\t\t\t\t\t   KEY `userid` (`userid`),\n\t\t\t\t\t   KEY `postype` (`postype`,`id`),\n\t\t\t\t\t   KEY `status` (`status`,`postype`,`id`)\n\t\t\t\t\t ) ENGINE=MyISAM  DEFAULT CHARSET=" . DB_CHARSET;
             iCMS_DB::query($tableSQL);
         }
     }
     model::cache();
     $moreaction = array(array("text" => "下一步添加字段", "url" => __SELF__ . "?mo=models&do=addfield&id=" . $id), array("text" => "返回模块列表", "url" => __SELF__ . "?mo=models&do=manage"));
     javascript::dialog('模块' . ($id ? '编辑' : '添加') . '完成!<br />模块基础建表完成...<br />10秒后返回模块列表', "url:" . __SELF__ . "?mo=models&do=manage", $moreaction, 10);
 }
Пример #2
0
 function doupdateHTML()
 {
     !$_GET['id'] && javascript::alert("请选择要更新的项目");
     $mid = (int) $_GET['mid'];
     $table = model::tbn($_GET['table']);
     include iPATH . 'include/iHtml.class.php';
     iHtml::content($_GET['id'], $mid, $table) && javascript::dialog('更新完成!', "url:1");
 }
Пример #3
0
    function dopreview()
    {
        $id = (int) $_GET['id'];
        $mid = $_GET['mid'];
        $table = model::tbn($_GET['table']);
        $id = $_GET['id'];
        !$id && javascript::alert("请选择要删除的文章");
        $id && ($rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` where `id`='{$id}' AND userid='" . member::$uId . "' AND postype='0'", ARRAY_A));
        echo '<style type="text/css">
.preview .title { height:53px; line-height:53px; margin:0px auto 0px; text-align: center; }
.preview .title h1 { font-size:24px; font-weight: bold; }
.preview .content { overflow:hidden; margin:10px auto; color:#444; font-size:14px; line-height:160%; padding:5px; }
.preview .content p { font-size: 14px; margin-top: 10px; margin-right: auto; margin-bottom: 0px; margin-left: auto; line-height: 25px; text-indent: 2em; padding: 0px; }
.preview .content img { clear: both; display: block; margin: 0 auto; }
.preview .content a { border-bottom:1px dotted #0B3B8C; color:#0B3B8C; text-decoration:none; }
        </style>';
        echo '<div class="preview"><div class="title"><h1>' . $rs['title'] . '</h1></div>';
        echo '<div class="content"><pre>';
        print_r($rs);
        echo '</pre></div></div>';
    }