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


PHP access::forbidden方法代码示例

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


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

示例1: upgrade

 public function upgrade()
 {
     if (php_sapi_name() == "cli") {
         // @todo this may screw up some module installers, but we don't have a better answer at
         // this time.
         $_SERVER["HTTP_HOST"] = "example.com";
     } else {
         if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
     }
     // Upgrade gallery and user first
     module::install("gallery");
     module::install("user");
     // Then upgrade the rest
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             module::install($id);
         }
     }
     if (php_sapi_name() == "cli") {
         print "Upgrade complete\n";
     } else {
         url::redirect("upgrader?done=1");
     }
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:29,代码来源:upgrader.php

示例2: delete_user

  public function delete_user($id) {
    access::verify_csrf();

    if ($id == user::active()->id || $id == user::guest()->id) {
      access::forbidden();
    }

    $user = ORM::factory("user", $id);
    if (!$user->loaded) {
      kohana::show_404();
    }

    $form = user::get_delete_form_admin($user);
    if($form->validate()) {
      $name = $user->name;
      $user->delete();
    } else {
      print json_encode(array("result" => "error",
                              "form" => $form->__toString()));
    }

    $message = t("Deleted user %user_name", array("user_name" => p::clean($name)));
    log::success("user", $message);
    message::success($message);
    print json_encode(array("result" => "success"));
  }
开发者ID:kovert,项目名称:gallery3,代码行数:26,代码来源:admin_users.php

示例3: required

 static function required($perm_name, $item)
 {
     // Original code from the required function in modules/gallery/helpers/access.php.
     if (!access::can($perm_name, $item)) {
         if ($perm_name == "view") {
             // Treat as if the item didn't exist, don't leak any information.
             throw new Kohana_404_Exception();
         } else {
             access::forbidden();
         }
         // Begin rWatcher modifications.
         //   Throw a 404 error when a user attempts to access a protected item,
         //   unless the password has been provided, or the user is the item's owner.
     } elseif (module::get_var("albumpassword", "hideonly") == false) {
         $item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
         if (count($item_protected) > 0) {
             $existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
             if ($existing_password->loaded()) {
                 if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
                     throw new Kohana_404_Exception();
                 }
             }
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:MY_access.php

示例4: auth

 public function auth()
 {
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     access::verify_csrf();
     $form = self::_form();
     $valid = $form->validate();
     $user = identity::active_user();
     if ($valid) {
         module::event("user_auth", $user);
         if (!request::is_ajax()) {
             message::success(t("Successfully re-authenticated!"));
         }
         url::redirect(Session::instance()->get_once("continue_url"));
     } else {
         $name = $user->name;
         log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
         module::event("user_auth_failed", $name);
         if (request::is_ajax()) {
             $v = new View("reauthenticate.html");
             $v->form = $form;
             $v->user_name = identity::active_user()->name;
             json::reply(array("html" => (string) $v));
         } else {
             self::_show_form($form);
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:29,代码来源:reauthenticate.php

示例5: _form_edit

 public function _form_edit($user)
 {
     if ($user->guest || $user->id != user::active()->id) {
         access::forbidden();
     }
     print user::get_edit_form($user);
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:7,代码来源:users.php

示例6: upgrade

 public function upgrade()
 {
     if (php_sapi_name() == "cli") {
         // @todo this may screw up some module installers, but we don't have a better answer at
         // this time.
         $_SERVER["HTTP_HOST"] = "example.com";
     } else {
         if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
         try {
             access::verify_csrf();
         } catch (Exception $e) {
             url::redirect("upgrader");
         }
     }
     $available = module::available();
     // Upgrade gallery first
     $gallery = $available["gallery"];
     if ($gallery->code_version != $gallery->version) {
         module::upgrade("gallery");
         module::activate("gallery");
     }
     // Then upgrade the rest
     $failed = array();
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             try {
                 module::upgrade($id);
             } catch (Exception $e) {
                 // @todo assume it's MODULE_FAILED_TO_UPGRADE for now
                 $failed[] = $id;
             }
         }
     }
     // If the upgrade failed, this will get recreated
     site_status::clear("upgrade_now");
     // Clear any upgrade check strings, we are probably up to date.
     site_status::clear("upgrade_checker");
     if (php_sapi_name() == "cli") {
         if ($failed) {
             print "Upgrade completed ** WITH FAILURES **\n";
             print "The following modules were not successfully upgraded:\n";
             print "  " . implode($failed, "\n  ") . "\n";
             print "Try getting newer versions or deactivating those modules\n";
         } else {
             print "Upgrade complete\n";
         }
     } else {
         if ($failed) {
             url::redirect("upgrader?failed=" . join(",", $failed));
         } else {
             url::redirect("upgrader");
         }
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:59,代码来源:upgrader.php

示例7: form_edit

 public function form_edit($id)
 {
     $user = user::lookup($id);
     if ($user->guest || $user->id != user::active()->id) {
         access::forbidden();
     }
     print $this->_get_edit_form($user);
 }
开发者ID:CardinS2U,项目名称:gallery3,代码行数:8,代码来源:users.php

示例8: form

 function form($id)
 {
     $item = ORM::factory("item", $id);
     access::required("edit", $item);
     if ($item->type != "album") {
         access::forbidden();
     }
     print $this->_get_form($item);
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:9,代码来源:permissions.php

示例9: form_add

 /**
  * Present a form for adding a new comment to this item or editing an existing comment.
  */
 public function form_add($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     if (!comment::can_comment()) {
         access::forbidden();
     }
     print comment::prefill_add_form(comment::get_add_form($item));
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:12,代码来源:comments.php

示例10: delete

 static function delete($request)
 {
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     $comment = rest::resolve($request->url);
     access::required("edit", $comment->item());
     $comment->delete();
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:9,代码来源:comment_rest.php

示例11: _check_star_permissions

 /**
  * Checks whether the given object can be starred by the active user.
  *
  * @param Item_Model $item  the item
  */
 private function _check_star_permissions(Item_Model $item)
 {
     access::verify_csrf();
     access::required("view", $item);
     access::required("edit", $item);
     if (!star::can_star()) {
         access::forbidden();
     }
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:14,代码来源:display.php

示例12: form_send

 /**
  * Present a form for sending a new ecard.
  */
 public function form_send($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     if (!ecard::can_send_ecard()) {
         access::forbidden();
     }
     print ecard::prefill_send_form(ecard::get_send_form($item));
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:12,代码来源:ecard.php

示例13: form

 function form($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     if (!$item->is_album()) {
         access::forbidden();
     }
     print $this->_get_form($item);
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:10,代码来源:permissions.php

示例14: toggle_l10n_mode

 public function toggle_l10n_mode()
 {
     access::verify_csrf();
     if (!user::active()->admin) {
         access::forbidden();
     }
     $session = Session::instance();
     $session->set("l10n_mode", !$session->get("l10n_mode", false));
     url::redirect("albums/1");
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:10,代码来源:l10n_client.php

示例15: delete

 static function delete($request)
 {
     // Restrict deleting tags to admins.  Otherwise, a logged in user can do great harm to an
     // install.
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     $tag = rest::resolve($request->url);
     $tag->delete();
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:10,代码来源:tag_rest.php


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