当前位置: 首页>>代码示例>>PHP>>正文


PHP Tool类代码示例

本文整理汇总了PHP中Tool的典型用法代码示例。如果您正苦于以下问题:PHP Tool类的具体用法?PHP Tool怎么用?PHP Tool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: approve

 function approve($id)
 {
     if ($_POST) {
         $rs = new Tool($id);
         $rs->from_array($_POST);
         $rs->save();
     }
 }
开发者ID:unisexx,项目名称:imac,代码行数:8,代码来源:tools.php

示例2: __construct

 public function __construct($request_path, $request_params, $request_method, $return_type)
 {
     $function = array('class_name' => __NAMESPACE__, 'method_name' => __METHOD__);
     //validating the return type and set default if not found
     if (array_contains($return_type, Constants::get('allowed_return_types') == false)) {
         $return_type = Constants::get('default_return_type');
     } else {
         $this->return_type = set_default($return_type, Constants::get('allowed_return_types'));
     }
     //validate if request path is valid else throw error
     if (is_ready($request_path) == false) {
         $error = Tool::prepare('Request path is invalid, unable to process routing request.', 'Request path is null, verify that index router has parsed the information correctly.', __LINE__, $this->return_type, Constants::get('default_error_code'));
         Tool::error($function, $error, false);
     } else {
         enforce_inputs(array($request_path, 'array', null, null, false), $this->return_type);
         $this->original_path = $request_path;
         $this->request_path = $request_path;
     }
     //validate if request method is valid, else set as default (post takes precendence if both are used)
     $this->request_method = set_default($request_method, Constants::get('default_http_method'));
     $allowed_http_methods = Constants::get('allowed_http_methods');
     if (array_contains($request_method, $allowed_http_methods, false) == false) {
         $request_method = Constants::get('default_http_method');
     }
     $this->request_method = strtolower($request_method);
     //add post params to class if exist
     $this->request_params = $request_params;
     //normalise request_path
     if (is_ready(end($this->request_path)) == false) {
         array_pop($this->request_path);
     }
 }
开发者ID:kennho,项目名称:router,代码行数:32,代码来源:route.php

示例3: upload

 public function upload()
 {
     if (isset($_FILES['userfile']['tmp_name'])) {
         switch ($_POST['type']) {
             case 'face':
                 $width = 99;
                 $height = 100;
                 $info = '头像上传成功';
                 break;
             case 'ok':
                 $width = 300;
                 $height = 300;
                 $info = '图片上传成功';
                 break;
             case 'rotator':
                 $width = 1200;
                 $height = 530;
                 $info = '轮播器图片上传成功';
                 break;
             default:
                 exit('非法操作');
         }
         $upload = new UploadFile('userfile', $_POST['MAX_FILE_SIZE']);
         $path = $upload->getPath();
         $thumb = new Image($path);
         $thumb->thumb($width, $height);
         $thumb->outImage();
         $upload->alertThumbClose($info, $path);
     } else {
         Tool::alertBack('警告:未知错误');
     }
 }
开发者ID:zhendeguoke1008,项目名称:shop-1,代码行数:32,代码来源:CallAction.class.php

示例4: start

 /**
  * 应用程序初始化
  */
 public static function start()
 {
     // 加载默认配置
     C(include CONF_PATH . '/convention.php');
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 环境变量
     putenv('LC_ALL=C');
     putenv('LANG="zh_CN.UTF-8"');
     spl_autoload_register(array('M3d', 'autoload'));
     require_array(array(LIB_PATH . '/Core/Dispatcher.class.php', LIB_PATH . '/Core/Model.class.php', LIB_PATH . '/Core/Action.class.php', LIB_PATH . '/Core/View.class.php', LIB_PATH . '/Core/Tool.class.php', LIB_PATH . '/Core/Plugin.class.php'));
     define('REQUEST_METHOD', strtolower($_SERVER['REQUEST_METHOD']));
     define('IS_GET', REQUEST_METHOD === 'get');
     define('IS_POST', REQUEST_METHOD === 'post');
     define('IS_PUT', REQUEST_METHOD === 'put');
     define('IS_DELETE', REQUEST_METHOD === 'delete');
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
     Tool::start();
     Plugin::start();
     // 加载全局配置
     C(include C('M3D_CONF_PATH') . '/config.php');
     // 加载project配置
     C(include PROJECT_PATH . '/conf/config.php');
     Dispatcher::dispatch();
     self::exec();
 }
