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


PHP Base::redirect方法代码示例

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


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

示例1: themes

 private function themes()
 {
     if (isset($_GET['theme']) && Validate::slug($_GET['theme']) && file_exists(PATH . '/themes/' . $_GET['theme'] . '/theme.json')) {
         $opt = Options::where('name', 'theme')->findOne();
         $opt->value = $_GET['theme'];
         $opt->save();
         Base::redirect('/admin/themes');
     }
     /**
      * Get themes
      */
     $dir = PATH . '/themes/';
     if ($dh = opendir($dir)) {
         $themes = array();
         while (($theme = readdir($dh)) !== false) {
             $file = $dir . $theme . '/theme.json';
             if (file_exists($file)) {
                 $file = file_get_contents($file);
                 $file = (array) json_decode($file);
                 $file['theme'] = $theme;
                 $themes[] = $file;
             }
         }
         closedir($dh);
     }
     View::set('themes', $themes);
     View::show('admin/themes');
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:28,代码来源:admin.php

示例2: edit

 private function edit()
 {
     Base::requireAdmin();
     if (!isset($_POST['page']) && !isset($_POST['draft'])) {
         // Preparations for View
         View::set('page', $this->page);
         View::show('page/edit');
     }
     // Token
     $this->page->title = $_POST['title'];
     // Filter
     $this->page->slug = Base::slug($_POST['title']);
     $this->page->html = $_POST['html'];
     $this->page->published = isset($_POST['page']);
     $this->page->save();
     // Successfully edited
     Base::redirect('/page/' . $this->page->slug, 'Page successfully edited');
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:18,代码来源:page.php

示例3: register

 /**
  * User registration page
  */
 private function register()
 {
     Base::requireNotLogged();
     if (!isset($_POST['register'])) {
         View::show('user/register');
     }
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $email = $_POST['email'];
     // Password errors
     if (!Validate::len($password, 4, 128)) {
         $error = 'Password must have more than 4 characters';
     } elseif ($password != $password2) {
         $error = 'Passwords don\'t match';
     } elseif (!Validate::captcha($_POST['captcha'])) {
         $error = 'Invalid captcha';
     } elseif (!Validate::len($username)) {
         $error = 'Username character count must be between 4 and 64';
     } elseif (!Validate::username($username)) {
         $error = 'Please only use letters, digits, dots and underscores in username';
     } elseif (method_exists($this, $username)) {
         $error = 'You cannot use that username';
     } elseif (User::where('username', $username)->findOne()) {
         $error = 'You cannot use that username';
     } elseif (!Validate::len($email)) {
         $error = 'Email character count must be between 4 and 64';
     } elseif (!Validate::email($email)) {
         $error = 'Please enter a valid email';
     } elseif (User::where('email', $email)->findOne()) {
         $error = 'You cannot use that email address';
     }
     if ($error) {
         View::set('error', $error);
         View::show('user/register');
     }
     $user = User::create();
     $user->username = $username;
     $user->password = Base::hashPassword($password);
     $user->email = $email;
     $user->reg_date = time();
     $user->avatar = Base::createIdenticon($username, 200);
     $user->admin = 0;
     $user->save();
     // Logs user in
     Session::login($user->id());
     Base::redirect('', "Welcome, {$user->username}! We're glad to know you");
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:51,代码来源:user.php

示例4: edit


//.........这里部分代码省略.........
             View::error('playlist/edit', $error);
         }
         $this->playlist->cover = $cover;
     }
     /**
      * Inserts tags into database
      */
     if (!empty($_POST['tags'])) {
         // Separates tags by commas
         $tags = strtolower($_POST['tags']);
         $tags = explode(',', $tags, 6);
         // Tag limit
         $tags = array_slice($tags, 0, 5);
         // Filter tags
         foreach ($tags as $k => &$tag) {
             if (!ADMIN && $tag === 'staff') {
                 continue;
             }
             $tag = preg_replace('/[^a-z]+/', ' ', $tag);
             $tag = trim($tag, ' ');
             // Tag must have at least 2 chars
             // And it must be lesser than 32 chars
             if (!Validate::len($tag, 1, 32)) {
                 unset($tags[$k]);
             }
         }
         if (!empty($tags)) {
             // Remove tags from PlaylistTag
             PlaylistTag::where('playlist_id', $this->playlist->id)->deleteMany();
             // Insert tags
             $sql = str_repeat(',(?)', count($tags));
             $sql[0] = ' ';
             Tag::rawExecute("INSERT IGNORE INTO tag(name) VALUES {$sql}", $tags);
             // Get inserted tags ids and point them to the new playlist
             $tags = Tag::select('id')->whereIn('name', $tags)->findMany();
             foreach ($tags as $tag) {
                 $link = PlaylistTag::create();
                 $link->playlist_id = $this->playlist->id;
                 $link->tag_id = $tag->id;
                 $link->save();
             }
         }
     }
     // Published status
     $this->playlist->published = isset($_POST['playlist']);
     /**
      * Add tracks into db
      */
     if (!isset($_POST['tracks'])) {
         $error = 'You can\'t publish without any tracks';
         $this->playlist->published = 0;
     } else {
         if (is_array($_POST['tracks'])) {
             $max = Base::$g['playlist_max_tracks'];
             $min = Base::$g['playlist_min_tracks'];
             $tracks = $_POST['tracks'];
             if (!isset($tracks[$min - 1])) {
                 $error = "You can't publish without at least {$min} tracks";
                 $this->playlist->published = 0;
             } elseif (isset($track[$max])) {
                 $error = "You can't have more than {$max} tracks in a playlist";
                 $tracks = array_slice($tracks, 0, $max);
             }
             /**
              * Check for haxing
              */
             foreach ($tracks as $k => &$item) {
                 $item = Validate::int($item);
                 if ($item === false) {
                     unset($tracks[$k]);
                 }
             }
             // Also get duration
             $row = Track::whereIn('id', $tracks)->selectExpr('COUNT(id)', 'count')->selectExpr('SUM(duration)', 'duration')->findOne();
             if ($row->count != count(array_unique($tracks))) {
                 View::error('playlist/edit', 'Massive error 2. Contact the admin');
             }
             // Store duration in minutes
             $this->playlist->tracks_count = $row->count;
             $this->playlist->duration = $row->duration / 60;
             // Delete the ones already in
             PlaylistTrack::where('playlist_id', $this->playlist->id)->deleteMany();
             // Add new ones
             foreach ($tracks as $track) {
                 $table = PlaylistTrack::create();
                 $table->playlist_id = $this->playlist->id;
                 $table->track_id = $track;
                 $table->save();
             }
         } else {
             View::error('playlist/edit', 'Massive error. Contact the admin');
         }
     }
     /**
      * Update playlist in database
      */
     $this->playlist->save();
     $msg = $error ?: 'Playlist succesfully edited';
     Base::redirect('/' . $this->playlist->id, $msg);
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:101,代码来源:playlist.php

示例5: delete

 /**
  * User delete
  */
 private function delete()
 {
     Base::requireAdmin();
     $this->user->delete();
     Base::redirect('/admin/manage_users', 'User successfully deleted');
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:9,代码来源:profile.php


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