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


PHP Event::page_matches方法代码示例

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


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

示例1: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("admin")) {
         if (!$user->is_admin()) {
             $this->theme->display_permission_denied($page);
         } else {
             send_event(new AdminBuildingEvent($page));
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("admin_utils")) {
         if ($user->is_admin() && $user->check_auth_token()) {
             log_info("admin", "Util: {$_POST['action']}");
             set_time_limit(0);
             $redirect = false;
             switch ($_POST['action']) {
                 case 'delete by query':
                     $this->delete_by_query($_POST['query']);
                     $redirect = true;
                     break;
                 case 'lowercase all tags':
                     $this->lowercase_all_tags();
                     $redirect = true;
                     break;
                 case 'recount tag use':
                     $this->recount_tag_use();
                     $redirect = true;
                     break;
                 case 'purge unused tags':
                     $this->purge_unused_tags();
                     $redirect = true;
                     break;
                 case 'convert to innodb':
                     $this->convert_to_innodb();
                     $redirect = true;
                     break;
                 case 'database dump':
                     $this->dbdump($page);
                     break;
             }
             if ($redirect) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_page($page);
         $this->theme->display_form($page);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Board Admin", make_link("admin"));
         }
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:59,代码来源:main.php

示例2: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_edit")) {
         if ($event->get_arg(0) == "replace") {
             if ($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
                 $search = $_POST['search'];
                 $replace = $_POST['replace'];
                 $this->mass_tag_edit($search, $replace);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof ImageInfoSetEvent) {
         if ($this->can_tag()) {
             send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
             if ($this->can_source()) {
                 send_event(new SourceSetEvent($event->image, $_POST['tag_edit__source']));
             }
         } else {
             $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
         }
     }
     if ($event instanceof TagSetEvent) {
         $event->image->set_tags($event->tags);
     }
     if ($event instanceof SourceSetEvent) {
         $event->image->set_source($event->source);
     }
     if ($event instanceof ImageDeletionEvent) {
         $event->image->delete_tags_from_image();
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_mass_editor($page);
     }
     // When an alias is added, oldtag becomes inaccessable
     if ($event instanceof AddAliasEvent) {
         $this->mass_tag_edit($event->oldtag, $event->newtag);
     }
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_tag_editor_html($event->image), 40);
         }
         if ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_source_editor_html($event->image), 41);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Editing");
         $sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
         $sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
         $event->panel->add_block($sb);
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:58,代码来源:main.php

示例3: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int("history_limit", -1);
         // shimmie is being installed so call install to create the table.
         if ($config->get_int("ext_tag_history_version") < 3) {
             $this->install();
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_history")) {
         if ($event->get_arg(0) == "revert") {
             // this is a request to revert to a previous version of the tags
             if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
                 $this->process_revert_request($_POST['revert']);
             }
         } else {
             if ($event->count_args() == 1) {
                 // must be an attempt to view a tag history
                 $image_id = int_escape($event->get_arg(0));
                 $this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
             } else {
                 $this->theme->display_global_page($page, $this->get_global_tag_history());
             }
         }
     }
     if ($event instanceof DisplayingImageEvent) {
         // handle displaying a link on the view page
         $this->theme->display_history_link($page, $event->image->id);
     }
     if ($event instanceof ImageDeletionEvent) {
         // handle removing of history when an image is deleted
         $this->delete_all_tag_history($event->image->id);
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag History");
         $sb->add_label("Limit to ");
         $sb->add_int_option("history_limit");
         $sb->add_label(" entires per image");
         $sb->add_label("<br>(-1 for unlimited)");
         $event->panel->add_block($sb);
     }
     if ($event instanceof TagSetEvent) {
         $this->add_tag_history($event->image, $event->tags);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Tag Changes", make_link("tag_history"));
         }
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:54,代码来源:main.php

