本文整理汇总了PHP中Authorization::Authorize方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::Authorize方法的具体用法?PHP Authorization::Authorize怎么用?PHP Authorization::Authorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::Authorize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editCategory
public function editCategory($id)
{
if (Authorization::Authorize('Admin')) {
$this->view->category = $this->model->getCategory();
// viet code xy lu o day
$this->data = array();
$this->view->title = 'Edit Category';
$this->view->cat = $this->model->showCatById($id);
if (isset($_POST['submit'])) {
if (empty($_POST['catname'])) {
$this->view->msg = "Vui lòng nhập tên Category";
$this->view->renderAdmin('category/editcategory');
} else {
$this->data['catname'] = mysqli_real_escape_string($this->model->connect, $_POST['catname']);
$this->data['parent'] = $_POST['category'];
if ($this->model->editCat($this->data, $id) == true) {
$this->view->redirect('listcategory');
} else {
$this->view->msg = "Edit category faild";
$this->view->renderAdmin('category/editcategory');
}
}
} else {
$this->view->renderAdmin("category/editcategory");
}
} else {
$this->view->render("user/index");
}
}
示例2: index
public function index()
{
$this->view->title = "Dashboard";
if (Authorization::Authorize('Admin')) {
$this->view->title = "Dashboard";
$this->view->cat = $this->model->getCat();
$this->view->post = $this->model->getPost();
$this->view->comment = $this->model->getComment();
$this->view->user = $this->model->getUser();
$this->view->page = $this->model->getPage();
$this->view->renderAdmin("dashboard/index");
} else {
$this->view->render("user/index");
}
}
示例3: Authorize
function Authorize($request)
{
$A = new Authorization();
return $A->Authorize($request);
}
示例4: edit
public function edit($id)
{
if (Authorization::Authorize('Admin')) {
$this->view->title = "Edit Post";
$this->view->cat = $this->category->getCategory();
$this->view->news = $this->model->getPostById($id);
if (isset($_POST['submit'])) {
///////////////////////////////////////
//VALIDATE FORM
//////////////////////////////////////
$error = NULL;
$data = array();
if (isset($_POST['title'])) {
$data['title'] = $this->model->escape($_POST['title']);
} else {
$error[] = 'title';
}
if (isset($_POST['category']) && filter_var($_POST['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) {
$data['category'] = $_POST['category'];
} else {
$error[] = 'category';
}
///////////////////////////////////////////////
//VALIDATE IMAGE
///////////////////////////////////////////////
if (isset($_FILES['image'])) {
$allow = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif');
if (in_array(strtolower($_FILES['image']['type']), $allow)) {
$tmp = explode('.', $_FILES['image']['name']);
$ext = end($tmp);
$reName = uniqid(rand(), true) . '.' . $ext;
if (!move_uploaded_file($_FILES['image']['tmp_name'], "public/public/upload/images/" . $reName)) {
$this->view->error['image'] = "Vui long nhap Image";
} else {
$data['image'] = SITE_PATH . "public/public/upload/images/" . $reName;
}
} else {
$this->view->error['image2'] = "Ko dung dinh dang";
}
}
///////////////////////////////////////////////////////
//END VALIDATE
//////////////////////////////////////////////////////
if (isset($_POST['content'])) {
$data['content'] = Functions::the_content($_POST['content']);
} else {
$error[] = 'content';
}
if (isset($_POST['status'])) {
$data['status'] = $_POST['status'];
} else {
$error[] = 'status';
}
if (empty($error)) {
$this->model->editById($data, $id);
$this->view->redirect('listpost');
} else {
$this->view->renderAdmin('news/edit');
}
} else {
$this->view->renderAdmin('news/edit');
}
} else {
$this->view->render("user/index");
}
}