开发者ID:chenyongze,项目名称:m3d,代码行数:28,代码来源:M3d.class.php

示例5: configureData

 public function configureData()
 {
     // Look if this login exists
     $rs = DB::select('
         SELECT `id`
         FROM `user`
         WHERE `login`="' . $_POST['login'] . '" AND `valided`=1
     ');
     // If this user is not already registered
     // TODO : check if the email is not allready taken
     if ($rs['total'] == 0) {
         // Encrypte password
         $key = md5(rand(0, 1000) + microtime());
         // Insert user's infos in the base
         $id = DB::insert('INSERT INTO `user` (`login`, `zip`, `male`, `email`, `password`, `key`, `register_date`) VALUES
         (
             "' . $_POST['login'] . '",
             "' . $_POST['zip'] . '",
             "' . $_POST['gender'] . '",
             "' . $_POST['email'] . '",
             "' . md5($_POST['password']) . '",
             "' . $key . '",
             "' . time() . '"
         )');
         $subject = 'Bienvenue sur Opipop - confirmation de votre enregistrement';
         $message = 'Clicked ici pour activer votre compte : ' . Conf::get('ROOT_PATH') . $_POST['login'] . '/confirm?u=' . $id . '&k=' . $key;
         Tool::sendMail(Conf::get('SITE_NAME'), Conf::get('ADMIN_EMAIL'), $_POST['email'], $subject, $message);
     }
 }
开发者ID:xpac27,项目名称:Opipop,代码行数:29,代码来源:Submit.php

示例6: Action

 public function Action()
 {
     switch ($_GET['action']) {
         case 'login':
             if (isset($_POST['send'])) {
                 if (!Validate::Check_Length($_POST['code'], 4, 'equals')) {
                     Tool::alertBack('验证码必须为四位');
                 }
                 if (!Validate::Check_Equals($_POST['code'], strtolower($_SESSION['code']))) {
                     Tool::alertBack('验证码不正确');
                 }
                 $object = $this->model->Manage_Login();
                 if (!Validate::Check_Null($object)) {
                     $_SESSION['admin']['username'] = $object->username;
                     //生成session
                     $_SESSION['admin']['level_position'] = $object->level_position;
                     $this->model->Login_Count();
                     Tool::alertLocation(null, 'admin.php');
                 } else {
                     Tool::alertBack('用户名或者密码错误,请重新输入');
                 }
             }
             break;
         case 'logout':
             if (session_start()) {
                 session_destroy();
             }
             Tool::alertLocation(null, 'admin_login.php');
             break;
     }
 }
开发者ID:hachi-zzq,项目名称:guest-cms,代码行数:31,代码来源:LoginAction.class.php

示例7: configure

 public function configure()
 {
     // Init category
     $category = new Model_Category(Conf::get('MAIN_CATEGORY'));
     if ($category->getQuestionsTotal(true, true) == 0) {
         return;
     }
     // Get questions
     $questions = $category->getQuestions('latest', $this->page, true, true);
     if ($category->getQuestionsTotal(true, true) <= ($this->page + 1) * Conf::get('QUESTION_PER_PAGE')) {
         header('X-JSON: (Question.setEndReached())');
     }
     $colors = Conf::get('GRAPH_COLORS');
     // Loop through all questions
     foreach ($questions as $key => $question) {
         // Get question's answers
         $answers = $question->getAnswers();
         $data = array();
         foreach (array_reverse($answers) as $key => $answer) {
             $data[] = array('value' => $answer->getPercentResultsMatching() / 100, 'color' => $colors[$key]);
         }
         // Assign question infos
         Globals::$tpl->assignLoopVar('question_archive', array('id' => $question->getId(), 'label' => $question->getLabel(), 'guid' => Tool::makeGuid($question->getLabel()), 'data' => json_encode($data), 'time' => Tool::timeWarp($question->getEndDate())));
         // Assign answers infos
         foreach ($answers as $key => $answer) {
             Globals::$tpl->assignLoopVar('question_archive.answer', array('percentFormated' => round($answer->getPercentResultsMatching()), 'label' => $answer->getLabel(), 'key' => $key));
         }
     }
 }
开发者ID:xpac27,项目名称:Opipop,代码行数:29,代码来源:Archive.php

示例8: actionEdit

 /**
  * 编辑
  */
 public function actionEdit($id)
 {
     $model = parent::_model(new Article(), $id);
     $addonarticle = parent::_model(new Addonarticle(), $id);
     if (isset($_POST['Article'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $model->attributes = $_POST['Article'];
             if (!$model->save()) {
                 Tool::logger('article', var_export($model->getErrors(), true));
                 throw new CException('文章更新失败');
             }
             $addonarticle->attributes = $_POST['Addonarticle'];
             if (!$addonarticle->save()) {
                 Tool::logger('article', var_export($addonarticle->getErrors(), true));
                 throw new CException('文章附表更新失败');
             }
             $this->redirect(array('list'));
         } catch (Exception $e) {
             Tool::logger('article', $e->getMessage());
             $transaction->rollback();
         }
     }
     $this->render('edit', array('model' => $model, 'addonarticle' => $addonarticle));
 }
开发者ID:njz817,项目名称:ycms,代码行数:28,代码来源:ArticleController.php

示例9: getValueByKey

 public static function getValueByKey($key, $valueType = _STRING)
 {
     $config = "";
     try {
         if (empty($key)) {
             throw new Exception("参数异常!");
             Tool::logger(__METHOD__, __LINE__, "参数异常!");
         }
         if (empty(self::$configs)) {
             self::$configs = Tool::readConfig();
         }
         if (isset(self::$configs[$key])) {
             $config = self::$configs[$key];
             if ($valueType === _BOOL) {
                 //bool类型
                 $config = $config == TRUE;
             } else {
                 if ($valueType === _INT) {
                     //int类型
                     if (is_numeric($config)) {
                         $config = intval($config);
                     } else {
                         $config = -1;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         Tool::logger(__METHOD__, __LINE__, sprintf("读取配置文件失败: %s", $e->getMessage()));
     }
     return $config;
 }
开发者ID:BassYang1,项目名称:YueXinChina,代码行数:32,代码来源:Config.php

示例10: index

 public function index()
 {
     $_cookie = new Cookie('user');
     $_user = $_cookie->getCookie();
     $_cookie = new Cookie('face');
     $_face = $_cookie->getCookie();
     if ($_user && $_face) {
         $_member .= '<h2>会员信息</h2>';
         $_member .= '<div class="a">您好,<strong>' . Tool::subStr($_user, null, 8, 'utf-8') . '</strong> 欢迎光临</div>';
         $_member .= '<div class="b">';
         $_member .= '<img src="images/' . $_face . '" alt="' . $_user . '" />';
         $_member .= '<a href="###">个人中心</a>';
         $_member .= '<a href="###">我的评论</a>';
         $_member .= '<a href="register.php?action=logout">退出登录</a>';
         $_member .= '</div>';
     } else {
         $_member .= '<h2>会员登录</h2>';
         $_member .= '<form method="post" name="login" action="register.php?action=login">';
         $_member .= '<label>用户名:<input type="text" name="user" class="text" /></label>';
         $_member .= '<label>密 码:<input type="password" name="pass" class="text" /></label>';
         $_member .= '<label class="yzm">验证码:<input type="text" name="code" class="text code" /> <img src="config/code.php" onclick=javascript:this.src="config/code.php?tm="+Math.random(); class="code" /></label>';
         $_member .= '<p><input type="submit" name="send" value="登录" onclick="return checkLogin();" class="submit" /> <a href="register.php?action=reg">注册会员</a> <a href="###">忘记密码?</a></p>';
         $_member .= '</form>';
     }
     echo "function getIndexLogin() {\n\t\t\t\tdocument.write('{$_member}');\n\t\t\t  }";
 }
开发者ID:echo-tang,项目名称:XMFreamwork,代码行数:26,代码来源:Cache.class.php

示例11: error

 public function error($_info)
 {
     $this->_controll->assign('message', $_info);
     $this->_controll->assign('prev', Tool::getPrevPage());
     $this->_controll->display(SMARTY_ADMIN . 'public/error.html');
     exit;
 }
开发者ID:156248605,项目名称:cishop,代码行数:7,代码来源:Redirect.class.php

示例12: configure

 public function configure()
 {
     // Get answers
     $answers = $this->question->getAnswers();
     $colors = Conf::get('GRAPH_COLORS');
     $dataWomen = array();
     $dataMen = array();
     // Percent MALE
     foreach (array_reverse($answers) as $key => $answer) {
         $dataMen[] = array('value' => Tool::percent($answer->getTotalMale(), $this->question->getTotalMale()) / 100 * 0.95 + 0.05, 'color' => $colors[$key]);
     }
     foreach ($answers as $key => $answer) {
         Globals::$tpl->assignLoopVar('question_men', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format(Tool::percent($answer->getTotalMale(), $this->question->getTotalMale()), 1, ',', ' ')));
     }
     // Percent FEMALE
     foreach (array_reverse($answers) as $key => $answer) {
         $dataWomen[] = array('value' => Tool::percent($answer->getTotalFemale(), $this->question->getTotalFemale()) / 100 * 0.95 + 0.05, 'color' => $colors[$key]);
     }
     foreach ($answers as $key => $answer) {
         Globals::$tpl->assignLoopVar('question_women', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format(Tool::percent($answer->getTotalFemale(), $this->question->getTotalFemale()), 1, ',', ' ')));
     }
     Globals::$tpl->assignVar('question_men_data', json_encode($dataMen));
     Globals::$tpl->assignVar('question_women_data', json_encode($dataWomen));
     Globals::$tpl->assignVar('question_label', $this->question->getLabel());
 }
开发者ID:Hiswe,项目名称:Opipop,代码行数:25,代码来源:Gender.php

示例13: ifConnect

 /**
  * Verifier si l'utilisateur est connecté
  * @param array liste des rôles
  */
 public static function ifConnect($rolesAuth = array(), $url = null)
 {
     /* Vérifier si l'utilisateur est connecté */
     if (!isset($_SESSION['utilisateur']['id']) || empty($_SESSION['utilisateur']['id'])) {
         /* Afficher une erreur 403 navigateur */
         if (is_null($url)) {
             header('HTTP/1.0 403 Forbidden');
         } else {
             /* Rediréction + message d'erreur */
             header('location:' . $url);
             Tool::setFlash('Vous devez être connecté pour utiliser cette page', 'erreur');
         }
         /* Fin du script */
         die;
     } else {
         /* si l'utilisateur est connecté, verifier le rôle */
         if (!empty($roles)) {
             if (!in_array($_SESSION['role']['id'], $rolesAuth)) {
                 /* Afficher une erreur 403 navigateur */
                 header('HTTP/1.0 403 Forbidden');
                 die;
             }
         }
     }
 }
开发者ID:kiou,项目名称:DevKit2016,代码行数:29,代码来源:Utilisateur.php

示例14: index

 public function index()
 {
     $_cookie = new Cookie('user');
     $_user = $_cookie->getCookie();
     $_cookie = new Cookie('face');
     $_face = $_cookie->getCookie();
     if ($_user && $_face) {
         $_member .= '<h2>Member Info</h2>';
         $_member .= '<div class="a">Hello, Welcome <strong>' . Tool::subStr($_user, null, 8, null) . '</strong></div>';
         $_member .= '<div class="b">';
         $_member .= '<img src="image/' . $_face . '" />';
         $_member .= '<a href="###">Personal</a>';
         $_member .= '<a href="###">My Comment</a>';
         $_member .= '<a href="register.php?action=logout">Logout</a>';
         $_member .= '</div>';
     } else {
         $_member .= '<h2>Member Login</h2>';
         $_member .= '<form method="post" name="login" action="register.php?action=login">';
         $_member .= '<label>Username: <input type="text" name="user" class="text" /></label>';
         $_member .= '<label>Password: <input type="password" name="pass" class="text" /></label>';
         $_member .= '<label class="yzm">Validation: <input type="text" name="code" class="text code" /><img src="config/code.php" onclick=javascript:this.src="config/code.php?tm="+Math.random(); class="code" /></label>';
         $_member .= '<p><input type="submit" name="send" value="login" class="submit" /><a href="register.php?action=reg">Register</a><a href="###">Forgot Password?</a></p>';
         $_member .= '</form>';
     }
     echo "function getIndexLogin() {document.write('{$_member}');}";
 }
开发者ID:e0zhao02,项目名称:sample_code,代码行数:26,代码来源:Cache.class.php

示例15: configureData

 public function configureData()
 {
     if (!Tool::isOk($_POST['id']) || !($user = Model_User::getLoggedUser()) || $user->getId() != $_POST['id'] || !Tool::isOk($_POST['zip']) || !isset($_POST['gender']) || !Tool::isOk($_POST['login'])) {
         header('Location: ' . Conf::get('ROOT_PATH'));
         exit;
     }
     DB::update('UPDATE `user` SET
         `zip`="' . $_POST['zip'] . '",
         `male`="' . $_POST['gender'] . '"
         WHERE `id`="' . $_POST['id'] . '"');
     if (isset($_FILES) && isset($_FILES['avatar']) && $_FILES['avatar']['error'] != 4) {
         $size = filesize($_FILES['avatar']['tmp_name']);
         $stat = stat($_FILES['avatar']['tmp_name']);
         if ($size[0] <= 1680 && $size[1] <= 1680 && $stat['size'] <= 450 * 1024) {
             $extention = strtolower(preg_replace('#.+\\.([a-zA-Z]+)$#isU', '$1', $_FILES['avatar']['name']));
             $original = Conf::get('MEDIA_DIR') . 'avatar/original/' . $_POST['id'] . '.' . $extention;
             move_uploaded_file($_FILES['avatar']['tmp_name'], $original);
             $sizeSmall = explode('x', Conf::get('AVATAR_SMALL_SIZE'));
             $sizeMedium = explode('x', Conf::get('AVATAR_MEDIUM_SIZE'));
             $sizeLarge = explode('x', Conf::get('AVATAR_LARGE_SIZE'));
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_LARGE_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeLarge[0], isset($sizeLarge[1]) ? $sizeLarge[1] : false, true);
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_MEDIUM_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeMedium[0], isset($sizeMedium[1]) ? $sizeMedium[1] : false, true);
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_SMALL_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeSmall[0], isset($sizeSmall[1]) ? $sizeSmall[1] : false, true);
         }
     }
     $_SESSION['feedback'] = 'Your informations has been updated';
     header('Location: ' . Conf::get('ROOT_PATH') . $_POST['login']);
 }
开发者ID:Hiswe,项目名称:Opipop,代码行数:28,代码来源:submit.php


注:本文中的Tool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。