public function modPassword() { $userInfo = $this->_user->getUserInfo(); //D($userInfo); $uid = $userInfo['uid']; if ($uid == 0 && isset($uid)) { $this->alert('参数错误'); return; } if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $password = $_POST['password']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; $pwd = $this->_user->password($password); //md5(KEY_PASSWORD.$password); if ($userInfo['passwd'] != $pwd) { $success = false; $errors[] = '密码不正确'; } if (!isset($password1)) { $success = false; $errors[] = '新登陆密码不能为空'; } if (!isset($password2)) { $success = false; $errors[] = '再次输入密码不能为空'; } if ($password1 != $password2) { $success = false; $errors[] = '两次输入的密码不一致,请检查'; } // 插入数据库(接口没有验证数据是否重复,需添加者自己注意) if ($success) { $result = $this->_user->update_pwd(1, $uid, $password1); if (isset($result) && $result != 0) { $success = false; $errors[] = '插入数据库出错,不可连续修改两次密码且不可与原密码相同'; } } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = Doo::conf()->APP_URL . 'index.php/in'; } } // 处理表单位提交 $this->ajaxFormResult($success, $errors, true, 'loginOut'); } else { //取某用户信息 $row = $this->_user->get_one($uid); //D($row); // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getPasswordFormConfig(false, $row)); $this->contentlayoutRender($form->render()); } }
public function mod() { $configKey = 'settingConfig'; // $cachePath = Doo::conf()->CACHE_PATH; // Doo::conf()->CACHE_PATH = Doo::conf()->SITE_PATH.'protect/confCache/'; array_push($this->_includeJsFileList, 'js/ueditor/ueditor.config.js'); array_push($this->_includeJsFileList, 'js/ueditor/ueditor.all.min.js'); array_push($this->_includeJsFileList, 'js/ueditor/lang/zh-cn/zh-cn.js'); array_push($this->_includeJsFileList, 'js/ueditor/ueditor.use.js'); $shopNameList = DBproxy::getProcedure('Manage')->setDimension(2)->getShopName(); $shopNameOpt = '<select class="m-wrap" name="shopname" id="city-element">'; foreach ($shopNameList as $key => $value) { $selected = $this->getUrlVar('shopname') == $value['cityid'] . ',' . $value['shopname'] ? 'selected=selected' : ''; $shopNameOpt .= '<option ' . $selected . ' value="' . $value['cityid'] . ',' . $value['shopname'] . '">' . $value['cityNshopname'] . '</option>'; } $shopNameOpt .= '</select>'; if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); DOO::cache('php')->set($configKey, json_encode($_POST), 3600 * 24 * 365 * 100); // 处理返回路径 if ($success) { $errors = ConfigController::$dataTableUrl; } $this->ajaxFormResult($success, $errors); } else { $infoCache = DOO::cache('php')->get($configKey); $info = json_decode($infoCache, true); // echo Doo::conf()->CACHE_PATH = $cachePath; Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt(array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label' => false, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'peiSwitch' => array('select', array('label' => L('菜品调剂发送开关:'), 'attributes' => array('class' => "m-wrap"), 'multioptions' => array(0 => '关', 1 => '开'), 'value' => isset($info['peiSwitch']) ? $info['peiSwitch'] : '0')), 'waimaiSum' => array('text', array('label' => '外卖起送份数', 'attributes' => array('class' => "m-wrap"), 'value' => isset($info['waimaiSum']) ? $info['waimaiSum'] : '1')), 'aboutTxt' => array('display', array('label' => '关于我们', 'attributes' => array('class' => "m-wrap"), 'content' => '<script id="about" type="text/plain" style="width:1024px;height:500px;">' . $info['editorValue'] . '</script>')), 'saveAndSee' => array('button', array('div' => false, 'left' => ' ', 'label' => '保存&查看<i class="icon-arrow-right"></i>', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'cancelAndReturn' => array('display', array('div' => false, 'left' => ' ', 'right' => '</div>', 'content' => '<a class="btn" href="' . ConfigController::$dataTableUrl . '"><i class="icon-arrow-left"></i>取消&返回</a>'))))); $this->contentlayoutRender($form->render()); } }
private function table() { Doo::loadHelper('DooFile'); $id = Lua::get('id'); $db = $this->_get($id); $list = $this->_tree($id); include Lua::display('table', $this->dir); }
public function validate($checkMode = 'all', $requireMode = 'null') { //You do not need this if you extend DooModel or DooSmartModel //MODE: all, all_one, skip Doo::loadHelper('DooValidator'); $v = new DooValidator(); $v->checkMode = $checkMode; $v->requiredMode = $requireMode; return $v->validate(get_object_vars($this), $this->getVRules()); }
public function __construct() { Doo::loadHelper('DooFile'); $this->fileManager = new DooFile(0777); $this->defaultRootViewPath = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'view/'; $this->rootViewPath = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'view/'; $this->rootCompiledPath = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'viewc/'; if (self::$uniqueId == 0) { self::$uniqueId = time(); } }
function url2($addRootUrl, $controller, $method, $param = null) { Doo::loadHelper('DooUrlBuilder'); // param pass in as string with format // 'param1=>this_is_my_value, param2=>something_here' if ($param != null) { $param = explode(', ', $param); $param2 = null; foreach ($param as $p) { $splited = explode('=>', $p); $param2[$splited[0]] = $splited[1]; } return DooUrlBuilder::url2($controller, $method, $param2, $addRootUrl); } return DooUrlBuilder::url2($controller, $method, null, $addRootUrl); }
private function home() { Doo::loadHelper('DooFile'); $f = new DooFile(); $list = $f->getList($this->plugin_dir, DooFile::LIST_FOLDER); $ps = array(); if ($list) { foreach ($list as $k => $v) { $rs['name'] = $f->readFileContents($v['path'] . '/readme.txt'); $rs['ico'] = '/' . ADMIN_ROOT . '/' . Doo::conf()->PROTECTED_FOLDER . 'plugin/' . $v['name'] . '/ico.png'; $rs['act'] = $v['name']; $ps[$v['name']] = $rs; } } include Lua::display('plugin', $this->dir); }
public function twitter_follower() { Doo::loadHelper('DooRestClient'); $client = new DooRestClient(); // Check out this Twitter API http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends-daily $client->connect_to('http://twitter.com/followers/ids/doophp.xml')->get(); if ($client->isSuccess()) { $data['title'] = 'Twitter Followers\' Id <em>http://twitter.com/followers/ids/doophp.xml</em>'; $data['content'] = '<br/>HTTP result code: ' . $client->resultCode() . '<br/>Received content-type: ' . $client->resultContentType(); $data['content'] .= '<br/><br/>XML string: <pre>' . htmlentities($client->result()) . '</pre>'; $data['baseurl'] = Doo::conf()->APP_URL; $data['printr'] = $client->xml_result(); } else { print_r($client->resultCode()); print_r($client->result()); echo 'Failed to get Twitter API!'; exit; } $this->view()->render('template', $data); }
public function __add() { if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $rules = $this->_getFormRule(); // 验证数据 if ($errors = $v->validate($_POST, $rules)) { $success = false; } //数据处理 $param['name'] = trim($_POST['name']); $param['city'] = trim($_POST['city']); $param['longitude'] = intval($_POST['longitude']); $param['latitude'] = intval($_POST['latitude']); $param['status'] = intval($_POST['status']); $res = DBproxy::getProcedure('Manage')->setDimension(2)->mapIU('i', $param); if ($res['status'] != 0) { $success = false; $errors[] = '添加DB异常!'; } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = UserController::$dataTableUrl; } else { $errors = UserController::$addUrl; } } // 处理表单位提交 $this->ajaxFormResult($success, $errors); } else { // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getFormConfig(true)); $btn = '<a class="btn green-stripe" href="' . UserController::$dataTableUrl . '"><i class="icon-backward"> </i>门店列表</a>'; // 显示模版 $this->contentlayoutRender($btn . $form->render()); } }
public function getMovies() { Doo::loadClass('Movie'); $this->dbapi = new Movie(); Doo::loadHelper('DooPager'); $mtype = $this->ppv_cat_code; if ($_POST['mtype'] == 'svod') { $mtype = $this->svod_cat_code; } $pager = new DooPager(Doo::conf()->APP_URL . "ajax/movie", count($this->dbapi->get_movie_by_id($mtype)), 10, 10); if (isset($this->params['page'])) { $pager->paginate(intval($this->params['page'])); } else { $pager->paginate(1); } $data['pager'] = $pager->output; list($start, $limit) = explode(',', $pager->limit); $movies = $this->dbapi->get_movie_by_id($mtype, (int) $start, (int) $limit, $orderby, $order); $this->setContentType('json'); echo json_encode($movies); }
public function mod() { $configKey = 'settingConfig'; if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); DOO::cache('php')->set($configKey, json_encode($_POST), 3600 * 24 * 365 * 100); // 处理返回路径 if ($success) { $errors = ConfigController::$dataTableUrl; } $this->ajaxFormResult($success, $errors); } else { Doo::loadClassAt('html/DooFormExt', 'default'); $infoCache = DOO::cache('php')->get($configKey); $info = json_decode($infoCache, true); $form = new DooFormExt(array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label' => false, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'peiSum' => array('text', array('label' => '菜品调剂数', 'attributes' => array('class' => "m-wrap"), 'value' => isset($info['peiSum']) ? $info['peiSum'] : '', 'help' => '根据历史的订单加上这个数量,作为菜品配送数')), 'shopMaster' => array('text', array('label' => '店长微信openid', 'attributes' => array('class' => "m-wrap"), 'value' => isset($info['shopMaster']) ? $info['shopMaster'] : '', 'help' => '可以根据店长订餐时绑定的电话号码,从用户列表中查到店长的微信openid')), 'saveAndSee' => array('button', array('div' => false, 'left' => ' ', 'label' => '保存&查看<i class="icon-arrow-right"></i>', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'cancelAndReturn' => array('display', array('div' => false, 'left' => ' ', 'right' => '</div>', 'content' => '<a class="btn" href="' . ConfigController::$dataTableUrl . '"><i class="icon-arrow-left"></i>取消&返回</a>'))))); $this->contentlayoutRender($form->render()); } }
function init() { Doo::loadHelper('DooTextHelper'); $usession = $this->usession; if (isset($_POST['table_row'])) { $usession->uset('table_row_option', $_POST['table_row']); } $rows_data = $usession->uget('table_row_option'); $data['limit'] = 20; if ($rows_data) { $data['limit'] = $rows_data; } $gpage = $_GET['page'] - 1; $gsearch = addslashes($_POST['search']); $gdtform = addslashes($_GET['dtform']); $gdtto = addslashes($_GET['dtto']); if (!$gdtform) { $gdtform = date("m/d/Y", strtotime("-1 week")); } if (!$gdtto) { $gdtto = date("m/d/Y"); } $data['gdtto'] = $gdtto; $data['gdtform'] = $gdtform; $start_date = $gdtform = date("Y-m-d H:i:s", strtotime($gdtform)); $end_date = $gdtto = date("Y-m-d", strtotime($gdtto)) . " 23:59:59"; if (isset($gpage) && $gpage >= 0) { $start = $gpage * $data['limit']; } $this->limit = $data['limit']; $this->start = $start; $this->start_date = $start_date; $this->end_date = $end_date; $this->gsearch = $gsearch; $this->gdtto = $data['gdtto']; $this->gdtform = $data['gdtform']; }
/** * Validate the Model with the rules defined in getVRules() * * @param object $model Model object to be validated. * @param string $checkMode Validation mode. all, all_one, skip * @param string $requireMode Require Check Mode. null, nullempty * @return array Return array of errors if exists. Return null if data passes the validation rules. */ public static function _validate($model, $checkMode = 'all', $requireMode = 'null') { //all, all_one, skip Doo::loadHelper('DooValidator'); $v = new DooValidator(); $v->checkMode = $checkMode; $v->requiredMode = $requireMode; return $v->validate(get_object_vars($model), $model->getVRules()); }
public static function genPgSQL($path = null) { if ($path === null) { $path = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'model/'; } Doo::loadHelper('DooFile'); $fileManager = new DooFile(0777); $dbconf = Doo::db()->getDefaultDbConfig(); $dbSchema = $dbconf[6]; $dbname = $dbconf[1]; echo "<html><head><title>DooPHP Model Generator - DB: {$dbname}</title></head><body bgcolor=\"#2e3436\">"; $smt = Doo::db()->query("SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = '{$dbSchema}'"); $tables = $smt->fetchAll(); foreach ($tables as $tbl) { $tblname = $tbl["name"]; //tablename //Get table description $smt2 = Doo::db()->query("SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null,\n column_default AS default, ordinal_position AS position, character_maximum_length AS char_length,\n character_octet_length AS oct_length FROM information_schema.columns\n WHERE table_name = '{$tblname}' AND table_schema = '{$dbSchema}' ORDER BY position"); $fields = $smt2->fetchAll(); //Get primary key $smt3 = Doo::db()->query("SELECT relname, indkey\n FROM pg_class, pg_index\n WHERE pg_class.oid = pg_index.indexrelid\n AND pg_class.oid IN (\n SELECT indexrelid\n FROM pg_index, pg_class\n WHERE pg_class.relname='{$tblname}'\n AND pg_class.oid=pg_index.indrelid\n AND indisprimary = 't')"); //indkey $fields3 = $smt3->fetchAll(); $smt4 = Doo::db()->query("SELECT t.relname, a.attname, a.attnum\n FROM pg_index c\n LEFT JOIN pg_class t\n ON c.indrelid = t.oid\n LEFT JOIN pg_attribute a\n ON a.attrelid = t.oid\n AND a.attnum = ANY(indkey)\n WHERE t.relname = '{$tblname}'\n AND a.attnum = {$fields3[0]['indkey']}"); $fields4 = $smt4->fetchAll(); $pkey = $fields4[0]['attname']; //Prepare model class $classname = ''; $temptbl = $tblname; for ($i = 0; $i < strlen($temptbl); $i++) { if ($i == 0) { $classname .= strtoupper($temptbl[0]); } else { if ($temptbl[$i] == '_' || $temptbl[$i] == '-' || $temptbl[$i] == '.') { $classname .= strtoupper($temptbl[$i + 1]); $arr = str_split($temptbl); array_splice($arr, $i, 1); $temptbl = implode('', $arr); } else { $classname .= $temptbl[$i]; } } } $filestr = "<?php\nclass {$classname}{\n"; $fieldnames = array(); foreach ($fields as $f) { $filestr .= " public \${$f['name']};\n"; $fieldnames[] = $f['name']; } $fieldnames = implode($fieldnames, "','"); $filestr .= " public \$_table = '{$tblname}';\n"; $filestr .= " public \$_primarykey = '{$pkey}';\n"; $filestr .= " public \$_fields = array('{$fieldnames}');\n"; $filestr .= "}\n?>"; if ($fileManager->create($path . "{$classname}.php", $filestr, 'w+')) { echo "<span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;\"><span style=\"color:#fff;\">Model for table </span><strong><span style=\"color:#e7c118;\">{$tblname}</span></strong><span style=\"color:#fff;\"> generated. File - </span><strong><span style=\"color:#729fbe;\">{$classname}</span></strong><span style=\"color:#fff;\">.php</span></span><br/><br/>"; } else { echo "<span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;\"><span style=\"color:#f00;\">Model for table </span><strong><span style=\"color:#e7c118;\">{$tblname}</span></strong><span style=\"color:#f00;\"> could not be generated. File - </span><strong><span style=\"color:#729fbe;\">{$classname}</span></strong><span style=\"color:#f00;\">.php</span></span><br/><br/>"; } } $total = sizeof($tables); echo "<span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;color:#fff;\">Total {$total} file(s) generated.</span></body></html>"; }
/** * short hand of Doo::loadHelper() * @param string $class_name * @param bool $createObj * @return mixed If $createObj is True, it returns the created Object */ public function helper($class_name, $createObj = false) { return Doo::loadHelper($class_name, $createObj); }
public function indexKoreanpackage() { Doo::loadHelper('DooPager'); Doo::loadClass('Movie'); $mv = new Movie(); $data = $this->conf_data; $data['title'] = 'UseeTV - Korean Packet'; $data['content_view'] = 'content/new_svod.php'; if (!$this->start) { $this->start = 0; } $data['limit'] = $this->limit; $data['gdtto'] = $this->gdtto; $data['gdtform'] = $this->gdtform; $data['content_data'] = $mv->get_korean_register($_GET['userProvider'], $_REQUEST['speedyRegional'], $_REQUEST['speedySubRegional'], $this->start_date, $this->end_date, $this->start, $data['limit'], $this->ord, $this->gsearch); if ($_REQUEST['print'] == 'excel') { DooTextHelper::download_send_headers('koreanpackage_' . date("Ymd") . ".csv"); echo DooTextHelper::array2csv($data['content_data']); exit; } $data['total'] = $mv->get_total_from_query(); $data['graph'] = $mv->get_graph_korean_register($_GET['userProvider'], $_REQUEST['speedyRegional'], $_REQUEST['speedySubRegional'], $this->start_date, $this->end_date); $data['filter_action'] = 'koreanpackage'; $data['table_row_option'] = array(20, 100, 500, 1000, 10000); $data['label'] = 'KOREAN PACKAGE'; $this->view()->renderc(Doo::conf()->language . '/t3', $data); }
/** * Save the uploaded image(s) in HTTP File Upload variables * * @param string $filename The file field name in $_FILES HTTP File Upload variables * @param string $rename Rename the uploaded file (without extension) * @return string|array The file name of the uploaded image. */ public function uploadImage($filename, $rename = '') { $img = !empty($_FILES[$filename]) ? $_FILES[$filename] : null; if ($img == Null) { return; } if (!file_exists($this->uploadPath)) { Doo::loadHelper('DooFile'); $fileManager = new DooFile(0777); $fileManager->create($this->uploadPath); } if (is_array($img['name']) === False) { $pic = strrpos($img['name'], '.'); $ext = strtolower(substr($img['name'], $pic + 1)); if ($this->timeAsName) { $newName = time() . '-' . mt_rand(1000, 9999) . '.' . $ext; } else { $newName = $img['name']; } if ($rename == '') { $imgPath = $this->uploadPath . $newName; } else { $imgPath = $this->uploadPath . $rename . '.' . $ext; } if (move_uploaded_file($img['tmp_name'], $imgPath)) { return $rename == '' ? $newName : $rename . '.' . $ext; } } else { $uploadImagesPath = array(); foreach ($img['error'] as $k => $error) { if (empty($img['name'][$k])) { continue; } if ($error == UPLOAD_ERR_OK) { $pic = strrpos($img['name'][$k], '.'); $ext = strtolower(substr($img['name'][$k], $pic + 1)); if ($this->timeAsName) { $newName = time() . '-' . mt_rand(1000, 9999) . '_' . $k . '.' . $ext; } else { $newName = $img['name'][$k]; } if ($rename == '') { $imgPath = $this->uploadPath . $newName; } else { $imgPath = $this->uploadPath . $rename . '_' . $k . '.' . $ext; } if (move_uploaded_file($img['tmp_name'][$k], $imgPath)) { $uploadImagesPath[] = $newName; } } else { return false; } } return $uploadImagesPath; } }
public function modPassword() { $id = (int) $this->getUrlVar('id', 0); if ($id == 0) { $this->alert('参数错误'); return; } if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $password = $_POST['password']; $password2 = $_POST['password2']; if (!isset($password2)) { $success = false; $errors[] = '再次输入密码不能为空'; } if ($password != $password2) { $success = false; $errors[] = '两次输入的密码不一致,请检查'; } // 插入数据库(接口没有验证数据是否重复,需添加者自己注意) if ($success) { $result = $this->_user->update_pwd(1, $id, $password); if ($result != 0) { $success = false; $errors[] = '插入数据库出错,不可连续修改两次密码且不可与原密码相同'; } } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = UserController::$dataTableUrl; } else { if (isset($_POST['saveAndSee'])) { $errors = UserController::$modUrl . $id; } else { $errors = UserController::$addUrl; } } } // 处理表单位提交 $this->ajaxFormResult($success, $errors); } else { //取某用户信息 $row = $this->_user->get_one($id); // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getPasswordFormConfig(false, $row)); array_push($this->_includeJsFileList, 'js/default/user.js'); $this->contentlayoutRender('<a class="btn green-stripe" href="' . UserController::$dataTableUrl . '"><i class="icon-plus"></i>用户列表</a>' . $form->render()); } }
function setErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = null) { Doo::loadHelper('DooTextHelper'); //require if ($errno == 2 && strpos($errstr, 'require_once(') === 0 && strpos(str_replace('\\', '/', $errfile), str_replace('\\', '/', Doo::conf()->BASE_PATH) . 'Doo.php') === 0) { $dmsg = debug_backtrace(); foreach ($dmsg as $k => $a) { //if is user file, and must be a load method if (strpos(str_replace('\\', '/', $a['file']), str_replace('\\', '/', Doo::conf()->SITE_PATH)) === 0 && stripos($a['function'], 'load') === 0) { //print_r($a);exit; $errfile = $a['file']; $errline = $a['line']; break; } } } else { if ($errno == 2 && strpos(str_replace('\\', '/', $errfile), str_replace('\\', '/', Doo::conf()->BASE_PATH) . 'view/DooView.php') === 0) { $dmsg = debug_backtrace(); foreach ($dmsg as $k => $a) { if (strpos(str_replace('\\', '/', $a['file']), str_replace('\\', '/', Doo::conf()->SITE_PATH)) === 0 && stripos(str_replace('\\', '/', $a['file']), '/controller') !== false) { $errfile = $a['file']; $errline = $a['line']; if (strpos($errstr, 'file_get_contents') !== false) { $errstr = 'Template not found ' . str_replace('[<a href=\'function.file-get-contents\'>function.file-get-contents</a>]: failed to open stream: ', '', str_replace('file_get_contents', '', $errstr)); } break; } } } } if (strpos(str_replace('\\', '/', $errfile), str_replace('\\', '/', Doo::conf()->BASE_PATH)) === 0) { $dmsg = debug_backtrace(); $last = array_pop($dmsg); if (isset($last['file'])) { // $errfile = $last['file']; // $errline = $last['line']; } else { $errfile = $dmsg[0]['args'][2]; $errline = $dmsg[0]['args'][3]; } } $script = file_get_contents($errfile); $script = DooTextHelper::highlightPHP($script); $pre = ''; $Xpre = ''; if (!empty($script)) { //if template file addon the <pre> if (strpos(str_replace('\\', '/', $errfile), str_replace('\\', '/', Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER) . 'view') === 0) { $pre = '<pre>'; $Xpre = '</pre>'; } $lines = explode('<br />', $script); $errLineContent = '<div class="errorbig" onclick="javascript:viewCode();">' . $pre . $lines[$errline - 1] . $Xpre . '</div>'; //highlight the error line $lines[$errline - 1] = '<div id="eerrline" class="errline" onclick="javascript:closeCode();" title="Click to close"><a id="' . $errline . '" name="' . $errline . '"></a>' . $lines[$errline - 1] . '</div>'; //remove the code tag from 1st and last line $lines[0] = str_replace('<code>', '', $lines[0]); $lines[sizeof($lines) - 1] = str_replace('</code>', '', $lines[sizeof($lines) - 1]); } $imgloader = Doo::conf()->SUBFOLDER . 'index.php?doodiagnostic_pic='; if (ob_get_level() !== 0) { ob_clean(); } $confData = traceVar(Doo::conf()); $getData = traceVar($_GET); $postData = traceVar($_POST); if (isset($_SESSION)) { $sessionData = traceVar($_SESSION); } if (isset($_COOKIE)) { $cookieData = traceVar($_COOKIE); } echo "<html><head><title>DooPHP 诊断 - {$errstr}</title>"; echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />'; //css echo '<style> html{padding:0px;margin:0px;} body{ background-color:#62C4E1;padding:0px;margin:0px;font-family:"Consolas","Monaco","Bitstream Vera Sans Mono","Courier New",Courier,monospace; } #logo{ height:130px;width:260px;text-indent:-9999px; float:left;cursor:pointer; background:transparent url(' . $imgloader . 'logo-b2.png) no-repeat center left; } #header { min-height:130px; background:#142830 url(' . $imgloader . 'bg-footer.gif) repeat-x scroll 0 0; } #header h1, #content h2{margin:0px;letter-spacing:-1px;} #header h1{ letter-spacing:-2px;font-size:36px;color:#FFD000;padding:40px 0px 20px 10px; } #errorFile{font-family:Georgia,serif;font-weight:normal;padding:10px;} #errorLine{font-family:Georgia;font-size:18px;padding:0px;} #content{ padding:20px 20px 0px 20px; background:#62C4E1 url(' . $imgloader . 'bg-down.png) repeat-x scroll 0 0; } .errorbig, .errline{ background:#6CE26C; } .errorbig{background:#fff;border:1px solid #c0ff0e;padding:20px;margin:12px;cursor:pointer;} #eerrline{cursor:pointer;} .scriptcode{ display:none;padding:30px;border:1px solid #d9d9d9;margin:20px;padding-top:15px; background:transparent url(' . $imgloader . 'bgcode.png); } hr{color:#BDE6F2;} ol, pre{background:#fff;border:1px solid #c0ff0e;padding:20px 20px 20px 20px;margin:20px;} li{font-size:14px;line-height:20px;margin-left:30px;font-family:Georgia;} .error_backtrace{font-family:Georgia;font-size:18px;padding:0px;margin:0px;} .back{ background:#8FD5E9; color:#FFFFFF; font-size:1em; font-weight:bold; letter-spacing:2px; line-height:2; margin:0 0 20px; text-shadow:0 1px 0 #51A5C0; text-transform:uppercase; width:100%;height:30px; text-align:center; } .back a{ color:#fff;text-decoration:none; display:block; } .back a:hover{background:#4370A4;} .var a{color:#fff;text-decoration:none;display:inline;font-size:18px;} .var a:hover{background:#8FD5E9;} #panelConf,#panelGet,#panelPost,#panelSession,#panelCookie,#goVar{display:none;} </style>'; //script echo '<script> function viewCode(){ document.getElementById("scriptcode").style.display = "block"; window.location.hash = "' . $errline . '"; } function closeCode(){ window.location.hash = "#top" document.getElementById("scriptcode").style.display = "none"; } var lastcode=""; function code(n){ var arr = ["panelConf","panelGet","panelPost","panelSession","panelCookie"]; if(arr[n]==lastcode){ var onOrOff = (document.getElementById(arr[n]).style.display == "none")?"block":"none"; document.getElementById(arr[n]).style.display = onOrOff; document.getElementById("goVar").style.display = onOrOff; if(onOrOff=="none") document.getElementById("b"+arr[n]).style.backgroundColor = ""; return; }else{ document.getElementById(arr[n]).style.display = "block"; document.getElementById("goVar").style.display = "block"; document.getElementById("b"+arr[n]).style.backgroundColor = "#8FD5E9"; } if(lastcode!=""){ document.getElementById(lastcode).style.display = "none"; document.getElementById("b"+lastcode).style.backgroundColor = ""; } lastcode = arr[n]; } function goVisit(){ document.location.href="http://doophp.net/"; } </script>'; //headings echo "</head><body>"; echo '<div id="header">'; //echo "Unknown error type: [$errno] $errstr<br />\n"; echo "<span id=\"logo\" onclick=\"javascript:goVisit();\">DooPHP</span><h1>{$errstr}</h1>"; echo '</div><div id="content">'; echo "<h2 id=\"errorFile\">See file <a href=\"javascript:viewCode();\" title=\"Click to see code\">{$errfile}</a></h2><br/>"; echo "<h2 id=\"errorLine\"> + Error on line <a href=\"javascript:viewCode();\" title=\"Click to see code\">{$errline}</a></h2>"; if (isset($errLineContent)) { echo "<h3>" . $errLineContent . "</h3>"; } //error code script echo $pre . '<code id="scriptcode" class="scriptcode">'; if (isset($lines)) { echo implode('<br />', $lines); } echo '</code>' . $Xpre; echo '<br/><hr/><h2 style="background-color:#4370A4;color:#fff;width:320px;padding:5px;"> * Stack Trace...</h2>'; global $errTrace; if (!empty($errTrace)) { echo '<pre>'; echo $errTrace; echo '</pre>'; } else { errorBacktrace(); } echo '<br/><hr/><h2 class="var" style="background-color:#4370A4;color:#fff;width:760px;padding:5px;"> * Variables... <a id="bpanelConf" href="javascript:code(0);"> Conf </a> . <a id="bpanelGet" href="javascript:code(1);"> GET </a> . <a id="bpanelPost" href="javascript:code(2);"> POST </a> . <a id="bpanelSession" href="javascript:code(3);"> Session </a> . <a id="bpanelCookie" href="javascript:code(4);"> Cookie </a></h2>'; //config data echo '<pre id="goVar">'; $confData = str_replace(']=><br /> ', '] => ', DooTextHelper::highlightPHP($confData)); echo str_replace('<code>', '<code id="panelConf">', $confData); if (!empty($_GET)) { $getData = str_replace(']=><br /> ', '] => ', DooTextHelper::highlightPHP($getData)); echo str_replace('<code>', "<code id=\"panelGet\"><span style=\"color:#0000BB;\">\$_GET Variables</span>", $getData); } if (!empty($_POST)) { $postData = str_replace(']=><br /> ', '] => ', DooTextHelper::highlightPHP($postData)); echo str_replace('<code>', "<code id=\"panelPost\"><span style=\"color:#0000BB;\">\$_POST Variables</span>", $postData); } if (isset($sessionData)) { $sessionData = str_replace(']=><br /> ', '] => ', DooTextHelper::highlightPHP($sessionData)); echo str_replace('<code>', "<code id=\"panelSession\"><span style=\"color:#0000BB;\">\$_SESSION Variables</span>", $sessionData); } if (isset($_COOKIE)) { $cookieData = str_replace(']=><br /> ', '] => ', DooTextHelper::highlightPHP($cookieData)); echo str_replace('<code>', "<code id=\"panelCookie\"><span style=\"color:#0000BB;\">\$_COOKIE Variables</span>", $cookieData); } echo '</pre><br/>'; echo "</div><div class=\"back\"><a href=\"#top\">BACK TO TOP </a></div></body></html>"; exit; }
/** * Generates Model class files from a MySQL database * @param bool $comments Generate comments along with the Model class */ public static function gen_mysql($comments = true, $vrules = true) { $dbconf = Doo::db()->getDefaultDbConfig(); if (!isset($dbconf) || empty($dbconf)) { echo "<html><head><title>DooPHP Model Generator - DB: Error</title></head><body bgcolor=\"#2e3436\"><span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;\"><span style=\"color:#fff;\">Please setup the DB first in index.php and db.conf.php</span></span>"; exit; } $dbname = $dbconf[1]; echo "<html><head><title>DooPHP Model Generator - DB: {$dbname}</title></head><body bgcolor=\"#2e3436\">"; $smt = Doo::db()->query("SHOW TABLES"); $tables = $smt->fetchAll(); foreach ($tables as $tbl) { if (stristr($_SERVER['SERVER_SOFTWARE'], 'Win32')) { $tblname = $tbl['Tables_in_' . strtolower($dbname)]; } else { $tblname = $tbl['Tables_in_' . $dbname]; } $smt2 = Doo::db()->query("DESC `{$tblname}`"); $fields = $smt2->fetchAll(); //print_r($fields); $classname = ''; $temptbl = $tblname; for ($i = 0; $i < strlen($temptbl); $i++) { if ($i == 0) { $classname .= strtoupper($temptbl[0]); } else { if ($temptbl[$i] == '_' || $temptbl[$i] == '-' || $temptbl[$i] == '.') { $classname .= strtoupper($temptbl[$i + 1]); $arr = str_split($temptbl); array_splice($arr, $i, 1); $temptbl = implode('', $arr); } else { $classname .= $temptbl[$i]; } } } $filestr = "<?php\nclass {$classname}{\n"; $pkey = ''; $ftype = ''; $fieldnames = array(); if ($vrules) { Doo::loadHelper('DooValidator'); } $rules = array(); foreach ($fields as $f) { $fstring = ''; if ($comments && isset($f['Type']) && !empty($f['Type'])) { preg_match('/([^\\(]+)[\\(]?([\\d]*)?[\\)]?(.+)?/', $f['Type'], $ftype); $length = ''; $more = ''; if (isset($ftype[2]) && !empty($ftype[2])) { $length = " Max length is {$ftype['2']}."; } if (isset($ftype[3]) && !empty($ftype[3])) { $more = " {$ftype['3']}."; $ftype[3] = trim($ftype[3]); } $fstring = "\n /**\n * @var {$ftype[1]}{$length}{$more}\n */\n"; //-------- generate rules for the setupValidation() in Model ------ if ($vrules) { $rule = array(); if ($rulename = DooValidator::dbDataTypeToRules(strtolower($ftype[1]))) { $rule = array(array($rulename)); } if (isset($ftype[3]) && $ftype[3] == 'unsigned') { $rule[] = array('min', 0); } if (ctype_digit($ftype[2])) { if ($ftype[1] == 'varchar' || $ftype[1] == 'char') { $rule[] = array('maxlength', intval($ftype[2])); } else { if ($rulename == 'integer') { $rule[] = array('maxlength', intval($ftype[2])); } } } if (strtolower($f['Null']) == 'no') { $rule[] = array('notnull'); } else { $rule[] = array('optional'); } if (isset($rule[0])) { $rules[$f['Field']] = $rule; } } } $filestr .= "{$fstring} public \${$f['Field']};\n"; $fieldnames[] = $f['Field']; if ($f['Key'] == 'PRI') { $pkey = $f['Field']; } } $fieldnames = implode($fieldnames, "','"); $filestr .= "\n public \$_table = '{$tblname}';\n"; $filestr .= " public \$_primarykey = '{$pkey}';\n"; $filestr .= " public \$_fields = array('{$fieldnames}');\n"; if ($vrules && isset($rules) && !empty($rules)) { $filestr .= "\n public function getVRules() {\n return " . self::exportRules($rules) . "\n }\n\n"; $filestr .= " public function validate(\$checkMode='all'){\r\n //You do not need this if you extend DooModel or DooSmartModel\r\n //MODE: all, all_one, skip\r\n Doo::loadHelper('DooValidator');\r\n \$v = new DooValidator;\r\n \$v->checkMode = \$checkMode;\r\n return \$v->validate(get_object_vars(\$this), \$this->getVRules());\r\n }\n\n"; } $filestr .= "}\n?>"; $handle = fopen(Doo::conf()->SITE_PATH . "/protected/model/{$classname}.php", 'w+'); fwrite($handle, $filestr); fclose($handle); echo "<span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;\"><span style=\"color:#fff;\">Model for table </span><strong><span style=\"color:#e7c118;\">{$tblname}</span></strong><span style=\"color:#fff;\"> generated. File - </span><strong><span style=\"color:#729fbe;\">{$classname}</span></strong><span style=\"color:#fff;\">.php</span></span><br/><br/>"; //print_r($rules); } $total = sizeof($tables); echo "<span style=\"font-size:190%;font-family: 'Courier New', Courier, monospace;color:#fff;\">Total {$total} file(s) generated.</span></body></html>"; }
public function submitOrder() { $addRes = false; $list = $this->countPrice(); if (empty($list)) { header("Location:" . appurl('index')); exit; } // 验证数据 $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array('Exception!'); $rules = $this->_getFormRule(true); if ($errors = $v->validate($list, $rules)) { $success = false; } //验证外卖起送份数 $infoCache = DOO::cache('php')->get($this->_configKey); $info = json_decode($infoCache, true); $waimaiSum = isset($info['waimaiSum']) ? intval($info['waimaiSum']) : 1; if ($list['allSum'] < $waimaiSum) { $this->alert('外卖起送份数为:' . $info['waimaiSum'] . '份'); exit; } //检查验证 foreach ($list['data'] as $key => $value) { $this->checkCanSum($key, $value); // //验证剩余数量是否足够 // $todayBookOrder = DBproxy::getProcedure('Manage')->setDimension(2)->getTodayOKBookSum($key,0); // $yestodayBookOrder = DBproxy::getProcedure('Manage')->setDimension(2)->getTodayOKBookSum($key,1); // // var_dump($yestodayBookOrder,$todayBookOrder);die; // $todayCanSum = $todayBookOrder[0]['booksum']; // $yestodayCanSum = $yestodayBookOrder[0]['booksum']+$yestodayBookOrder[0]['peiSongSum']; // $hasBookSum = $yestodayCanSum - $todayCanSum; // if($value['sum'] > $hasBookSum){ // $this->alert($value['name'].'已经供应完毕,明天请尽早下单~');exit; // } //验证是否能预定 if (!$this->checkBook($key)) { $this->alert($value['name'] . '的售卖结束时间是:' . $value['endSaleTime']); exit; } } //#验证数据 if ($success) { //gen_orderid $orderid = DBproxy::getProcedure('Manage')->setDimension(2)->gen_orderid($_SESSION['uid']); $list['orderid'] = $orderid; if (isset($_SESSION['waimai'])) { $iswaimai = $_SESSION['waimai']; unset($_SESSION['waimai']); } else { $iswaimai = 0; } $list['waimai'] = $iswaimai; $addRes = DBproxy::getProcedure('Manage')->setDimension(2)->addOrder($list); if ($addRes == true) { $cartKey = $_SESSION['uid'] . '_cart'; $cart = DOO::cache('php')->flush($cartKey); } else { $this->alert('生成订单失败'); } } $dbres = DBproxy::getProcedure('Manage')->setDimension(2)->getMsg(); $res = array_keys($dbres); // $res[0] = 4;//4是成功 if ($res[0] == 4) { // Doo::loadControllerAt('PayController','default'); // //调用支付接口 // $pay = new PayController(); // $pay->wxJsPay($list); $_SESSION['orderinfo'] = $list; $cartKey = $_SESSION['uid'] . '_cart'; $cart = DOO::cache('php')->flush($cartKey); header("Location:" . appurl('wxpay')); } else { $this->alert($dbres, 'success', true, appurl('getMeOrder'), 2); } }
public function mod() { $id = $_GET['id']; $info = $_GET; $page_url = urldecode($_GET['page_url']); $info['page_url'] = $page_url; Doo::loadClassAt('Menu', 'default'); $menu = new menu(DBproxy::getManage()); //通过url传递id值查询数据库 if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $rules = $this->_getFormRule(); // 验证数据 if ($errors = $v->validate($_POST, $rules)) { $success = false; } //验证权限 $permission = isset($_POST['permission']) ? array_sum($_POST['permission']) : 0; if ($permission == 0) { $success = false; $errors = '请选择用户权限'; } // 插入数据库 if ($success) { $param = array('menu_name' => trim($_POST['menu_name']), 'sort_id' => $_POST['sort_id'], 'type_id' => $_POST['type_id'], 'perm_id' => $permission, 'is_show' => $_POST['is_show'], 'url' => $_POST['page_url'], 'parent_id' => $_POST['parent_id']); $res = $menu->menuEdit($id, $param); if ($res['status'] == 0) { //$id = $res['id']; } else { $success = false; $errors[] = '插入数据库出错'; } } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = MenuController::$dataTableUrl; } else { $errors = MenuController::$addUrl; } } // 处理表单位提交 $this->ajaxFormResult($success, $errors); } else { $data = $menu->getMenuTreeList(); //D($data); // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getFormConfig(false, $data, $info)); array_push($this->_includeJsFileList, 'js/default/sysMenu.js'); $this->contentlayoutRender('<a class="btn blue-stripe" href="' . MenuController::$dataTableUrl . '"><i class="icon-plus"></i>添加菜单</a>' . $form->render()); } }
private function import() { set_time_limit(0); $path = Lua::get('path'); $path = LUA_ROOT . $path . '/cache/update/'; if (!file_exists($path)) { Lua::admin_msg('错误提示', '安装目录不存在'); } // 第一步 频道数据 $file = $path . 'channel.php'; include $file; $data = $data[1]; unset($data['id']); $data['createtime'] = time(); $data['isdefault'] = 0; $channel_id = Lua::insert('lua_channel', $data); // 第二步 导入数据结构 $file = $path . 'create.php'; include $file; // 第三步 模型数据 unset($data); $file = $path . 'model.php'; include $file; $models = $data[1]; $new_models = array(); $new_tables_1 = array(); // 栏目 $new_tables_2 = array(); // 碎片 $new_tables_3 = array(); // 插件 unset($data); foreach ($models as $v) { $model_id = $v['id']; unset($v['id']); $v['createtime'] = time(); $v['cid'] = $channel_id; $lastid = Lua::insert('lua_model', $v); $new_models[$model_id] = $lastid; // 第四步 数据表数据 $file = $path . 'model.' . $model_id . '.php'; include $file; $table = $data[1]; switch ($v['mtype']) { case 1: $new_tables_1 = array_merge($new_tables_1, $table); break; case 2: $new_tables_2 = array_merge($new_tables_2, $table); break; case 3: $new_tables_3 = array_merge($new_tables_3, $table); break; } $this->__import($model_id, $lastid, $table, $path); } // 第七步 栏目数据 $file = $path . 'cate.php'; include $file; $cate = $data[1]; $this->__cate(1, $new_models, $cate, $new_tables_1); unset($data); $file = $path . 'piece.php'; include $file; $cate = $data[1]; $this->__cate(2, $new_models, $cate, $new_tables_2); Doo::loadHelper('DooFile'); $fileManager = new DooFile(0777); $fileManager->delete($path); Lua::admin_msg('信息提示', '导入成功', './channel.htm'); }
public function mod() { $id = (int) $this->getUrlVar('id'); $res = DBproxy::getProcedure('Manage')->setDimension(2)->getBook(array('id' => $id), '1'); if (empty($res)) { $this->alert('data null'); } if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $rules = $this->_getFormRule(); // 验证数据 if ($errors = $v->validate($_POST, $rules)) { $success = false; } //数据处理 if ($success) { //图片处理 $img = ''; Doo::loadClassAt('Picupload', 'default'); $Picupload = new Picupload(); $imgRes = $Picupload->upload('img'); if ($imgRes) { $img = $Picupload::$picinfo['dirname'] . '/' . $Picupload::$picinfo['basename']; } else { $img = trim($_POST['img']); } //数据处理 $param['categoryid'] = intval($_POST['categoryid']); $param['name'] = trim($_POST['name']); $param['sort'] = intval($_POST['sort']); $param['status'] = intval($_POST['status']); $param['la'] = trim($_POST['la']); $param['descript'] = trim($_POST['descript']); $param['img'] = $img; $param['price'] = trim($_POST['price']); $param['wxprice'] = trim($_POST['wxprice']); $param['peiSongSum'] = intval($_POST['peiSongSum']); $res = DBproxy::getProcedure('Manage')->setDimension(2)->bookIU('u', $param, $id); if ($res['status'] != 0) { $success = false; $errors[] = 'DB异常!'; } } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = BookController::$dataTableUrl; } else { $errors = BookController::$addUrl; } } // 处理表单位提交 $this->ajaxFormResult($success, $errors); } else { // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getFormConfig(false, $res['data'][0])); $btn = '<a class="btn green-stripe" href="' . BookController::$dataTableUrl . '"><i class="icon-backward"> </i>' . L('列表') . '</a>'; // 显示模版 $this->contentlayoutRender($btn . $form->render()); } }
public function userList() { Doo::loadHelper('DooTextHelper'); $data = $this->conf_data; Doo::loadClass('UserSession'); $usession = new UserSession(); $username = $usession->uget('username'); if (isset($_POST['table_row'])) { $usession->uset('table_row_option', $_POST['table_row']); } $rows_data = $usession->uget('table_row_option'); if (!$username) { header('Location:' . DOO::conf()->SUBFOLDER . 'login'); } $dbapi = $this->dbapi; $data['limit'] = 20; if ($rows_data) { $data['limit'] = $rows_data; } $gpage = $_GET['page'] - 1; if ($_REQUEST['print'] == 'excel') { set_time_limit(0); ini_set('memory_limit', '512M'); $data['limit'] = 99999999; unset($gpage); } $gord = $_GET['ord']; $gsearch = addslashes($_POST['search']); $gdtform = addslashes($_GET['dtform']); $gdtto = addslashes($_GET['dtto']); if (!$gdtform) { $gdtform = date("m/d/Y", strtotime("-1 month")); } if (!$gdtto) { $gdtto = date("m/d/Y"); } $data['gdtto'] = $gdtto; $data['gdtform'] = $gdtform; $start = 0; $ord = ''; $qsearch = ''; $qutype = ''; $qfilter = ''; $qSpeedyReginal = $qSubregional = ''; $ordby = "ASC"; if ($username == 'dcs_timur') { $_GET['userProvider'] = 1; if (!$_REQUEST['speedyRegional']) { $_REQUEST['speedyRegional'] = "14;15;16;17"; } } if ($username == 'dcs_barat') { $_GET['userProvider'] = 1; if (!$_REQUEST['speedyRegional']) { $_REQUEST['speedyRegional'] = "11;12;13"; } } if ($username == 'telkomsel') { $_GET['userProvider'] = 2; } if ($_REQUEST['speedyRegional']) { $tempSpeedyReg = explode(';', $_REQUEST['speedyRegional']); $impSpeedyReg = implode("','", $tempSpeedyReg); $qSpeedyReginal = " AND left( ota.bill_account,2) in ('{$impSpeedyReg}') "; if ($_REQUEST['speedySubRegional']) { $qSpeedyReginal = " AND left( ota.bill_account,5) in ('{$_REQUEST['speedySubRegional']}') "; } } if ($_GET['ascd'] == '0') { $ordby = "DESC"; } switch ($gord) { case 'name': $ord = 'subscriber_name '; break; case 'email': $ord = 'user_id '; break; case 'created': $ord = 'create_time '; break; case 'status': $ord = 'status '; break; default: $ord = 'create_time '; $ordby = "DESC"; break; } if ($ord) { $ord .= $ordby; } if ($_GET['userProvider']) { $qutype = " AND type = '" . (int) $_GET['userProvider'] . "'"; } if (isset($gpage) && $gpage >= 0) { $start = $gpage * $data['limit']; } if ($gsearch) { $qsearch = " AND ( subscriber_name LIKE '%{$gsearch}%' OR user_id LIKE '%{$gsearch}%' or email like '%{$gsearch}%') "; } if ($gdtform && $gdtto) { $start_date = $gdtform = date("Y-m-d H:i:s", strtotime($gdtform)); $end_date = $gdtto = date("Y-m-d", strtotime($gdtto)) . " 23:59:59"; $qfilter = " AND create_time >= '{$gdtform}' AND create_time <= '{$gdtto}' "; if ($gdtform == $gdtto) { $qfilter = " AND create_time like '" . date("Y-m-d", strtotime($gdtto)) . "%' "; } } else { $qfilter = " AND create_time > '2012-08-31' "; } $qwhere = "1=1 {$qsearch} {$qfilter} {$qutype} {$qSpeedyReginal}"; if ($qSpeedyReginal) { $dbapi->join_table = "LEFT JOIN ott_business_account ota ON (ics.id=ota.subscriber_id)"; } $data['content_data'] = $dbapi->get_user('ics.id, customer_id, user_id, type, create_time,update_time,subscriber_name, ics.bill_account_type, ics.bill_account, ics.home_phone, email', $qwhere, $start, $data['limit'], $ord); $data['total'] = $dbapi->get_total_from_query(); if ($_REQUEST['print'] == 'excel') { DooTextHelper::download_send_headers('users_' . date("Ymd") . ".csv"); echo DooTextHelper::array2csv($data['content_data']); exit; } if (!$start_date) { $start_date = date("Y-m-d", strtotime("-1 month")); } if (!$end_date) { $end_date = date("Y-m-d"); } $data['graph'] = $dbapi->get_graph_register($_GET['userProvider'], $_REQUEST['speedyRegional'], $_REQUEST['speedySubRegional'], $start_date, $end_date); $data['username'] = $username; $data['dbapi'] = $this->dbapi; $data['subregion'] = $this->subregion; $data['filter_action'] = 'user/list'; $data['content_view'] = 'content/list_user.php'; $data['table_row_option'] = array(20, 100, 500, 1000, 10000); $this->view()->renderc(Doo::conf()->language . '/t3', $data); }
/** * Write to file. * If rotate file size is set, logs and profiles are automatically rotate when the file size is reached. * @param string $data Data string to be logged * @param string $filename File name for the log/profile */ protected function writeToFile($data, $filename) { //aising 20151020 logpath addpend category $subPath = ''; if (isset($this->_logs[0][2])) { $subPath = $this->_logs[0][2]; } $filename = $subPath . DIRECTORY_SEPARATOR . $filename; //only write to file if there's a record if ($data != NULL) { $mode = 'a+'; if (isset(Doo::conf()->LOG_PATH)) { $filename = Doo::conf()->LOG_PATH . $filename; } if ($this->rotate_size != 0) { if (file_exists($filename) && filesize($filename) > $this->rotate_size) { $mode = 'w+'; } } Doo::loadHelper('DooFile'); $file = new DooFile(0777); $file->create($filename, $data, $mode); } }
/** * Validate form * * @var array Values for form, for example $_POST * * @return boolean True or false if form is not valid */ public function isValid($values) { $valid = true; $errors = array(); try { Doo::loadHelper('DooValidator'); $v = new DooValidator(); } catch (DooFormException $e) { echo 'Validator class coulndt be loaded ' . $e->getMessage() . '\\n'; } $formElements = $this->_formElements; $elementValues = array(); foreach ($this->_elements as $element => $e) { // handle values if (isset($values[$element])) { $elementValues[$element] = $values[$element]; } // handle validators if (isset($e[1]['validators'])) { if (!isset($e[1]['required']) || $e[1]['required'] != false) { $elementRules = array($element => $e[1]['validators']); $errors[$element] = $v->validate($values, $elementRules); if ($errors[$element]) { unset($elementValues[$element]); } } else { if (isset($elementValues[$element]) && $elementValues[$element] != "") { $elementRules = array($element => $e[1]['validators']); $errors[$element] = $v->validate($values, $elementRules); } } } // handle captcha if (isset($e[0]) && $e[0] == 'captcha') { $sessionData = isset($_SESSION['doo_captcha_' . $element]) ? md5($_SESSION['doo_captcha_' . $element]) : ''; $msg = isset($e[1]['message']) ? $e[1]['message'] : null; $elementRules = array($element => array('equal', $sessionData, $msg)); $values[$element] = md5($values[$element]); $errors[$element] = $v->validate($values, $elementRules); if ($errors[$element]) { unset($elementValues[$element]); } // delete captcha if captcha is good if (isset($e[1]['url']) && file_exists($e[1]['directory'] . '/' . $sessionData . ".jpg")) { unlink($e[1]['directory'] . '/' . $sessionData . ".jpg"); } } // handle file if (isset($e[0]) && $e[0] == 'file') { // if there is file check if file exists if (isset($_FILES[$element])) { // check file extension if (isset($e[1]['extension'])) { $extensions = array(); $extension = substr($_FILES[$element]['name'], strrpos($_FILES[$element]['name'], '.') + 1); $extensions = explode(',', $e[1]['extension']); if (!in_array($extension, $extensions)) { $errors[$element] = array('File must have ' . $e[1]['extension'] . ' extension.'); } } // check file size if (isset($e[1]['size'])) { if ($e[1]['size'] < $_FILES[$element]['size']) { $errors[$element] = array('File is too big!'); } } } else { if (isset($e[1]['required']) && $e[1]['required'] == 1) { $errors[$element][] = array('File for upload is required.'); } } } } // set values $this->_elementValues = $elementValues; if (count($errors) > 0) { $this->_errors = $errors; foreach ($errors as $error => $e) { if (!empty($e)) { $valid = false; } } } return $valid; }
/** * Write to file. * If rotate file size is set, logs and profiles are automatically rotate when the file size is reached. * @param string $data Data string to be logged * @param string $filename File name for the log/profile */ protected function writeToFile($data, $filename) { //only write to file if there's a record if ($data != NULL) { $mode = 'a+'; if (isset(Doo::conf()->LOG_PATH)) { $filename = Doo::conf()->LOG_PATH . $filename; } if ($this->rotate_size != 0) { if (file_exists($filename) && filesize($filename) > $this->rotate_size) { $mode = 'w+'; } } Doo::loadHelper('DooFile'); $file = new DooFile(0777); $file->create($filename, $data, $mode); } }
/** * Parse and compile the template file. Templates generated in protected/viewc folder * @param string $file Template file name without extension .html * @param string $vfilename Full path of the template file * @param string $cfilename Full path of the compiled file to be saved */ protected function compile($file, $vfilename, $cfilename) { $this->mainRenderFolder = $file; //--------------------------- Parsing ----------------------------- //if no compiled file exist or compiled file is older, generate new one $str = $this->compileTags(file_get_contents($vfilename)); Doo::loadHelper('DooFile'); $fileManager = new DooFile(0777); $fileManager->create($cfilename, $str, 'w+'); }
public function mod() { $id = (int) $this->getUrlVar('id'); $param['id'] = intval($id); $res = DBproxy::getProcedure('Manage')->setDimension(2)->getPeiSongList($param); if (empty($res)) { $this->alert('data error'); die; } if ($this->isAjax() && $_POST) { $v = Doo::loadHelper('DooValidator', true); $success = true; $errors = array(); $rules = $this->_getFormRule(); // 验证数据 if ($errors = $v->validate($_POST, $rules)) { $success = false; } //数据处理 $param['cityid'] = intval($_POST['city']); $param['shopname'] = trim($_POST['shopname']); $param['shopNamePhone'] = make_semiangle(trim($_POST['shopNamePhone'])); $param['peisongPhone'] = make_semiangle(trim($_POST['peisongPhone'])); $list = DBproxy::getProcedure('Manage')->setDimension(2)->getPeiSongIU('u', $param, $param['id']); if ($list['status'] != 0) { $success = false; $errors[] = L('添加失败!DB异常!'); } // 处理返回路径 if ($success) { if (isset($_POST['saveAndReutrn'])) { $errors = PeiSongController::$dataTableUrl; } else { $errors = PeiSongController::$addUrl; } } // 处理表单位提交 $this->ajaxFormResult($success, $errors); } else { // 显示生成表单 Doo::loadClassAt('html/DooFormExt', 'default'); $form = new DooFormExt($this->_getFormConfig(false, $res[0])); $btn = '<a class="btn green-stripe" href="' . PeiSongController::$dataTableUrl . '"><i class="icon-backward"> </i>' . L('列表') . '</a>'; // 显示模版 $this->contentlayoutRender($btn . $form->render()); } }