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


PHP system::registerEvent方法代码示例

本文整理汇总了PHP中system::registerEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP system::registerEvent方法的具体用法?PHP system::registerEvent怎么用?PHP system::registerEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system的用法示例。


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

示例1: writePost

 public static function writePost($post)
 {
     if (self::postExist("slug", $post["slug"])) {
         system::registerEvent("error", "slug", "Такой адрес поста уже занят", "URL");
     }
     if (!self::checkPostErrors($post)) {
         return false;
     }
     $post["author"] = $_SESSION["user"]["nick"];
     $post["userID"] = $_SESSION["user"]["userID"];
     $content = array();
     foreach ($post as $k => $v) {
         $v = self::$db->escapeString($v);
         $content[$k] = "`{$k}`='{$v}'";
     }
     $content['dt'] = "`dt`='" . date("Y-m-d") . "'";
     $new_picture_name = time();
     file_put_contents(ROOT_PATH . "/content/videoPreview/" . $new_picture_name . '.jpg', file_get_contents($post['pictures']));
     $content['pictures'] = "`pictures`='" . $new_picture_name . ".jpg" . "'";
     unset($content['savePost'], $content['url']);
     //        echo "INSERT INTO `content` SET ".implode (", ", $content);
     //        echo '<pre>'.print_r($post,1).'</pre>';
     //        exit;
     self::$db->query("INSERT INTO `video` SET " . implode(", ", $content));
     $id = self::$db->insert_id();
     self::$smarty->clearCache(null, "MAINPAGE|offset_0");
     self::$smarty->clearCache(null, "mainpage|offset_0");
     self::$smarty->clearCache(null, "MODULE_VIDEO");
     self::$smarty->clearCache(null, "SEARCH_RES");
     self::$smarty->clearCache(null, "RSS");
     return 'test';
 }
开发者ID:ygres,项目名称:sblog,代码行数:32,代码来源:model.video.php

示例2: writePost

 public static function writePost($post)
 {
     if (self::postExist("slug", $post["slug"])) {
         system::registerEvent("error", "slug", "Такой адрес поста уже занят", "URL");
     }
     if (!self::checkPostErrors($post)) {
         return false;
     }
     unset($post['savePost']);
     $post["author"] = $_SESSION["user"]["nick"];
     $post["userID"] = $_SESSION["user"]["userID"];
     $content = array();
     foreach ($post as $k => $v) {
         $v = self::$db->escapeString($v);
         $content[$k] = "`{$k}`='{$v}'";
     }
     $content['dt'] = "`dt`='" . date("Y-m-d") . "'";
     self::$db->query("INSERT INTO `photo` SET " . implode(", ", $content));
     $id = self::$db->insert_id();
     self::$smarty->clearCache(null, "MAINPAGE|offset_0");
     self::$smarty->clearCache(null, "mainpage|offset_0");
     self::$smarty->clearCache(null, "MODULE_PHOTO");
     self::$smarty->clearCache(null, "SEARCH_RES");
     self::$smarty->clearCache(null, "RSS");
     return $id;
 }
开发者ID:ygres,项目名称:sblog,代码行数:26,代码来源:model.photo.php

