本文整理汇总了PHP中osc_reset_preferences函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_reset_preferences函数的具体用法?PHP osc_reset_preferences怎么用?PHP osc_reset_preferences使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osc_reset_preferences函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: youtube_update
function youtube_update()
{
// convert version
$version = osc_get_preference('youtube_version', 'youtube');
if ($version == '') {
$version = 12;
}
if ($version < 200) {
$conn = DBConnectionClass::newInstance();
$data = $conn->getOsclassDb();
$dbCommand = new DBCommandClass($data);
$dbCommand->query(sprintf('ALTER TABLE %s ADD COLUMN s_id VARCHAR(15) NOT NULL DEFAULT \'-no-id-\' AFTER s_youtube', YOUTUBE_TABLE));
// update s_id
$dbCommand->select();
$dbCommand->from(YOUTUBE_TABLE);
$rs = $dbCommand->get();
if ($rs !== false) {
$result = $rs->result();
foreach ($result as $video) {
$video_code = youtube_get_code_from_url($video['s_youtube']);
$dbCommand->update(YOUTUBE_TABLE, array('s_id' => $video_code), array('fk_i_item_id' => $video['fk_i_item_id']));
}
}
osc_set_preference('youtube_version', '200', 'youtube', 'STRING');
osc_reset_preferences();
}
}
示例2: classified_theme_install
function classified_theme_install()
{
osc_set_preference('keyword_placeholder', __('ie. PHP Programmer', 'classified'), 'classified');
osc_set_preference('version', '1.0.0', 'classified');
osc_set_preference('default_logo', '1', 'classified');
osc_reset_preferences();
}
示例3: __construct
function __construct()
{
parent::__construct();
osc_run_hook('init_admin');
// check if exist a new version each day
if (time() - osc_last_version_check() > 24 * 3600) {
$data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
$data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
$json = json_decode($data);
if ($json->version > osc_version()) {
osc_set_preference('update_core_json', $data);
} else {
osc_set_preference('update_core_json', '');
}
osc_set_preference('last_version_check', time());
osc_reset_preferences();
}
$config_version = str_replace('.', '', OSCLASS_VERSION);
$config_version = preg_replace('|-.*|', '', $config_version);
if ($config_version > Preference::newInstance()->get('version')) {
if (get_class($this) == 'CAdminTools') {
} else {
if (get_class($this) != 'CAdminUpgrade') {
$this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
}
}
}
}
示例4: __construct
function __construct()
{
parent::__construct();
// check if is moderator and can enter to this page
if ($this->isModerator()) {
if (!in_array($this->page, array('items', 'comments', 'media', 'login', 'admins', 'ajax', 'stats', ''))) {
osc_add_flash_error_message(_m("You don't have enough permissions"), 'admin');
$this->redirectTo(osc_admin_base_url());
}
}
osc_run_hook('init_admin');
// check if exist a new version each day
if (time() - osc_last_version_check() > 24 * 3600) {
$data = osc_file_get_contents('http://osclass.org/latest_version.php?callback=?');
$data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
$json = json_decode($data);
if ($json->version > osc_version()) {
osc_set_preference('update_core_json', $data);
} else {
osc_set_preference('update_core_json', '');
}
osc_set_preference('last_version_check', time());
osc_reset_preferences();
}
$config_version = str_replace('.', '', OSCLASS_VERSION);
$config_version = preg_replace('|-.*|', '', $config_version);
if ($config_version > Preference::newInstance()->get('version')) {
if (get_class($this) == 'CAdminTools') {
} else {
if (get_class($this) != 'CAdminUpgrade') {
$this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
}
}
}
// show messages subscribed
$status_subscribe = Params::getParam('subscribe_osclass');
if ($status_subscribe != '') {
switch ($status_subscribe) {
case -1:
osc_add_flash_error_message(_m('Entered an invalid email'), 'admin');
break;
case 0:
osc_add_flash_warning_message(_m("You're already subscribed"), 'admin');
break;
case 1:
osc_add_flash_ok_message(_m('Subscribed correctly'), 'admin');
break;
default:
osc_add_flash_warning_message(_m("Error subscribing"), 'admin');
break;
}
}
// show donation successful
if (Params::getParam('donation') == 'successful') {
osc_add_flash_ok_message(_m('Thank you very much for your donation'), 'admin');
}
}
示例5: item_success_update_version
function item_success_update_version()
{
$version = osc_get_preference('item_success_version', 'item_success');
if ($version == '') {
$version = 0;
}
if ($version < 110) {
osc_set_preference('item_success_add_meta_og', 'true', 'item_success', 'BOOLEAN');
osc_set_preference('item_success_version', '110', 'item_success', 'STRING');
osc_reset_preferences();
}
}
示例6: __construct
function __construct()
{
parent::__construct();
// check if is moderator and can enter to this page
if( $this->isModerator() ) {
if( !in_array($this->page, osc_apply_filter('moderator_access', array('items', 'comments', 'media', 'login', 'admins', 'ajax', 'stats',''))) ) {
osc_add_flash_error_message(_m("You don't have enough permissions"), 'admin');
$this->redirectTo(osc_admin_base_url());
}
}
osc_run_hook( 'init_admin' );
// check if exist a new version each day
if( (time() - osc_last_version_check()) > (24 * 3600) ) {
$data = osc_file_get_contents('http://osclass.org/latest_version_v1.php?callback=?');
$data = preg_replace('|^\?\((.*?)\);$|', '$01', $data);
$json = json_decode($data);
if( $json->version > osc_version() ) {
osc_set_preference( 'update_core_json', $data );
} else {
osc_set_preference( 'update_core_json', '' );
}
osc_set_preference( 'last_version_check', time() );
osc_reset_preferences();
}
$config_version = str_replace('.', '', OSCLASS_VERSION);
$config_version = preg_replace('|-.*|', '', $config_version);
if( $config_version > osc_get_preference('version') ) {
if(get_class($this) == 'CAdminTools') {
} else {
if(get_class($this) != 'CAdminUpgrade' )
$this->redirectTo(osc_admin_base_url(true) . '?page=upgrade');
}
}
// show donation successful
if( Params::getParam('donation') == 'successful' ) {
osc_add_flash_ok_message(_m('Thank you very much for your donation'), 'admin');
}
// enqueue scripts
osc_enqueue_script('jquery');
osc_enqueue_script('jquery-ui');
osc_enqueue_script('admin-osc');
osc_enqueue_script('admin-ui-osc');
}
示例7: _osc_check_languages_update
function _osc_check_languages_update()
{
$total = 0;
$array = array();
$array_downloaded = array();
$languages = OSCLocale::newInstance()->listAll();
foreach ($languages as $lang) {
if (osc_check_language_update($lang['pk_c_code'], $lang['s_version'])) {
$array[] = $lang['pk_c_code'];
$total++;
}
$array_downloaded[] = $lang['pk_c_code'];
}
osc_set_preference('languages_to_update', json_encode($array));
osc_set_preference('languages_downloaded', json_encode($array_downloaded));
osc_set_preference('languages_update_count', $total);
osc_set_preference('languages_last_version_check', time());
osc_reset_preferences();
return $total;
}
示例8: doModel
function doModel()
{
parent::doModel();
if (time() - (int) osc_market_data_update() > 86400) {
//84600 = 24*60*60
$json = osc_file_get_contents(osc_market_url() . 'categories/', array('api_key' => osc_market_api_connect()));
$data = @json_decode($json, true);
if (is_array($data)) {
osc_set_preference('marketCategories', $json);
osc_set_preference('marketDataUpdate', time());
osc_reset_preferences();
}
}
switch ($this->action) {
case 'buy':
osc_csrf_check();
$json = osc_file_get_contents(osc_market_url() . 'token/', array('api_key' => osc_market_api_connect()));
$data = json_decode($json, true);
osc_redirect_to(Params::getParam('url') . '?token=' . @$data['token']);
break;
case 'purchases':
case 'plugins':
case 'themes':
case 'languages':
$section = $this->action;
$title = array('plugins' => __('Recommended plugins for You'), 'themes' => __('Recommended themes for You'), 'languages' => __('Languages for this version'), 'purchases' => __('My purchases'));
// page number
$marketPage = Params::getParam("mPage");
$url_actual = osc_admin_base_url(true) . '?page=market&action=' . $section . '&mPage=' . $marketPage;
if ($marketPage >= 1) {
$marketPage--;
}
// api
$url = osc_market_url($section) . (Params::getParam('sCategory') != '' ? 'category/' . Params::getParam('sCategory') . '/' : '') . "page/" . $marketPage . '/length/9/';
// default sort
$sort_actual = '';
$sort_download = $url_actual . '&sort=downloads&order=desc';
$sort_updated = $url_actual . '&sort=updated&order=desc';
// sorting options (default)
$_order = 'desc';
$order_download = $_order;
$order_updated = $_order;
$sort = Params::getParam("sort");
$order = Params::getParam("order");
if ($sort == '') {
$sort = 'updated';
}
if ($order == '') {
$order = $_order;
}
$aux = $order == 'desc' ? 'asc' : 'desc';
switch ($sort) {
case 'downloads':
$sort_actual = '&sort=downloads&order=';
$sort_download = $url_actual . $sort_actual . $aux;
$sort_actual .= $order;
$order_download = $order;
// market api call
$url .= 'order/downloads/' . $order;
break;
case 'updated':
$sort_actual = '&sort=updated&order=';
$sort_updated = $url_actual . $sort_actual . $aux;
$sort_actual .= $order;
$order_updated = $order;
// market api call
$url .= 'order/updated/' . $order;
break;
default:
break;
}
// pageSize or length attribute is hardcoded
$out = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));
$array = json_decode($out, true);
$output_pagination = '';
if (is_numeric($array['total']) && $array['total'] > 0) {
$totalPages = ceil($array['total'] / $array['sizePage']);
$pageActual = $array['page'];
$params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => osc_admin_base_url(true) . '?page=market' . '&action=' . $section . '&mPage={PAGE}' . $sort_actual, 'sides' => 5);
// set pagination
$pagination = new Pagination($params);
$output_pagination = $pagination->doPagination();
} else {
$array['total'] = 0;
}
// export variable to view
$this->_exportVariableToView("sort", $sort);
$this->_exportVariableToView("title", $title);
$this->_exportVariableToView("section", $section);
$this->_exportVariableToView("array", $array);
$this->_exportVariableToView("sort_download", $sort_download);
$this->_exportVariableToView("sort_updated", $sort_updated);
$this->_exportVariableToView("order_download", $order_download);
$this->_exportVariableToView("order_updated", $order_updated);
$this->_exportVariableToView("market_categories", json_decode(osc_market_categories(), true));
$this->_exportVariableToView('pagination', $output_pagination);
$this->doView("market/section.php");
break;
default:
$aPlugins = array();
//.........这里部分代码省略.........
示例9: osc_check_languages_update
function osc_check_languages_update( $force = false )
{
$total = 0;
$array = array();
$array_downloaded = array();
// check if exist a new version each day
if( (time() - osc_languages_last_version_check()) > (24 * 3600) || $force ) {
$languages = OSCLocale::newInstance()->listAll();
foreach($languages as $lang) {
if(osc_check_language_update($lang['pk_c_code'], $lang['s_version'] )) {
$array[] = $lang['pk_c_code'];
$total++;
}
$array_downloaded[] = $lang['pk_c_code'];
}
osc_set_preference( 'languages_to_update' , json_encode($array) );
osc_set_preference( 'languages_downloaded', json_encode($array_downloaded) );
osc_set_preference( 'languages_update_count', $total );
osc_set_preference( 'languages_last_version_check', time() );
osc_reset_preferences();
} else {
$total = getPreference('languages_update_count');
}
return $total;
}
示例10: theme_osclasswizards_actions_admin
function theme_osclasswizards_actions_admin()
{
if (Params::getParam('file') == 'oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php') {
if (Params::getParam('donation') == 'successful') {
osc_set_preference('donation', '1', 'osclasswizards_theme');
osc_reset_preferences();
}
}
switch (Params::getParam('action_specific')) {
case 'settings':
osc_set_preference('welcome_message', Params::getParam('welcome_message'), 'osclasswizards_theme');
osc_set_preference('defaultShowAs@all', Params::getParam('defaultShowAs@all'), 'osclasswizards_theme');
osc_set_preference('defaultShowAs@search', Params::getParam('defaultShowAs@all'));
osc_add_flash_ok_message(__('Theme settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php'));
break;
case 'templates_home':
osc_set_preference('show_banner', Params::getParam('show_banner') ? '1' : '0', 'osclasswizards_theme');
osc_set_preference('keyword_placeholder', Params::getParam('keyword_placeholder'), 'osclasswizards_theme');
osc_set_preference('show_search_country', Params::getParam('show_search_country') ? '1' : '0', 'osclasswizards_theme');
osc_set_preference('premium_listings_shown_home', Params::getParam('premium_listings_shown_home'), 'osclasswizards_theme');
osc_set_preference('sub_cat_limit', Params::getParam('sub_cat_limit'), 'osclasswizards_theme');
osc_set_preference('show_popular', Params::getParam('show_popular'), 'osclasswizards_theme');
osc_set_preference('show_popular_regions', Params::getParam('show_popular_regions'), 'osclasswizards_theme');
osc_set_preference('show_popular_cities', Params::getParam('show_popular_cities'), 'osclasswizards_theme');
osc_set_preference('show_popular_searches', Params::getParam('show_popular_searches'), 'osclasswizards_theme');
osc_set_preference('popular_regions_limit', Params::getParam('popular_regions_limit'), 'osclasswizards_theme');
osc_set_preference('popular_cities_limit', Params::getParam('popular_cities_limit'), 'osclasswizards_theme');
osc_set_preference('popular_searches_limit', Params::getParam('popular_searches_limit'), 'osclasswizards_theme');
osc_add_flash_ok_message(__('Templates settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#templates'));
break;
case 'templates_search':
osc_set_preference('premium_listings_shown', Params::getParam('premium_listings_shown'), 'osclasswizards_theme');
osc_add_flash_ok_message(__('Templates settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#templates'));
break;
case 'templates_item_post':
$locations_input_as = Params::getParam('locations_input_as', 'osclasswizards_theme');
$locations_required = Params::getParam('locations_required', 'osclasswizards_theme');
$category_multiple_selects = Params::getParam('category_multiple_selects', 'osclasswizards_theme');
osc_set_preference('title_minimum_length', Params::getParam('title_minimum_length', 'osclasswizards_theme'), 'osclasswizards_theme');
osc_set_preference('description_minimum_length', Params::getParam('description_minimum_length', 'osclasswizards_theme'), 'osclasswizards_theme');
osc_set_preference('locations_input_as', $locations_input_as, 'osclasswizards_theme');
osc_set_preference('locations_required', $locations_required ? '1' : '0', 'osclasswizards_theme');
osc_set_preference('category_multiple_selects', $category_multiple_selects ? '1' : '0', 'osclasswizards_theme');
osc_add_flash_ok_message(__('Templates settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#templates'));
break;
case 'ads_mgmt':
osc_set_preference('header-728x90', trim(Params::getParam('header-728x90', false, false, false)), 'osclasswizards_theme');
osc_set_preference('homepage-728x90', trim(Params::getParam('homepage-728x90', false, false, false)), 'osclasswizards_theme');
osc_set_preference('sidebar-300x250', trim(Params::getParam('sidebar-300x250', false, false, false)), 'osclasswizards_theme');
osc_set_preference('search-results-top-728x90', trim(Params::getParam('search-results-top-728x90', false, false, false)), 'osclasswizards_theme');
osc_set_preference('search-results-middle-728x90', trim(Params::getParam('search-results-middle-728x90', false, false, false)), 'osclasswizards_theme');
osc_add_flash_ok_message(__('Ads management updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#ads'));
break;
case 'categories_icons':
$catsIcons = Params::getParam('cat-icons');
foreach ($catsIcons as $catId => $iconName) {
osc_set_preference('cat-icons-' . $catId, $iconName, 'osclasswizards_theme_cat_icons');
}
osc_add_flash_ok_message(__('Category icons settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#category-icons'));
break;
case 'theme_style':
$color_mode = Params::getParam('theme_color_mode');
osc_set_preference('theme_color_mode', $color_mode, 'osclasswizards_theme');
osc_set_preference('google_fonts', Params::getParam('google_fonts'), 'osclasswizards_theme');
$rtl_view = Params::getParam('rtl_view', 'osclasswizards_theme');
osc_set_preference('rtl_view', $rtl_view ? '1' : '0', 'osclasswizards_theme');
osc_set_preference('custom_css', trim(Params::getParam('custom_css', false, false, false)), 'osclasswizards_theme');
osc_add_flash_ok_message(__('Theme color settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#theme-style'));
break;
case 'facebook':
osc_set_preference('facebook-url', trim(Params::getParam('facebook-url', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-width', trim(Params::getParam('facebook-width', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-height', trim(Params::getParam('facebook-height', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-hidecover', trim(Params::getParam('facebook-hidecover', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-showface', trim(Params::getParam('facebook-showface', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-showpost', trim(Params::getParam('facebook-showpost', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-showitem', trim(Params::getParam('facebook-showitem', false, false, false)), 'osclasswizards_theme');
osc_set_preference('facebook-showsearch', trim(Params::getParam('facebook-showsearch', false, false, false)), 'osclasswizards_theme');
osc_add_flash_ok_message(__('Facebook Page settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/' . OSCLASSWIZARDS_THEME_FOLDER . '/admin/settings.php#facebook'));
break;
case 'upload_favicon':
$package = Params::getFiles('favicon');
if ($package['error'] == UPLOAD_ERR_OK) {
$img = ImageResizer::fromFile($package['tmp_name']);
$ext = $img->getExt();
$logo_name = 'favicon';
$logo_name .= '.' . $ext;
$path = osc_uploads_path() . $logo_name;
$img->saveToFile($path);
osc_set_preference('favicon', $logo_name, 'osclasswizards_theme');
osc_add_flash_ok_message(__('The favicon image has been uploaded correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
} else {
//.........这里部分代码省略.........
示例11: payment_pro_unregister_service
function payment_pro_unregister_service($name)
{
$services = json_decode(osc_get_preference('services', 'payment_pro'), true);
unset($services[$name]);
osc_set_preference('services', json_encode($services), 'payment_pro');
osc_reset_preferences();
}
示例12: doModel
//.........这里部分代码省略.........
} else {
Preference::newInstance()->update(array('s_value' => $rewrite_user_alerts), array('s_name' => 'rewrite_user_alerts'));
}
$rewrite_user_recover = substr(str_replace('//', '/', Params::getParam('rewrite_user_recover') . '/'), 0, -1);
if (!osc_validate_text($rewrite_user_recover)) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => $rewrite_user_recover), array('s_name' => '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 {
Preference::newInstance()->update(array('s_value' => $rewrite_user_forgot), array('s_name' => '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 {
Preference::newInstance()->update(array('s_value' => $rewrite_user_change_password), array('s_name' => '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 {
Preference::newInstance()->update(array('s_value' => $rewrite_user_change_email), array('s_name' => 'rewrite_user_change_email'));
}
$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 {
Preference::newInstance()->update(array('s_value' => $rewrite_user_change_email_confirm), array('s_name' => '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) {
示例13: osc_check_themes_update
function osc_check_themes_update($force = false)
{
$total = 0;
$array = array();
$array_downloaded = array();
// check if exist a new version each day
if (time() - osc_themes_last_version_check() > 24 * 3600 || $force) {
$themes = WebThemes::newInstance()->getListThemes();
foreach ($themes as $theme) {
$info = WebThemes::newInstance()->loadThemeInfo($theme);
if (osc_check_theme_update(@$info['theme_update_uri'], @$info['version'])) {
$array[] = $theme;
$total++;
}
$array_downloaded[] = @$info['theme_update_uri'];
}
osc_set_preference('themes_to_update', json_encode($array));
osc_set_preference('themes_downloaded', json_encode($array_downloaded));
osc_set_preference('themes_update_count', $total);
osc_set_preference('themes_last_version_check', time());
osc_reset_preferences();
} else {
$total = getPreference('themes_update_count');
}
return $total;
}
示例14: theme_flatter_actions_admin
//.........这里部分代码省略.........
$adsenseEnable = Params::getParam('google_adsense');
osc_set_preference('google_adsense', $adsenseEnable ? '1' : '0', 'flatter_theme');
osc_set_preference('ads_pubid', Params::getParam('ads_pubid'), 'flatter_theme');
osc_set_preference('ads_slotid', Params::getParam('ads_slotid'), 'flatter_theme');
osc_add_flash_ok_message(__('Adsense settings updated correctly', 'flatter'), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/flatter/admin/settings.php#adsense'));
break;
case 'footer_settings':
$facebookLink = Params::getParam('facebook_likebox');
$footerLink = Params::getParam('footer_link');
osc_set_preference('facebook_likebox', $facebookLink ? '1' : '0', 'flatter_theme');
osc_set_preference('footer_link', $footerLink ? '1' : '0', 'flatter_theme');
osc_add_flash_ok_message(__('Widgets updated correctly', 'flatter'), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/flatter/admin/settings.php#footerwidget'));
break;
case 'other_settings':
$position1 = Params::getParam('position1_enable');
$position2 = Params::getParam('position2_enable');
$position3 = Params::getParam('position3_enable');
$position4 = Params::getParam('position4_enable');
$position5 = Params::getParam('position5_enable');
$position6 = Params::getParam('position6_enable');
$position7 = Params::getParam('position7_enable');
$position8 = Params::getParam('position8_enable');
$position9 = Params::getParam('position9_enable');
$position10 = Params::getParam('position10_enable');
$positionhide1 = Params::getParam('position1_hide');
$positionhide2 = Params::getParam('position2_hide');
$positionhide3 = Params::getParam('position3_hide');
$positionhide4 = Params::getParam('position4_hide');
$positionhide5 = Params::getParam('position5_hide');
$positionhide6 = Params::getParam('position6_hide');
$positionhide7 = Params::getParam('position7_hide');
$positionhide8 = Params::getParam('position8_hide');
$positionhide9 = Params::getParam('position9_hide');
$positionhide10 = Params::getParam('position10_hide');
osc_set_preference('position1_enable', $position1 ? '1' : '0', 'flatter_theme');
osc_set_preference('position2_enable', $position2 ? '1' : '0', 'flatter_theme');
osc_set_preference('position3_enable', $position3 ? '1' : '0', 'flatter_theme');
osc_set_preference('position4_enable', $position4 ? '1' : '0', 'flatter_theme');
osc_set_preference('position5_enable', $position5 ? '1' : '0', 'flatter_theme');
osc_set_preference('position6_enable', $position6 ? '1' : '0', 'flatter_theme');
osc_set_preference('position7_enable', $position7 ? '1' : '0', 'flatter_theme');
osc_set_preference('position8_enable', $position8 ? '1' : '0', 'flatter_theme');
osc_set_preference('position9_enable', $position9 ? '1' : '0', 'flatter_theme');
osc_set_preference('position10_enable', $position10 ? '1' : '0', 'flatter_theme');
osc_set_preference('position1_hide', $positionhide1 ? '1' : '0', 'flatter_theme');
osc_set_preference('position2_hide', $positionhide2 ? '1' : '0', 'flatter_theme');
osc_set_preference('position3_hide', $positionhide3 ? '1' : '0', 'flatter_theme');
osc_set_preference('position4_hide', $positionhide4 ? '1' : '0', 'flatter_theme');
osc_set_preference('position5_hide', $positionhide5 ? '1' : '0', 'flatter_theme');
osc_set_preference('position6_hide', $positionhide6 ? '1' : '0', 'flatter_theme');
osc_set_preference('position7_hide', $positionhide7 ? '1' : '0', 'flatter_theme');
osc_set_preference('position8_hide', $positionhide8 ? '1' : '0', 'flatter_theme');
osc_set_preference('position9_hide', $positionhide9 ? '1' : '0', 'flatter_theme');
osc_set_preference('position10_hide', $positionhide10 ? '1' : '0', 'flatter_theme');
osc_set_preference('position1_content', Params::getParam('position1_content', false, false), 'flatter_theme');
osc_set_preference('position2_content', Params::getParam('position2_content', false, false), 'flatter_theme');
osc_set_preference('position3_content', Params::getParam('position3_content', false, false), 'flatter_theme');
osc_set_preference('position4_content', Params::getParam('position4_content', false, false), 'flatter_theme');
osc_set_preference('position5_content', Params::getParam('position5_content', false, false), 'flatter_theme');
osc_set_preference('position6_content', Params::getParam('position6_content', false, false), 'flatter_theme');
osc_set_preference('position7_content', Params::getParam('position7_content', false, false), 'flatter_theme');
osc_set_preference('position8_content', Params::getParam('position8_content', false, false), 'flatter_theme');
osc_set_preference('position9_content', Params::getParam('position9_content', false, false), 'flatter_theme');
osc_set_preference('position10_content', Params::getParam('position10_content', false, false), 'flatter_theme');
osc_add_flash_ok_message(__('Settings updated correctly', 'flatter'), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/flatter/admin/settings.php#others'));
break;
case 'upload_logo':
$package = Params::getFiles('logo');
if ($package['error'] == UPLOAD_ERR_OK) {
$img = ImageResizer::fromFile($package['tmp_name']);
$ext = $img->getExt();
$logo_name = 'flatter_logo';
$logo_name .= '.' . $ext;
$path = osc_uploads_path() . $logo_name;
$img->saveToFile($path);
osc_set_preference('logo', $logo_name, 'flatter_theme');
osc_add_flash_ok_message(__('The logo image has been uploaded correctly', 'flatter'), 'admin');
} else {
osc_add_flash_error_message(__("An error has occurred, please try again", 'flatter'), 'admin');
}
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/flatter/admin/settings.php#logo'));
break;
case 'remove':
$logo = osc_get_preference('logo', 'flatter_theme');
$path = osc_uploads_path() . $logo;
if (file_exists($path)) {
@unlink($path);
osc_delete_preference('logo', 'flatter_theme');
osc_reset_preferences();
osc_add_flash_ok_message(__('The logo image has been removed', 'flatter'), 'admin');
} else {
osc_add_flash_error_message(__("Image not found", 'flatter'), 'admin');
}
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/flatter/admin/settings.php#logo'));
break;
}
}
示例15: doModel
//.........这里部分代码省略.........
} else {
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) {