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


PHP Security::safeName方法代码示例

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


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

示例1: __

        $errors['storage'] = true;
    }
    if (trim(Request::post('backups') !== '')) {
        $errors['backups'] = true;
    }
    if (trim(Request::post('tmp') !== '')) {
        $errors['tmp'] = true;
    }
    // If errors is 0 then install cms
    if (count($errors) == 0) {
        // Update options
        Option::update(array('maintenance_status' => 'off', 'sitename' => Request::post('sitename'), 'siteurl' => Request::post('siteurl'), 'description' => __('Site description', 'system'), 'keywords' => __('Site keywords', 'system'), 'slogan' => __('Site slogan', 'system'), 'defaultpage' => 'home', 'timezone' => Request::post('timezone'), 'system_email' => Request::post('email'), 'theme_site_name' => 'default', 'theme_admin_name' => 'default'));
        // Get users table
        $users = new Table('users');
        // Insert new user with role = admin
        $users->insert(array('login' => Security::safeName(Request::post('login')), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => 'admin'));
        // Write .htaccess
        $htaccess = file_get_contents('.htaccess');
        $save_htaccess_content = str_replace("/%siteurlhere%/", $rewrite_base, $htaccess);
        $handle = fopen('.htaccess', "w");
        fwrite($handle, $save_htaccess_content);
        fclose($handle);
        // Installation done :)
        header("location: index.php?install=done");
    } else {
        Notification::setNow('errors', $errors);
    }
}
?>
<!DOCTYPE html>
<html lang="en">
开发者ID:Repkit,项目名称:monstra,代码行数:31,代码来源:install.php