示例3: writePost

 public static function writePost($post, $type = "blog")
 {
     if (self::postExist("slug", $post["slug"])) {
         system::registerEvent("error", "slug", "Такой адрес поста уже занят", "URL");
     }
     if (!self::checkPostErrors($post)) {
         return false;
     }
     unset($post["savePost"]);
     $post["author"] = $_SESSION["user"]["nick"];
     $post["userID"] = $_SESSION["user"]["userID"];
     $post["type"] = $type;
     if (isset($post["catName"])) {
         if (!empty($post["catName"])) {
             self::addNewCat();
         }
         unset($post["catName"]);
         unset($post["catSlug"]);
     }
     $cats = array();
     if (isset($post["categories"])) {
         $cats = $post["categories"];
         unset($post["categories"]);
     }
     $content = array();
     foreach ($post as $k => $v) {
         $v = self::$db->escapeString($v);
         switch ($k) {
             case "dt":
                 $v = "STR_TO_DATE ('{$v}', '%d-%m-%Y')";
                 break;
             case "short":
             case "body":
                 $v = "'" . str_replace("\n", "<br />", $v) . "'";
                 break;
             default:
                 if (!is_numeric($v)) {
                     $v = "'{$v}'";
                 }
         }
         $content[$k] = "`{$k}`={$v}";
     }
     $short = preg_split("/(?:&lt;|<)!--\\s*more\\s*--(?:&gt;|>)+/i", $post["body"]);
     if (is_array($short) && count($short) > 1) {
         $content["short"] = "`short`='" . self::$db->escapeString(nl2br(array_shift($short))) . "'";
     }
     //print_r ($_POST);
     //echo "INSERT INTO `content` SET ".implode (", ", $content);
     self::$db->query("INSERT INTO `content` SET " . implode(", ", $content));
     $id = self::$db->insert_id();
     self::handleCats($cats, $id);
     self::$smarty->clearCache(null, "MAINPAGE|SEARCH_RES|BLOG|CATSELECT|RSS");
     self::$smarty->clearCache(null, "MAINPAGE");
     return $content;
 }
开发者ID:ygres,项目名称:sblog,代码行数:55,代码来源:model.blog.php

示例4: initialVerify

 public static function initialVerify($ignoreExistingPost = false)
 {
     if (!empty($_POST["slug"])) {
         $_POST["slug"] = blog::handlePostName($_POST["slug"]);
     } else {
         if (!empty($_POST["title"])) {
             $_POST["slug"] = blog::handlePostName($_POST["title"]);
         }
     }
     if (!$ignoreExistingPost && self::postExist("slug", $_POST["slug"])) {
         system::registerEvent("error", "slug", "Такой адрес объекта уже занят", "URL");
     }
     if (empty($_POST["title"])) {
         system::registerEvent("error", "title", "Заголовок не может быть пустым", "Заголовок объекта");
     }
     if (isset($_FILES["picRealUpload"]) && $_FILES["picRealUpload"]["error"] === 0) {
         system::registerEvent("error", "picUpld", "Ошибка при загрузке файла", "Файл картинки");
     }
     if (system::checkErrors()) {
         return false;
     }
     return true;
 }
开发者ID:ygres,项目名称:sblog,代码行数:23,代码来源:model.portfolio.php

