/** * @brief postPost 写入一篇文章或页面 * * @param $p 文章内容 * * @return int */ public function postPost($p) { $time = time(); Database::query("INSERT INTO `{$this->prefix}posts` \n\t\t\t(`uid`, `ptime`,`mtime`,`title`, `alias`, `content`, `type`, `status`, `allow_reply`, `top`, `view`,`reply`) VALUES \n\t\t\t({$p['uid']},{$time},{$time},'{$p['title']}','{$p['alias']}','{$p['content']}',{$p['type']},{$p['status']},{$p['allow_reply']},{$p['top']},0, 0)"); return Database::insertID(); }
/** * @brief addMeta 添加一个 Meta * * @param $m * * @return mix */ public function addMeta($m) { $m['type'] = isset($m['type']) ? $m['type'] : 1; $m['name'] = isset($m['name']) ? $m['name'] : ''; $m['alias'] = isset($m['alias']) ? $m['alias'] : ''; $m['description'] = isset($m['description']) ? $m['description'] : ''; $m['parent'] = isset($m['parent']) ? $m['parent'] : 0; // 检查数据完整性 if ($m['type'] == 1 || $m['type'] == 2) { // 分类 if ($m['type'] == 1 && ($m['name'] == '' || $m['alias'] == '')) { return FALSE; } // 标签 if ($m['type'] == 2 && $m['name'] == '') { return FALSE; } // 检查重复 $this->name = $m['name']; if ($this->getMeta()) { return FALSE; } $this->name = ''; $this->alias = $m['alias']; if ($this->alias && $this->getMeta()) { return FALSE; } } // 写入数据库 Database::query("INSERT INTO `{$this->prefix}posts_meta` \n\t\t\t(`name`, `description`, `alias`, `type`, `top`,`reply`,`parent`) VALUES \n\t\t\t('{$m['name']}','{$m['description']}','{$m['alias']}',{$m['type']},0, 0, {$m['parent']})"); return Database::insertID(); }
} if ($_POST['user_password1'] != $_POST['user_password2']) { $GLOBALS['script_error_log'][] = _("Your new passwords did not match."); } if (strlen($_POST['user_password1']) < 2) { $GLOBALS['script_error_log'][] = _("Your password must be longer than 2 characters."); } $dob_year = (int) $_POST['dob_year']; $dob_month = (int) $_POST['dob_month']; $dob_day = (int) $_POST['dob_day']; $dob = formatDate($dob_year, $dob_month, $dob_day); if (empty($GLOBALS['script_error_log'])) { if (isset($user_id)) { $query = "UPDATE " . $db->prefix . "_user \n\t\t\t\t\tSET \n\t\t\t\t\tuser_name=" . $db->qstr($_POST['user_name']) . ",\n\t\t\t\t\tuser_location=" . $db->qstr($_POST['user_location']) . ", \n\t\t\t\t\tuser_password="******", \n\t\t\t\t\tuser_email=" . $db->qstr($_POST['user_email']) . ", \n\t\t\t\t\tuser_dob=" . $db->qstr($dob) . " \n\t\t\t\t\tWHERE\n\t\t\t\t\tuser_id=" . $user_id; $db->Execute($query); $user_id = $db->insertID(); } else { // we insert record $rec = array(); $rec['user_name'] = $_POST['user_name']; $rec['user_location'] = $_POST['user_location']; $rec['user_create_datetime'] = time(); $rec['user_password'] = md5($_POST['user_password1']); $rec['user_email'] = $_POST['user_email']; $rec['user_dob'] = $dob; $rec['openid_name'] = $openid_name; $rec['user_live'] = 1; $table = $db->prefix . '_user'; $db->insertDB($rec, $table); $user_id = $db->insertID(); }
/** * @brief postComment 写入一条评论 * * @param $c 评论信息 * * @return int */ public function postComment($c) { $time = time(); $ip = Request::getIP(); Database::query("INSERT INTO `{$this->prefix}comments` \n\t\t\t(`pid`, `uid`, `author`, `email`, `website`, `content`, `status`, `ptime`,`mtime`,`ip`, `parent`) VALUES \n\t\t\t({$c['pid']},{$c['uid']},'{$c['author']}','{$c['email']}','{$c['website']}','{$c['content']}',{$this->status},{$time},{$time},'{$ip}',0)"); return Database::insertID(); }