示例2: main

 /**
  * Snippets admin function
  */
 public static function main()
 {
     // Init vars
     $snippets_path = STORAGE . DS . 'snippets' . DS;
     $snippets_list = array();
     $errors = array();
     // Check for get actions
     // -------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -------------------------------------
         switch (Request::get('action')) {
             // Add snippet
             // -------------------------------------
             case "add_snippet":
                 if (Request::post('add_snippets') || Request::post('add_snippets_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['snippets_empty_name'] = __('Required field', 'snippets');
                         }
                         if (file_exists($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php')) {
                             $errors['snippets_exists'] = __('This snippet already exists', 'snippets');
                         }
                         if (count($errors) == 0) {
                             // Save snippet
                             File::setContent($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php', Request::post('content'));
                             Notification::set('success', __('Your changes to the snippet <i>:name</i> have been saved.', 'snippets', array(':name' => Security::safeName(Request::post('name')))));
                             if (Request::post('add_snippets_and_exit')) {
                                 Request::redirect('index.php?id=snippets');
                             } else {
                                 Request::redirect('index.php?id=snippets&action=edit_snippet&filename=' . Security::safeName(Request::post('name')));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/snippets/views/backend/add')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->display();
                 break;
                 // Edit snippet
                 // -------------------------------------
             // Edit snippet
             // -------------------------------------
             case "edit_snippet":
                 // Save current snippet action
                 if (Request::post('edit_snippets') || Request::post('edit_snippets_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['snippets_empty_name'] = __('Required field', 'snippets');
                         }
                         if (file_exists($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php') and Security::safeName(Request::post('snippets_old_name')) !== Security::safeName(Request::post('name'))) {
                             $errors['snippets_exists'] = __('This snippet already exists', 'snippets');
                         }
                         // Save fields
                         if (Request::post('content')) {
                             $content = Request::post('content');
                         } else {
                             $content = '';
                         }
                         if (count($errors) == 0) {
                             $snippet_old_filename = $snippets_path . Request::post('snippets_old_name') . '.snippet.php';
                             $snippet_new_filename = $snippets_path . Security::safeName(Request::post('name')) . '.snippet.php';
                             if (!empty($snippet_old_filename)) {
                                 if ($snippet_old_filename !== $snippet_new_filename) {
                                     rename($snippet_old_filename, $snippet_new_filename);
                                     $save_filename = $snippet_new_filename;
                                 } else {
                                     $save_filename = $snippet_new_filename;
                                 }
                             } else {
                                 $save_filename = $snippet_new_filename;
                             }
                             // Save snippet
                             File::setContent($save_filename, Request::post('content'));
                             Notification::set('success', __('Your changes to the snippet <i>:name</i> have been saved.', 'snippets', array(':name' => basename($save_filename, '.snippet.php'))));
                             if (Request::post('edit_snippets_and_exit')) {
                                 Request::redirect('index.php?id=snippets');
                             } else {
                                 Request::redirect('index.php?id=snippets&action=edit_snippet&filename=' . Security::safeName(Request::post('name')));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:snippets.admin.php

示例3: main

 /**
  * Themes plugin admin
  */
 public static function main()
 {
     // Get current themes
     $current_site_theme = Option::get('theme_site_name');
     $current_admin_theme = Option::get('theme_admin_name');
     // Init vars
     $themes_site = Themes::getSiteThemes();
     $themes_admin = Themes::getAdminThemes();
     $templates = Themes::getTemplates();
     $chunks = Themes::getChunks();
     $styles = Themes::getStyles();
     $scripts = Themes::getScripts();
     $errors = array();
     $chunk_path = THEMES_SITE . DS . $current_site_theme . DS;
     $template_path = THEMES_SITE . DS . $current_site_theme . DS;
     $style_path = THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS;
     $script_path = THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS;
     // Save site theme
     if (Request::post('save_site_theme')) {
         if (Security::check(Request::post('csrf'))) {
             Option::update('theme_site_name', Request::post('themes'));
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             // Increment Styles and Javascript version
             Stylesheet::stylesVersionIncrement();
             Javascript::javascriptVersionIncrement();
             Request::redirect('index.php?id=themes');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Save site theme
     if (Request::post('save_admin_theme')) {
         if (Security::check(Request::post('csrf'))) {
             Option::update('theme_admin_name', Request::post('themes'));
             // Clean Monstra TMP folder.
             Monstra::cleanTmp();
             Request::redirect('index.php?id=themes');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Its mean that you can add your own actions for this plugin
     Action::run('admin_themes_extra_actions');
     // Check for get actions
     // -------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -------------------------------------
         switch (Request::get('action')) {
             // Add chunk
             // -------------------------------------
             case "add_chunk":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
                             $errors['file_empty_name'] = __('Required field', 'themes');
                         }
                         if (file_exists($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php')) {
                             $errors['file_exists'] = __('This chunk already exists', 'themes');
                         }
                         if (count($errors) == 0) {
                             // Save chunk
                             File::setContent($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php', Request::post('content'));
                             Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
                             if (Request::post('add_file_and_exit')) {
                                 Request::redirect('index.php?id=themes');
                             } else {
                                 Request::redirect('index.php?id=themes&action=edit_chunk&filename=' . Security::safeName(Request::post('name'), null, false));
                             }
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Save fields
                 if (Request::post('name')) {
                     $name = Request::post('name');
                 } else {
                     $name = '';
                 }
                 if (Request::post('content')) {
                     $content = Request::post('content');
                 } else {
                     $content = '';
                 }
                 // Display view
                 View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'chunk')->display();
                 break;
                 // Add template
                 // -------------------------------------
             // Add template
             // -------------------------------------
             case "add_template":
                 if (Request::post('add_file') || Request::post('add_file_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('name')) == '') {
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:themes.admin.php

示例4: main

 /**
  * Main
  */
 public static function main()
 {
     // Get slider table
     SliderAdmin::$slider = new Table('slider');
     // Get pages table
     $pages = new Table('pages');
     // Create target array
     $slider_item_target_array = array('' => '', '_blank' => '_blank', '_parent' => '_parent', '_top' => '_top');
     // Create order array
     $slider_item_order_array = range(0, 40);
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         $add_mode = false;
         $item = array();
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Edit slider item
             // -----------------------------------------
             case "add":
                 $add_mode = true;
                 // fall thru to edit
             // fall thru to edit
             case "edit":
                 if ($add_mode) {
                     // set defaults
                     $item['title'] = '';
                     $item['summary'] = '';
                     $item['link'] = '';
                     $item['category'] = '';
                     $item['target'] = '';
                     $item['order'] = '';
                     $item['misc_text'] = '';
                     $item['image'] = '';
                 } else {
                     // Select item
                     $item = SliderAdmin::$slider->select('[id="' . Request::get('item_id') . '"]', null);
                 }
                 $map_fields = array('slider_item_title' => 'title', 'slider_item_summary' => 'summary', 'slider_item_link' => 'link', 'slider_item_category' => 'category', 'slider_item_target' => 'target', 'slider_item_order' => 'order', 'slider_item_misc_text' => 'misc_text', 'slider_item_image' => 'image');
                 $errors = array();
                 // Edit current slider item
                 if (Request::post('slider_add_item')) {
                     if (Security::check(Request::post('csrf'))) {
                         // apply posted data
                         // eg.
                         //          if (Request::post('slider_item_title')) $item['title'] = Request::post('slider_item_title');
                         //
                         $data = array();
                         foreach ($map_fields as $key => $value) {
                             //if (Request::post($key))
                             $item[$value] = Request::post($key);
                             $data[$value] = $item[$value];
                         }
                         // apply specialized fixups needed for DB:
                         $data['category'] = Security::safeName($data['category'], '-', true);
                         if (trim($item['title']) == '') {
                             // bad food
                             $errors['slider_item_title_empty'] = __('Required field', 'slider');
                         }
                         // Update slider item
                         if (count($errors) == 0) {
                             if ($add_mode) {
                                 SliderAdmin::$slider->insert($data);
                             } else {
                                 SliderAdmin::$slider->update(Request::get('item_id'), $data);
                             }
                             Request::redirect('index.php?id=slider');
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Display view
                 $v = View::factory('slider/views/backend/edit');
                 foreach ($map_fields as $key => $value) {
                     $v->assign($key, $item[$value]);
                 }
                 $v->assign('add_mode', $add_mode)->assign('slider_item_target_array', $slider_item_target_array)->assign('slider_item_order_array', $slider_item_order_array)->assign('errors', $errors)->assign('categories', SliderAdmin::getCategories())->assign('images', SliderAdmin::getImages())->assign('pages_list', SliderAdmin::getPages())->assign('components_list', SliderAdmin::getComponents())->display();
                 break;
                 // Add slider item
                 // -----------------------------------------
                 /*
                 case "add":
                 
                     $slider_item_title = '';
                     $slider_item_summary = '';
                     $slider_item_link = '';
                     $slider_item_category = '';
                     $slider_item_target = '';
                     $slider_item_order = '';
                     $slider_item_has_button = 0; //false;
                     $slider_item_button_class = '';
                     $slider_item_image = '';
                     $errors = array();
                 
                     // Get current category
//.........这里部分代码省略.........
开发者ID:cmroanirgo,项目名称:monstra-slider,代码行数:101,代码来源:slider.admin.php

示例5: main

 /**
  * Main
  */
 public static function main()
 {
     // Get menu table
     MenuAdmin::$menu = new Table('menu');
     // Get pages table
     $pages = new Table('pages');
     // Create target array
     $menu_item_target_array = array('' => '', '_blank' => '_blank', '_parent' => '_parent', '_top' => '_top');
     // Create order array
     $menu_item_order_array = range(0, 40);
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Edit menu item
             // -----------------------------------------
             case "edit":
                 // Select item
                 $item = MenuAdmin::$menu->select('[id="' . Request::get('item_id') . '"]', null);
                 $menu_item_name = $item['name'];
                 $menu_item_link = $item['link'];
                 $menu_item_category = $item['category'];
                 $menu_item_target = $item['target'];
                 $menu_item_order = $item['order'];
                 $errors = array();
                 // Edit current menu item
                 if (Request::post('menu_add_item')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('menu_item_name')) == '') {
                             if (Request::post('menu_item_name')) {
                                 $menu_item_name = Request::post('menu_item_name');
                             } else {
                                 $menu_item_name = $item['name'];
                             }
                             if (Request::post('menu_item_link')) {
                                 $menu_item_link = Request::post('menu_item_link');
                             } else {
                                 $menu_item_link = $item['link'];
                             }
                             if (Request::post('menu_item_category')) {
                                 $menu_item_category = Request::post('menu_item_category');
                             } else {
                                 $menu_item_category = $item['category'];
                             }
                             if (Request::post('menu_item_target')) {
                                 $menu_item_target = Request::post('menu_item_target');
                             } else {
                                 $menu_item_target = $item['target'];
                             }
                             if (Request::post('menu_item_order')) {
                                 $menu_item_order = Request::post('menu_item_order');
                             } else {
                                 $menu_item_order = $item['order'];
                             }
                             $errors['menu_item_name_empty'] = __('Required field', 'menu');
                         }
                         // Update menu item
                         if (count($errors) == 0) {
                             MenuAdmin::$menu->update(Request::get('item_id'), array('name' => Request::post('menu_item_name'), 'link' => Request::post('menu_item_link'), 'category' => Security::safeName(Request::post('menu_item_category'), '-', true), 'target' => Request::post('menu_item_target'), 'order' => Request::post('menu_item_order')));
                             Request::redirect('index.php?id=menu');
                         }
                     } else {
                         die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                     }
                 }
                 // Display view
                 View::factory('box/menu/views/backend/edit')->assign('menu_item_name', $menu_item_name)->assign('menu_item_link', $menu_item_link)->assign('menu_item_category', $menu_item_category)->assign('menu_item_target', $menu_item_target)->assign('menu_item_order', $menu_item_order)->assign('menu_item_target_array', $menu_item_target_array)->assign('menu_item_order_array', $menu_item_order_array)->assign('errors', $errors)->assign('categories', MenuAdmin::getCategories())->assign('pages_list', MenuAdmin::getPages())->assign('components_list', MenuAdmin::getComponents())->display();
                 break;
                 // Add menu item
                 // -----------------------------------------
             // Add menu item
             // -----------------------------------------
             case "add":
                 $menu_item_name = '';
                 $menu_item_link = '';
                 $menu_item_category = '';
                 $menu_item_target = '';
                 $menu_item_order = '';
                 $errors = array();
                 // Get current category
                 $menu_item_category = $current_category = Request::get('category') ? Request::get('category') : '';
                 // Add new menu item
                 if (Request::post('menu_add_item')) {
                     if (Security::check(Request::post('csrf'))) {
                         if (trim(Request::post('menu_item_name')) == '') {
                             if (Request::post('menu_item_name')) {
                                 $menu_item_name = Request::post('menu_item_name');
                             } else {
                                 $menu_item_name = '';
                             }
                             if (Request::post('menu_item_link')) {
                                 $menu_item_link = Request::post('menu_item_link');
                             } else {
                                 $menu_item_link = '';
                             }
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:menu.admin.php

示例6: main

 /**
  * Users admin
  */
 public static function main()
 {
     // Users roles
     $roles = array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users'));
     // Get uses table
     $users = new Table('users');
     if (Option::get('users_frontend_registration') === 'true') {
         $users_frontend_registration = true;
     } else {
         $users_frontend_registration = false;
     }
     if (Request::post('users_frontend_submit')) {
         if (Security::check(Request::post('csrf'))) {
             if (Request::post('users_frontend_registration')) {
                 $users_frontend_registration = 'true';
             } else {
                 $users_frontend_registration = 'false';
             }
             if (Option::update('users_frontend_registration', $users_frontend_registration)) {
                 Notification::set('success', __('Your changes have been saved.', 'users'));
             } else {
                 Notification::set('error', __('Your changes was not saved.', 'users'));
             }
             Request::redirect('index.php?id=users');
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Add
             // -------------------------------------
             case "add":
                 if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
                     // Errors
                     $errors = array();
                     if (Request::post('register')) {
                         if (Security::check(Request::post('csrf'))) {
                             $user_login = trim(Request::post('login'));
                             $user_password = trim(Request::post('password'));
                             $user_email = trim(Request::post('email'));
                             if ($user_login == '') {
                                 $errors['users_empty_login'] = __('Required field', 'users');
                             }
                             if ($user_password == '') {
                                 $errors['users_empty_password'] = __('Required field', 'users');
                             }
                             if ($user_email == '') {
                                 $errors['users_empty_email'] = __('Required field', 'users');
                             }
                             if ($users->select("[login='" . $user_login . "']")) {
                                 $errors['users_this_user_already_exists'] = __('This user already exists', 'users');
                             }
                             if ($users->select("[email='" . $user_email . "']")) {
                                 $errors['users_this_email_already_exists'] = __('This email already exists', 'users');
                             }
                             if (count($errors) == 0) {
                                 if ($users->insert(array('login' => Security::safeName($user_login), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => Request::post('role')))) {
                                     Notification::set('success', __('New user have been registered.', 'users'));
                                 } else {
                                     Notification::set('error', __('New user was not registered.', 'users'));
                                 }
                                 Request::redirect('index.php?id=users');
                             }
                         } else {
                             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                         }
                     }
                     // Display view
                     View::factory('box/users/views/backend/add')->assign('roles', $roles)->assign('errors', $errors)->display();
                 } else {
                     Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
                 }
                 break;
                 // Edit
                 // -------------------------------------
             // Edit
             // -------------------------------------
             case "edit":
                 // Get current user record
                 $user = $users->select("[id='" . (int) Request::get('user_id') . "']", null);
                 if (isset($user['firstname'])) {
                     $user_firstname = $user['firstname'];
                 } else {
                     $user_firstname = '';
                 }
                 if (isset($user['lastname'])) {
                     $user_lastname = $user['lastname'];
                 } else {
                     $user_lastname = '';
                 }
                 if (isset($user['email'])) {
                     $user_email = $user['email'];
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:users.admin.php

示例7: main

 /**
  * Main function
  */
 public static function main()
 {
     // Array of forbidden types
     $forbidden_types = array('html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'shtml', 'jhtml', 'pl', 'py', 'cgi', 'sh', 'ksh', 'bsh', 'c', 'htaccess', 'htpasswd', 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', 'empty');
     // Array of image types
     $image_types = array('jpg', 'png', 'bmp', 'gif', 'tif');
     // Get Site url
     $site_url = Option::get('siteurl');
     // Init vars
     if (Request::get('path')) {
         $path = Request::get('path');
     } else {
         $path = 'uploads/';
     }
     // Add slash if not exists
     if (substr($path, -1, 1) != '/') {
         $path .= '/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Upload corectly!
     if ($path == 'uploads' || $path == 'uploads//') {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Only 'uploads' folder!
     if (strpos($path, 'uploads') === false) {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Set default path value if path is empty
     if ($path == '') {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     $files_path = ROOT . DS . 'public' . DS . $path;
     $current = explode('/', $path);
     // Delete file
     // -------------------------------------
     if (Request::get('id') == 'filesmanager' && Request::get('delete_file')) {
         if (Security::check(Request::get('token'))) {
             File::delete($files_path . Request::get('delete_file'));
             if (!is_file($files_path . Request::get('delete_file'))) {
                 Notification::set('success', __('File was deleted', 'filesmanager'));
             } else {
                 Notification::set('error', __('File was not deleted', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Delete dir
     // -------------------------------------
     if (Request::get('id') == 'filesmanager' && Request::get('delete_dir')) {
         if (Security::check(Request::get('token'))) {
             Dir::delete($files_path . Request::get('delete_dir'));
             if (!is_dir($files_path . Request::get('delete_dir'))) {
                 Notification::set('success', __('Directory was deleted', 'filesmanager'));
             } else {
                 Notification::set('error', __('Directory was not deleted', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Rename file/dir
     // -------------------------------------
     if (Request::post('rename_type')) {
         if (Security::check(Request::post('csrf'))) {
             $rename_type = Request::post('rename_type');
             $rename_from = Request::post('rename_from');
             $rename_to = Request::post('rename_to');
             if (empty($rename_to)) {
                 Notification::set('error', __('Can not be empty', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             $ext = $rename_type === 'file' ? '.' . File::ext($rename_from) : '';
             $rename_to = $files_path . Security::safeName($rename_to, null, false) . $ext;
             if (is_dir($rename_to)) {
                 Notification::set('error', __('Directory exists', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             if (is_file($rename_to)) {
                 Notification::set('error', __('File exists', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             $success = rename($files_path . $rename_from, $rename_to);
             if ($success) {
                 Notification::set('success', __('Renamed successfully', 'filesmanager'));
             } else {
                 Notification::set('error', __('Failure', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:filesmanager.admin.php

示例8: getProfileEdit

 /**
  * Edit user profile
  */
 public static function getProfileEdit($id)
 {
     // Is Current User Loged in ?
     if (Users::isLoged()) {
         $user = Users::$users->select("[id='" . (int) $id . "']", null);
         // Edit Profile Submit
         if (Request::post('edit_profile')) {
             // Check csrf
             if (Security::check(Request::post('csrf'))) {
                 if (Security::safeName(Request::post('login')) != '') {
                     if (Users::$users->update(Request::post('user_id'), array('login' => Security::safeName(Request::post('login')), 'firstname' => Request::post('firstname'), 'lastname' => Request::post('lastname'), 'email' => Request::post('email'), 'skype' => Request::post('skype'), 'about_me' => Request::post('about_me'), 'twitter' => Request::post('twitter')))) {
                         // Change password
                         if (trim(Request::post('new_password')) != '') {
                             Users::$users->update(Request::post('user_id'), array('password' => Security::encryptPassword(trim(Request::post('new_password')))));
                         }
                         Notification::set('success', __('Your changes have been saved.', 'users'));
                         Request::redirect(Site::url() . '/users/' . $user['id']);
                     }
                 } else {
                 }
             } else {
                 die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
             }
         }
         View::factory('box/users/views/frontend/edit')->assign('user', $user)->display();
     } else {
         Request::redirect(Site::url() . '/users/login');
     }
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:32,代码来源:users.plugin.php

示例9: main

 /**
  * Pages admin function
  */
 public static function main()
 {
     $current_theme = Option::get('theme_site_name');
     $site_url = Option::get('siteurl');
     $templates_path = THEMES_SITE;
     $errors = array();
     $pages = new Table('pages');
     PagesAdmin::$pages = $pages;
     $users = new Table('users');
     $user = $users->select('[id=' . Session::get('user_id') . ']', null);
     // Page author
     if (!empty($user['firstname'])) {
         $author = empty($user['lastname']) ? $user['firstname'] : $user['firstname'] . ' ' . $user['lastname'];
     } else {
         $author = Session::get('user_login');
     }
     $author = Html::toText($author);
     // Status array
     $status_array = array('published' => __('Published', 'pages'), 'draft' => __('Draft', 'pages'));
     // Access array
     $access_array = array('public' => __('Public', 'pages'), 'registered' => __('Registered', 'pages'));
     // Check for get actions
     // ---------------------------------------------
     if (Request::get('action')) {
         // Switch actions
         // -----------------------------------------
         switch (Request::get('action')) {
             // Clone page
             // -------------------------------------
             case "clone_page":
                 if (Security::check(Request::get('token'))) {
                     // Generate rand page name
                     $rand_page_name = Request::get('name') . '_clone_' . date("Ymd_His");
                     // Get original page
                     $orig_page = $pages->select('[slug="' . Request::get('name') . '"]', null);
                     // Generate rand page title
                     $rand_page_title = $orig_page['title'] . ' [copy]';
                     // Clone page
                     if ($pages->insert(array('slug' => $rand_page_name, 'template' => $orig_page['template'], 'parent' => $orig_page['parent'], 'robots_index' => $orig_page['robots_index'], 'robots_follow' => $orig_page['robots_follow'], 'status' => $orig_page['status'], 'access' => isset($orig_page['access']) ? $orig_page['access'] : 'public', 'expand' => isset($orig_page['expand']) ? $orig_page['expand'] : '0', 'title' => $rand_page_title, 'meta_title' => $orig_page['meta_title'], 'description' => $orig_page['description'], 'keywords' => $orig_page['keywords'], 'tags' => $orig_page['tags'], 'date' => $orig_page['date'], 'author' => $orig_page['author']))) {
                         // Get cloned page ID
                         $last_id = $pages->lastId();
                         // Save cloned page content
                         File::setContent(STORAGE . DS . 'pages' . DS . $last_id . '.page.txt', File::getContent(STORAGE . DS . 'pages' . DS . $orig_page['id'] . '.page.txt'));
                         // Send notification
                         Notification::set('success', __('The page <i>:page</i> cloned.', 'pages', array(':page' => Security::safeName(Request::get('name'), '-', true))));
                     }
                     // Run add extra actions
                     Action::run('admin_pages_action_clone');
                     // Redirect
                     Request::redirect('index.php?id=pages');
                 } else {
                     die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
                 }
                 break;
                 // Add page
                 // -------------------------------------
             // Add page
             // -------------------------------------
             case "add_page":
                 // Add page
                 if (Request::post('add_page') || Request::post('add_page_and_exit')) {
                     if (Security::check(Request::post('csrf'))) {
                         // Get parent page
                         if (Request::post('pages') == '0') {
                             $parent_page = '';
                         } else {
                             $parent_page = Request::post('pages');
                         }
                         // Validate
                         //--------------
                         if (trim(Request::post('page_name')) == '') {
                             $errors['pages_empty_name'] = __('Required field', 'pages');
                         }
                         if (trim(Request::post('page_title')) == '') {
                             $errors['pages_empty_title'] = __('Required field', 'pages');
                         }
                         if (count($pages->select('[slug="' . Security::safeName(Request::post('page_name'), '-', true) . '"]')) != 0) {
                             $errors['pages_exists'] = __('This page already exists', 'pages');
                         }
                         // Prepare date
                         if (Valid::date(Request::post('page_date'))) {
                             $date = strtotime(Request::post('page_date'));
                         } else {
                             $date = time();
                         }
                         if (Request::post('robots_index')) {
                             $robots_index = 'noindex';
                         } else {
                             $robots_index = 'index';
                         }
                         if (Request::post('robots_follow')) {
                             $robots_follow = 'nofollow';
                         } else {
                             $robots_follow = 'follow';
                         }
                         // If no errors then try to save
                         if (count($errors) == 0) {
//.........这里部分代码省略.........
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:101,代码来源:pages.admin.php

示例10: _createInlineBlock

 /**
  * Create Inline Block
  */
 public static function _createInlineBlock($attributes, $content)
 {
     if (isset($attributes['name'])) {
         Block::$inline_blocks[Security::safeName($attributes['name'], '_', true)] = array('content' => (string) $content);
     }
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:9,代码来源:blocks.plugin.php


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