示例5: controlpanel

 function controlpanel()
 {
     if (!isset($_SESSION["user"])) {
         return system::redirect('/');
     }
     system::setParam("page", "userProfile");
     $cacheID = "USERPANEL|user_" . $_SESSION["user"]["userID"];
     $this->smarty->setCacheID($cacheID);
     if ($_POST) {
         system::checkFields(array("email" => "E-mail", "nick" => "Имя"));
         if (!system::checkErrors()) {
             $post = array_map("htmlspecialchars", $_POST);
             $post = array_map("trim", $post);
             if (!isset($_POST["showEmail"]) || !$_POST["showEmail"]) {
                 $post["showEmail"] = "N";
             }
             $filtredPost = $post;
             if (!empty($post["password1"]) && empty($post["password2"])) {
                 system::registerEvent("error", "password1", "Введите проверочный пароль", "Проверочный пароль");
             } else {
                 if (!empty($post["password2"]) && empty($post["password1"])) {
                     system::registerEvent("error", "password2", "Введите пароль", "Пароль");
                 }
             }
             if (!empty($post["password1"]) && !empty($post["password2"]) && $_SESSION["user"]["source"] == "direct") {
                 unset($filtredPost["password1"], $filtredPost["password2"]);
                 if ($post["password2"] == $post["password1"]) {
                     $filtredPost["password"] = md5(md5($post["password1"]));
                 } else {
                     system::registerEvent("error", "password2", "Пароли не совпадают", "Проверочный пароль");
                     system::registerEvent("error", "password1", "Пароли не совпадают", "Проверочный пароль");
                 }
             }
             if (isset($filtredPost["password1"])) {
                 unset($filtredPost["password1"]);
             }
             if (isset($filtredPost["password2"])) {
                 unset($filtredPost["password2"]);
             }
             if (isset($_FILES["avatar"]) && $_FILES["avatar"]["error"] === 0 && $_SESSION["user"]["source"] == "direct") {
                 $expectedPics = user::processAvatar($_SESSION["user"]["userID"]);
                 $filtredPost["avatar"] = $expectedPics["avatar"]["big"];
                 $filtredPost["avatar_small"] = $expectedPics["avatar"]["small"];
             }
             $_SESSION["user"] = array_merge($_SESSION["user"], $filtredPost);
             foreach ($filtredPost as $k => $v) {
                 if (!$v) {
                     unset($filtredPost[$k]);
                 }
             }
             $this->db->updateTable("users", $filtredPost, "userID", $_SESSION["user"]["userID"]);
             $this->smarty->clearCache(null, "USERPROFILE|USERPANEL|user_" . $_SESSION["user"]["userID"]);
         }
         $this->smarty->clearCurrentCache();
         $this->smarty->clearBrowserCache();
     }
     if (isset($_GET["delUserAvatar"]) && $_GET["delUserAvatar"] == "true") {
         $this->smarty->clearCurrentCache();
         $this->smarty->clearBrowserCache();
     }
     if (isset($_GET["delUserAvatar"]) && $_GET["delUserAvatar"] == "true") {
         if (!$user["avatar"]) {
             unlink(CONTENT_PATH . "/avatars/" . $user["avatar"]);
         }
         if (!$user["avatar_small"]) {
             unlink(CONTENT_PATH . "/avatars/" . $user["avatar_small"]);
         }
         $this->db->updateTable("users", array("avatar" => "", "avatar_small" => ""), "userID", intval($_SESSION["user"]["userID"]));
         $_SESSION["user"]["avatar"] = $_SESSION["user"]["avatar_small"] = "";
         system::redirect("/{$this->controllerCall}/controlpanel");
     }
     if (!$this->smarty->isCached()) {
         $user = $this->db->query("SELECT * FROM `users` WHERE `userID`=?", $_SESSION["user"]["userID"])->fetch();
         $this->smarty->assign("fill", $user);
     }
 }
开发者ID:ygres,项目名称:sblog,代码行数:76,代码来源:user.php

