/** * 添加版块内容 */ public function sumbit_content() { $this->admin_priv('addimage'); $en_title = yf_empty($_POST['en_title'], '', true); $title = yf_empty($_POST['title'], Lang('标题不能为空')); $info['title'] = isset($_POST['title']) ? CH_SC . $title . DIG_EC . EN_SC . $en_title . DIG_EC : ''; $en_des = yf_empty($_POST['en_description'], '', true); $info['description'] = isset($_POST['description']) ? CH_SC . $_POST['description'] . DIG_EC . EN_SC . $en_des . DIG_EC : ''; $info['url'] = yf_empty($_POST['url'], '#', true); $info['ordering'] = yf_empty(intval($_POST['ordering']), 0, true); $info['block_id'] = yf_empty($_POST['block_id'], '', true); $info['pic_path'] = yf_empty($_POST['pic_path'], '', true); $data = array('error' => 1, 'content' => Lang('INVALID_OPERATION')); $info['created'] = yf_time(); $result = Model('ad')->add_images($info); if ($result) { $data['error'] = 0; $data['content'] = Lang('SUCCESS_ADD'); } else { $data['content'] = "添加失败"; } $this->showMsg($data); }
/** * 更新微信规则 * @param $info * @param $content * @param $id * @return */ public function update_rule($info, $content, $id) { $result = array('error' => 0, 'content' => ''); if ($id) { $info['modifytime'] = yf_time(); $data = yf_set_update($info); $sql = "UPDATE " . $this->table('rule') . " SET " . $data . " WHERE id='" . $id . "'"; $res = $this->query($sql); if (!$res) { $result['error'] = 1; $result['content'] = Lang('SQL_ERROR'); } else { if (is_array($content)) { if (is_array($content) && count($content) > 0) { foreach ($content as $key => $val) { $content[$key]['rid'] = $id; } $error = 0; foreach ($content as $kk => $vv) { $reply_id = ""; if (!empty($vv['id'])) { $reply_id = $vv['id']; } unset($vv['id']); if (!empty($reply_id)) { $yf_data = yf_set_update($vv); $sql = "update " . $this->table('news_reply') . " set " . $yf_data . " where id=" . $reply_id; if (!($res = $this->query($sql))) { $error++; } } else { $yf_data = yf_set_insert($vv); $sql = "insert into " . $this->table('news_reply') . " (" . $yf_data['key'] . ") values (" . $yf_data['val'] . ")"; if (!($res = $this->query($sql))) { $error++; } } } if ($error != 0) { $result['error'] = 1; $result['content'] = Lang('SQL_ERROR'); } } } else { $sql = "UPDATE " . $this->table('basic_reply') . " SET content='" . $content . "' WHERE rid='" . $id . "'"; $res = $this->query($sql); } } } return $result; }
/** * 添加文章数据 */ public function new_art() { $this->admin_priv('add_news'); $data = array('error' => 1, 'content' => ''); $info['cat_id'] = yf_empty(intval($_POST['cat_id']), '', true); //自动截取summary if ($_POST['summary'] === '' && $_POST['content'] != '') { $_POST['summary'] = hy_substr(str_replace(PHP_EOL, '', strip_tags($_POST['content'])), 200); } if ($_POST['en_summary'] === '' && $_POST['en_content'] != '') { $_POST['en_summary'] = hy_substr(str_replace(PHP_EOL, '', strip_tags($_POST['en_content'])), 200); } $en_summary = yf_empty($_POST['en_summary'], "", true); $info['summary'] = isset($_POST['summary']) ? CH_SC . $_POST['summary'] . DIG_EC . EN_SC . $en_summary . DIG_EC : ''; $en_title = yf_empty($_POST['en_title'], '', true); $en_author = yf_empty($_POST['en_author'], '', true); $en_content = yf_empty($_POST['en_content'], '', true); $title = yf_empty($_POST['title'], Lang('KEY_EMPTY')); $info['title'] = isset($_POST['title']) ? CH_SC . $title . DIG_EC . EN_SC . $en_title . DIG_EC : ''; $info['abstract'] = yf_empty($_POST['abstract'], '', true); $info['flags'] = is_array($_POST['flags']) ? implode(',', $_POST['flags']) : $_POST['flags']; $info['keywords'] = yf_empty($_POST['keywords'], '', true); $info['author'] = isset($_POST['author']) ? CH_SC . $_POST['author'] . DIG_EC . EN_SC . $en_author . DIG_EC : ''; $info['source'] = yf_empty($_POST['source'], '', true); $info['content'] = isset($_POST['content']) ? CH_SC . $_POST['content'] . DIG_EC . EN_SC . $en_content . DIG_EC : ''; $info['ordering'] = yf_empty($_POST['ordering'], 0, true); $info['hits'] = yf_empty($_POST['hits'], 0, true); $info['source_url'] = yf_empty($_POST['source_url'], '', true); $info['page_title'] = yf_empty($_POST['page_title'], '', true); $info['created'] = empty($_POST['created']) ? yf_time() : strtotime($_POST['created']); $info['thumb'] = yf_empty($_POST['thumb'], '', true); $info['is_show'] = yf_empty($_POST['is_show'], 1, true); if (!empty($_POST['photo'])) { $photo = is_array($_POST['photo']) ? $_POST['photo'] : array($_POST['photo']); } else { $photo = array(); } $info['form_id'] = yf_empty($_POST['form_id'], 0, true); $pattern = "/<[img|IMG].*?src=[\\'|\"](.*?(?:[\\.gif|\\.jpg|\\.png]))[\\'|\"].*?[\\/]?>/"; preg_match_all($pattern, stripslashes($info['content']), $match); if ($match) { $file = array('name' => '', 'type' => 'image/png', 'tmp_name' => '', 'size' => '', 'error' => 0); //上传word图片-start foreach ($match[1] as $k => $v) { $pattern2 = '/^(file:\\/\\/).*$/'; if (preg_match($pattern2, $v)) { $file['name'] = basename($v); $ex = explode(".", $file['name']); $ext = end($ex); switch ($ext) { case "png": $file['type'] = 'image/png'; break; case "jpeg": $file['type'] = 'image/jpeg'; break; case "jpg": $file['type'] = 'image/jpeg'; break; case "gif": $file['type'] = 'image/gif'; break; } $file['tmp_name'] = $v; $thumb_url = Model('image')->upload_image($file, 'article/' . date('Ym')); if ($thumb_url) { $info['content'] = str_replace(addslashes($v), addslashes($thumb_url), $info['content']); } } else { //对于已经上传的图片,自动截取文章第一个图片为缩略图 if (empty($info['thumb'])) { $info['thumb'] = $match[1][0]; } } } //上传word图片-end } if (Model('article')->create_art($info, $photo)) { $data['content'] = Lang('SUCCESS_ADD'); $data['error'] = 0; } else { $data['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($data); }
/** * 更新规则数据 */ public function update_rule() { $this->admin_priv('edit_rule'); $img_arr = array(); $i = 0; foreach ($_POST as $k => $v) { $i++; if (strstr($k, 'field')) { $img_arr[$i]['title'] = $v[0]; $img_arr[$i]['description'] = $v[1]; $img_arr[$i]['url'] = $v[2]; $img_arr[$i]['thumb'] = $v[3]; $img_arr[$i]['id'] = $v[4]; } } $id = yf_empty(intval($_POST['id']), '', true); $info['name'] = yf_empty($_POST['name'], '标题不能为空'); $info['createtime'] = yf_time(); //$info['status'] = isset($_POST['is_show'])?intval($_POST['is_show']):0; $data = array('error' => 0, 'content' => ''); if ($_POST['type'] == 1) { $content = yf_empty($_POST['content'], '', true); } else { $content = $img_arr; } $result = Model('wxrule')->update_rule($info, $content, $id); if ($result) { $data['content'] = Lang('SUCCESS_EDIT'); $data['url'] = "index.php?g=admin&m=wxrule&a=index"; } else { $data['error'] = 1; $data['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($data); }
/** * 编辑角色信息 */ public function update_role() { $this->admin_priv('edituser', 2); $res = array('error' => 1, 'content' => ''); $id = yf_empty($_POST['id'], "系统错误"); $info['role_name'] = yf_empty($_POST['role_name'], "角色名不能为空"); $info['role_des'] = yf_empty($_POST['role_des'], "", true); $mod = yf_empty($_POST['action_mod'], "", true); $action = yf_empty($_POST['action_list'], "", true); $info['role_mod'] = is_array($mod) ? implode(",", $mod) : $mod; $info['role_action'] = is_array($action) ? implode(",", $action) : $action; $info['modified'] = yf_time(); if (!Model('admin')->roleEisted($info['role_name'], $id)) { $res['content'] = Lang('ROLE_EXISTED'); } else { if (Model('admin')->updateRole($info, $id)) { $res = array('error' => 0, 'content' => Lang('SUCCESS_EDIT')); } else { $res['content'] = Lang('INVALID_OPERATION'); } } $this->showMsg($res); }
/** * 获取jsdk的参数 * @author yf */ public function get_jsdk() { // $access_token = $this->getAccessToken(); // $sql = "SELECT op_value FROM ".$this->table('options')." WHERE op_key='appid' OR op_key='appsecret' OR op_key='jsapi_ticket' OR op_key='jsapi_time'"; // $temp = $this->getCol($sql); // $app['appid'] = $temp[0]; // $app['appsecret'] = $temp[1]; // $wx_token['jsapi_ticket'] = $temp[2]; // $wx_token['jsapi_time'] = $temp[3]; // if($wx_token['jsapi_ticket'] == '' || $_SERVER['REQUEST_TIME'] > $wx_token['jsapi_time'])//7200 // { // $new_info = Ctrl("weixin")->getJsapiTicket($access_token); // if(empty($new_info['ticket'])) // { // $sql = "UPDATE ".$this->table('options')." SET op_value='' WHERE op_key='access_token'"; // $this->query($sql); // unset($new_info); // $access_token = $this->getAccessToken(); // $new_info = Ctrl("weixin")->getJsapiTicket($access_token); // } // $sql = "UPDATE ".$this->table('options')." SET op_value='".$new_info['ticket']."' WHERE op_key='jsapi_ticket'"; // $res = $this->db->query($sql); // $time = $_SERVER['REQUEST_TIME']+$new_info['expires_in']-800; // $sql = "UPDATE ".$this->table('options')." SET op_value='".$time."' WHERE op_key='jsapi_time'"; // $res2 = $this->db->query($sql); // $jsapi_ticket = $new_info['ticket']; // } // else // { // $jsapi_ticket = $wx_token['jsapi_ticket']; // } $sql = "SELECT op_value FROM " . $this->table('options') . " WHERE op_key='appid'"; $appid = $this->getOne($sql); $path = ROOT_PATH . "/Qiaqia/Json/jsapi_ticket.json"; $data = json_decode(file_get_contents($path), true); if (empty($data['jsapi_ticket']) || $data['expire_time'] < yf_time()) { $access_token = $this->getAccessToken(); $new_info = Ctrl("weixin")->getJsapiTicket($access_token); $info['jsapi_ticket'] = $new_info['ticket']; $info['expire_time'] = yf_time() + 7000; $fp = fopen($path, "w"); fwrite($fp, json_encode($info)); fclose($fp); $jsapi_ticket = $new_info['ticket']; } else { $jsapi_ticket = $data['jsapi_ticket']; } $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $url = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $timestamp = yf_time(); $nonceStr = $this->createNonceStr(); // 这里参数的顺序要按照 key 值 ASCII 码升序排序 $string = "jsapi_ticket={$jsapi_ticket}&noncestr={$nonceStr}×tamp={$timestamp}&url={$url}"; $signature = sha1($string); $signPackage = array("appId" => $appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string); return $signPackage; }
public function get_send_list() { $res = array('error' => 1, 'content' => ''); $mod = Model('attend'); $sort['wxid'] = yf_empty(intval($_REQUEST['wxid']), $_SESSION['wxid'], true); $sort['year'] = yf_empty(intval($_REQUEST['year']), date('Y', yf_time()), true); $sort['month'] = yf_empty(intval($_REQUEST['month']), date('m', yf_time()), true); $page = yf_empty(intval($_REQUEST['page']), 1, true) + 1; $limit = yf_empty(intval($_REQUEST['limit']), 5, true); $art = $mod->get_send_list($sort, $page, $limit); $html = ""; if ($art['result']) { foreach ($art['result'] as $k => $v) { $rank = $v['rank'] + 1; $html .= "<div class=\"content-list\">\r\n\t\t\t\t\t\t\t<p class=\"send-title\">{$v['title']}</p>\r\n\t\t\t\t\t\t\t<span class=\"send-date\">{$v['created']}</span>\r\n\t\t\t\t\t\t\t<p class=\"send-content\">{$v['message']}</p>\r\n\t\t\t\t\t\t\t<ul class=\"send-img\" data-img=\"{$v['pic']}\">"; if (!empty($v['img'])) { foreach ($v['img'] as $kk => $vv) { if ($kk < 9) { $html .= "<li>\r\n\t\t\t\t\t\t\t\t\t\t<img src=\"{$vv}\" class=\"send-img-info\">\r\n\t\t\t\t\t\t\t\t\t</li>"; } } } $html .= "</ul>\r\n\t\t\t\t\t\t\t<div class=\"send-address\">\r\n\t\t\t\t\t\t\t\t<span class=\"glyphicon glyphicon-map-marker\"></span> {$v['address']}\r\n\t\t\t\t\t\t\t</div>"; if ($_SESSION['wxid'] == $v['wxid']) { $html .= "<div class=\"send-del\" data-id=\"{$v['send_id']}\">\r\n\t\t\t\t\t\t\t\t<span class=\"glyphicon glyphicon-trash\"></span>\r\n\t\t\t\t\t\t\t</div>"; } $html .= "</div>"; } } $res = array('error' => 0, 'content' => $html); $this->showMsg($res); }
/** * 获取jsdk的参数 * @author yf */ public function get_jsdk() { $appid = $this->weixin_config('appid'); $path = ROOT_PATH . "/Qiaqia/Json/jsapi_ticket.json"; $data = json_decode(file_get_contents($path), true); if (empty($data['jsapi_ticket']) || $data['expire_time'] < yf_time()) { $access_token = $this->getAccessToken(); $new_info = Ctrl("weixin")->getJsapiTicket($access_token); $info['jsapi_ticket'] = $new_info['ticket']; $info['expire_time'] = yf_time() + 7000; $fp = fopen($path, "w"); fwrite($fp, json_encode($info)); fclose($fp); $jsapi_ticket = $new_info['ticket']; } else { $jsapi_ticket = $data['jsapi_ticket']; } $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $url = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $timestamp = yf_time(); $nonceStr = $this->createNonceStr(); // 这里参数的顺序要按照 key 值 ASCII 码升序排序 $string = "jsapi_ticket={$jsapi_ticket}&noncestr={$nonceStr}×tamp={$timestamp}&url={$url}"; $signature = sha1($string); $signPackage = array("appId" => $appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string); return $signPackage; }
/** * 添加新的表单 */ public function new_form() { $this->admin_priv('add_form'); $result = array('error' => 1, 'content' => ''); $info['name'] = yf_empty($_POST['title'], "表单标题不能为空"); $info['submit_interval'] = yf_empty($_POST['interval'], 0, true); $info['stime'] = yf_empty($_POST['stime'], 0, true) == 0 ? 0 : strtotime($_POST['stime']); $info['etime'] = yf_empty($_POST['etime'], 0, true) == 0 ? 0 : strtotime($_POST['etime']); $info['created'] = yf_time(); $is_exist = Model('forms')->check_form_name($info['name']); if ($is_exist > 0) { $result['content'] = '该表单名已经存在,请换一个表单名,这样才好区分'; $this->showMsg($result); } $id = Model('forms')->insert_forms($info); if ($id) { $result['error'] = 0; $result['content'] = "建表成功"; } else { $result['content'] = Lang('INVALID_OPERATION'); } $this->showMsg($result); }
public function comment() { $res = array('error' => 1, 'content' => '系统繁忙'); $info['message'] = yf_empty($_POST['message'], "不能提交空留言"); $info['wxid'] = $_SESSION['wxid']; $info['created'] = yf_time(); $id = Model('index')->insert_comment($info); if ($id) { $res = array('error' => 0, 'content' => '谢谢你的留言建议'); } $this->showMsg($res); }
public function coll() { $res = array('error' => 1, 'content' => '系统错误', 'type' => ''); $info['store_id'] = yf_empty(intval($_POST['store_id']), "系统错误"); $type = yf_empty($_POST['type'], 'set_coll', true); $info['wxid'] = $_SESSION['wxid']; $info['created'] = yf_time(); $id = Model('store')->coll_store($info, $type); if ($id) { $res = array('error' => 0, 'content' => "收藏", 'type' => 'set_coll'); if ($type == 'set_coll') { $res = array('error' => 0, 'content' => "取消收藏", 'type' => 'del_coll'); } } $this->showMsg($res); }