function sort_save() { $model = new sort_model(); if (isset($_POST['id'])) { $model->id = $_POST['id']; } else { $model->id = 0; } if (isset($_POST['title'])) { $model->title = $_POST['title']; } if (isset($_POST['fid'])) { $model->fid = $_POST['fid']; } if (isset($_POST['sort'])) { $model->sort = $_POST['sort']; } if ($model->id == 0) { if ($model->insert_entry()) { $arr = array("success" => "true", "msg" => "栏目新建失败!"); } else { $arr = array("success" => "false", "msg" => "栏目新建失败!"); } } else { if ($model->update_entry()) { $arr = array("success" => "true", "msg" => "栏目更新失败!"); } else { $arr = array("success" => "false", "msg" => "fail sort update!"); } } echo json_encode(gbk2utf8($arr), true); }
/** * 转换编码 * @param array $storeData * @return multitype:string */ function gbkToUtf8($storeData) { $data = array(); foreach ($storeData as $k => $v) { $data[$k] = gbk2utf8($v); } return $data; }
function news_del() { $this->model->id = $_POST['id']; $this->model->delete_entry_by_id(); if ($this->model->result) { $arr = array("success" => "true", "msg" => ""); } else { $arr = array("success" => "false", "msg" => "文章删除失败!"); } echo json_encode(gbk2utf8($arr), true); }
function word_filtration() { $file = 'upload/02.txt'; $content = gbk2utf8(file_get_contents($file)); $content = trim($content, '|1'); $array = explode("|1", $content); for ($i = 0; $i < count($array); $i++) { //echo $array[$i]."<br />"; $value = explode('|1', $array[$i]); $arr_data[] = $value[0]; } return $arr_data; //return $arr_data; }
public function postData($url, $params = NULL, $urlFixParams = NULL) { $result = ""; $url = $this->base_url . $url . "?access_token=" . $this->tokens; if ($urlFixParams) { $url .= "&" . http_build_query($urlFixParams); } if (is_array($params)) { $options = array("http" => array("method" => "POST", "content" => self::encode_json(gbk2utf8($params)))); $context = stream_context_create($options); $result = file_get_contents($url, FALSE, $context); } return json_decode($result, TRUE); }
function gbk2utf8(&$data) { foreach ($data as $k => $v) { if (is_array($v)) { gbk2utf8($data[$k]); } else { if (MB_CONV_ENCODE) { $encode = mb_detect_encoding($v, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); //echo $encode; if ($encode != 'UTF-8') { $data[$k] = mb_convert_encoding($v, 'UTF-8', 'GBK'); } } else { $data[$k] = iconv('GBK', 'UTF-8', $v); } } } }
/** * 专营店营销基金-项目补贴上限额度导入 * @return boolean */ function commonProjectFixedAdd() { if ($_POST) { $year = (int) $this->input->post('year'); $year || showError('请选择年份'); //上传文件 $fileData = $this->upload(); $fullPath = $fileData['full_path']; $handle = fopen($fullPath, "r"); $i = 0; $ok = 0; $err = 0; $errorSellpoint = array(); //载入单店主线流程模型 $this->load->model('commonPFixedModel'); while ($item = fgetcsv($handle, 10000, ",")) { if ($i == 0) { $i++; continue; } //跳过第一行 $where = array('year' => (int) $year, 'city' => trim(gbk2utf8($item[1]))); $data = array('systemCity' => trim(gbk2utf8($item[1])), 'cityLevel' => (int) $item[3], 'createTime' => time()); $moneyData = array('money1' => (double) $item[4], 'money2' => (double) $item[5], 'money3' => (double) $item[6], 'money4' => (double) $item[7], 'money5' => (double) $item[8], 'money6' => (double) $item[9], 'money7' => (double) $item[10], 'money8' => (double) $item[11], 'money9' => (double) $item[12], 'money10' => (double) $item[13], 'money11' => (double) $item[14]); $data['moneyData'] = serialize($moneyData); if ($this->commonPFixedModel->upset($where, $data)) { $ok++; } else { $err++; } usleep(500); } showSuccess('导入完成:(成功条数:' . $ok . ',失败条数:' . $err . ')', '', 3); } else { //年 $year = $this->input->get('year'); $year || ($year = $this->config->item('nowYear')); $this->viewData['year'] = $year; $this->load->view('Import/commonProjectFixedAdd', $this->viewData); } }
/** * 双月来店量目标导入 */ function reachTimeUnitAdd() { if ($_POST) { $year = (int) $this->input->post('year'); $year || showError('请选择年份'); $timeUnit = (int) $this->input->post('timeUnit'); $timeUnit || showError('请选择双月'); //上传文件 $fileData = $this->upload(); $fullPath = $fileData['full_path']; $handle = fopen($fullPath, "r"); $i = 0; $ok = 0; $err = 0; $errorSellpoint = array(); //载入来店达成周版模型 $this->load->model('reachWeekModel'); $this->load->model('reachTimeUnitModel'); while ($item = fgetcsv($handle, 10000, ",")) { if ($i == 0) { $i++; continue; } //跳过第一行 $coding = $item[5]; $storeData = $this->sellpointModel->getNewData(array('Coding' => $coding, 'SpState_sys' => 1, 'isOpen' => 1)); if (!$storeData) { $err++; $errorSellpoint[] = "【" . gbk2utf8($item[4]) . "】的编码【" . $coding . "】错误"; continue; } $where = array('storeId' => (int) $storeData['userId'], 'timeUnit' => (int) $timeUnit, 'year' => (int) $year); $data = array('coding' => $storeData['coding'], 'storeName' => $storeData['storeName'], 'comeStoreTarget' => (double) $item[6], 'updateTime' => time()); $id = $this->reachTimeUnitModel->upset($where, $data); if ($id) { $weekList = $this->reachWeekModel->getList(array('reachTimeUnitId' => $id)); foreach ($weekList as $v) { $this->reachWeekModel->updateMoney($v['id']); } $ok++; //后续处理 } else { $err++; } usleep(500); } showSuccess('导入完成:(成功条数:' . $ok . ',失败条数:' . $err . ')' . ($errorSellpoint ? "<br>" . implode('<br>', $errorSellpoint) : ''), '', $errorSellpoint ? 120 : 3); } else { //年 $year = $this->input->get('year'); $year || ($year = $this->config->item('nowYear')); $this->viewData['year'] = $year; //时段 $timeUnit = $this->input->get('timeUnit'); $this->viewData['timeUnit'] = $timeUnit; $this->viewData['templateFile'] = 'public/template/' . 'reachTimeUnit.zip'; $this->load->view('Import/reachTimeUnitAdd', $this->viewData); } }
/** * 固定传播基金专营店类新增 * @return boolean */ function spreadStoreAdd() { if ($_POST) { $year = (int) $this->input->post('year'); $year || showError('请选择年份'); //上传文件 $fileData = $this->upload(); $fullPath = $fileData['full_path']; $handle = fopen($fullPath, "r"); $i = 0; $ok = 0; $err = 0; $errorSellpoint = array(); //载入单店主线流程模型 $this->load->model('spreadStoreModel'); while ($item = fgetcsv($handle, 10000, ",")) { if ($i == 0) { $i++; continue; } //跳过第一行 $coding = $item[5]; $storeData = $this->sellpointModel->getNewData(array('Coding' => $coding, 'SpState_sys' => 1, 'isOpen' => 1)); if (!$storeData) { $err++; $errorSellpoint[] = "【" . gbk2utf8($item[4]) . "】的编码【" . $coding . "】错误"; continue; } $type = (int) $item[6]; $where = array('storeId' => (int) $storeData['userId'], 'timeUnit' => 0, 'year' => (int) $year); $data = array('area' => $storeData['area'], 'region' => $storeData['region'], 'spsarea' => $storeData['spsarea'], 'city' => $storeData['city'], 'coding' => $storeData['coding'], 'storeName' => $storeData['storeName'], 'type' => $type, 'createTime' => time()); if ($this->spreadStoreModel->upset($where, $data)) { $ok++; } else { $err++; } usleep(500); } showSuccess('导入完成:(成功条数:' . $ok . ',失败条数:' . $err . ')', '', 3); } else { //年 $year = $this->input->get('year'); $year || ($year = $this->config->item('nowYear')); $this->viewData['year'] = $year; $this->load->view('Import/spreadStoreAdd', $this->viewData); } }
} } $rss = $db->get_one(" SELECT * FROM {$pre}special WHERE id='{$cid}' "); if (!$rss) { die("原数据不存在"); } $username || ($username = $lfjid); /*如果系统做了限制,那么有的评论将不给提交成功,但没做提示评论失败*/ if ($allow) { if (is_utf8($content) || is_utf8($username)) { $content = utf82gbk($content); $username = utf82gbk($username); } if (WEB_LANG == 'utf-8') { $content = gbk2utf8($content); $username = gbk2utf8($username); } elseif (WEB_LANG == 'big5') { require_once ROOT_PATH . "inc/class.chinese.php"; $cnvert = new Chinese("GB2312", "BIG5", $content, ROOT_PATH . "./inc/gbkcode/"); $content = $cnvert->ConvertIT(); $cnvert = new Chinese("GB2312", "BIG5", $username, ROOT_PATH . "./inc/gbkcode/"); $username = $cnvert->ConvertIT(); } $db->query("INSERT INTO `{$pre}special_comment` (`cid` , `uid` , `username` , `posttime` , `content` , `ip` , `icon` , `yz` ) VALUES ('{$cid}', '{$lfjuid}', '{$username}', '{$timestamp}', '{$content}', '{$onlineip}', '{$icon}', '{$yz}')"); } } elseif ($action == "del") { $rs = $db->get_one("SELECT * FROM `{$pre}special_comment` WHERE id='{$id}'"); if ($web_admin || $lfjuid == $rs[uid]) { $db->query("DELETE FROM `{$pre}special_comment` WHERE id='{$id}'"); } }
/** * @desc 批量处理gbk->utf-8 **/ function icon_to_utf8($s) { if (is_array($s)) { foreach ($s as $key => $val) { $s[$key] = icon_to_utf8($val); } } else { $s = gbk2utf8($s); } return $s; }
function sms_send($mob, $content) { global $webdb; if ($webdb[fetion_id] && $webdb[fetion_pwd] && in_array($mob, explode("\r\n", $webdb[fetion_friend]))) { $url = "http://sms.api.bz/fetion.php?username={$webdb['fetion_id']}&password={$webdb['fetion_pwd']}&sendto={$mob}&message={$content}"; $msg = sockOpenUrl($url); die("{$msg}-{$url}"); return 1; } elseif ($webdb[sms_type] == 'eshang8') { $url = "http://http.chinasms.com.cn/tx/?uid={$webdb['sms_es_name']}&key=" . strtolower(md5($webdb[sms_es_key])) . "&msg={$content}&phone={$mob}&smskind=1"; if (!($msg = sockOpenUrl($url))) { //$msg=file_get_contents($url); } if ($msg === '') { return 0; } elseif ($msg === '100') { return 1; //·¢Ëͳɹ¦ } else { return $msg; } } elseif ($webdb[sms_type] == 'winic') { $url = "http://service.winic.org/sys_port/gateway/?id={$webdb['sms_wi_id']}&pwd={$webdb['sms_wi_pwd']}&to={$mob}&content={$content}&time="; if (!($msg = sockOpenUrl($url))) { //$msg=file_get_contents($url); } if ($msg === '') { return 0; } $detail = explode("/", $msg); if ($detail[0] === '000') { return 1; //·¢Ëͳɹ¦ } else { return $detail[0]; } } elseif ($webdb[sms_type] == 'ccell') { if (WEB_LANG != 'utf-8') { $content = gbk2utf8($content); } $url = "http://server4.chineseserver.net:9801/CASServer/SmsAPI/SendMessage.jsp?userid={$webdb['sms_ccell_id']}&password={$webdb['sms_ccell_pwd']}&destnumbers={$mob}&msg={$content}&sendtime="; if (!($msg = file_get_contents($url))) { //$msg=file_get_contents($url); } if ($msg === '') { return 0; } if (strstr($msg, 'messages="1"')) { return 1; //·¢Ëͳɹ¦ } else { return $msg; } } else { showerr("ϵͳûÓÐÑ¡Ôñ¶ÌÐŽӿÚƽ̨!"); } }
function chinese_yzimg($str) { $fnt = ROOT_PATH . "inc/font.ttf"; if (WEB_LANG == 'gb2312') { $str = gbk2utf8($str); } $c = 'red'; $x = 0; $y = 0; $size = 11; $image = ROOT_PATH . 'images/default/chinese_yzimg.jpg'; if (!is_file($image)) { die('背景图片不存在'); } $img_array = getimagesize($image); $font_array = ImageTTFBBox($size, 0, $fnt, $str); $font_wight = intval($font_array[2] - $font_array[0]); $font_height = intval($font_array[3] - $font_array[5]); $x || ($x = intval(($img_array[0] - $font_wight) / 2)); $y || ($y = intval($img_array[1] / 2 + $font_height / 2)); $im = imagecreatefromjpeg($image); if ($c == 'blue') { $color = imagecolorclosestalpha($im, 00, 00, 255, 20); $color2 = imagecolorclosestalpha($im, 00, 00, 00, 98); imagettftext($im, $size, 0, $x + 2, $y + 2, $color2, $fnt, $str); } elseif ($c == 'white') { $color = imagecolorclosestalpha($im, 255, 255, 255, 20); $color2 = imagecolorclosestalpha($im, 00, 00, 00, 99); imagettftext($im, $size, 0, $x + 2, $y + 2, $color2, $fnt, $str); } elseif ($c == 'red') { $color = imagecolorclosestalpha($im, 255, 00, 00, 20); $color2 = imagecolorclosestalpha($im, 255, 255, 255, 20); imagettftext($im, $size, 0, $x + 2, $y + 2, $color2, $fnt, $str); } else { $color = imagecolorclosestalpha($im, 00, 00, 00, 20); $color2 = imagecolorclosestalpha($im, 255, 255, 255, 40); imagettftext($im, $size, 0, $x + 2, $y + 2, $color2, $fnt, $str); } imagettftext($im, $size, 0, $x, $y, $color, $fnt, $str); ImageJPEG($im); ImageDestroy($im); }