示例6: updatePost

 public static function updatePost($id, $data)
 {
     if (!blog::postExist("contentID", $id)) {
         system::registerEvent("error", "title", "Новости, которую вы редактируете не существует.", "URL");
     }
     if (!self::checkPostErrors($data)) {
         return false;
     }
     if (isset($data["savePost"])) {
         unset($data["savePost"]);
     }
     if (isset($data["picWidth"])) {
         unset($data["picWidth"]);
     }
     if (isset($data["picHeigth"])) {
         unset($data["picHeigth"]);
     }
     self::handleCats($data["categories"], $id);
     if (!isset($data["showOnSite"])) {
         $data["showOnSite"] = 'N';
         self::$smarty->clearAllCache();
     }
     if (empty($data["short"])) {
         $data["short"] = preg_split("/(?:&lt;|<)!--\\s*more\\s*--(?:&gt;|>)+/i", $data["body"]);
         if (is_array($data["short"])) {
             $data["short"] = array_shift($data["short"]);
         }
     } else {
         $data["short"] = nl2br($data["short"]);
     }
     if (isset($data["catName"])) {
         unset($data["catName"]);
     }
     if (isset($data["catSlug"])) {
         unset($data["catSlug"]);
     }
     if (!empty($data["slug"])) {
         $data["slug"] = core::generateSlug($data["slug"]);
     } else {
         if (!empty($data["title"])) {
             $data["slug"] = core::generateSlug($data["title"]);
         }
     }
     //self::$db->updateTable ("content", $data, "contentID", $id);
     $date = date("d-m-Y", strtotime($data["dt"]));
     self::$smarty->clearCache(null, "{$date}_newsdate|{$data["slug"]}");
     self::clearCommonCache();
     if ($data["poster"]) {
         return self::$db->query("UPDATE `content` SET `dt`=STR_TO_DATE ('?', '%d-%m-%Y'), `title`='?', slug='?', `body`='?', `short`='?',\n\t\t\t\t`showOnSite`='?', `editedByID`=?, `editedByNick`='?', `editedOn`=NOW(), `poster`='?' WHERE `contentID`=?", $data["dt"], $data["title"], $data["slug"], $data["body"], $data["short"], $data["showOnSite"], $_SESSION["user"]["userID"], $_SESSION["user"]["nick"], $data["poster"], $id);
     } else {
         return self::$db->query("UPDATE `content` SET `dt`=STR_TO_DATE ('?', '%d-%m-%Y'), `title`='?', slug='?', `body`='?', `short`='?',\n\t\t\t\t`showOnSite`='?', `editedByID`=?, `editedByNick`='?', `editedOn`=NOW() WHERE `contentID`=?", $data["dt"], $data["title"], $data["slug"], $data["body"], $data["short"], $data["showOnSite"], $_SESSION["user"]["userID"], $_SESSION["user"]["nick"], $id);
     }
 }
开发者ID:ygres,项目名称:sblog,代码行数:53,代码来源:model.news.php

示例7: sendUserMail

 public static function sendUserMail(array $receiverIDs, $senderID, $subject, $body)
 {
     if (!$receiverIDs || !isset($_SESSION["user"])) {
         return false;
     }
     $receivers = array_map("intval", $receiverIDs);
     $subject = htmlspecialchars($subject);
     $body = htmlspecialchars($body);
     $senderID = intval($senderID);
     $isOk = true;
     $emailDataIDs = array();
     $senderMessagesIDs = array();
     $messageID = 0;
     for ($i = 0; count($receivers) > $i; ++$i) {
         if (!self::$db->query("INSERT INTO `messages` (`senderID`,`nick`,`receiverID`,`body`,`subject`)" . " VALUES (?,'?',?,'?','?')", $senderID, $_SESSION["user"]["nick"], $receivers[$i], $body, $subject)) {
             $isOk = false;
             break;
         } else {
             $messageID = self::$db->insert_id();
             $senderMessagesIDs[] = $messageID;
             self::$smarty->clearCache(null, "USER|USERMAIL|usermail_" . $receivers[$i]);
         }
     }
     $emailDataRes = self::$db->query("SELECT * FROM `users` WHERE `userID` IN (" . implode(",", $receivers) . ")");
     if ($emailDataRes->getNumRows()) {
         $emailData = $emailDataRes->fetchAll();
         foreach ($emailData as $k => $v) {
             if (!$v["email"]) {
                 if ($senderMessagesIDs) {
                     array_shift($senderMessagesIDs);
                 }
                 continue;
             }
             $messageID = 0;
             if ($senderMessagesIDs) {
                 $messageID = array_shift($senderMessagesIDs);
             }
             $v["data"] = array("senderID" => $senderID, "subject" => $subject, "body" => $body, "messageID" => $messageID);
             self::$mail->assign("mail", $v);
             system::registerEvent("mail", "mailSendReport", $v["email"]);
         }
     }
     self::$smarty->clearCache(null, "USER|USERMAIL|usermail_{$senderID}");
     if (!$isOk) {
         return false;
     }
     return true;
 }
开发者ID:ygres,项目名称:sblog,代码行数:48,代码来源:model.user.php


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