Ejemplo n.º 1
0
 /**
  * 欢迎页.
  * 
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function index()
 {
     $model = M('system_log');
     $field = ['a.id', 'a.type', 'b.username', 'a.action_ip' => 'ip', 'a.remark', 'a.create_time'];
     $join = ['INNER JOIN __USER__ AS b on a.user_id = b.id'];
     $where = array();
     $p = I('get.p') ?: 1;
     $get = I('get.');
     trim_all($get);
     $get['type'] = isset($get['type']) ? $get['type'] : -1;
     if ($get['type'] != -1) {
         $where['a.type'] = $get['type'];
     }
     if (!empty($get['username'])) {
         $where['b.username'] = ['like', '%' . $get['username'] . '%'];
     }
     if (!empty($get['ip'])) {
         $where['a.action_ip'] = ['like', '%' . $get['ip'] . '%'];
     }
     if (!empty($get['startTime']) && !empty($get['endTime'])) {
         $where['a.create_time'] = [['gt', strtotime($get['startTime'])], ['lt', strtotime($get['endTime'])], 'and'];
     } else {
         if (!empty($get['startTime'])) {
             //fb(strtotime($get['startTime']));
             $where['a.create_time'] = ['gt', strtotime($get['startTime'])];
         }
         if (!empty($get['endTime'])) {
             //fb(strtotime($get['endTime']));
             $where['a.create_time'] = ['lt', strtotime($get['endTime'])];
         }
     }
     $count = $model->alias('a')->field($field)->where($where)->join($join)->count('*');
     $page = new Page($count, 10);
     $data = $model->alias('a')->field($field)->where($where)->join($join)->page($p, 10)->order('create_time desc')->select();
     $show = $page->show();
     int_to_string($data, ['type' => ['0' => '后台', '1' => '中介']]);
     $this->assign('data', $data);
     $this->assign('show', $show);
     $this->assign('get', $get);
     $this->display();
 }
Ejemplo n.º 2
0
                         }
                         $div_string = $div_string . "</table>";
                         $div_string = $div_string . "</font>";
                         $div_string = $div_string . "</div>";
                         echo "<script>document.getElementById('output_div').innerHTML=\"" . $div_string . "\";</script>";
                     } else {
                         echo "<script>alert('There is no table in the database: \\'" . $_SESSION['db_selected_query'] . "\\'')</script>";
                     }
                 }
             }
         } else {
             echo "<script>alert('Enter the command \\'SHOW\\' in proper format.');</script>";
         }
         break;
     case "USE":
         $use_db_name = trim_all(substr($query_string, strlen("use")));
         if (strpos($use_db_name, " ") === FALSE) {
             if (is_dir("databases/" . $_SESSION['uname_query'] . "/" . $use_db_name)) {
                 $_SESSION['db_selected_query'] = $use_db_name;
                 echo "<script>document.getElementById('log').innerHTML=\"Selected DataBase:'" . $_SESSION['db_selected_query'] . "'\\n----------------------\\n\" + document.getElementById('log').innerHTML + \"\\n\";</script>";
             } else {
                 echo "<script>alert('DataBase:\\'{$use_db_name}\\' does not exist.');</script>";
                 //
             }
         } else {
             die("<script>alert('\\'USE\\' query is not in proper format.');</script>");
         }
         break;
 }
 if (isset($invalid_command)) {
     unset($invalid_command);
Ejemplo n.º 3
0
 /**
  * 编辑一条分类信息.
  * 
  * @access public
  * @return void
  */
 public function editAction()
 {
     $dataId = (int) I('post.id', 0);
     $postCityName = (string) I('post.city_name', '');
     // 发布的城市名称.
     $loginedUserInfo = $this->getLoginedUserInfo();
     // 已登录的用户信息.
     $modelCtgData = new CtgDataModel();
     // 检查城市和栏目 ID 是否有效.
     try {
         $cityInfo = $this->_checkCity($postCityName);
         // 检查城市.
         $locateCountryInfo = $this->getLocateCountry();
         // 定位国家.
         $info = $modelCtgData->checkInfo($dataId);
         if ($loginedUserInfo['uid'] != $info['user_id']) {
             // 发布与修改不是同一用户.
             throw new \Exception(Message::get(Message::FAILED), '无此操作权限!');
         }
         if (FALSE === $info) {
             // 该条信息是否有效.
             throw new \Exception(Message::get(Message::PARAM_ERROR), Message::PARAM_ERROR);
         }
         // 判断发布城市的国家是否为定位国家, 不是表示非法提交.
         if ($cityInfo['countryID'] != $locateCountryInfo['id']) {
             throw new \Exception(Message::get(Message::PARAM_ERROR), Message::PARAM_ERROR);
         }
     } catch (\Exception $e) {
         $this->setAjaxData($e->getCode(), $e->getMessage())->myAjaxReturn();
     }
     $cityId = $cityInfo['id'];
     // 发布城市 ID.
     $moduleId = $info['module_id'];
     // 模型 ID.
     unset($cityInfo, $info);
     $moduleConfig = C('module_config')[$moduleId];
     // 模型配置.
     $flagIsPic = $moduleConfig['ispic'];
     // 是否有图标记.
     $postData = I('post.');
     // 接收 $_POST 数据.
     trim_all($postData);
     // 去掉首尾空格.
     // -------------------------------------- 赋值主表数据 -------------------------------------------------------
     $postData['city_id'] = $cityId;
     // 发布城市.
     $postData['module_id'] = $moduleId;
     // 模型 ID.
     $postData['pub_user_id'] = $loginedUserInfo['uid'];
     // 用户 ID.
     $postData['edit_user_name'] = $postData['pub_user_name'] = $loginedUserInfo['userName'];
     // 发布人用户名和编辑用户名.
     $postData['ip'] = get_client_ip(0);
     // IP 地址.
     $postData['country_id'] = $locateCountryInfo['id'];
     // 定位的国家 ID.
     if ($flagIsPic) {
         // pic 有图时接收的是数组.
         $arrPicUrl = (array) I('post.picurl', []);
         // 提交的上传图片地址.
         $arrPicUrl = array_slice($arrPicUrl, 0, C('classified_upload_image_num'));
         // 有图片上传的, 只取前 10 张.
         $postData['picurl'] = $this->_removeSiteDomainOfPic($arrPicUrl);
     } else {
         $postData['picurl'] = '';
         // 无图.
     }
     $postData['edit_time'] = $postData['create_time'] = time();
     // 编辑时间.
     $postData['msn'] = (string) I('post.msn', '');
     // msn.
     // 判断联系方式三者必填一项.
     $telephone = (string) I('post.telephone', '');
     $email = (string) I('post.email', '');
     $qq = (string) I('post.qq', '');
     $resValidate = [];
     if (empty($telephone) && empty($email) && empty($qq)) {
         $resValidate['contact_way'] = '联系方式至少填一项';
     }
     // 主表数据赋值完成.
     // 执行字段映射, 返回 main(主表数据), detail(副表数据), label(字段显示名称).
     $mainTblField = C('module_config')['postMainTableField'];
     // 主表字段.
     $detailTblField = $moduleConfig['postPage'];
     // 副表字段.
     // 字段映射并赋字段默认值和处理有其它值的情况.
     $postData = Util::autoFieldMap($postData, $mainTblField, $detailTblField);
     // 执行验证规则.
     $validator = Validator::getInstance();
     // 实例化验证器.
     $flag = $validator->validate($postData['main'], RuleOfClassifiedInfo::$mainRule) && $validator->validate($postData['detail'], RuleOfClassifiedInfo::getRule($moduleId));
     if (FALSE === $flag) {
         // 验证失败.
         $_errors = $validator->getError();
         $resValidate = array_merge($resValidate, $_errors);
         $this->setAjaxData(Message::FAILED, Message::get(Message::FAILED), $resValidate)->myAjaxReturn();
     } elseif (!empty($resValidate)) {
         $this->setAjaxData(Message::FAILED, Message::get(Message::FAILED), $resValidate)->myAjaxReturn();
     }
     // 验证通过, 执行入库操作.
     // 删除不能修改的字段.
     $mainDeleteField = ['ctgClassID', 'modID', 'userID', 'userName', 'ip', 'gid', 'create_time', ''];
     foreach ($mainDeleteField as $v) {
         unset($postData['main'][$v]);
     }
     // 设置信息发布来源, 0表示web, 1表示app.
     $postData['main']['is_from'] = 1;
     $result = $modelCtgData->editInfo($dataId, $moduleId, $postData['main'], $postData['detail']);
     if ($result) {
         $this->setAjaxData(Message::SUCCESS, '修改成功')->myAjaxReturn();
     }
     $this->setAjaxData(Message::FAILED, '修改失败')->myAjaxReturn();
 }
