public function index() { $db = Controller::model('DBconnect', ''); $res = "Main"; $module = Controller::module('works/index'); $news = Controller::module('news/index'); Controller::view('home/index', array('name' => $res, 'module' => $module, 'news' => $news)); }
public function Games($id = -1) { parent::model('BD'); if ($id <= 0) { $table = BD::LoadAPIGames(); echo json_encode($table); } else { $table = BD::LoadAPIGame($id); echo json_encode($table); } }
/** * 相关文章列表 */ protected function relation($id, $num = 10) { if (empty($id)) { return false; } $db = Controller::model('content'); $row = $db->from('content_' . App::get_site_id() . '_extend')->where('id=' . (int) $id)->select(false); if (empty($row) || empty($row['relation'])) { return null; } $ids = $row['relation']; $data = $db->relation($ids, $num); return $data; }
/** * 添加、修改内容数据 */ public function set($id, $tablename, $data) { $id = intval($id); if (!$this->is_table_exists($tablename)) { return lang('m-con-37', array('1' => $tablename)); } $table = Controller::model($tablename); //加载附表Model if (empty($data['catid'])) { return lang('m-con-8'); } $_data = $id ? $this->find($id) : null; //数组转化为字符 foreach ($data as $i => $t) { if (is_array($t)) { $data[$i] = array2string($t); } } //描述截取 if (empty($data['description']) && isset($data['content'])) { $len = isset($data['fn_add_introduce']) && $data['fn_add_introduce'] && $data['fn_introcude_length'] ? $data['fn_introcude_length'] : 200; $data['description'] = str_replace(array(PHP_EOL, ' '), array('', ''), strcut(clearhtml($data['content']), $len)); } //下载远程图片 if (isset($data['content']) && isset($data['fn_down_image']) && $data['fn_down_image']) { $content = str_replace(array('\\', '"'), array('', '\''), htmlspecialchars_decode($data['content'])); if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $imgs)) { $userid = !$data['sysadd'] && $data['userid'] ? $data['userid'] : (!$_data['sysadd'] && $_data['userid'] ? $_data['userid'] : 0); $sysadd = $data['sysadd'] ? $data['sysadd'] : ($_data['sysadd'] ? $_data['sysadd'] : 0); if ($userid) { //表示会员投稿 $member = $this->execute("select groupid from {$this->prefix}member where id=" . $userid, false); $group = $this->execute("select * from {$this->prefix}member_group where id=" . (int) $member['groupid'], false); $result = $this->download_images($imgs[3], $userid, (int) $group['filesize']); } elseif ($sysadd) { //表示管理员投稿 $result = $this->download_images($imgs[3]); } if (isset($result) && $result) { $image = $result['replace'][0]; $data['content'] = str_replace($result['regex'], $result['replace'], $data['content']); } } } //提取缩略图 if (empty($data['thumb']) && isset($data['content']) && isset($data['fn_auto_thumb']) && $data['fn_auto_thumb']) { if (isset($image)) { $data['thumb'] = $image; } else { $content = str_replace(array('\\', '"'), array('', '\''), htmlspecialchars_decode($data['content'])); if (preg_match("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $img)) { $data['thumb'] = $img[3]; } } } //关键字处理 if ($data['keywords']) { $data['keywords'] = str_replace(',', ',', $data['keywords']); $tags = @explode(',', $data['keywords']); if ($tags) { foreach ($tags as $t) { $name = trim($t); if ($name) { $d = $this->from('tag', 'id')->where('name=?', $name)->select(false); if (empty($d)) { $this->query('INSERT INTO `' . $this->prefix . 'tag` (`name`,`letter`) VALUES ("' . $name . '", "' . word2pinyin($name) . '")'); } } } } } $status = 1; //用于判断积分增加 $is_add = 0; if ($id) { //修改 if (empty($_data)) { $data['id'] = $id; $data['url'] = getUrl($data); //更新URL $data['status'] = 1; //插入时状态设置为1 $this->insert($data); $table->insert($data); $is_add = 1; } else { $data['id'] = $data['id'] ? $data['id'] : $id; $data['url'] = getUrl($data); //更新URL unset($data['id']); $data['status'] = $data['status'] > 0 ? 1 : 0; //修改时,非0状态设置为1 $this->update($data, 'id=' . $id); $table->update($data, 'id=' . $id); $status = 0; //修改时不作为积分处理 $data['userid'] = $_data['userid']; } } else { //添加 $data['id'] = $id = $this->get_content_id(); if (empty($id)) { return lang('m-con-36'); } $data['url'] = getUrl($data); //更新URL $data['status'] = 1; //插入时状态设置为1 $this->insert($data); $table->insert($data); $is_add = 1; } //积分处理 非系统添加且(增加时,文档状态等于1) if (!$data['sysadd'] && $status == 1) { $this->credits($data['userid'], 1); } //处理内容扩展数据 $this->set_extend_data($id, $data); // 添加数据的处理 if ($is_add) { // 回调函数 $table = str_replace($this->prefix, '', $table->table_name); $function = 'callback_' . $table; $file = MODEL_DIR . 'callback/' . $table . '.php'; if (is_file($file)) { include_once $file; if (function_exists($function)) { $function($data); } } // 执行任务表 $table = $this->db->dbprefix . "sb"; $this->db->query("CREATE TABLE IF NOT EXISTS `" . $table . "` (\n `id` int(10) AUTO_INCREMENT NOT NULL,\n `type` varchar(50) NOT NULL,\n `value` text NOT NULL,\n PRIMARY KEY (`id`),\n KEY `type` (`type`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); $this->db->insert($table, array('type' => 'content_add', 'value' => array2string($data))); // 推送微信 $this->post_weixin($id); } return $id; }
/** * 相关文章列表 */ protected function relation($id, $num = 10, $more = 0) { if (empty($id)) { return false; } $db = Controller::model('content'); $row = $db->from('content_' . App::get_site_id() . '_extend')->where('id=' . (int) $id)->select(false); if (empty($row) || empty($row['relation'])) { return null; } $ids = $row['relation']; $num = $num ? $num : 10; if ($more) { $cats = get_category_data(App::get_site_id()); $models = get_model_data('content', App::get_site_id()); $table = $models[$cats[$row['catid']]['modelid']]['tablename']; if ($table) { $sql = 'select * from `' . $this->ci->db->dbprefix('content_' . App::get_site_id()) . '` as a left join `' . $this->ci->db->dbprefix($table) . '` as b on a.id=b.id where a.id IN (' . $ids . ') order by a.listorder desc, a.updatetime desc limit ' . $num; $data = $this->ci->db->query($sql)->result_array(); return $data; } } $data = $db->from('content_' . App::get_site_id())->where('id in (' . $ids . ')')->order('listorder desc, updatetime desc')->limit($num)->select(); return $data; }
public function log() { parent::model("docs"); $_model = new docs(); //Contient toutes les données à afficher $data = array(); if (isset($_POST["logText"])) { if ($_POST["logText"] != "") { $_model->SaveLog($_SESSION['ID'], $_POST["logText"]); } } $data['logs'] = $_model->LoadLog($_SESSION['ID']); $data['logs'] = array_reverse($data['logs']); parent::view("shared/header"); parent::view("intern/menu"); parent::view('intern/log', $data); parent::view('shared/footer'); }
/** * 单例模式实例化一个Model对象 */ public function model($table_name) { return Controller::model($table_name); }
public function __construct() { parent::model("models"); parent::model("installer"); $this->installer = new installer(); }
public function submitCie() { parent::model("business"); parent::model("accounts"); $business = new business(); $user = new accounts(); if (!$business->EmailExist($_POST["email"])) { if ($user->UsernameExist($_POST["user"]) || $_POST["user"] == "") { $_POST["user"] = $user->PassGen(); } try { $user->CreateUser($_POST["name"], $_POST["user"], $user->PassGen(), 1); $business->CreateBusiness($_POST["address"], $_POST["city"], $_POST["tel"], $_POST["email"], $user->DBLastInsertedID('users')); $data['alert'] = "alert-success"; $data['message'] = "L'entreprise a été soumise aux coordonnateurs de stage. Merci de votre participation."; } catch (PDOException $e) { $data['alert'] = "alert-warning"; $data['message'] = "L'entreprise n'a pu être soumise aux coordonnateurs de stage. Veuillez réessayer."; } } else { $data['alert'] = "alert-warning"; $data['message'] = "Une entreprise avec ce même email existe déjà."; } parent::view('shared/header'); parent::view('home/menu'); parent::view('home/index', $data); parent::view('shared/footer'); }
public static function model($className = __CLASS__) { return parent::model($className); }
public function action_form_postulacion() { if (isset($_GET['postulacion']) && $_GET['postulacion'] == 'nueva' && isset($_POST['postulacion']) && $_POST['postulacion']) { $data = $_POST['postulacion']; $data['ext_curriculum'] = 'none'; parent::model('Model_Postulacion')->set_data($data); $valid_data = parent::model('Model_Postulacion')->validate(); if (isset($_FILES) && $_FILES['curriculum']) { $fileCurriculum = $_FILES['curriculum']; $fileName = explode('.', $fileCurriculum['name']); $secciones = count($fileName); $upload = Upload::factory('private_files'); $upload->file($fileCurriculum); $upload->set_max_file_size(3); $upload->set_allowed_mime_types(array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/msword')); if ($upload->check() && parent::model('Model_Postulacion')->valid) { if ($secciones > 1) { $extencion = $fileName[$secciones - 1]; parent::model('Model_Postulacion')->ext_curriculum = $extencion; if ($id_postulacion = parent::model('Model_Postulacion')->save()) { $upload->set_filename($id_postulacion . '.' . parent::model('Model_Postulacion')->ext_curriculum); $upload->save(); parent::set_mensaje('Gracias, tu postulacion ha sido aceptada y guardada con éxito'); // envío correo administrador de nueva postulación $email_admin = get_option('admin_email'); parent::model('Correos', array('to' => $email_admin, 'subject' => 'Nueva Postulacion')); // exit(); parent::model('Correos')->send('Nueva Postulacion para la oferta "' . get_the_title(parent::model('Model_Postulacion')->id_oferta) . '"'); header('Location: ' . get_permalink(parent::model('Model_Postulacion')->id_oferta)); exit; } else { parent::set_error('Ha ocurrido un error al guardar los datos, por favor intentalo mas tarde'); parent::model('Model_Postulacion')->set_session_data(); header('Location: ' . get_permalink(parent::model('Model_Postulacion')->id_oferta)); exit; } } else { parent::set_error('Archivo no válido'); parent::model('Model_Postulacion')->set_session_data(); header('Location: ' . get_permalink(parent::model('Model_Postulacion')->id_oferta)); exit; } } else { parent::model('Model_Postulacion')->set_session_data(); if (!parent::model('Model_Postulacion')->valid) { parent::set_error($valid_data); } parent::set_error($upload->get_errors()); header('Location: ' . get_permalink(parent::model('Model_Postulacion')->id_oferta)); exit; } } } else { // // parent::model('Model_Postulacion')->set_session_data(); // header('Location: /'); // exit(); } }
public function evalAdv($_review) { parent::model("accounts"); parent::model("docs"); $model1 = new accounts(); $model2 = new docs(); if (isset($_review["intern"]) && isset($_review["#review"]) || isset($_POST["intern"])) { $data['advisors'] = $model1->ShowUsersByRank(0); $data['interns'] = $model1->ShowUsersByRank(2); $intern = null; $review = null; if (isset($_POST['intern'])) { $_review = null; $intern = $_POST['intern']; $review = $_POST['review']; } else { if ($_review != null) { $intern = $_review["intern"]; $review = $_review["#review"]; } } $data['readOnly'] = $model2->ReadOnlyAdvisor($intern, $review); parent::model("projects"); $project = new projects(); $projectIntern = null; if (ctype_digit($intern)) { $projectIntern = $project->ShowProjectByIntern($intern); } if ($projectIntern != null) { if (!$data['readOnly']) { if (isset($_POST['evalIntern']) && $_SESSION['form_timer'] + 300 > time()) { try { $model2->SaveAdvisor($_SESSION['ID'], $review, $_POST); $data['alert'] = "alert-success"; $data['message'] = "L'évaluation a été enregistrée avec succès!"; $data['review'] = $model2->LoadAdvisor($intern, $review); $data['readOnly'] = true; } catch (exception $ex) { $data['alert'] = "alert-warning"; $data['message'] = "L'enregistrement de l'évaluation a échoué."; $this->ShowInterns($data); } } } else { $data['alert'] = "alert-warning"; $data['message'] = "Cette évaluation existe déjà pour ce stagiaire."; $data['review'] = $model2->LoadAdvisor($intern, $review); } $data['intern'] = $intern; $data['#review'] = $review; parent::view("shared/header"); parent::view("advisor/menu"); parent::view("advisor/eval", $data); parent::view("shared/footer"); } else { $data['alert'] = "alert-warning"; $data['message'] = "Ce stagiaire n'a pas encore été jumelé à un projet."; $this->ShowInterns($data); } } else { $this->ShowInterns(null); } }
/** * Create and return the instance of the model specified by the parameter * * @param string $className Class name of model * @param string $alias Alias in SQL * @param PDO $db PDO instance * @return Model */ public function model($className, $alias = null, $db = null) { return $this->_controllerInstance->model($className, $alias, $db); }
function get_content_value($content) { if ($content != '' && preg_match('/^\\{M:(.+)\\}$/U', $content, $field)) { if (App::get_namespace_id() == 'admin') { return null; } if (!get_cookie('member_id')) { return null; } $member = Controller::model('member'); $name = trim($field[1]); $data = $member->find(get_cookie('member_id')); if (isset($data[$name])) { return $data[$name]; } $cache = new cache_file(); $model = $cache->get('model_member'); $_member = Controller::model($model[$data['modelid']]['tablename']); $_data = $_member->find(get_cookie('member_id')); if (isset($_data[$name])) { return $_data[$name]; } } else { return $content; } }
/** * 会员信息调用 * @param $uid * @param $more * @return array */ function get_member_info($uid, $more = 0) { if (empty($uid)) { return null; } $member = Controller::model('member'); $data = $member->find($uid); if (empty($data)) { return null; } if ($more) { //会员附表 $cache = new cache_file(); $model = $cache->get('model_member'); if (isset($model[$data['modelid']])) { $d = Controller::model($model[$data['modelid']]['tablename']); $r = $d->find($uid); $data = array_merge($r, $data); } } unset($data['password']); return $data; }
public function review($_projectID) { parent::view("shared/header"); parent::view("cie/menu"); parent::model("projects"); $model = new projects(); if ($_projectID != null || isset($_POST['project'])) { parent::model("docs"); $model1 = new docs(); parent::model("projects"); $model2 = new projects(); if (isset($_POST['project'])) { $project = $model2->ShowProjectByID($_POST['project']); } else { $project = $model2->ShowProjectByID($_projectID[0]); } if ($project != null) { parent::model("business"); $model4 = new business(); $cie = $model4->ShowCieByUserID($_SESSION['ID']); if ($project->status == 1 && $project->businessID == $cie->ID) { $data['title'] = $project->title; $data['projectID'] = $project->ID; $internId = $project->internID; if ($internId != null) { //Vérifier l'existence d'une évaluation de stage $data['readOnly'] = $model1->ReadOnlyAdvisor($internId, 'cieReview'); parent::model("accounts"); $model3 = new accounts(); $data['intern'] = $model3->ShowUserByID($internId); if ($data['readOnly']) { //si le formulaire existe $data['review'] = $model1->LoadAdvisor($internId, "cieReview"); $data['alert'] = "alert-warning"; $data['message'] = "L'évaluation pour ce stagiaire et pour ce projet existe déjà."; } else { //si le formulaire n'existe pas //Enregistrer le formulaire d'évaluation. if (isset($_POST['sendReview']) && isset($_POST['project']) && $_SESSION['form_timer'] + 1200 > time()) { try { $_POST['intern'] = $internId; $model1->SaveAdvisor($_SESSION['ID'], "cieReview", $_POST); $data['review'] = $model1->LoadAdvisor($internId, 'cieReview'); $data['alert'] = "alert-success"; $data['message'] = "L'évaluation a été enregistrée avec succès."; $data['readOnly'] = true; } catch (Exception $e) { $data['alert'] = "alert-warning"; $data['message'] = "L'évaluation n'a pas pu être enregistrée."; } } } parent::view("cie/review", $data); parent::view("shared/footer"); } else { $data['alert'] = "alert-warning"; $data['message'] = "Aucun stagiaire associé à ce projet."; $this->index($data); } } else { $data['alert'] = "alert-warning"; $data['message'] = "Il vous est interdit de visualiser ce formulaire."; $this->index($data); } } else { $data['alert'] = "alert-warning"; $data['message'] = "Ce projet n'existe pas."; $this->index($data); } } else { $this->index(null); } }
function cpanel(){ parent::model(); }
public static function ModifyAccount() { parent::model("Account"); $str = explode(",", $_POST["Modify"]); Account::ModifyAccount($str[0], $str[1], $str[2], $str[3]); }
/** * 实例化模型类 * * 用于自定义业务逻辑时,实例化其它的模型类。 * * @access public * * @param string $modelName 所要实例化的模型类的名称 * * @return object */ public function model($modelName) { //参数分析 if (!$modelName) { return false; } return Controller::model($modelName); }
/** * 实例化model */ public function load_model($model_name) { if (!$model_name) { return false; } return Controller::model($model_name); }
public static function ShowOld() { parent::model("Account"); $table = Account::LoadOld(); echo json_encode($table); }
public static function Update() { parent::model('BD'); BD::UpdateBD(); }