本文整理汇总了PHP中Rewrite::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Rewrite::newInstance方法的具体用法?PHP Rewrite::newInstance怎么用?PHP Rewrite::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rewrite
的用法示例。
在下文中一共展示了Rewrite::newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
function doModel()
{
switch ($this->action) {
case 'login_post':
//post execution for the login
if (!osc_users_enabled()) {
osc_add_flash_error_message(_m('Users are not enabled'));
$this->redirectTo(osc_base_url());
}
osc_csrf_check();
osc_run_hook('before_validating_login');
// e-mail or/and password is/are empty or incorrect
$wrongCredentials = false;
$email = Params::getParam('email');
$password = Params::getParam('password', false, false);
if ($email == '') {
osc_add_flash_error_message(_m('Please provide an email address'));
$wrongCredentials = true;
}
if ($password == '') {
osc_add_flash_error_message(_m('Empty passwords are not allowed. Please provide a password'));
$wrongCredentials = true;
}
if ($wrongCredentials) {
$this->redirectTo(osc_user_login_url());
}
if (osc_validate_email($email)) {
$user = User::newInstance()->findByEmail($email);
}
if (empty($user)) {
$user = User::newInstance()->findByUsername($email);
}
if (empty($user)) {
osc_add_flash_error_message(_m("The user doesn't exist"));
$this->redirectTo(osc_user_login_url());
}
if (!osc_verify_password($password, isset($user['s_password']) ? $user['s_password'] : '')) {
osc_add_flash_error_message(_m('The password is incorrect'));
$this->redirectTo(osc_user_login_url());
// @TODO if valid user, send email parameter back to the login form
} else {
if (@$user['s_password'] != '') {
if (preg_match('|\\$2y\\$([0-9]{2})\\$|', $user['s_password'], $cost)) {
if ($cost[1] != BCRYPT_COST) {
User::newInstance()->update(array('s_password' => osc_hash_password($password)), array('pk_i_id' => $user['pk_i_id']));
}
} else {
User::newInstance()->update(array('s_password' => osc_hash_password($password)), array('pk_i_id' => $user['pk_i_id']));
}
}
}
// e-mail or/and IP is/are banned
$banned = osc_is_banned($email);
// int 0: not banned or unknown, 1: email is banned, 2: IP is banned, 3: both email & IP are banned
if ($banned & 1) {
osc_add_flash_error_message(_m('Your current email is not allowed'));
}
if ($banned & 2) {
osc_add_flash_error_message(_m('Your current IP is not allowed'));
}
if ($banned !== 0) {
$this->redirectTo(osc_user_login_url());
}
osc_run_hook('before_login');
$url_redirect = osc_get_http_referer();
$page_redirect = '';
if (osc_rewrite_enabled()) {
if ($url_redirect != '') {
$request_uri = urldecode(preg_replace('@^' . osc_base_url() . '@', "", $url_redirect));
$tmp_ar = explode("?", $request_uri);
$request_uri = $tmp_ar[0];
$rules = Rewrite::newInstance()->listRules();
foreach ($rules as $match => $uri) {
if (preg_match('#' . $match . '#', $request_uri, $m)) {
$request_uri = preg_replace('#' . $match . '#', $uri, $request_uri);
if (preg_match('|([&?]{1})page=([^&]*)|', '&' . $request_uri . '&', $match)) {
$page_redirect = $match[2];
if ($page_redirect == '' || $page_redirect == 'login') {
$url_redirect = osc_user_dashboard_url();
}
}
break;
}
}
}
}
require_once LIB_PATH . 'osclass/UserActions.php';
$uActions = new UserActions(false);
$logged = $uActions->bootstrap_login($user['pk_i_id']);
if ($logged == 0) {
osc_add_flash_error_message(_m("The user doesn't exist"));
} else {
if ($logged == 1) {
if (time() - strtotime($user['dt_access_date']) > 1200) {
// EACH 20 MINUTES
osc_add_flash_error_message(sprintf(_m('The user has not been validated yet. Would you like to re-send your <a href="%s">activation?</a>'), osc_user_resend_activation_link($user['pk_i_id'], $user['s_email'])));
} else {
osc_add_flash_error_message(_m('The user has not been validated yet'));
}
} else {
//.........这里部分代码省略.........
示例2: osc_get_osclass_section
/**
* Get section
*
* @return string
*/
function osc_get_osclass_section()
{
return Rewrite::newInstance()->get_section();
}
示例3: do410
function do410()
{
Rewrite::newInstance()->set_location('error');
header('HTTP/1.1 410 Gone');
osc_current_web_theme_path('404.php');
exit;
}
示例4: addTableHeader
private function addTableHeader()
{
$arg_date = '&sort=date';
if (Params::getParam('sort') == 'date') {
if (Params::getParam('direction') == 'desc') {
$arg_date .= '&direction=asc';
}
}
$arg_item = '&sort=attached_to';
if (Params::getParam('sort') == 'attached_to') {
if (Params::getParam('direction') == 'desc') {
$arg_item .= '&direction=asc';
}
}
Rewrite::newInstance()->init();
$page = (int) Params::getParam('iPage');
if ($page == 0) {
$page = 1;
}
Params::setParam('iPage', $page);
$url_base = preg_replace('|&direction=([^&]*)|', '', preg_replace('|&sort=([^&]*)|', '', osc_base_url() . Rewrite::newInstance()->get_raw_request_uri()));
$this->addColumn('bulkactions', '<input id="check_all" type="checkbox" />');
$this->addColumn('file', __('File'));
$this->addColumn('action', __('Action'));
$this->addColumn('attached_to', '<a href="' . osc_esc_html($url_base . $arg_item) . '">' . __('Attached to') . '</a>');
$this->addColumn('date', '<a href="' . osc_esc_html($url_base . $arg_date) . '">' . __('Date') . '</a>');
$dummy =& $this;
osc_run_hook("admin_media_table", $dummy);
}
示例5: item_success_item_validate
function item_success_item_validate()
{
if (Params::getParam('page') == 'item' && Params::getParam('action') == 'activate') {
$secret = Params::getParam('secret');
$id = Params::getParam('id');
$item = Item::newInstance()->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s') OR (i.fk_i_user_id = '%d'))", addslashes($id), addslashes($secret), addslashes(osc_logged_user_id()));
// item doesn't exist
if (count($item) == 0) {
Rewrite::newInstance()->set_location('error');
header('HTTP/1.1 404 Not Found');
osc_current_web_theme_path('404.php');
exit;
}
View::newInstance()->_exportVariableToView('item', $item[0]);
if ($item[0]['b_active'] == 0) {
// ACTIVETE ITEM
$mItems = new ItemActions(false);
$success = $mItems->activate($item[0]['pk_i_id'], $item[0]['s_secret']);
if ($success) {
osc_add_flash_ok_message(_m('The listing has been validated'));
item_success_redirect(Item::newInstance()->findByPrimaryKey($item[0]['pk_i_id']));
exit;
} else {
osc_add_flash_error_message(_m("The listing can't be validated"));
}
} else {
osc_add_flash_warning_message(_m('The listing has already been validated'));
}
osc_redirect_to(osc_item_url());
}
}
示例6: __construct
public function __construct($lang = array())
{
$this->location = Rewrite::newInstance()->get_location();
$this->section = Rewrite::newInstance()->get_section();
$this->aLevel = array();
$this->setTitles($lang);
}
示例7: social_bookmarks_header
function social_bookmarks_header()
{
$location = Rewrite::newInstance()->get_location();
$section = Rewrite::newInstance()->get_section();
if ($location == 'item' && $section == '') {
echo '
<style type="text/css">
.social-bookmarks ul { margin: 10px 0; list-style: none; }
.social-bookmarks ul li { float: left; }
.social-bookmarks .clear { clear:both; }
</style>';
}
}
示例8: doModel
function doModel()
{
$user_menu = false;
if(Params::existParam('route')) {
$routes = Rewrite::newInstance()->getRoutes();
$rid = Params::getParam('route');
$file = '../';
if(isset($routes[$rid]) && isset($routes[$rid]['file'])) {
$file = $routes[$rid]['file'];
$user_menu = $routes[$rid]['user_menu'];
}
} else {
// DEPRECATED: Disclosed path in URL is deprecated, use routes instead
// This will be REMOVED in 3.4
$file = Params::getParam('file');
}
// valid file?
if( strpos($file, '../') !== false || strpos($file, '..\\') !==false || stripos($file, '/admin/') !== false ) { //If the file is inside an "admin" folder, it should NOT be opened in frontend
$this->do404();
return;
}
// check if the file exists
if( !file_exists(osc_plugins_path() . $file) ) {
$this->do404();
return;
}
osc_run_hook('custom_controller');
$this->_exportVariableToView('file', $file);
if($user_menu) {
if(osc_is_web_user_logged_in()) {
Params::setParam('in_user_menu', true);
$this->doView('user-custom.php');
} else {
$this->redirectTo(osc_user_login_url());
}
} else {
$this->doView('custom.php');
}
}
示例9: payment_pro_show_item
function payment_pro_show_item($item)
{
if (osc_get_preference("pay_per_post", 'payment_pro') == "1" && !ModelPaymentPro::newInstance()->publishFeeIsPaid($item['pk_i_id'])) {
if (osc_is_admin_user_logged_in()) {
osc_get_flash_message('pubMessages', true);
osc_add_flash_warning_message(__('The listing hasn\'t been paid', 'payment_pro'));
} else {
if (osc_is_web_user_logged_in() && osc_logged_user_id() == $item['fk_i_user_id']) {
osc_get_flash_message('pubMessages', true);
osc_add_flash_warning_message(sprintf(__('To make this listing available to others, you need to pay a publish fee. <a href="%s">Continue and make the ad public</a>', 'payment_pro'), osc_route_url('payment-pro-user-menu')));
} else {
ob_get_clean();
Rewrite::newInstance()->set_location('error');
header('HTTP/1.1 400 Bad Request');
osc_current_web_theme_path('404.php');
exit;
}
}
}
}
示例10: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'add':
$this->doView("appearance/add.php");
break;
case 'add_post':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=appearance');
}
osc_csrf_check();
$filePackage = Params::getFiles('package');
if (isset($filePackage['size']) && $filePackage['size'] != 0) {
$path = osc_themes_path();
(int) ($status = osc_unzip_file($filePackage['tmp_name'], $path));
@unlink($filePackage['tmp_name']);
} else {
$status = 3;
}
switch ($status) {
case 0:
$msg = _m('The theme folder is not writable');
osc_add_flash_error_message($msg, 'admin');
break;
case 1:
$msg = _m('The theme has been installed correctly');
osc_add_flash_ok_message($msg, 'admin');
break;
case 2:
$msg = _m('The zip file is not valid');
osc_add_flash_error_message($msg, 'admin');
break;
case 3:
$msg = _m('No file was uploaded');
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=add");
break;
case -1:
default:
$msg = _m('There was a problem adding the theme');
osc_add_flash_error_message($msg, 'admin');
break;
}
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance");
break;
case 'delete':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=appearance');
}
osc_csrf_check();
$theme = Params::getParam('webtheme');
if ($theme != '') {
if ($theme != osc_current_web_theme()) {
if (file_exists(osc_content_path() . "themes/" . $theme . "/functions.php")) {
include osc_content_path() . "themes/" . $theme . "/functions.php";
}
osc_run_hook("theme_delete_" . $theme);
if (osc_deleteDir(osc_content_path() . "themes/" . $theme . "/")) {
osc_add_flash_ok_message(_m("Theme removed successfully"), "admin");
} else {
osc_add_flash_error_message(_m("There was a problem removing the theme"), "admin");
}
} else {
osc_add_flash_error_message(_m("Current theme can not be deleted"), "admin");
}
} else {
osc_add_flash_error_message(_m("No theme selected"), "admin");
}
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance");
break;
/* widgets */
/* widgets */
case 'widgets':
$info = WebThemes::newInstance()->loadThemeInfo(osc_theme());
$this->_exportVariableToView("info", $info);
$this->doView('appearance/widgets.php');
break;
case 'add_widget':
$this->doView('appearance/add_widget.php');
break;
case 'edit_widget':
$id = Params::getParam('id');
$widget = Widget::newInstance()->findByPrimaryKey($id);
$this->_exportVariableToView("widget", $widget);
$this->doView('appearance/add_widget.php');
break;
case 'delete_widget':
osc_csrf_check();
Widget::newInstance()->delete(array('pk_i_id' => Params::getParam('id')));
osc_add_flash_ok_message(_m('Widget removed correctly'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
break;
case 'edit_widget_post':
osc_csrf_check();
if (!osc_validate_text(Params::getParam("description"))) {
osc_add_flash_error_message(_m('Description field is required'), 'admin');
//.........这里部分代码省略.........
示例11: do404
function do404()
{
Rewrite::newInstance()->set_location('error');
header('HTTP/1.1 404 Not Found');
osc_current_web_theme_path('404.php');
}
示例12: meta_title
function meta_title()
{
$location = Rewrite::newInstance()->get_location();
$section = Rewrite::newInstance()->get_section();
$text = '';
switch ($location) {
case 'item':
switch ($section) {
case 'item_add':
$text = __('Publish a listing');
break;
case 'item_edit':
$text = __('Edit your listing');
break;
case 'send_friend':
$text = __('Send to a friend') . ' - ' . osc_item_title();
break;
case 'contact':
$text = __('Contact seller') . ' - ' . osc_item_title();
break;
default:
$text = osc_item_title() . ' ' . osc_item_city();
break;
}
break;
case 'page':
$text = osc_static_page_title();
break;
case 'error':
$text = __('Error');
break;
case 'search':
$region = osc_search_region();
$city = osc_search_city();
$pattern = osc_search_pattern();
$category = osc_search_category_id();
$s_page = '';
$i_page = Params::getParam('iPage');
if ($i_page != '' && $i_page > 1) {
$s_page = ' - ' . __('page') . ' ' . $i_page;
}
$b_show_all = $region == '' && $city == '' && $pattern == '' && empty($category);
$b_category = !empty($category);
$b_pattern = $pattern != '';
$b_city = $city != '';
$b_region = $region != '';
if ($b_show_all) {
$text = __('Show all listings') . ' - ' . $s_page . osc_page_title();
}
$result = '';
if ($b_pattern) {
$result .= $pattern . ' » ';
}
if ($b_category && is_array($category) && count($category) > 0) {
$cat = Category::newInstance()->findByPrimaryKey($category[0]);
if ($cat) {
$result .= $cat['s_name'] . ' ';
}
}
if ($b_city) {
$result .= $city . ' » ';
} else {
if ($b_region) {
$result .= $region . ' » ';
}
}
$result = preg_replace('|\\s?»\\s$|', '', $result);
if ($result == '') {
$result = __('Search results');
}
$text = '';
if (osc_get_preference('seo_title_keyword') != '') {
$text .= osc_get_preference('seo_title_keyword') . ' ';
}
$text .= $result . $s_page;
break;
case 'login':
switch ($section) {
case 'recover':
$text = __('Recover your password');
default:
$text = __('Login');
}
break;
case 'register':
$text = __('Create a new account');
break;
case 'user':
switch ($section) {
case 'dashboard':
$text = __('Dashboard');
break;
case 'items':
$text = __('Manage my listings');
break;
case 'alerts':
$text = __('Manage my alerts');
break;
case 'profile':
$text = __('Update my profile');
//.........这里部分代码省略.........
示例13: addTableHeaderReported
private function addTableHeaderReported()
{
Rewrite::newInstance()->init();
$page = (int)Params::getParam('iPage');
if($page==0) { $page = 1; };
Params::setParam('iPage', $page);
$url_base = preg_replace('|&direction=([^&]*)|', '', preg_replace('|&sort=([^&]*)|', '', osc_base_url().Rewrite::newInstance()->get_raw_request_uri()));
$arg_spam = '&sort=spam'; $arg_bad = '&sort=bad';
$arg_rep = '&sort=rep'; $arg_off = '&sort=off';
$arg_exp = '&sort=exp'; $arg_date = '&sort=date';
$arg_expiration = '&sort=expiration';
$sort = Params::getParam("sort");
$direction = Params::getParam("direction");
switch ($sort) {
case('spam'):
if($direction == 'desc' || $direction == '') $arg_spam .= '&direction=asc';
break;
case('bad'):
if($direction == 'desc' || $direction == '') $arg_bad .= '&direction=asc';
break;
case('rep'):
if($direction == 'desc' || $direction == '') $arg_rep .= '&direction=asc';
break;
case('off'):
if($direction == 'desc' || $direction == '') $arg_off .= '&direction=asc';
break;
case('exp'):
if($direction == 'desc' || $direction == '') $arg_exp .= '&direction=asc';
break;
case('date'):
if($direction == 'desc' || $direction == '') $arg_date .= '&direction=asc';
break;
case('expiration'):
if($direction == 'desc' || $direction == '') $arg_expiration .= '&direction=asc';
break;
default:
break;
}
$url_spam = $url_base.$arg_spam;
$url_bad = $url_base.$arg_bad;
$url_rep = $url_base.$arg_rep;
$url_off = $url_base.$arg_off;
$url_exp = $url_base.$arg_exp;
$url_date = $url_base.$arg_date;
$url_expiration = $url_base.$arg_expiration;
$this->addColumn('bulkactions', '<input id="check_all" type="checkbox" />');
$this->addColumn('title', __('Title'));
$this->addColumn('user', __('User'));
$this->addColumn('spam', '<a id="order_spam" href="'.osc_esc_html($url_spam).'">'.__('Spam').'</a>');
$this->addColumn('bad', '<a id="order_bad" href="'.osc_esc_html($url_bad).'">'.__('Misclassified').'</a>');
$this->addColumn('rep', '<a id="order_rep" href="'.osc_esc_html($url_rep).'">'.__('Duplicated').'</a>');
$this->addColumn('exp', '<a id="order_exp" href="'.osc_esc_html($url_exp).'">'.__('Expired').'</a>');
$this->addColumn('off', '<a id="order_off" href="'.osc_esc_html($url_off).'">'.__('Offensive').'</a>');
$this->addColumn('date', '<a id="order_date" href="'.osc_esc_html($url_date).'">'.__('Date').'</a>');
$this->addColumn('expiration', '<a id="order_expiration" href="'.osc_esc_html($url_expiration).'">'.__('Expiration date').'</a>');
$dummy = &$this;
osc_run_hook("admin_items_reported_table", $dummy);
}
示例14: doModel
//.........这里部分代码省略.........
osc_set_preference('rewrite_user_recover', $rewrite_user_recover);
}
$rewrite_user_forgot = substr(str_replace('//', '/', Params::getParam('rewrite_user_forgot') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_forgot)) {
$errors += 1;
} else {
osc_set_preference('rewrite_user_forgot', $rewrite_user_forgot);
}
$rewrite_user_change_password = substr(str_replace('//', '/', Params::getParam('rewrite_user_change_password') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_change_password)) {
$errors += 1;
} else {
osc_set_preference('rewrite_user_change_password', $rewrite_user_change_password);
}
$rewrite_user_change_email = substr(str_replace('//', '/', Params::getParam('rewrite_user_change_email') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_change_email)) {
$errors += 1;
} else {
osc_set_preference('rewrite_user_change_email', $rewrite_user_change_email);
}
$rewrite_user_change_username = substr(str_replace('//', '/', Params::getParam('rewrite_user_change_username') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_change_username)) {
$errors += 1;
} else {
osc_set_preference('rewrite_user_change_username', $rewrite_user_change_username);
}
$rewrite_user_change_email_confirm = substr(str_replace('//', '/', Params::getParam('rewrite_user_change_email_confirm') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_change_email_confirm)) {
$errors += 1;
} else {
osc_set_preference('rewrite_user_change_email_confirm', $rewrite_user_change_email_confirm);
}
osc_reset_preferences();
$rewrite = Rewrite::newInstance();
osc_run_hook("before_rewrite_rules", array(&$rewrite));
$rewrite->clearRules();
/*****************************
********* Add rules *********
*****************************/
// Contact rules
$rewrite->addRule('^' . osc_get_preference('rewrite_contact') . '/?$', 'index.php?page=contact');
// Feed rules
$rewrite->addRule('^' . osc_get_preference('rewrite_feed') . '/?$', 'index.php?page=search&sFeed=rss');
$rewrite->addRule('^' . osc_get_preference('rewrite_feed') . '/(.+)/?$', 'index.php?page=search&sFeed=$1');
// Language rules
$rewrite->addRule('^' . osc_get_preference('rewrite_language') . '/(.*?)/?$', 'index.php?page=language&locale=$1');
// Search rules
$rewrite->addRule('^' . $search_url . '$', 'index.php?page=search');
$rewrite->addRule('^' . $search_url . '/(.*)$', 'index.php?page=search&sParams=$1');
// Item rules
$rewrite->addRule('^' . osc_get_preference('rewrite_item_mark') . '/(.*?)/([0-9]+)/?$', 'index.php?page=item&action=mark&as=$1&id=$2');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_send_friend') . '/([0-9]+)/?$', 'index.php?page=item&action=send_friend&id=$1');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_contact') . '/([0-9]+)/?$', 'index.php?page=item&action=contact&id=$1');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_new') . '/?$', 'index.php?page=item&action=item_add');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_new') . '/([0-9]+)/?$', 'index.php?page=item&action=item_add&catId=$1');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_activate') . '/([0-9]+)/(.*?)/?$', 'index.php?page=item&action=activate&id=$1&secret=$2');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_edit') . '/([0-9]+)/(.*?)/?$', 'index.php?page=item&action=item_edit&id=$1&secret=$2');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_delete') . '/([0-9]+)/(.*?)/?$', 'index.php?page=item&action=item_delete&id=$1&secret=$2');
$rewrite->addRule('^' . osc_get_preference('rewrite_item_resource_delete') . '/([0-9]+)/([0-9]+)/([0-9A-Za-z]+)/?(.*?)/?$', 'index.php?page=item&action=deleteResource&id=$1&item=$2&code=$3&secret=$4');
// Item rules
$id_pos = stripos($item_url, '{ITEM_ID}');
$title_pos = stripos($item_url, '{ITEM_TITLE}');
$cat_pos = stripos($item_url, '{CATEGORIES');
$param_pos = 1;
if ($title_pos !== false && $id_pos > $title_pos) {
$param_pos++;
示例15: osclass_pm_is_pmSettings
/**
* Get if user is on user pm settings page
*
* @return boolean
*/
function osclass_pm_is_pmSettings()
{
$location = Rewrite::newInstance()->get_location();
$file = rtrim(Params::getParam('file'), '?');
if ($location == 'custom' && $file == 'osclass_pm/user-pm-settings.php') {
return TRUE;
}
return FALSE;
}