本文整理汇总了PHP中osc_validate_text函数的典型用法代码示例。如果您正苦于以下问题:PHP osc_validate_text函数的具体用法?PHP osc_validate_text怎么用?PHP osc_validate_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osc_validate_text函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
//.........这里部分代码省略.........
osc_add_flash_ok_message(_m('The comment has been approved'), 'admin');
} else {
if ($value == 'INACTIVE') {
$iUpdated = $this->itemCommentManager->update(array('b_active' => 0), array('pk_i_id' => $id));
osc_add_hook("deactivate_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disapproved'), 'admin');
} else {
if ($value == 'ENABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 1), array('pk_i_id' => $id));
osc_add_hook("enable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been enabled'), 'admin');
} else {
if ($value == 'DISABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 0), array('pk_i_id' => $id));
osc_add_hook("disable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disabled'), 'admin');
}
}
}
}
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'comment_edit':
$comment = ItemComment::newInstance()->findByPrimaryKey(Params::getParam('id'));
$this->_exportVariableToView('comment', $comment);
$this->doView('comments/frm.php');
break;
case 'comment_edit_post':
osc_csrf_check();
$msg = '';
if (!osc_validate_email(Params::getParam('authorEmail'), true)) {
$msg .= _m('Email is not correct') . "<br/>";
}
if (!osc_validate_text(Params::getParam('body'), 1, true)) {
$msg .= _m('Comment is required') . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments&action=comment_edit&id=" . Params::getParam('id'));
}
$this->itemCommentManager->update(array('s_title' => Params::getParam('title'), 's_body' => Params::getParam('body'), 's_author_name' => Params::getParam('authorName'), 's_author_email' => Params::getParam('authorEmail')), array('pk_i_id' => Params::getParam('id')));
osc_run_hook('edit_comment', Params::getParam('id'));
osc_add_flash_ok_message(_m('Great! We just updated your comment'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'delete':
osc_csrf_check();
$this->itemCommentManager->deleteByPrimaryKey(Params::getParam('id'));
osc_add_flash_ok_message(_m('The comment has been deleted'), 'admin');
osc_run_hook('delete_comment', Params::getParam('id'));
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
default:
require_once osc_lib_path() . "osclass/classes/datatables/CommentsDataTable.php";
// set default iDisplayLength
if (Params::getParam('iDisplayLength') != '') {
Cookie::newInstance()->push('listing_iDisplayLength', Params::getParam('iDisplayLength'));
Cookie::newInstance()->set();
} else {
// set a default value if it's set in the cookie
if (Cookie::newInstance()->get_value('listing_iDisplayLength') != '') {
Params::setParam('iDisplayLength', Cookie::newInstance()->get_value('listing_iDisplayLength'));
} else {
Params::setParam('iDisplayLength', 10);
}
}
示例2: contact
public function contact()
{
$flash_error = '';
$aItem = $this->prepareDataForFunction( 'contact' );
// check parameters
if ( !osc_validate_text($aItem['yourName']) ){
$flash_error = __("Your name: this field is required") . PHP_EOL;
}
if( !osc_validate_email($aItem['yourEmail'], true) ){
$flash_error .= __("Invalid email address") . PHP_EOL;
}
if( !osc_validate_text($aItem['message']) ){
$flash_error .= __("Message: this field is required") . PHP_EOL;
}
if($flash_error != ''){
return $flash_error;
} else {
osc_run_hook('hook_email_item_inquiry', $aItem);
}
}
示例3: doModel
//.........这里部分代码省略.........
$rewriteEnabled = Params::getParam('rewrite_enabled') ? true : false;
if ($rewriteEnabled) {
Preference::newInstance()->update(array('s_value' => '1'), array('s_name' => 'rewriteEnabled'));
$rewrite_base = REL_WEB_URL;
$htaccess = <<<HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$rewrite_base}
RewriteRule ^index\\.php\$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$rewrite_base}index.php [L]
</IfModule>
HTACCESS;
// 1. OK (ok)
// 2. OK no apache module detected (warning)
// 3. No se puede crear + apache
// 4. No se puede crear + no apache
$status = 3;
if (file_exists($htaccess_file)) {
if (is_writable($htaccess_file) && file_put_contents($htaccess_file, $htaccess)) {
$status = 1;
}
} else {
if (is_writable(osc_base_path()) && file_put_contents($htaccess_file, $htaccess)) {
$status = 1;
}
}
if (!@apache_mod_loaded('mod_rewrite')) {
$status++;
}
$errors = 0;
$item_url = substr(str_replace('//', '/', Params::getParam('rewrite_item_url') . '/'), 0, -1);
if (!osc_validate_text($item_url)) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => $item_url), array('s_name' => 'rewrite_item_url'));
}
$page_url = substr(str_replace('//', '/', Params::getParam('rewrite_page_url') . '/'), 0, -1);
if (!osc_validate_text($page_url)) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => $page_url), array('s_name' => 'rewrite_page_url'));
}
$cat_url = substr(str_replace('//', '/', Params::getParam('rewrite_cat_url') . '/'), 0, -1);
if (!osc_validate_text($cat_url)) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => $cat_url), array('s_name' => 'rewrite_cat_url'));
}
$search_url = substr(str_replace('//', '/', Params::getParam('rewrite_search_url') . '/'), 0, -1);
if (!osc_validate_text($search_url)) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => $search_url), array('s_name' => 'rewrite_search_url'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_country'))) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => Params::getParam('rewrite_search_country')), array('s_name' => 'rewrite_search_country'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_region'))) {
$errors += 1;
} else {
Preference::newInstance()->update(array('s_value' => Params::getParam('rewrite_search_region')), array('s_name' => 'rewrite_search_region'));
}
示例4: doModel
//.........这里部分代码省略.........
$iUpdated = 0;
$languageCode = Params::getParam('pk_c_code');
$enabledWebstie = Params::getParam('b_enabled');
$enabledBackoffice = Params::getParam('b_enabled_bo');
$languageName = Params::getParam('s_name');
$languageShortName = Params::getParam('s_short_name');
$languageDescription = Params::getParam('s_description');
$languageCurrencyFormat = Params::getParam('s_currency_format');
$languageDecPoint = Params::getParam('s_dec_point');
$languageNumDec = Params::getParam('i_num_dec');
$languageThousandsSep = Params::getParam('s_thousands_sep');
$languageDateFormat = Params::getParam('s_date_format');
$languageStopWords = Params::getParam('s_stop_words');
// formatting variables
if (!preg_match('/.{2}_.{2}/', $languageCode)) {
osc_add_flash_error_message(_m('Language id isn\'t in the correct format'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
}
$enabledWebstie = $enabledWebstie != '' ? true : false;
$enabledBackoffice = $enabledBackoffice != '' ? true : false;
$languageName = strip_tags($languageName);
$languageName = trim($languageName);
$languageShortName = strip_tags($languageShortName);
$languageShortName = trim($languageShortName);
$languageDescription = strip_tags($languageDescription);
$languageDescription = trim($languageDescription);
$languageCurrencyFormat = strip_tags($languageCurrencyFormat);
$languageCurrencyFormat = trim($languageCurrencyFormat);
$languageDateFormat = strip_tags($languageDateFormat);
$languageDateFormat = trim($languageDateFormat);
$languageStopWords = strip_tags($languageStopWords);
$languageStopWords = trim($languageStopWords);
$msg = '';
if (!osc_validate_text($languageName)) {
$msg .= _m("Language name field is required") . "<br/>";
}
if (!osc_validate_text($languageShortName)) {
$msg .= _m("Language short name field is required") . "<br/>";
}
if (!osc_validate_text($languageDescription)) {
$msg .= _m("Language description field is required") . "<br/>";
}
if (!osc_validate_text($languageCurrencyFormat)) {
$msg .= _m("Currency format field is required") . "<br/>";
}
if (!osc_validate_int($languageNumDec)) {
$msg .= _m("Number of decimals must only contain numeric characters") . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=languages&action=edit&id=' . $languageCode);
}
$array = array('b_enabled' => $enabledWebstie, 'b_enabled_bo' => $enabledBackoffice, 's_name' => $languageName, 's_short_name' => $languageShortName, 's_description' => $languageDescription, 's_currency_format' => $languageCurrencyFormat, 's_dec_point' => $languageDecPoint, 'i_num_dec' => $languageNumDec, 's_thousands_sep' => $languageThousandsSep, 's_date_format' => $languageDateFormat, 's_stop_words' => $languageStopWords);
$iUpdated = $this->localeManager->update($array, array('pk_c_code' => $languageCode));
if ($iUpdated > 0) {
osc_add_flash_ok_message(sprintf(_m('%s has been updated'), $languageShortName), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
break;
case 'enable_selected':
osc_csrf_check();
$msg = _m('Selected languages have been enabled for the website');
$iUpdated = 0;
$aValues = array('b_enabled' => 1);
$id = Params::getParam('id');
if (!is_array($id)) {
示例5: doModel
function doModel()
{
switch($this->action) {
case('check_updates'):
osc_admin_toolbar_update_themes(true);
osc_admin_toolbar_update_plugins(true);
osc_add_flash_ok_message( _m('Last check') . ': ' . date("Y-m-d H:i") , 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings');
break;
case('update'):
// update index view
osc_csrf_check();
$iUpdated = 0;
$sPageTitle = Params::getParam('pageTitle');
$sPageDesc = Params::getParam('pageDesc');
$sContactEmail = Params::getParam('contactEmail');
$sLanguage = Params::getParam('language');
$sDateFormat = Params::getParam('dateFormat');
$sCurrency = Params::getParam('currency');
$sWeekStart = Params::getParam('weekStart');
$sTimeFormat = Params::getParam('timeFormat');
$sTimezone = Params::getParam('timezone');
$sNumRssItems = Params::getParam('num_rss_items');
$maxLatestItems = Params::getParam('max_latest_items_at_home');
$numItemsSearch = Params::getParam('default_results_per_page');
$contactAttachment = Params::getParam('enabled_attachment');
$selectableParent = Params::getParam('selectable_parent_categories');
$bAutoCron = Params::getParam('auto_cron');
$bMarketSources = (Params::getParam('market_external_sources') != '' ? true: false);
$sAutoUpdate = join("|", Params::getParam('auto_update'));
// preparing parameters
$sPageTitle = trim(strip_tags($sPageTitle));
$sPageDesc = trim(strip_tags($sPageDesc));
$sContactEmail = trim(strip_tags($sContactEmail));
$sLanguage = trim(strip_tags($sLanguage));
$sDateFormat = trim(strip_tags($sDateFormat));
$sCurrency = trim(strip_tags($sCurrency));
$sWeekStart = trim(strip_tags($sWeekStart));
$sTimeFormat = trim(strip_tags($sTimeFormat));
$sNumRssItems = (int) trim(strip_tags($sNumRssItems));
$maxLatestItems = (int) trim(strip_tags($maxLatestItems));
$numItemsSearch = (int) $numItemsSearch;
$contactAttachment = ($contactAttachment != '' ? true : false);
$bAutoCron = ($bAutoCron != '' ? true : false);
$error = "";
$msg = '';
if(!osc_validate_text($sPageTitle)) {
$msg .= _m("Page title field is required")."<br/>";
}
if(!osc_validate_text($sContactEmail)) {
$msg .= _m("Contact email field is required")."<br/>";
}
if(!osc_validate_int($sNumRssItems)) {
$msg .= _m("Number of listings in the RSS has to be a numeric value")."<br/>";
}
if(!osc_validate_int($maxLatestItems)) {
$msg .= _m("Max latest listings has to be a numeric value")."<br/>";
}
if(!osc_validate_int($numItemsSearch)) {
$msg .= _m("Number of listings on search has to be a numeric value")."<br/>";
}
if($msg!='') {
osc_add_flash_error_message( $msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=settings');
}
$iUpdated += osc_set_preference('pageTitle', $sPageTitle);
$iUpdated += osc_set_preference('pageDesc', $sPageDesc);
if( !defined('DEMO') ) {
$iUpdated += osc_set_preference('contactEmail', $sContactEmail);
}
$iUpdated += osc_set_preference('language', $sLanguage);
$iUpdated += osc_set_preference('dateFormat', $sDateFormat);
$iUpdated += osc_set_preference('currency', $sCurrency);
$iUpdated += osc_set_preference('weekStart', $sWeekStart);
$iUpdated += osc_set_preference('timeFormat', $sTimeFormat);
$iUpdated += osc_set_preference('timezone', $sTimezone);
$iUpdated += osc_set_preference('marketAllowExternalSources', $bMarketSources);
$iUpdated += osc_set_preference('auto_update', $sAutoUpdate);
if(is_int($sNumRssItems)) {
$iUpdated += osc_set_preference('num_rss_items', $sNumRssItems);
} else {
if($error != '') $error .= "</p><p>";
$error .= _m('Number of listings in the RSS must be an integer');
}
if(is_int($maxLatestItems)) {
$iUpdated += osc_set_preference('maxLatestItems@home', $maxLatestItems);
} else {
if($error != '') $error .= "</p><p>";
$error .= _m('Number of recent listings displayed at home must be an integer');
}
$iUpdated += osc_set_preference('defaultResultsPerPage@search', $numItemsSearch);
$iUpdated += osc_set_preference('contact_attachment', $contactAttachment);
//.........这里部分代码省略.........
示例6: 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 cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=appearance');
}
$filePackage = Params::getFiles('package');
if (isset($filePackage['size']) && $filePackage['size'] != 0) {
$path = osc_themes_path();
(int) ($status = osc_unzip_file($filePackage['tmp_name'], $path));
} 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 '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':
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':
if (!osc_validate_text(Params::getParam("description"))) {
osc_add_flash_error_message(_m('Description field is required'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
}
$res = Widget::newInstance()->update(array('s_description' => Params::getParam('description'), 's_content' => Params::getParam('content', false, false)), array('pk_i_id' => Params::getParam('id')));
if ($res) {
osc_add_flash_ok_message(_m('Widget updated correctly'), 'admin');
} else {
osc_add_flash_ok_message(_m('Widget cannot be updated correctly'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
break;
case 'add_widget_post':
if (!osc_validate_text(Params::getParam("description"))) {
osc_add_flash_error_message(_m('Description field is required'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
}
Widget::newInstance()->insert(array('s_location' => Params::getParam('location'), 'e_kind' => 'html', 's_description' => Params::getParam('description'), 's_content' => Params::getParam('content', false, false)));
osc_add_flash_ok_message(_m('Widget added correctly'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
break;
case 'activate':
Preference::newInstance()->update(array('s_value' => Params::getParam('theme')), array('s_section' => 'osclass', 's_name' => 'theme'));
osc_add_flash_ok_message(_m('Theme activated correctly'), 'admin');
osc_run_hook("theme_activate", Params::getParam('theme'));
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance");
break;
default:
$themes = WebThemes::newInstance()->getListThemes();
$info = WebThemes::newInstance()->loadThemeInfo(osc_theme());
//preparing variables for the view
$this->_exportVariableToView("themes", $themes);
$this->_exportVariableToView("info", $info);
$this->doView('appearance/index.php');
//.........这里部分代码省略.........
示例7: osc_validate_location
/**
* Validate if exist $city, $region, $country in db
*
* @param string $city
* @param string $region
* @param string $country
* @return boolean
*/
function osc_validate_location($city, $sCity, $region, $sRegion, $country, $sCountry)
{
if (osc_validate_nozero($city) && osc_validate_nozero($region) && osc_validate_text($country, 2)) {
$data = Country::newInstance()->findByCode($country);
$countryId = $data['pk_c_code'];
if ($countryId) {
$data = Region::newInstance()->findByPrimaryKey($region);
$regionId = $data['pk_i_id'];
if ($data['b_active'] == 1) {
$data = City::newInstance()->findByPrimaryKey($city);
if ($data['b_active'] == 1 && $data['fk_i_region_id'] == $regionId && strtolower($data['fk_c_country_code']) == strtolower($countryId)) {
return true;
}
}
}
} else {
if (osc_validate_nozero($region) && osc_validate_text($country, 2) && $sCity != "") {
return true;
} else {
if ($sRegion != "" && osc_validate_text($country, 2) && $sCity != "") {
return true;
} else {
if ($sRegion != "" && $sCountry != "" && $sCity != "") {
return true;
}
}
}
}
return false;
}
示例8: 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');
//.........这里部分代码省略.........
示例9: 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));
} 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 (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');
$this->redirectTo(osc_admin_base_url(true) . "?page=appearance&action=widgets");
}
$res = Widget::newInstance()->update(array('s_description' => Params::getParam('description'), 's_content' => Params::getParam('content', false, false)), array('pk_i_id' => Params::getParam('id')));
if ($res) {
osc_add_flash_ok_message(_m('Widget updated correctly'), 'admin');
//.........这里部分代码省略.........
示例10: doModel
function doModel()
{
switch ($this->action) {
case 'permalinks':
// calling the permalinks view
$htaccess = Params::getParam('htaccess_status');
$file = Params::getParam('file_status');
$this->_exportVariableToView('htaccess', $htaccess);
$this->_exportVariableToView('file', $file);
$this->doView('settings/permalinks.php');
break;
case 'permalinks_post':
// updating permalinks option
osc_csrf_check();
$htaccess_file = osc_base_path() . '.htaccess';
$rewriteEnabled = Params::getParam('rewrite_enabled') ? true : false;
$rewrite_base = REL_WEB_URL;
$htaccess = <<<HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$rewrite_base}
RewriteRule ^index\\.php\$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$rewrite_base}index.php [L]
</IfModule>
HTACCESS;
if ($rewriteEnabled) {
osc_set_preference('rewriteEnabled', '1');
// 1. OK (ok)
// 2. OK no apache module detected (warning)
// 3. No se puede crear + apache
// 4. No se puede crear + no apache
// 5. .htaccess exists, no overwrite
$status = 3;
if (file_exists($htaccess_file)) {
$status = 5;
} else {
if (is_writable(osc_base_path()) && file_put_contents($htaccess_file, $htaccess)) {
$status = 1;
}
}
if (!@apache_mod_loaded('mod_rewrite')) {
$status++;
}
$errors = 0;
$item_url = substr(str_replace('//', '/', Params::getParam('rewrite_item_url') . '/'), 0, -1);
if (!osc_validate_text($item_url)) {
$errors += 1;
} else {
osc_set_preference('rewrite_item_url', $item_url);
}
$page_url = substr(str_replace('//', '/', Params::getParam('rewrite_page_url') . '/'), 0, -1);
if (!osc_validate_text($page_url)) {
$errors += 1;
} else {
osc_set_preference('rewrite_page_url', $page_url);
}
$cat_url = substr(str_replace('//', '/', Params::getParam('rewrite_cat_url') . '/'), 0, -1);
// DEPRECATED: backward compatibility, remove in 3.4
$cat_url = str_replace('{CATEGORY_SLUG}', '{CATEGORY_NAME}', $cat_url);
if (!osc_validate_text($cat_url)) {
$errors += 1;
} else {
osc_set_preference('rewrite_cat_url', $cat_url);
}
$search_url = substr(str_replace('//', '/', Params::getParam('rewrite_search_url') . '/'), 0, -1);
if (!osc_validate_text($search_url)) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_url', $search_url);
}
if (!osc_validate_text(Params::getParam('rewrite_search_country'))) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_country', Params::getParam('rewrite_search_country'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_region'))) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_region', Params::getParam('rewrite_search_region'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_city'))) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_city', Params::getParam('rewrite_search_city'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_city_area'))) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_city_area', Params::getParam('rewrite_search_city_area'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_category'))) {
$errors += 1;
} else {
osc_set_preference('rewrite_search_category', Params::getParam('rewrite_search_category'));
}
if (!osc_validate_text(Params::getParam('rewrite_search_user'))) {
$errors += 1;
} else {
//.........这里部分代码省略.........
示例11: doModel
//.........这里部分代码省略.........
if (!is_numeric($id)) {
return false;
}
if (!in_array($value, array('ACTIVE', 'INACTIVE', 'ENABLE', 'DISABLE'))) {
return false;
}
if ($value == 'ACTIVE') {
$iUpdated = $this->itemCommentManager->update(array('b_active' => 1), array('pk_i_id' => $id));
if ($iUpdated) {
$this->sendCommentActivated($id);
}
osc_add_hook("activate_comment", $id);
osc_add_flash_ok_message(_m('The comment has been approved'), 'admin');
} else {
if ($value == 'INACTIVE') {
$iUpdated = $this->itemCommentManager->update(array('b_active' => 0), array('pk_i_id' => $id));
osc_add_hook("deactivate_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disapproved'), 'admin');
} else {
if ($value == 'ENABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 1), array('pk_i_id' => $id));
osc_add_hook("enable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been enabled'), 'admin');
} else {
if ($value == 'DISABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 0), array('pk_i_id' => $id));
osc_add_hook("disable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disabled'), 'admin');
}
}
}
}
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'comment_edit':
$comment = ItemComment::newInstance()->findByPrimaryKey(Params::getParam('id'));
$this->_exportVariableToView('comment', $comment);
$this->doView('comments/frm.php');
break;
case 'comment_edit_post':
$msg = '';
if (!osc_validate_email(Params::getParam('authorEmail'), true)) {
$msg .= _m('Email is not correct') . "<br/>";
}
if (!osc_validate_text(Params::getParam('body'), 1, true)) {
$msg .= _m('Comment is required') . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments&action=comment_edit&id=" . Params::getParam('id'));
}
$this->itemCommentManager->update(array('s_title' => Params::getParam('title'), 's_body' => Params::getParam('body'), 's_author_name' => Params::getParam('authorName'), 's_author_email' => Params::getParam('authorEmail')), array('pk_i_id' => Params::getParam('id')));
osc_run_hook('edit_comment', Params::getParam('id'));
osc_add_flash_ok_message(_m('Great! We just updated your comment'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'delete':
$this->itemCommentManager->deleteByPrimaryKey(Params::getParam('id'));
osc_add_flash_ok_message(_m('The comment has been deleted'), 'admin');
osc_run_hook('delete_comment', Params::getParam('id'));
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
default:
if (Params::getParam('iDisplayLength') == '') {
Params::setParam('iDisplayLength', 10);
}
// showAll == ''
// -> show all comments filtered
// showAll != ''
// -> show comments which are not
// -> diplayed at frontend
if (Params::getParam('showAll') == '' || Params::getParam('showAll') == '1') {
Params::setParam('showAll', true);
} else {
Params::setParam('showAll', false);
}
$this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
require_once osc_admin_base_path() . 'ajax/comments_processing.php';
$params = Params::getParamsAsArray("get");
$comments_processing = new CommentsProcessingAjax($params);
$aData = $comments_processing->result($params);
$page = (int) Params::getParam('iPage');
if (count($aData['aaData']) == 0 && $page != 1) {
$total = (int) $aData['iTotalDisplayRecords'];
$maxPage = ceil($total / (int) $aData['iDisplayLength']);
$url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
if ($maxPage == 0) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
$this->redirectTo($url);
}
if ($page > 1) {
$url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
$this->redirectTo($url);
}
}
$this->_exportVariableToView('aComments', $aData);
$this->doView('comments/index.php');
break;
}
}
示例12: doModel
//.........这里部分代码省略.........
foreach ($id as $_id) {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 1), array('pk_i_id' => $_id));
if ($iUpdated) {
$this->sendCommentActivated($_id);
}
osc_add_hook("enable_comment", $_id);
}
osc_add_flash_ok_message(_m('The comments have been approved'), 'admin');
break;
case 'disable_all':
foreach ($id as $_id) {
$this->itemCommentManager->update(array('b_enabled' => 0), array('pk_i_id' => $_id));
osc_add_hook("disable_comment", $_id);
}
osc_add_flash_ok_message(_m('The comments have been disapproved'), 'admin');
break;
}
}
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'status':
$id = Params::getParam('id');
$value = Params::getParam('value');
if (!$id) {
return false;
}
$id = (int) $id;
if (!is_numeric($id)) {
return false;
}
if (!in_array($value, array('ACTIVE', 'INACTIVE', 'ENABLE', 'DISABLE'))) {
return false;
}
if ($value == 'ACTIVE') {
$iUpdated = $this->itemCommentManager->update(array('b_active' => 1), array('pk_i_id' => $id));
if ($iUpdated) {
$this->sendCommentActivated($id);
}
osc_add_hook("activate_comment", $id);
osc_add_flash_ok_message(_m('The comment has been approved'), 'admin');
} else {
if ($value == 'INACTIVE') {
$iUpdated = $this->itemCommentManager->update(array('b_active' => 0), array('pk_i_id' => $id));
osc_add_hook("deactivate_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disapproved'), 'admin');
} else {
if ($value == 'ENABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 1), array('pk_i_id' => $id));
osc_add_hook("enable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been enabled'), 'admin');
} else {
if ($value == 'DISABLE') {
$iUpdated = $this->itemCommentManager->update(array('b_enabled' => 0), array('pk_i_id' => $id));
osc_add_hook("disable_comment", $id);
osc_add_flash_ok_message(_m('The comment has been disabled'), 'admin');
}
}
}
}
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'comment_edit':
$comment = ItemComment::newInstance()->findByPrimaryKey(Params::getParam('id'));
$this->_exportVariableToView('comment', $comment);
$this->doView('comments/frm.php');
break;
case 'comment_edit_post':
$msg = '';
if (!osc_validate_email(Params::getParam('authorEmail'), true)) {
$msg .= _m('Email is not correct') . "<br/>";
}
if (!osc_validate_text(Params::getParam('body'), 1, true)) {
$msg .= _m('Comment is required') . "<br/>";
}
if ($msg != '') {
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments&action=comment_edit&id=" . Params::getParam('id'));
}
$this->itemCommentManager->update(array('s_title' => Params::getParam('title'), 's_body' => Params::getParam('body'), 's_author_name' => Params::getParam('authorName'), 's_author_email' => Params::getParam('authorEmail')), array('pk_i_id' => Params::getParam('id')));
osc_run_hook('edit_comment', Params::getParam('id'));
osc_add_flash_ok_message(_m('Great! We just updated your comment'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
case 'delete':
$this->itemCommentManager->deleteByPrimaryKey(Params::getParam('id'));
osc_add_flash_ok_message(_m('The comment have been deleted'), 'admin');
osc_run_hook('delete_comment', Params::getParam('id'));
$this->redirectTo(osc_admin_base_url(true) . "?page=comments");
break;
default:
if (Params::getParam('id') != '') {
$comments = $this->itemCommentManager->getAllComments(Params::getParam('id'));
} else {
$comments = $this->itemCommentManager->getAllComments();
}
$this->_exportVariableToView('comments', $comments);
$this->doView('comments/index.php');
break;
}
}
示例13: doModel
function doModel()
{
switch ($this->action) {
case 'add':
// caliing add view
$this->doView('languages/add.php');
break;
case 'add_post':
// adding a new language
$filePackage = Params::getFiles('package');
if (isset($filePackage['size']) && $filePackage['size'] != 0) {
$path = osc_translations_path();
(int) ($status = osc_unzip_file($filePackage['tmp_name'], $path));
} else {
$status = 3;
}
switch ($status) {
case 0:
$msg = _m('The translation folder is not writable');
osc_add_flash_error_message($msg, 'admin');
break;
case 1:
if (osc_checkLocales()) {
$msg = _m('The language has been installed correctly');
osc_add_flash_ok_message($msg, 'admin');
} else {
$msg = _m('There was a problem adding the language');
osc_add_flash_error_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_warning_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=languages&action=add");
break;
case -1:
default:
$msg = _m('There was a problem adding the language');
osc_add_flash_error_message($msg, 'admin');
break;
}
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
break;
case 'edit':
// editing a language
$sLocale = Params::getParam('id');
if (!preg_match('/.{2}_.{2}/', $sLocale)) {
osc_add_flash_error_message(_m('Language id isn\'t in the correct format'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
}
$aLocale = $this->localeManager->findByPrimaryKey($sLocale);
if (count($aLocale) == 0) {
osc_add_flash_error_message(_m('Language id doesn\'t exist'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
}
$this->_exportVariableToView("aLocale", $aLocale);
$this->doView('languages/frm.php');
break;
case 'edit_post':
// edit language post
$iUpdated = 0;
$languageCode = Params::getParam('pk_c_code');
$enabledWebstie = Params::getParam('b_enabled');
$enabledBackoffice = Params::getParam('b_enabled_bo');
$languageName = Params::getParam('s_name');
$languageShortName = Params::getParam('s_short_name');
$languageDescription = Params::getParam('s_description');
$languageCurrencyFormat = Params::getParam('s_currency_format');
$languageDecPoint = Params::getParam('s_dec_point');
$languageNumDec = Params::getParam('i_num_dec');
$languageThousandsSep = Params::getParam('s_thousands_sep');
$languageDateFormat = Params::getParam('s_date_format');
$languageStopWords = Params::getParam('s_stop_words');
// formatting variables
if (!preg_match('/.{2}_.{2}/', $languageCode)) {
osc_add_flash_error_message(_m('Language id isn\'t in the correct format'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=languages');
}
$enabledWebstie = $enabledWebstie != '' ? true : false;
$enabledBackoffice = $enabledBackoffice != '' ? true : false;
$languageName = strip_tags($languageName);
$languageName = trim($languageName);
$languageShortName = strip_tags($languageShortName);
$languageShortName = trim($languageShortName);
$languageDescription = strip_tags($languageDescription);
$languageDescription = trim($languageDescription);
$languageCurrencyFormat = strip_tags($languageCurrencyFormat);
$languageCurrencyFormat = trim($languageCurrencyFormat);
$languageDateFormat = strip_tags($languageDateFormat);
$languageDateFormat = trim($languageDateFormat);
$languageStopWords = strip_tags($languageStopWords);
$languageStopWords = trim($languageStopWords);
$msg = '';
if (!osc_validate_text($languageName)) {
$msg .= _m("Language name field is required") . "<br/>";
}
//.........这里部分代码省略.........