Ejemplo n.º 4
0
function number_to_word($num = '')
{
    $num = (string) (int) $num;
    if ((int) $num && ctype_digit($num)) {
        $words = array();
        $num = str_replace(array(',', ' '), '', trim($num));
        $list1 = array('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen');
        $list2 = array('', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety', 'hundred');
        $list3 = array('', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quattuordecillion', 'quindecillion', 'sexdecillion', 'septendecillion', 'octodecillion', 'novemdecillion', 'vigintillion');
        $num_length = strlen($num);
        $levels = (int) (($num_length + 2) / 3);
        $max_length = $levels * 3;
        $num = substr('00' . $num, -$max_length);
        $num_levels = str_split($num, 3);
        foreach ($num_levels as $num_part) {
            $levels--;
            $hundreds = (int) ($num_part / 100);
            $hundreds = $hundreds ? ' ' . $list1[$hundreds] . ' Hundred' . ($hundreds == 1 ? '' : 's') . ' ' : '';
            $tens = (int) ($num_part % 100);
            $singles = '';
            if ($tens < 20) {
                $tens = $tens ? ' ' . $list1[$tens] . ' ' : '';
            } else {
                $tens = (int) ($tens / 10);
                $tens = ' ' . $list2[$tens] . ' ';
                $singles = (int) ($num_part % 10);
                $singles = ' ' . $list1[$singles] . ' ';
            }
            $words[] = $hundreds . $tens . $singles . ($levels && (int) $num_part ? ' ' . $list3[$levels] . ' ' : '');
        }
        $commas = count($words);
        if ($commas > 1) {
            $commas = $commas - 1;
        }
        $words = implode(', ', $words);
        //Some Finishing Touch
        //Replacing multiples of spaces with one space
        $words = trim(str_replace(' ,', ',', trim_all(ucwords($words))), ', ');
        if ($commas) {
            $words = str_replace_last(',', ' and', $words);
        }
        return $words;
    } else {
        if (!(int) $num) {
            return 'Zero';
        }
    }
    return '';
}
Ejemplo n.º 5
0
 /**
  * 处理发布内容
  * @author liuxiaolin <*****@*****.**>
  * @return void
  */
 public function postAction()
 {
     $uid = $_SESSION['userID'];
     //检测新注册用户
     $checkUserInfo = $this->checkNewUserPost();
     if ($checkUserInfo['status'] == false) {
         $this->ajaxReturn(['code' => -1, 'msg' => '新注册用户请在注册' . C('NEW_USER_POST_TIME') . '分钟后发帖'], 'json');
     }
     $idList = array(9, 10, 11, 12);
     $userInfo = M('user')->field('groupID')->where("userID={$uid}")->find();
     if (!in_array($userInfo['groupID'], $idList)) {
         //检测发贴是否超过限制
         $check = $this->checkPostTimes();
         if ($check['status'] == false) {
             $this->ajaxReturn(['code' => -1, 'msg' => '超过发贴限制~'], 'json');
         }
         //检测发帖时间间隔
         $message = $this->checkTimesInterval();
         if ($message['status'] == false) {
             $this->ajaxReturn(['code' => -1, 'msg' => '发帖时间间隔为' . C('INTERVAL_TIME') . '分钟'], 'json');
         }
     }
     $groupID = M('user')->where(array('userID' => $uid))->getField('groupID');
     if ($groupID == 4) {
         $this->ajaxReturn(['code' => -1, 'msg' => '你已被加入黑名单,不允许发布'], 'json');
     }
     $post = I('post.post');
     //存入ybirds_ctg_data表的原始数据
     $postdb = I('post.postdb');
     //存入ybirds_ctg_dataXX表的原始数据
     $token = I('post.token');
     //去除空白字符
     trim_all($post);
     trim_all($postdb);
     //初始化错误提示信息
     $errorMsg = '';
     //传入的数据验证处理
     //if (!empty($post['qq'])) {
     //    if (!preg_match('/^\d{5,12}$/', $post['qq'])) {
     //        $errorMsg .= 'qq号不符合规则';
     //    }
     //}
     //if (!empty($post['email'])) {
     //    if (!preg_match('/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/', $post['email'])) {
     //        $errorMsg .= '电子邮件不符合规则';
     //    }
     //}
     if (empty($post['title'])) {
         $errorMsg .= '标题必须填写';
     }
     if (empty($postdb['content_txt'])) {
         $errorMsg .= '详细内容必须填写';
     }
     //if (empty($post['address'])) {
     //    $errorMsg .= '联系地址必须填写';
     //}
     //if (empty($post['telephone'])) {
     //    $errorMsg .= '联系电话须填写';
     //}
     //如果有验证不通过,则返回code为-1
     if (!empty($errorMsg)) {
         $resData = ['code' => -1, 'msg' => $errorMsg];
         $this->ajaxReturn($resData, "json");
     }
     //处理$postdb数据, 如果是数组,则转换成字符串
     foreach ($postdb as $key => $value) {
         if (is_array($value)) {
             $postdb[$key] = implode(',', $value);
         }
     }
     //防止重复担提交
     if ($token != session('token')) {
         $resData = ['code' => -1, 'msg' => '你已经提交过了,请不要重复提交'];
         $this->ajaxReturn($resData, "json");
     }
     session('token', null);
     //处理token;
     $tokenArr = unserialize(authcode($token, 'DECODE', C('AUTH_TOKEN')));
     if (!is_array($tokenArr)) {
         $resData = ['code' => -1, 'msg' => '令牌token出错,请刷新页面重试'];
         $this->ajaxReturn($resData, "json");
     }
     //模型-栏目数据
     $dataModel = M('ctgData');
     $fdataModel = M('ctgData' . $tokenArr['mid']);
     //type=0表示新增,type=1表示编辑
     if ($tokenArr['type'] == 0) {
         //处理$post数组,
         $post['userID'] = session('userID');
         $post['userName'] = session('userName');
         $post['ip'] = get_client_ip();
         $post['postTime'] = time();
         $post['editTime'] = time();
         $post['editor'] = session('userName');
         $cityGid = get_city_gid();
         $post['gid'] = $cityGid[$post['cityID']];
         $post['modID'] = $tokenArr['mid'];
         $post['ctgClassID'] = $tokenArr['ctgClassID'];
         //开启事务
         $dataModel->startTrans();
         $res1 = $dataModel->data($post)->add();
         $postdb['dataID'] = $res1;
         $res2 = $fdataModel->data($postdb)->add();
         if ($res1 !== FALSE && $res2 !== FALSE) {
             $dataModel->commit();
             $trend['title'] = $post['title'];
             $trend['time'] = $post['postTime'];
             $trend['content'] = strip_tags($postdb['content_txt']);
             if (mb_strwidth($trend['content'], 'utf8') > 200) {
                 $trend['content'] = mb_strimwidth($trend['content'], 0, 200, '......', 'utf8');
             }
             $trend['dataID'] = $postdb['dataID'];
             genTrend($trend, 'cat');
             $this->checkCredit('Class');
             //发布分类积分处理
             $resData = ['code' => 1, 'msg' => '发布成功'];
             //发布的数量加1
             M('member')->where("uid={$_SESSION['userID']}")->setInc('ctgs');
         } else {
             $dataModel->rollback();
             $resData = ['code' => -1, 'msg' => '发布失败,请重试~'];
         }
         //编辑信息
     } elseif ($tokenArr['type'] == 1) {
         $post['editTime'] = time();
         $post['editor'] = session('?userName') ? session('userName') : session('adminUserName');
         $post['dataID'] = $tokenArr['dataID'];
         //开启事务
         $dataModel->startTrans();
         $res1 = $dataModel->data($post)->save();
         $res2 = $fdataModel->data($postdb)->where(['dataID' => $post['dataID']])->save();
         if ($res1 !== FALSE && $res2 !== FALSE) {
             $dataModel->commit();
             $resData = ['code' => 1, 'msg' => '编辑成功'];
         } else {
             $dataModel->rollback();
             $resData = ['code' => -1, 'msg' => '编辑失败,请重试~'];
         }
     }
     M('postlog')->data(['days' => date('Ymd'), 'uid' => session('userID'), 'type' => 0])->add();
     $this->ajaxReturn($resData, "json");
 }
Ejemplo n.º 6
0
 public function saveFileData($storage_id, $fileName)
 {
     $uploadpath = BACKEND_V2_TMP_PATH_ROOT . $fileName;
     $storage_id = (int) $storage_id;
     $rows = $this->CI->word->importFromDocx($uploadpath);
     @unlink($uploadpath);
     if (!empty($rows)) {
         $batchDataQuestions = [];
         $batchDataAnswers = [];
         $listHashQuestions = [];
         for ($i = 0, $n = count($rows); $i < $n; $i += 6) {
             $cell = $rows[$i][1];
             $data = [];
             $data['question_name'] = trim_all($this->CI->utils->smart_clean(addslashes($rows[$i][1])));
             if (!empty($data['question_name'])) {
                 $cell_correct_answer = explode(',', trim(strip_tags($rows[$i + 5][1])));
                 $cell_correct_answer = array_filter(array_map('trim', $cell_correct_answer));
                 $data['storage_id'] = $storage_id;
                 $hash = md5($data['storage_id'] . '_' . $data['question_name']);
                 $data['hashkey'] = $hash;
                 $data['select_any'] = count($cell_correct_answer) > 1 ? 0 : 1;
                 if (!in_array($hash, $listHashQuestions)) {
                     $batchDataQuestions[$hash] = $data;
                     $listHashQuestions[] = $hash;
                     // answers
                     for ($k = $i + 1; $k < $i + 5; $k++) {
                         $data = [];
                         $char = trim(strip_tags($rows[$k][0]));
                         if (in_array($char, $cell_correct_answer)) {
                             $data['correct_answer'] = 1;
                         } else {
                             $data['correct_answer'] = 0;
                         }
                         $data['answer'] = trim_all($this->CI->utils->smart_clean(addslashes($rows[$k][1])));
                         $data['hashkey'] = $hash;
                         if (!empty($data['answer']) || trim($data['answer']) != '' && intval($data['answer']) == 0) {
                             $batchDataAnswers[] = $data;
                         }
                     }
                 }
             }
         }
         // import csv into storage questions
         $questionsCsvName = BACKEND_V2_TMP_PATH_ROOT . uniqid() . '.csv';
         $this->exportToCsvTemp($questionsCsvName, $batchDataQuestions);
         $this->CI->storage_question_model->loadDataInfile($questionsCsvName);
         // truncate answer by hash key
         $this->CI->storage_answer_model->deleteByHash($listHashQuestions);
         // import csv into storage answers
         $answerCsvName = BACKEND_V2_TMP_PATH_ROOT . uniqid() . '.csv';
         $this->exportToCsvTemp($answerCsvName, $batchDataAnswers);
         $this->CI->storage_answer_model->loadDataInfile($answerCsvName);
         $storageQuestions = $this->CI->storage_question_model->getCountByStorageId($storage_id);
         // auto update storage_question_id
         // TODO: should be moved to background
         $this->autoUpdateStorageId($listHashQuestions);
         return ['status' => 0, 'message' => '', 'data' => ['numberOfQuestions' => $storageQuestions]];
     } else {
         return ['status' => 1, 'message' => 'Cấu trúc file không hợp lệ', 'data' => null];
     }
 }
Ejemplo n.º 7
0
if (!defined('PSYCHOSTATS_PAGE')) {
    define("PSYCHOSTATS_PAGE", true);
    include dirname(__FILE__) . "/includes/common.php";
    $cms->init_theme($ps->conf['main']['theme'], $ps->conf['theme']);
    $ps->theme_setup($cms->theme);
}
// collect url parameters ...
$validfields = array('src');
$cms->globalize_request_vars($validfields);
// nothing to do if there's no sources given
if (empty($src)) {
    exit;
}
// collect the sources and sanitize them.
$sources = explode(',', $src);
trim_all($sources);
// remove whitespace
$root = $cms->theme->template_dir;
//$ps->conf['theme']['template_dir'];
$files = array();
$missing = array();
$lastupdate = 0;
// Make sure each source is a relative path within the theme directory and does
// not contain '..'
for ($i = 0, $j = count($sources); $i < $j; $i++) {
    // I can't use the sanity checks below because some themes will use
    // relative paths with ../ which is perfectly valid and legal.
    // remove double dots and force backslashes to forward slashes
    //	$sources[$i] = str_replace(array('../','\\'), array('/','/'), $sources[$i]);
    // remove duplicate directory separators and remove the leading slash
    //	$sources[$i] = preg_replace(array('|//+|','|^/|'), array('/',''), $sources[$i]);
Ejemplo n.º 8
0
 function exportStorages($filename, $storages)
 {
     // Include the PHPWord.php, all other classes were loaded by an autoloader
     require_once APPPATH . 'libraries/PhpOffice/PhpWord/PHPWord.php';
     // New Word Document
     $PHPWord = new \PhpOffice\PhpWord\PhpWord();
     // New portrait section
     $section = $PHPWord->createSection();
     $styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
     // Add table style
     $PHPWord->addTableStyle('myOwnTableStyle', $styleTable);
     // Add table
     $table = $section->addTable('myOwnTableStyle');
     $styleCell = array('valign' => 'center', 'borderSize' => 6, 'borderColor' => '006699');
     for ($i = 0, $n = count($storages); $i < $n; $i++) {
         $item = $storages[$i];
         $list_answer = explode(SEPARATE_ANSWER, $item->answer);
         $list_correct_answer = explode(SEPARATE_CORRECT_ANSWER, $item->correct_answer);
         $template = array('col1' => 'Câu hỏi', 'col2' => trim_all($item->question_name));
         $this->_addDataToRow($table, $template, $styleCell);
         $c = 65;
         $index = array();
         foreach ($list_answer as $idx => $answer) {
             if ($list_correct_answer[$idx] == 1) {
                 $index[] = chr($c);
             }
             $template = array('col1' => chr($c++), 'col2' => trim_all($answer));
             $this->_addDataToRow($table, $template, $styleCell);
         }
         $template = array('col1' => 'Câu trả lời đúng', 'col2' => implode(SEPARATE_CORRECT_ANSWER, $index));
         $this->_addDataToRow($table, $template, $styleCell);
     }
     $xmlWriter = IOFactory::createWriter($PHPWord, 'Word2007');
     $xmlWriter->save($filename);
     $this->export($filename);
 }
Ejemplo n.º 9
0
 public function ajaxCheckName()
 {
     $name = I('get.name');
     $us_id = I('get.us_id');
     // $su_id = I('get.su_id');
     $model = M('university_majorlang');
     trim_all($name);
     $res = $model->where(array('name' => $name, 'us_id' => $us_id, 'lang' => 'en-us'))->find();
     if ($res) {
         $info = true;
     } else {
         $info = false;
     }
     $this->ajaxReturn($info, "json");
 }
Ejemplo n.º 10
0
function tidy_all(&$ary, $trimtags = 0)
{
    trim_all($ary, $trimtags);
    stripslashes_all($ary);
}
Ejemplo n.º 11
0
 /**
  * 得到条件选择后的学校列表
  * @access private
  * @param  $_POST
  * @return array
  * @author liuxiaolin <*****@*****.**>
  */
 public function getMatchList()
 {
     // 当前的语系, LANG_SET
     $lang = LANG_SET;
     trim_all($_POST);
     // post 的条件
     $post['schoolName'] = I('post.schoolName', '');
     $post['areaName'] = I('post.areaName', '');
     $post['cityName'] = I('post.cityName', '');
     $post['ranking'] = I('post.ranking', '');
     $post['subject'] = I('post.subject', '');
     // join
     $joins = array('INNER JOIN __UNIVERSITYLANG__ AS b ON a.id=b.fid');
     // 搜索条件
     $where = "a.is_del=0 AND b.is_del=0 && b.lang='{$lang}'";
     // 排序
     $order = 'a.rank DESC';
     // 字段列表
     $field = array('a.id AS us_id');
     // ----------------- 组装搜索条件 --------------------------------
     if (!empty($post['schoolName'])) {
         $where .= " AND b.name LIKE '%{$post['schoolName']}%'";
     }
     if (!empty($post['areaName'])) {
         $innerSql = M('Universitylang')->field('fid')->where("area='{$post['areaName']}'")->select(FALSE);
         $where .= " AND b.fid IN ({$innerSql})";
     }
     if (!empty($post['cityName'])) {
         $tmp = trim(strtolower($post['cityName']));
         if ('other' == $tmp) {
             // 城市的下标
             $key = empty($post['areaName']) ? 'All' : $post['areaName'];
             // 获取配置项
             $conf = C('SCHOOL_LIST_PAGE')['cities'];
             // 安全检查 key 不存在, 默认为 All
             $key = isset($conf[$key]) ? $key : 'All';
             $_cities = array_keys($conf[$key][$lang]);
             $_idx = array_search('Other', $_cities);
             if (FALSE !== $_idx) {
                 unset($_cities[$_idx]);
             }
             $_cond = "IN ('" . implode("','", $_cities) . "')";
             $innerSql = M('Universitylang')->field('fid')->where("city {$_cond}")->select(FALSE);
             $where .= " AND b.fid NOT IN ({$innerSql})";
             unset($_cities, $_idx, $_cond);
         } else {
             $innerSql = M('Universitylang')->field('fid')->where("city='{$post['cityName']}'")->select(FALSE);
             $where .= " AND b.fid IN ({$innerSql})";
         }
     }
     if (!empty($post['ranking'])) {
         if (FALSE === strpos($post['ranking'], '+')) {
             $_rank = array_map('intval', array_map('trim', explode('-', $post['ranking'])));
             $where .= " AND a.rank BETWEEN {$_rank[0]} AND {$_rank['1']}";
         } else {
             $_rank = intval(trim($post['ranking'], '+'));
             $where .= " AND a.rank > {$_rank}";
         }
     }
     // ------------------------------查询的结果数据集---------------------------------
     // 实例化 university 模型
     $model = M('University');
     // 获取数据
     $lists = $model->alias('a')->field($field)->join($joins)->order($order)->where($where)->select();
     if (!empty($lists)) {
         //把二维数组转换成一维数组
         foreach ($lists as $k => $v) {
             $usArr[] = $v['us_id'];
         }
     } else {
         $usArr = array(0);
     }
     return $usArr;
 }
Ejemplo n.º 12
0
foreach (scandir("workshops") as $workshop) {
    if (!file_exists("workshops/{$workshop}/title.txt")) {
        continue;
    }
    if (!file_exists("workshops/{$workshop}/editors.txt")) {
        continue;
    }
    $contents = array();
    $contents['shortname'] = $workshop;
    $contents['title'] = rtrim(file_get_contents("workshops/{$workshop}/title.txt"));
    $contents['editors'] = trim_all(file("workshops/{$workshop}/editors.txt"));
    $papers = array();
    foreach (scandir("workshops/{$workshop}/papers") as $paper) {
        if (!file_exists("workshops/{$workshop}/papers/{$paper}/title.txt")) {
            continue;
        }
        if (!file_exists("workshops/{$workshop}/papers/{$paper}/authors.txt")) {
            continue;
        }
        $paper_info = array();
        $paper_info['number'] = $paper;
        $paper_info['title'] = rtrim(file_get_contents("workshops/{$workshop}/papers/{$paper}/title.txt"));
        $paper_info['authors'] = trim_all(file("workshops/{$workshop}/papers/{$paper}/authors.txt"));
        $paper_info['length'] = pdf_length("workshops/{$workshop}/papers/{$paper}/paper.pdf");
        $papers[$paper] = $paper_info;
    }
    $contents['papers'] = $papers;
    $workshops[$workshop] = $contents;
}
$current_page = 1;
$current_paper = 1;
Ejemplo n.º 13
0
/**
 * 去除空白字符,支持多维数组
 * @author liuxiaolin <*****@*****.**>
 * @param  maxed array  $input 参数传入方式为传址方式
 * @return maxed
 */
function trim_all(&$input)
{
    if (is_array($input)) {
        foreach ($input as $key => &$value) {
            if (is_array($value)) {
                trim_all($value);
            } else {
                $value = trim($value);
            }
        }
        //传入是一个string, 则返回String
    } elseif (is_string($input)) {
        $input = trim($input);
    }
}
Ejemplo n.º 14
0
 /**
  * 显示的学校列表(仅 ajax)
  * 
  * @access public
  * @param boolean $isInnerCall TRUE 表示内部调用, 返回数组
  * @return void|array
  * @author Liuping <*****@*****.**>
  */
 public function getSchoolList($isInnerCall = FALSE)
 {
     // 当前的语系, LANG_SET
     $lang = LANG_SET;
     trim_all($_POST);
     // post 的条件
     $post['schoolName'] = I('post.schoolName', '');
     $post['areaName'] = I('post.areaName', '');
     $post['cityName'] = I('post.cityName', '');
     $post['ranking'] = I('post.ranking', '');
     $post['subject'] = I('post.subject', '');
     // join
     $joins = array('INNER JOIN __UNIVERSITYLANG__ AS b ON a.id=b.fid');
     // 搜索条件
     $where = "a.is_del=0 AND b.is_del=0 && b.lang='{$lang}'";
     // 排序
     $order = 'a.rank ASC';
     // 字段列表
     $field = array('a.id AS schollid', 'a.rank', 'a.logo', 'a.is_ship', 'a.stip_val', 'b.name AS schoolname', 'b.city', 'b.ship_intro', 'b.stip_intro');
     // ----------------- 组装搜索条件 --------------------------------
     if (!empty($post['schoolName'])) {
         $where .= " AND b.name LIKE '%{$post['schoolName']}%'";
     }
     if (!empty($post['areaName'])) {
         $innerSql = M('Universitylang')->field('fid')->where("area='{$post['areaName']}'")->select(FALSE);
         $where .= " AND b.fid IN ({$innerSql})";
     }
     if (!empty($post['cityName'])) {
         $tmp = trim(strtolower($post['cityName']));
         if ('other' == $tmp) {
             // 城市的下标
             $key = empty($post['areaName']) ? 'All' : $post['areaName'];
             // 获取配置项
             $conf = C('SCHOOL_LIST_PAGE')['cities'];
             // 安全检查 key 不存在, 默认为 All
             $key = isset($conf[$key]) ? $key : 'All';
             $_cities = array_keys($conf[$key][$lang]);
             $_idx = array_search('Other', $_cities);
             if (FALSE !== $_idx) {
                 unset($_cities[$_idx]);
             }
             $_cond = "IN ('" . implode("','", $_cities) . "')";
             $innerSql = M('Universitylang')->field('fid')->where("city {$_cond}")->select(FALSE);
             $where .= " AND b.fid NOT IN ({$innerSql})";
             unset($_cities, $_idx, $_cond);
         } else {
             $innerSql = M('Universitylang')->field('fid')->where("city='{$post['cityName']}'")->select(FALSE);
             $where .= " AND b.fid IN ({$innerSql})";
         }
     }
     if (!empty($post['ranking'])) {
         if (FALSE === strpos($post['ranking'], '+')) {
             $_rank = array_map('intval', array_map('trim', explode('-', $post['ranking'])));
             $where .= " AND a.rank BETWEEN {$_rank[0]} AND {$_rank['1']}";
         } else {
             $_rank = intval(trim($post['ranking'], '+'));
             $where .= " AND a.rank > {$_rank}";
         }
     }
     // 有选择学科, 增加 join 和 排序
     if (!empty($post['subject'])) {
         $order = 'c.score_require DESC, ' . $order;
         $joins[] = 'LEFT JOIN __UNIVERSITY_SUBJECT__ AS c ON a.id=c.us_id';
         $where .= " AND c.score_require!=0 AND c.su_id=" . intval($post['subject']);
         // 只显示有这个学科的学校
     }
     // ------------------------------查询的结果数据集---------------------------------
     $lists = array();
     // 每页显示的条数
     $pageSize = 16;
     // 实例化 university 模型
     $model = M('University');
     // 总记录数
     $totalRows = $model->alias('a')->field($field)->join($joins)->order($order)->where($where)->count();
     $totalPage = ceil($totalRows / $pageSize);
     $varPage = C('VAR_PAGE');
     if (isset($_GET[$varPage]) && intval($_GET[$varPage]) > $totalPage) {
         $_GET[$varPage] = $totalPage;
     }
     // 实例化分页类对象
     $pager = new \Think\Page($totalRows, $pageSize);
     $pager->setConfig('theme', '%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%');
     $pageList = '';
     // 2016-1-5 增加手机访问判断 liuping.
     if (is_wap()) {
         // 手机访问不分页.
         // 获取数据
         $lists = $model->alias('a')->field($field)->join($joins)->order($order)->where($where)->select();
         $pageList = '';
         $this->theme('bootstrap');
     } else {
         // 获取数据
         $lists = $model->alias('a')->field($field)->join($joins)->order($order)->where($where)->limit($pager->firstRow . ',' . $pager->listRows)->select();
         // 分页列表
         $pageList = $pager->show();
     }
     //fb($model->getLastSql());
     // 内部调用的, 把数据列表和分页列表返回
     if ($isInnerCall) {
         return array('lists' => $lists, 'pageList' => $pageList);
     }
     // 可以申请的年份
     $appYears = getApplyForYears();
     // 非内部调用
     $this->assign('year', $appYears[0]);
     $this->assign('schoolList', $lists);
     $this->assign('pageList', $pageList);
     $this->display();
 }
Ejemplo n.º 15
0
 /**
  * 编辑全局分类处理
  *
  * @author liuxiaolin <*****@*****.**>
  * @access  public
  * @param   $ejyClassID 分类栏目ID
  *
  * @return void
  */
 public function editPosAction()
 {
     //存入ybirds_ad_position表的原始数据
     $post = $_POST['post'];
     //传入进来的数据处理,安全过滤
     trim_all($post);
     fliter_script($post);
     //错误提示信息
     $errorMsg = '';
     //传入的数据验证处理
     if (empty($post['title'])) {
         $errorMsg .= '广告位的文字说明(如 首页侧面广告)必须填写<br/>';
     }
     if (empty($post['width'])) {
         $errorMsg .= '广告位的宽度必须填写<br/>';
     }
     if (empty($post['height'])) {
         $errorMsg .= '广告位的高度必须填写<br/>';
     }
     if (!preg_match('/^\\d{1,4}$/', $post['width'])) {
         $errorMsg .= '广告位的宽度只能是数字</br>';
     }
     if (!preg_match('/^\\d{1,4}$/', $post['height'])) {
         $errorMsg .= '广告位的高度只能是数字</br>';
     }
     //有错误则显示消息
     if (!empty($errorMsg)) {
         $this->error($errorMsg);
     }
     //处理广告位上传示意图
     if ($_FILES['srcUrl']['name']) {
         $info1 = $this->upload($_FILES['srcUrl']);
         $post['srcUrl'] = C('PIC_UPLOAD.rootPath') . $info1['savepath'] . $info1['savename'];
     }
     //处理默认广告
     if ($post['type'] == 2) {
         if ($_FILES['default']['name']) {
             $info2 = $this->upload($_FILES['default']);
             $post['default'] = C('PIC_UPLOAD.rootPath') . $info2['savepath'] . $info2['savename'];
         }
     } elseif ($post['type'] == 1) {
         if (!empty($_POST['default'])) {
             $post['default'] = $_POST['default'];
         }
     }
     $model = M('ad_position');
     $allModel = M('ad_all');
     //开户事务
     $model->startTrans();
     $adAll = $allModel->field('id')->where(array('pid' => $post['id']))->select();
     $res[0] = $model->data($post)->save();
     foreach ($adAll as $k => $v) {
         $res[] = $allModel->data(array('id' => $v['id'], 'page' => $post['page']))->save();
     }
     $url = session('advPosUrl');
     session('advPosUrl', null);
     //成功就提交,失败回滚
     if (!in_array(false, $res, true)) {
         $model->commit();
         operateLog('编辑广告位' . $post['id'], 4);
         $this->success('编辑广告位成功', $url);
     } else {
         $model->rollback();
         $this->error('编辑广告位失败', $url);
     }
 }
Ejemplo n.º 16
0
 /**
  * 订单确认处理
  *
  * @author liuxiaolin <*****@*****.**>
  * @access  protected
  *
  * @return array
  */
 public function orderConfirm()
 {
     $carts = I('post.data');
     $check = I('post.check');
     trim_all($carts);
     trim_all($check);
     fliter_script($carts);
     foreach ($check as $key => $val) {
         $Arr['aid'][$key] = $val;
         $Arr['num'][$key] = $carts[$val];
         if ($carts[$val] < 4) {
             $this->error('请至少购买4周');
         }
     }
     $uid = session('userID');
     $model = M('ad_all');
     //先判断所选的广告位,有没有被购买或被锁定
     $map['id'] = array('in', $Arr['aid']);
     $map['_string'] = 'isLock=1 OR isSall=1';
     $res = $model->where($map)->select();
     if ($res) {
         $this->error('你所选购的广告位已经被购买,请重新选择', U('Ucenter/Adv/listMyCarts'));
     }
     //把选购的广告位锁定, 以防止其它人再次购买
     $saveDate = array('isLock' => 1, 'lockTime' => time(), 'uid' => $uid);
     $saveMap = array('id' => array('in', $Arr['aid']));
     //开启事务
     $model->startTrans();
     $saveRes = $model->where($saveMap)->setField($saveDate);
     //成功后提交,失败后回滚
     if ($saveRes !== false) {
         $model->commit();
         $field = 'a.id, a.place, a.page, a.gid, a.price, b.type, b.title, c.name, b.width, b.height, b.srcUrl';
         $join = array('LEFT JOIN __AD_POSITION__ AS b on a.pid = b.id', 'LEFT JOIN __AD_COUNTRY__ AS c ON a.gid = c.gid');
         $where['a.id'] = array('in', $Arr['aid']);
         $data = $model->alias('a')->field($field)->where($where)->join($join)->select();
         //处理数据
         foreach ($data as $k => $v) {
             if ($Arr['num'][$v['id']] >= 52) {
                 $discount = 0.7;
             } else {
                 if ($Arr['num'][$v['id']] >= 26) {
                     $discount = 0.8;
                 } else {
                     $discount = 1;
                 }
             }
             //存在订单表中的数组
             $saveData['data'][] = array('uid' => $uid, 'aid' => $v['id'], 'adType' => $v['type'], 'price' => $v['price'], 'num' => $Arr['num'][$v['id']], 'total' => $Arr['num'][$v['id']] * $v['price'] * $discount, 'discount' => $discount, 'payMoney' => $Arr['num'][$v['id']] * $v['price']);
             //用于用户确认的数据
             $showData[] = array('aid' => $v['id'], 'page' => $v['page'], 'name' => $v['name'], 'type' => $v['type'], 'title' => $v['title'], 'width' => $v['width'], 'height' => $v['height'], 'srcUrl' => $v['srcUrl'], 'price' => $v['price'], 'num' => $Arr['num'][$v['id']], 'total' => $Arr['num'][$v['id']] * $v['price'] * $discount, 'discount' => $Arr['num'][$v['id']] . ' * ' . $v['price'] . ' * ' . $discount, 'payMoney' => $Arr['num'][$v['id']] * $v['price']);
         }
         //获得总价
         $totalMoney = 0;
         foreach ($showData as $value) {
             $totalMoney += $value['total'];
         }
         //存入session,以被插入订单表中使用
         $saveData['aid'] = $Arr['aid'];
         session('orderData', null);
         session('orderData', $saveData);
         session('totalMoney', $totalMoney);
         //生成令牌, 防止重复提交
         $auth = array('name' => session('userName'), 'key' => md5(time() . 'confirmOrder'));
         $token = data_auth_sign($auth);
         session('token', null);
         session('token', $token);
         //p($totalMoney, false);
         //p($saveData, false);
         //p($showData);
         $this->assign('token', $token);
         $this->assign('totalNum', count($data));
         $this->assign('totalMoney', $totalMoney);
         $this->assign('showData', $showData);
         $this->display();
     } else {
         $model->rollback();
         $this->error('结算失败,请重新选择', U('Ucenter/Adv/listMyCarts'));
     }
 }
Ejemplo n.º 17
0
 /**
  * 增加学校多语言信息页面显示
  * @author   wangtao
  * @param
  * @access   public
  * @return   void
  */
 public function addInfoAction()
 {
     if ($_POST) {
         if (isset($_POST['info_fid'])) {
             $_POST['zh-cn']['fid'] = $_POST['info_fid'];
             $_POST['en-us']['fid'] = $_POST['info_fid'];
         }
         $has = M()->query("select count(1) count from app_universitylang where fid={$_POST['info_fid']}");
         if ($has[0]['count'] >= 2) {
             echo json_encode(array('success' => 0));
             exit;
         }
         unset($_POST['info_fid'], $_POST['info_id']);
         // 去掉所有空格(liuping增加)
         trim_all($_POST);
         $schoolInfoModel = M('universitylang');
         $schoolInfoModel->startTrans();
         if ($schoolInfoModel->add($_POST['zh-cn']) && $schoolInfoModel->add($_POST['en-us'])) {
             $schoolInfoModel->commit();
             system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "新增了学校多语言信息" . $_POST['school']['name'], $schoolInfoModel->getTableName(), $schoolInfoModel->getLastInsID(), 'a', $_POST, null, 0);
             echo json_encode(array('success' => 1));
         } else {
             $schoolInfoModel->rollback();
             echo json_encode(array('success' => 0));
         }
     }
 }