function Messager($message, $redirectto = '', $time = -1, $return_msg = false, $js = null) { global $jishigou_rewrite; if ($time === -1) { $time = is_numeric($this->Config['msg_time']) ? $this->Config['msg_time'] : 5; } $to_title = ($redirectto === '' or $redirectto == -1) ? "返回上一页" : "跳转到指定页面"; if ($redirectto === null) { $return_msg = $return_msg === false ? " " : $return_msg; } else { $redirectto = $redirectto !== '' ? $redirectto : ($from_referer = referer()); if (str_exists($redirectto, 'mod=login', 'code=register', '/login', '/register')) { $referer = '&referer=' . urlencode('index.php?' . 'mod=plaza'); jsg_setcookie('referer', 'index.php?' . 'mod=plaza'); } if (is_numeric($redirectto) !== false and $redirectto !== 0) { if ($time !== null) { $url_redirect = "<script language=\"JavaScript\" type=\"text/javascript\">\r\n"; $url_redirect .= sprintf("window.setTimeout(\"history.go(%s)\",%s);\r\n", $redirectto, $time * 1000); $url_redirect .= "</script>\r\n"; } $redirectto = "javascript:history.go({$redirectto})"; } else { if ($message === null) { @header("Location: {$redirectto}"); #HEADER跳转 } if ($time !== null) { $url_redirect = $redirectto ? '<meta http-equiv="refresh" content="' . $time . '; URL=' . $redirectto . '">' : null; } } } $title = "消息提示:" . (is_array($message) ? implode(',', $message) : $message); $title = strip_tags($title); if ($js != "") { $js = "<script language=\"JavaScript\" type=\"text/javascript\">{$js}</script>"; } $additional_str = $url_redirect . $js; $this->Title = '操作提示'; $return_Url = $_SERVER['HTTP_REFERER']; include template('messager'); exit; }
public function article() { $post = $this->db->where(array('post_status' => 'publish', 'post_type' => 'post'))->order_by('ID ASC')->get('test111')->result(); foreach ($post as $k => $v) { $data = array(); switch ($v->post_author) { case 1: case 2: $data['uid'] = 2; break; case 3: $data['uid'] = 4; break; case 4: $data['uid'] = 3; break; } $content = str_replace(PHP_EOL, '</p><p>', $v->post_content); $content = '<p>' . $content . '</p>'; $content = strip_tags($content, '<p><a><strong><em><span><ul><ol><li><br>'); $content = htmlspecialchars($content); $data['cid'] = 1; $data['title'] = $v->post_title; $data['content'] = $content; $data['keyword'] = ''; $data['description'] = ''; $data['from'] = ''; $data['created'] = strtotime($v->post_date); $data['updated'] = strtotime($v->post_modified); $data['views'] = 0; $data['comments'] = 0; $data['image'] = str_exists($content, '<img src=') ? 1 : 0; $data['index'] = 1; $data['state'] = 1; $this->db->insert('article', $data); unset($data); } }
function show_photo($url) { if (str_exists($url, UPLOAD_URL)) { $imgurl_replace = str_replace(UPLOAD_URL, '', $url); if (!is_file(UPLOAD_PATH . $imgurl_replace)) { return IMG_PATH . 'nopic.gif'; } if (!file_exists(UPLOAD_PATH . $imgurl_replace)) { return IMG_PATH . 'nopic.gif'; } return $url; } else { return $url; } }
private final function _load_submenu($first_child_arr) { if ($first_child_arr && str_exists($first_child_arr['method'], 'go_') && $first_child_arr['is_parent']) { $arr_childid = explode(",", $first_child_arr['arr_childid']); $first_sub_child_arr = $this->Module_menu_model->get_one("parent_id = " . $arr_childid[1]); if ($first_sub_child_arr) { return $this->_load_submenu($first_sub_child_arr); } } return base_url($first_child_arr['folder'] . '/' . $first_child_arr['controller'] . '/' . $first_child_arr['method']); }
function is_robot() { if (!defined('IS_ROBOT')) { $kw_spiders = 'Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla'; $kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla'; if (!str_exists($_SERVER['HTTP_USER_AGENT'], 'http://') && preg_match("/({$kw_browsers})/i", $_SERVER['HTTP_USER_AGENT'])) { define('IS_ROBOT', false); } elseif (preg_match("/({$kw_spiders})/i", $_SERVER['HTTP_USER_AGENT'])) { define('IS_ROBOT', true); } else { define('IS_ROBOT', false); } } return IS_ROBOT; }
public function create_action() { if (!$this->input->is_ajax_request()) { show_404(); } $from = $this->input->post('fromurl', true); $title = $this->input->post('title', true); $content = $this->input->post('content'); $content = strip_tags($content, '<p><a><strong><img><em><span><ul><ol><li><br>'); $data['hid'] = NULL; $data['title'] = trim($title); $data['content'] = htmlspecialchars($content); $data['from'] = is_url($from) ? $from : ''; $data['created'] = $data['updated'] = time(); $data['views'] = 0; $data['image'] = str_exists($content, '<img src=') ? 1 : 0; $data['index'] = $from; $data['state'] = 1; $data['best'] = 0; $data['img_url'] = ''; $action = $this->input->post('action', true); switch ($action) { case 'update': $success = '恭喜,文章已更新成功!'; $error = '对不起,文章更新失败,请重试!'; break; case 'draft': $data['state'] = 0; $success = '草稿已存于 ' . date('Y年m月d H:i'); $error = '草稿保存失败,请重试!'; break; default: $success = '恭喜,文章已发布成功!'; $error = '对不起,文章发布失败,请重试!'; } $draft_id = (int) $this->input->post('draftid'); $state_id = $this->_create_huangye($draft_id, $data); if ($state_id) { JSON('success', $success, $state_id); } else { JSON('error', $error, $state_id); } }
/** * 返回分页路径 * * @param $urlrule 分页规则 * @param $page 当前页 * @param $array 需要传递的数组,用于增加额外的方法 * @return 完整的URL路径 */ function pageurl($urlrule, $page, $array = array()) { if (strpos($urlrule, '~')) { $urlrules = explode('~', $urlrule); $urlrule = $page < 2 ? $urlrules[0] : $urlrules[1]; } $findme = array('{$page}', '[page]'); $replaceme = array($page, $page); if (is_array($array)) { foreach ($array as $k => $v) { $findme[] = '{$' . $k . '}'; $replaceme[] = $v; } } $url = str_replace($findme, $replaceme, $urlrule); $url = str_replace(array('http://', '//', '~', ' '), array('~', '/', 'http://', '+'), $url); if (str_exists($url, '?')) { } else { if (!empty($_SERVER["QUERY_STRING"])) { $url .= '?' . $_SERVER["QUERY_STRING"]; } } return $url; }
public function create_action() { if (!$this->input->is_ajax_request()) { show_404(); } $cid = (int) $this->input->post('cid'); $index = (int) $this->input->post('index'); $from = $this->input->post('fromurl', true); $title = $this->input->post('title', true); $keyword = $this->input->post('keyword', true); $description = $this->input->post('description', true); $content = $this->input->post('content'); $content = strip_tags($content, '<p><a><strong><img><em><span><ul><ol><li><br>'); if (trim($description) == '') { $data['description'] = substring(strip_tags($content), 200); } else { $data['description'] = $description; } $data['cid'] = $cid; $data['from'] = is_url($from) ? $from : ''; $data['image'] = str_exists($content, '<img src=') ? 1 : 0; $data['title'] = trim($title); $data['index'] = $index; $data['keyword'] = format_keyword($keyword); $data['content'] = htmlspecialchars($content); $data['created'] = $data['updated'] = time(); $data['state'] = 1; if ($data['cid'] === 0) { JSON('error', '请选择文章分类!'); } if (empty($data['title'])) { JSON('error', '请填写文章标题!'); } if (strip_tags($content) == '') { JSON('error', '请填写文章内容!'); } $action = $this->input->post('action', true); switch ($action) { case 'update': $success = '恭喜,文章已更新成功!'; $error = '对不起,文章更新失败,请重试!'; break; case 'draft': $data['state'] = 0; $success = '草稿已存于 ' . date('Y年m月d H:i'); $error = '草稿保存失败,请重试!'; break; default: $success = '恭喜,文章已发布成功!'; $error = '对不起,文章发布失败,请重试!'; } $draft_id = (int) $this->input->post('draftid'); $state_id = $this->_create_article($draft_id, $data); if ($state_id) { JSON('success', $success, $state_id); } else { JSON('error', $error, $state_id); } }