示例4: receive_event

 public function receive_event(Event $event)
 {
     // Check if someone is accessing /api/danbooru (us)
     if ($event instanceof PageRequestEvent && $event->page_matches("api") && $event->get_arg(0) == 'danbooru') {
         // execute the danbooru processing code
         $this->api_danbooru($event);
     }
     if ($event instanceof SearchTermParseEvent) {
         $matches = array();
         if (preg_match("/^md5:([0-9a-fA-F]*)\$/i", $event->term, $matches)) {
             $hash = strtolower($matches[1]);
             $event->set_querylet(new Querylet("images.hash = '{$hash}'"));
         }
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:15,代码来源:main.php

示例5: receive_event

 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     // fucking PHP "security" measures -_-;;;
     $free_num = @disk_free_space(realpath("./images/"));
     if ($free_num === FALSE) {
         $is_full = false;
     } else {
         $is_full = $free_num < 100 * 1024 * 1024;
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int('upload_count', 3);
         $config->set_default_int('upload_size', '1MB');
         $config->set_default_bool('upload_anon', false);
         $config->set_default_bool('upload_replace', true);
     }
     if ($event instanceof PostListBuildingEvent) {
         if ($this->can_upload($user)) {
             if ($is_full) {
                 $this->theme->display_full($page);
             } else {
                 $this->theme->display_block($page);
             }
         }
     }
     if ($event instanceof PageRequestEvent) {
         if ($event->page_matches("upload/replace")) {
             /* Upload & Replace Image Request */
             if (!$config->get_bool("upload_replace")) {
                 throw new UploadException("Upload Replacing Images is not enabled.");
             }
             // check if the user is an administrator and can upload files.
             if (!$user->is_admin()) {
                 $this->theme->display_permission_denied($page);
             } else {
                 if ($is_full) {
                     throw new UploadException("Can not replace Image: disk nearly full");
                 }
                 // Try to get the image ID
                 $image_id = int_escape($event->get_arg(0));
                 if (empty($image_id)) {
                     $image_id = isset($_POST['image_id']) ? $_POST['image_id'] : null;
                 }
                 if (empty($image_id)) {
                     throw new UploadException("Can not replace Image: No valid Image ID given.");
                 }
                 $image_old = Image::by_id($image_id);
                 if (is_null($image_old)) {
                     $this->theme->display_error($page, "Image not found", "No image in the database has the ID #{$image_id}");
                 }
                 if (count($_FILES) + count($_POST) > 0) {
                     if (count($_FILES) > 1) {
                         throw new UploadException("Can not upload more than one image for replacing.");
                     }
                     $source = isset($_POST['source']) ? $_POST['source'] : null;
                     $tags = '';
                     // Tags aren't changed when uploading. Set to null to stop PHP warnings.
                     if (count($_FILES)) {
                         foreach ($_FILES as $file) {
                             $ok = $this->try_upload($file, $tags, $source, $image_id);
                             break;
                             // leave the foreach loop.
                         }
                     } else {
                         foreach ($_POST as $name => $value) {
                             if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
                                 $ok = $this->try_transload($value, $tags, $source, $image_id);
                                 break;
                                 // leave the foreach loop.
                             }
                         }
                     }
                     $this->theme->display_upload_status($page, $ok);
                 } else {
                     if (!empty($_GET['url'])) {
                         $url = $_GET['url'];
                         $ok = $this->try_transload($url, $tags, $url, $image_id);
                         $this->theme->display_upload_status($page, $ok);
                     } else {
                         $this->theme->display_replace_page($page, $image_id);
                     }
                 }
             }
             // END of if admin / can_upload
         } else {
             if ($event->page_matches("upload")) {
                 if (!$this->can_upload($user)) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     /* Regular Upload Image */
                     if (count($_FILES) + count($_POST) > 0) {
                         $tags = Tag::explode($_POST['tags']);
                         $source = isset($_POST['source']) ? $_POST['source'] : null;
                         $ok = true;
                         foreach ($_FILES as $file) {
                             $ok = $ok & $this->try_upload($file, $tags, $source);
                         }
//.........这里部分代码省略.........
开发者ID:nsuan,项目名称:shimmie2,代码行数:101,代码来源:main.php

示例6: onPageRequest

 public function onPageRequest(Event $event)
 {
     global $page, $database, $user;
     if ($event->page_matches("blotter")) {
         switch ($event->get_arg(0)) {
             case "editor":
                 /**
                  * Displays the blotter editor.
                  */
                 if (!$user->is_admin()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC");
                     $this->theme->display_editor($entries);
                 }
                 break;
             case "add":
                 /**
                  * Adds an entry
                  */
                 if (!$user->is_admin() || !$user->check_auth_token()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $entry_text = $_POST['entry_text'];
                     if ($entry_text == "") {
                         die("No entry message!");
                     }
                     if (isset($_POST['important'])) {
                         $important = 'Y';
                     } else {
                         $important = 'N';
                     }
                     // Now insert into db:
                     $database->execute("INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), ?, ?)", array($entry_text, $important));
                     log_info("blotter", "Added Message: {$entry_text}");
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("blotter/editor"));
                 }
                 break;
             case "remove":
                 /**
                  * Removes an entry
                  */
                 if (!$user->is_admin() || !$user->check_auth_token()) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     $id = int_escape($_POST['id']);
                     if (!isset($id)) {
                         die("No ID!");
                     }
                     $database->Execute("DELETE FROM blotter WHERE id=:id", array("id" => $id));
                     log_info("blotter", "Removed Entry #{$id}");
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("blotter/editor"));
                 }
                 break;
             case "":
                 /**
                  * Displays all blotter entries
                  */
                 $entries = $database->get_all("SELECT * FROM blotter ORDER BY id DESC");
                 $this->theme->display_blotter_page($entries);
                 break;
         }
     }
     /**
      * Finally, display the blotter on whatever page we're viewing.
      */
     $this->display_blotter();
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:70,代码来源:main.php

示例7: onPageRequest

 public function onPageRequest(Event $event)
 {
     global $config, $database, $page, $user;
     // user info is shown on all pages
     if ($user->is_anonymous()) {
         $this->theme->display_login_block($page);
     } else {
         $ubbe = new UserBlockBuildingEvent();
         send_event($ubbe);
         ksort($ubbe->parts);
         $this->theme->display_user_block($page, $user, $ubbe->parts);
     }
     if ($event->page_matches("user_admin")) {
         if ($event->get_arg(0) == "login") {
             if (isset($_POST['user']) && isset($_POST['pass'])) {
                 $this->login($page);
             } else {
                 $this->theme->display_login_page($page);
             }
         } else {
             if ($event->get_arg(0) == "logout") {
                 set_prefixed_cookie("session", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/");
                 if (CACHE_HTTP) {
                     # to keep as few versions of content as possible,
                     # make cookies all-or-nothing
                     set_prefixed_cookie("user", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/");
                 }
                 log_info("user", "Logged out");
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link());
             } else {
                 if ($event->get_arg(0) == "change_pass") {
                     $this->change_password_wrapper($page);
                 } else {
                     if ($event->get_arg(0) == "change_email") {
                         $this->change_email_wrapper($page);
                     } else {
                         if ($event->get_arg(0) == "recover") {
                             $user = User::by_name($_POST['username']);
                             if (is_null($user)) {
                                 $this->theme->display_error($page, "Error", "There's no user with that name");
                             }
                             if (is_null($user->email)) {
                                 //
                             }
                         } else {
                             if ($event->get_arg(0) == "create") {
                                 if (!$config->get_bool("login_signup_enabled")) {
                                     $this->theme->display_signups_disabled($page);
                                 } else {
                                     if (!isset($_POST['name'])) {
                                         $this->theme->display_signup_page($page);
                                     } else {
                                         if ($_POST['pass1'] != $_POST['pass2']) {
                                             $this->theme->display_error($page, "Password Mismatch", "Passwords don't match");
                                         } else {
                                             try {
                                                 if (!captcha_check()) {
                                                     throw new UserCreationException("Error in captcha");
                                                 }
                                                 $uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email']);
                                                 send_event($uce);
                                                 $this->set_login_cookie($uce->username, $uce->password);
                                                 $page->set_mode("redirect");
                                                 $page->set_redirect(make_link("user"));
                                             } catch (UserCreationException $ex) {
                                                 $this->theme->display_error($page, "User Creation Error", $ex->getMessage());
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($event->get_arg(0) == "set_more") {
                                     $this->set_more_wrapper($page);
                                 } else {
                                     if ($event->get_arg(0) == "list") {
                                         // select users.id,name,joindate,admin,
                                         // (select count(*) from images where images.owner_id=users.id) as images,
                                         // (select count(*) from comments where comments.owner_id=users.id) as comments from users;
                                         // select users.id,name,joindate,admin,image_count,comment_count
                                         // from users
                                         // join (select owner_id,count(*) as image_count from images group by owner_id) as _images on _images.owner_id=users.id
                                         // join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
                                         $this->theme->display_user_list($page, User::by_list(0), $user);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("user")) {
         $display_user = $event->count_args() == 0 ? $user : User::by_name($event->get_arg(0));
         if ($event->count_args() == 0 && $user->is_anonymous()) {
             $this->theme->display_error($page, "Not Logged In", "You aren't logged in. First do that, then you can see your stats.");
         } else {
             if (!is_null($display_user)) {
                 send_event(new UserPageBuildingEvent($display_user));
//.........这里部分代码省略.........
开发者ID:nsuan,项目名称:shimmie2,代码行数:101,代码来源:main.php


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