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');
     $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');
 }
Exemple #2
0
 function doModel()
 {
     switch ($this->action) {
         case 'latestsearches':
             //calling the comments settings view
             $this->doView('settings/searches.php');
             break;
         case 'latestsearches_post':
             // updating comment
             osc_csrf_check();
             if (Params::getParam('save_latest_searches') == 'on') {
                 osc_set_preference('save_latest_searches', 1);
             } else {
                 osc_set_preference('save_latest_searches', 0);
             }
             if (Params::getParam('customPurge') == '') {
                 osc_add_flash_error_message(_m('Custom number could not be left empty'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=latestsearches');
             } else {
                 osc_set_preference('purge_latest_searches', Params::getParam('customPurge'));
                 osc_add_flash_ok_message(_m('Last search settings have been updated'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=latestsearches');
             }
             break;
     }
 }
Exemple #3
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add_post':
             if (Params::getParam('field_name') != '') {
                 $field = $this->fieldManager->findByName(Params::getParam('field_name'));
                 if (!isset($field['pk_i_id'])) {
                     $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower(Params::getParam("field_slug"))));
                     $this->fieldManager->insertField(Params::getParam("field_name"), Params::getParam("field_type_new"), $slug, Params::getParam("field_required") == "1" ? 1 : 0, Params::getParam('field_options'), Params::getParam('categories'));
                     osc_add_flash_ok_message(_m("New custom field added"), "admin");
                 } else {
                     osc_add_flash_error_message(_m("Sorry, you already have one field with that name"), "admin");
                 }
             } else {
                 osc_add_flash_error_message(_m("Name can not be empty"), "admin");
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=cfields");
             break;
         default:
             $categories = Category::newInstance()->toTreeAll();
             $selected = array();
             foreach ($categories as $c) {
                 $selected[] = $c['pk_i_id'];
                 foreach ($c['categories'] as $cc) {
                     $selected[] = $cc['pk_i_id'];
                 }
             }
             $this->_exportVariableToView("categories", $categories);
             $this->_exportVariableToView("default_selected", $selected);
             $this->_exportVariableToView("fields", $this->fieldManager->listAll());
             $this->doView("fields/index.php");
     }
 }
Exemple #4
0
function theme_classified_actions_admin()
{
    switch (Params::getParam('action_specific')) {
        case 'upload_logo':
            $package = Params::getFiles('logo');
            if ($package['error'] == UPLOAD_ERR_OK) {
                if (move_uploaded_file($package['tmp_name'], WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) {
                    osc_add_flash_ok_message(__('The logo image has been uploaded correctly', 'classified'), 'admin');
                } else {
                    osc_add_flash_error_message(__("An error has occurred, please try again", 'classified'), 'admin');
                }
            } else {
                osc_add_flash_error_message(__("An error has occurred, please try again", 'classified'), 'admin');
            }
            header('Location: ' . osc_admin_render_theme_url('oc-content/themes/classified/admin/header.php'));
            exit;
            break;
        case 'remove':
            if (file_exists(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) {
                @unlink(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg");
                osc_add_flash_ok_message(__('The logo image has been removed', 'classified'), 'admin');
            } else {
                osc_add_flash_error_message(__("Image not found", 'classified'), 'admin');
            }
            header('Location: ' . osc_admin_render_theme_url('oc-content/themes/classified/admin/header.php'));
            exit;
            break;
    }
}
function adimporter_readxml($file)
{
    $xml = new DOMDocument();
    $xml->load($file);
    $listings = $xml->getElementsByTagName('listing');
    $cat_info = array();
    $meta_info = array();
    $errormsg = '';
    foreach ($listings as $klisting => $listing) {
        list($success, $cat_info, $meta_info) = adimporter_ad($listing, $cat_info, $meta_info);
        if ($success != 2) {
            //2 is the success code for active ads & 1 for inactive
            $errormsg .= sprintf(__("%s (Item %d)", "adimporter"), $success, $klisting) . "<br/>";
        }
        $delete_images = glob(osc_content_path() . "downloads/adimporterimage_*");
        foreach ($delete_images as $img) {
            @unlink($img);
        }
    }
    if ($errormsg != '') {
        osc_add_flash_error_message($errormsg, 'admin');
    } else {
        osc_add_flash_ok_message(__('All ads were imported correctly', 'adimporter'), 'admin');
    }
}
Exemple #6
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'delete':
             $ids = Params::getParam("id");
             if ($ids != '') {
                 foreach ($ids as $id) {
                     osc_deleteResource($id);
                 }
                 $this->resourcesManager->delete(array(DB_CUSTOM_COND => 'pk_i_id IN (' . implode(', ', $ids) . ')'));
             }
             osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . "?page=media");
             break;
         default:
             /*$resourceId = Params::getParam("id");
             
             
                                                     if( $resourceId != '' ) {
                                                         $resources = $this->resourcesManager->getAllResources($resourceId);
                                                     } else {
                                                         $resources = $this->resourcesManager->getAllResources(NULL);
                                                     }
             
                                                     //calling the view...
                                                     $this->_exportVariableToView("resources", $resources) ;
                                                     $this->_exportVariableToView("resourceId", $resourceId) ;*/
             $this->doView('media/index.php');
     }
 }
Exemple #7
0
 function doModel()
 {
     switch ($this->action) {
         case 'advanced':
             //calling the advanced settings view
             $this->doView('settings/advanced.php');
             break;
         case 'advanced_post':
             // updating advanced settings
             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=settings&action=advanced');
             }
             osc_csrf_check();
             $subdomain_type = Params::getParam('e_type');
             if (!in_array($subdomain_type, array('category', 'country', 'region', 'city', 'user'))) {
                 $subdomain_type = '';
             }
             $iUpdated = osc_set_preference('subdomain_type', $subdomain_type);
             $iUpdated += osc_set_preference('subdomain_host', Params::getParam('s_host'));
             if ($iUpdated > 0) {
                 osc_add_flash_ok_message(_m("Advanced settings have been updated"), 'admin');
             }
             osc_calculate_location_slug(osc_subdomain_type());
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=advanced');
             break;
         case 'advanced_cache_flush':
             osc_cache_flush();
             osc_add_flash_ok_message(_m("Cache flushed correctly"), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=advanced');
             break;
     }
 }
Exemple #8
0
 function doModel()
 {
     switch ($this->action) {
         case 'change_email_confirm':
             //change email confirm
             if (Params::getParam('userId') && Params::getParam('code')) {
                 $userManager = new User();
                 $user = $userManager->findByPrimaryKey(Params::getParam('userId'));
                 if ($user['s_pass_code'] == Params::getParam('code') && $user['b_enabled'] == 1) {
                     $userEmailTmp = UserEmailTmp::newInstance()->findByPk(Params::getParam('userId'));
                     $code = osc_genRandomPassword(50);
                     $userManager->update(array('s_email' => $userEmailTmp['s_new_email']), array('pk_i_id' => $userEmailTmp['fk_i_user_id']));
                     Item::newInstance()->update(array('s_contact_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     ItemComment::newInstance()->update(array('s_author_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Alerts::newInstance()->update(array('s_email' => $userEmailTmp['s_new_email']), array('fk_i_user_id' => $userEmailTmp['fk_i_user_id']));
                     Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']);
                     UserEmailTmp::newInstance()->delete(array('s_new_email' => $userEmailTmp['s_new_email']));
                     osc_add_flash_ok_message(_m('Your email has been changed successfully'));
                     $this->redirectTo(osc_user_profile_url());
                 } else {
                     osc_add_flash_error_message(_m('Sorry, the link is not valid'));
                     $this->redirectTo(osc_base_url());
                 }
             } else {
                 osc_add_flash_error_message(_m('Sorry, the link is not valid'));
                 $this->redirectTo(osc_base_url());
             }
             break;
         case 'activate_alert':
             $email = Params::getParam('email');
             $secret = Params::getParam('secret');
             $result = 0;
             if ($email != '' && $secret != '') {
                 $result = Alerts::newInstance()->activate($email, $secret);
             }
             if ($result == 1) {
                 osc_add_flash_ok_message(_m('Alert activated'));
             } else {
                 osc_add_flash_error_message(_m('Ops! There was a problem trying to activate alert. Please contact the administrator'));
             }
             $this->redirectTo(osc_base_url(true));
             break;
         case 'unsub_alert':
             $email = Params::getParam('email');
             $secret = Params::getParam('secret');
             if ($email != '' && $secret != '') {
                 Alerts::newInstance()->delete(array('s_email' => $email, 'S_secret' => $secret));
                 osc_add_flash_ok_message(_m('Unsubscribed correctly'));
             } else {
                 osc_add_flash_error_message(_m('Ops! There was a problem trying to unsubscribe you. Please contact the administrator'));
             }
             $this->redirectTo(osc_base_url());
             break;
         default:
             $this->redirectTo(osc_user_login_url());
             break;
     }
 }
Exemple #9
0
 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');
     }
 }
Exemple #10
0
 function doModel()
 {
     switch ($this->action) {
         case 'contact_post':
             //contact_post
             $yourName = Params::getParam('yourName');
             $yourEmail = Params::getParam('yourEmail');
             $subject = Params::getParam('subject');
             $message = Params::getParam('message');
             if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
                 if (!osc_check_recaptcha()) {
                     osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                     Session::newInstance()->_setForm("yourName", $yourName);
                     Session::newInstance()->_setForm("yourEmail", $yourEmail);
                     Session::newInstance()->_setForm("subject", $subject);
                     Session::newInstance()->_setForm("message_body", $message);
                     $this->redirectTo(osc_contact_url());
                     return false;
                     // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                 }
             }
             if (!preg_match('|.*?@.{2,}\\..{2,}|', $yourEmail)) {
                 osc_add_flash_error_message(_m('Please enter a correct email'));
                 Session::newInstance()->_setForm("yourName", $yourName);
                 Session::newInstance()->_setForm("subject", $subject);
                 Session::newInstance()->_setForm("message_body", $message);
                 $this->redirectTo(osc_contact_url());
             }
             $message = sprintf(__("%s (%s) left this message : %s"), $yourName, $yourEmail, $message);
             $params = array('reply_to' => $yourEmail, 'subject' => '[' . osc_page_title() . '] ' . __('Contact form') . ': ' . $subject, 'to' => osc_contact_email(), 'to_name' => __('Administrator'), 'body' => $message, 'alt_body' => $message);
             if (osc_contact_attachment()) {
                 $attachment = Params::getFiles('attachment');
                 $resourceName = $attachment['name'];
                 $tmpName = $attachment['tmp_name'];
                 $resourceType = $attachment['type'];
                 $path = osc_content_path() . 'uploads/' . time() . '_' . $resourceName;
                 if (!is_writable(osc_content_path() . 'uploads/')) {
                     osc_add_flash_error_message(_m('There have been some errors sending the message'));
                     $this->redirectTo(osc_contact_url());
                 }
                 if (!move_uploaded_file($tmpName, $path)) {
                     unset($path);
                 }
             }
             if (isset($path)) {
                 $params['attachment'] = $path;
             }
             osc_sendMail($params);
             osc_add_flash_ok_message(_m('Your email has been sent properly. Thank you for contacting us!'));
             $this->redirectTo(osc_contact_url());
             break;
         default:
             //contact
             $this->doView('contact.php');
     }
 }
function nm_copypaste_plugin_actions()
{
    $dao_preference = new Preference();
    $option = Params::getParam('nomoreoption');
    if (Params::getParam('file') != 'nm_copypaste_plugin/admin/settings.php') {
        return '';
    }
    if ($option == 'nomoresettings') {
        osc_set_preference('nm_id', Params::getParam("nm_id") ? Params::getParam("nm_id") : '0', 'nm_copypaste_plugin', 'STRING');
        osc_add_flash_ok_message(__('Nomore copy/paste settings has been updated', 'nm_copypaste_plugin'), 'admin');
        osc_redirect_to(osc_admin_render_plugin_url('nm_copypaste_plugin/admin/settings.php'));
    }
}
Exemple #12
0
/**
 * Re-send the flash messages of the given section. Usefull for custom theme/plugins files.
 *
 * @param string $$section
 */
function osc_resend_flash_messages($section = "pubMessages")
{
    $message = Session::newInstance()->_getMessage($section);
    if ($message["type"] == "info") {
        osc_add_flash_info_message($message['msg'], $section);
    } else {
        if ($message["type"] == "ok") {
            osc_add_flash_ok_message($message['msg'], $section);
        } else {
            osc_add_flash_error_message($message['msg'], $section);
        }
    }
}
Exemple #13
0
 function doModel()
 {
     switch ($this->action) {
         case 'spamNbots':
             // calling the spam and bots view
             $akismet_key = osc_akismet_key();
             $akismet_status = 3;
             if ($akismet_key != '') {
                 require_once osc_lib_path() . 'Akismet.class.php';
                 $akismet_obj = new Akismet(osc_base_url(), $akismet_key);
                 $akismet_status = 2;
                 if ($akismet_obj->isKeyValid()) {
                     $akismet_status = 1;
                 }
             }
             View::newInstance()->_exportVariableToView('akismet_status', $akismet_status);
             $this->doView('settings/spamNbots.php');
             break;
         case 'akismet_post':
             // updating spam and bots option
             osc_csrf_check();
             $updated = 0;
             $akismetKey = Params::getParam('akismetKey');
             $akismetKey = trim($akismetKey);
             $updated = osc_set_preference('akismetKey', $akismetKey);
             if ($akismetKey == '') {
                 osc_add_flash_info_message(_m('Your Akismet key has been cleared'), 'admin');
             } else {
                 osc_add_flash_ok_message(_m('Your Akismet key has been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
             break;
         case 'recaptcha_post':
             // updating spam and bots option
             osc_csrf_check();
             $iUpdated = 0;
             $recaptchaPrivKey = Params::getParam('recaptchaPrivKey');
             $recaptchaPrivKey = trim($recaptchaPrivKey);
             $recaptchaPubKey = Params::getParam('recaptchaPubKey');
             $recaptchaPubKey = trim($recaptchaPubKey);
             $iUpdated += osc_set_preference('recaptchaPrivKey', $recaptchaPrivKey);
             $iUpdated += osc_set_preference('recaptchaPubKey', $recaptchaPubKey);
             if ($recaptchaPubKey == '') {
                 osc_add_flash_info_message(_m('Your reCAPTCHA key has been cleared'), 'admin');
             } else {
                 osc_add_flash_ok_message(_m('Your reCAPTCHA key has been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
             break;
     }
 }
Exemple #14
0
 function doModel()
 {
     switch ($this->action) {
         case 'comments':
             //calling the comments settings view
             $this->doView('settings/comments.php');
             break;
         case 'comments_post':
             // updating comment
             osc_csrf_check();
             $iUpdated = 0;
             $enabledComments = Params::getParam('enabled_comments');
             $enabledComments = $enabledComments != '' ? true : false;
             $moderateComments = Params::getParam('moderate_comments');
             $moderateComments = $moderateComments != '' ? true : false;
             $numModerateComments = Params::getParam('num_moderate_comments');
             $commentsPerPage = Params::getParam('comments_per_page');
             $notifyNewComment = Params::getParam('notify_new_comment');
             $notifyNewComment = $notifyNewComment != '' ? true : false;
             $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
             $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
             $regUserPostComments = Params::getParam('reg_user_post_comments');
             $regUserPostComments = $regUserPostComments != '' ? true : false;
             $msg = '';
             if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
                 $msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
             }
             if (!osc_validate_int(Params::getParam("comments_per_page"))) {
                 $msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
             }
             if ($msg != '') {
                 osc_add_flash_error_message($msg, 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             }
             $iUpdated += osc_set_preference('enabled_comments', $enabledComments);
             if ($moderateComments) {
                 $iUpdated += osc_set_preference('moderate_comments', $numModerateComments);
             } else {
                 $iUpdated += osc_set_preference('moderate_comments', '-1');
             }
             $iUpdated += osc_set_preference('notify_new_comment', $notifyNewComment);
             $iUpdated += osc_set_preference('notify_new_comment_user', $notifyNewCommentUser);
             $iUpdated += osc_set_preference('comments_per_page', $commentsPerPage);
             $iUpdated += osc_set_preference('reg_user_post_comments', $regUserPostComments);
             if ($iUpdated > 0) {
                 osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             break;
     }
 }
Exemple #15
0
function google_analytics_actions()
{
    $dao_preference = new Preference();
    $option = Params::getParam('option');
    if (Params::getParam('file') != 'google_analytics/admin.php') {
        return '';
    }
    if ($option == 'stepone') {
        $webid = Params::getParam('webid');
        Preference::newInstance()->update(array("s_value" => $webid), array("s_section" => "plugin-google_analytics", "s_name" => "google_analytics_id"));
        osc_add_flash_ok_message(__('The tracking ID has been updated', 'google_analytics'), 'admin');
        osc_redirect_to(osc_admin_render_plugin_url('google_analytics/admin.php'));
    }
}
        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');
        }
Exemple #17
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'edit':
             if (Params::getParam("id") == '') {
                 $this->redirectTo(osc_admin_base_url(true) . "?page=emails");
             }
             $this->_exportVariableToView("email", $this->emailManager->findByPrimaryKey(Params::getParam("id")));
             $this->doView("emails/frm.php");
             break;
         case 'edit_post':
             $id = Params::getParam("id");
             $s_internal_name = Params::getParam("s_internal_name");
             $aFieldsDescription = array();
             $postParams = Params::getParamsAsArray('', false);
             $not_empty = false;
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     if ($m[2] == 's_title' && $v != '') {
                         $not_empty = true;
                     }
                     $aFieldsDescription[$m[1]][$m[2]] = $v;
                 }
             }
             if ($not_empty) {
                 foreach ($aFieldsDescription as $k => $_data) {
                     $this->emailManager->updateDescription($id, $k, $_data['s_title'], $_data['s_text']);
                 }
                 if (!$this->emailManager->internalNameExists($id, $s_internal_name)) {
                     if (!$this->emailManager->isIndelible($id)) {
                         $this->emailManager->updateInternalName($id, $s_internal_name);
                     }
                     osc_add_flash_ok_message(_m('The email/alert has been updated'), 'admin');
                     $this->redirectTo(osc_admin_base_url(true) . "?page=emails");
                 }
                 osc_add_flash_error_message(_m('You can\'t repeat internal name'), 'admin');
             } else {
                 osc_add_flash_error_message(_m('The email couldn\'t be updated, at least one title should not be empty'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=emails?action=edit&id=" . $id);
             break;
         default:
             $this->_exportVariableToView("prefLocale", osc_current_admin_locale());
             $this->_exportVariableToView("emails", $this->emailManager->listAll(1));
             $this->doView("emails/index.php");
     }
 }
Exemple #18
0
 function doModel()
 {
     switch ($this->action) {
         case 'mailserver':
             // calling the mailserver view
             $this->doView('settings/mailserver.php');
             break;
         case 'mailserver_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=settings&action=mailserver');
             }
             osc_csrf_check();
             // updating mailserver
             $iUpdated = 0;
             $mailserverAuth = Params::getParam('mailserver_auth');
             $mailserverAuth = $mailserverAuth != '' ? true : false;
             $mailserverPop = Params::getParam('mailserver_pop');
             $mailserverPop = $mailserverPop != '' ? true : false;
             $mailserverType = Params::getParam('mailserver_type');
             $mailserverHost = Params::getParam('mailserver_host');
             $mailserverPort = Params::getParam('mailserver_port');
             $mailserverUsername = Params::getParam('mailserver_username');
             $mailserverPassword = Params::getParam('mailserver_password', false, false);
             $mailserverSsl = Params::getParam('mailserver_ssl');
             $mailserverMailFrom = Params::getParam('mailserver_mail_from');
             $mailserverNameFrom = Params::getParam('mailserver_name_from');
             if (!in_array($mailserverType, array('custom', 'gmail'))) {
                 osc_add_flash_error_message(_m('Mail server type is incorrect'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=mailserver');
             }
             $iUpdated += osc_set_preference('mailserver_auth', $mailserverAuth);
             $iUpdated += osc_set_preference('mailserver_pop', $mailserverPop);
             $iUpdated += osc_set_preference('mailserver_type', $mailserverType);
             $iUpdated += osc_set_preference('mailserver_host', $mailserverHost);
             $iUpdated += osc_set_preference('mailserver_port', $mailserverPort);
             $iUpdated += osc_set_preference('mailserver_username', $mailserverUsername);
             $iUpdated += osc_set_preference('mailserver_password', $mailserverPassword);
             $iUpdated += osc_set_preference('mailserver_ssl', $mailserverSsl);
             $iUpdated += osc_set_preference('mailserver_mail_from', $mailserverMailFrom);
             $iUpdated += osc_set_preference('mailserver_name_from', $mailserverNameFrom);
             if ($iUpdated > 0) {
                 osc_add_flash_ok_message(_m('Mail server configuration has changed'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=mailserver');
             break;
     }
 }
Exemple #19
0
function theme_modern_actions_admin()
{
    if (Params::getParam('file') == 'oc-content/themes/modern/admin/settings.php') {
        if (Params::getParam('donation') == 'successful') {
            osc_set_preference('donation', '1', 'modern_theme');
            osc_reset_preferences();
        }
    }
    switch (Params::getParam('action_specific')) {
        case 'settings':
            $footerLink = Params::getParam('footer_link');
            $defaultLogo = Params::getParam('default_logo');
            osc_set_preference('keyword_placeholder', Params::getParam('keyword_placeholder'), 'modern_theme');
            osc_set_preference('footer_link', $footerLink ? '1' : '0', 'modern_theme');
            osc_set_preference('default_logo', $defaultLogo ? '1' : '0', 'modern_theme');
            osc_add_flash_ok_message(__('Theme settings updated correctly', 'modern'), 'admin');
            header('Location: ' . osc_admin_render_theme_url('oc-content/themes/modern/admin/settings.php'));
            exit;
            break;
        case 'upload_logo':
            $package = Params::getFiles('logo');
            if ($package['error'] == UPLOAD_ERR_OK) {
                if (move_uploaded_file($package['tmp_name'], WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) {
                    osc_add_flash_ok_message(__('The logo image has been uploaded correctly', 'modern'), 'admin');
                } else {
                    osc_add_flash_error_message(__("An error has occurred, please try again", 'modern'), 'admin');
                }
            } else {
                osc_add_flash_error_message(__("An error has occurred, please try again", 'modern'), 'admin');
            }
            header('Location: ' . osc_admin_render_theme_url('oc-content/themes/modern/admin/header.php'));
            exit;
            break;
        case 'remove':
            if (file_exists(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg")) {
                @unlink(WebThemes::newInstance()->getCurrentThemePath() . "images/logo.jpg");
                osc_add_flash_ok_message(__('The logo image has been removed', 'modern'), 'admin');
            } else {
                osc_add_flash_error_message(__("Image not found", 'modern'), 'admin');
            }
            header('Location: ' . osc_admin_render_theme_url('oc-content/themes/modern/admin/header.php'));
            exit;
            break;
    }
}
Exemple #20
0
function seo_init_admin()
{
    //scripts
    osc_enqueue_style('seoCSS', osc_plugin_url(SEO_PLUGIN_FOLDER . '/css/style.css') . 'style.css');
    //admin menu pages
    osc_add_admin_menu_page(__('SEO Wiz', SEO_PLUGIN_FOLDER), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'configure.php'), 'seo_dashboard');
    osc_add_admin_submenu_page('seo_dashboard', __('Configure Plugin', SEO_PLUGIN_FOLDER), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'configure.php'), 'configure');
    osc_add_admin_submenu_page('seo_dashboard', __('Titles & Metas', SEO_PLUGIN_FOLDER), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'titles_metas.php'), 'titles_metas');
    //form actions
    switch (Params::getParam('seo_action')) {
        //configure page
        case 'seo_configure':
            $page_title_separator = Params::getParam('page_title_separator', false, false, false);
            osc_set_preference('page_title_separator', $page_title_separator, 'seo_plugin');
            osc_add_flash_ok_message(__('Saved correctly', SEO_PLUGIN_FOLDER), 'admin');
            osc_redirect_to(osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'configure.php'));
            break;
            //titles_metas_home
        //titles_metas_home
        case 'titles_metas_home':
            $seo_titles = Params::getParam('seo_titles');
            if (!empty($seo_titles)) {
                foreach ($seo_titles as $key => $value) {
                    osc_set_preference($key, trim($value), 'seo_plugin');
                }
            }
            osc_add_flash_ok_message(__('Saved correctly', SEO_PLUGIN_FOLDER), 'admin');
            osc_redirect_to(osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'titles_metas.php#home'));
            break;
            //titles_metas_pages
        //titles_metas_pages
        case 'titles_metas_pages':
            $seo_titles = Params::getParam('seo_titles');
            if (!empty($seo_titles)) {
                foreach ($seo_titles as $key => $value) {
                    osc_set_preference($key, trim($value), 'seo_plugin');
                }
            }
            osc_add_flash_ok_message(__('Saved correctly', SEO_PLUGIN_FOLDER), 'admin');
            osc_redirect_to(osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'titles_metas.php#pages'));
            break;
    }
}
Exemple #21
0
    /**
     * Re-send the flash messages of the given section. Usefull for custom theme/plugins files.
     *
     * @param string $$section
     */
    function osc_resend_flash_messages($section = "pubMessages") {
        $messages = Session::newInstance()->_getMessage($section);
        if (is_array($messages)) {

            foreach ($messages as $message) {
      
                $message = Session::newInstance()->_getMessage($section);
                if(isset($message['msg'])) {
                    if(isset($message["type"]) && $message["type"]=="info") {
                        osc_add_flash_info_message($message['msg'], $section);
                    } else if(isset($message["type"]) && $message["type"]=="ok") {
                        osc_add_flash_ok_message($message['msg'], $section);
                    } else {
                        osc_add_flash_error_message($message['msg'], $section);
                    }
                }
            }
        }
    }
Exemple #22
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add_post_default':
             // add default category and reorder parent categories
             $fields['fk_i_parent_id'] = NULL;
             $fields['i_expiration_days'] = 0;
             $fields['i_position'] = 0;
             $fields['b_enabled'] = 1;
             $default_locale = osc_language();
             $aFieldsDescription[$default_locale]['s_name'] = "NEW CATEGORY, EDIT ME!";
             $categoryId = $this->categoryManager->insert($fields, $aFieldsDescription);
             // reorder parent categories. NEW category first
             $rootCategories = $this->categoryManager->findRootCategories();
             foreach ($rootCategories as $cat) {
                 $order = $cat['i_position'];
                 $order++;
                 $this->categoryManager->updateOrder($cat['pk_i_id'], $order);
             }
             $this->categoryManager->updateOrder($categoryId, '0');
             $this->redirectTo(osc_admin_base_url(true) . '?page=categories');
             break;
         case 'settings':
             // calling the categories settings view
             $this->doView('categories/settings.php');
             break;
         case 'settings_post':
             // updating categories option
             $selectableParent = Params::getParam('selectable_parent_categories');
             $updated = Preference::newInstance()->update(array('s_value' => $selectableParent), array('s_name' => 'selectable_parent_categories'));
             if ($updated > 0) {
                 osc_add_flash_ok_message(_m("Categories' settings have been updated"), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=categories&action=settings');
             break;
         default:
             //
             $this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
             $this->doView("categories/index.php");
     }
 }
Exemple #23
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             switch (Params::getParam('bulk_actions')) {
                 case 'delete_all':
                     $ids = Params::getParam("id");
                     if (is_array($ids)) {
                         foreach ($ids as $id) {
                             osc_deleteResource($id, true);
                         }
                         $log_ids = substr(implode(",", $ids), 0, 250);
                         Log::newInstance()->insertLog('media', 'delete bulk', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
                         $this->resourcesManager->deleteResourcesIds($ids);
                     }
                     osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
                     break;
                 default:
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=media');
             break;
         case 'delete':
             $ids = Params::getParam('id');
             if (is_array($ids)) {
                 foreach ($ids as $id) {
                     osc_deleteResource($id, true);
                 }
                 $log_ids = substr(implode(",", $ids), 0, 250);
                 Log::newInstance()->insertLog('media', 'delete', $log_ids, $log_ids, 'admin', osc_logged_admin_id());
                 $this->resourcesManager->deleteResourcesIds($ids);
             }
             osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . '?page=media');
             break;
         default:
             $this->doView('media/index.php');
             break;
     }
 }
function fb_page_plugin_actions()
{
    $dao_preference = new Preference();
    $option = Params::getParam('fbpageoption');
    if (Params::getParam('file') != 'fb_page_plugin/admin.php') {
        return '';
    }
    if ($option == 'fbpagesettings') {
        osc_set_preference('fb_page_url', Params::getParam("fb_page_url") ? Params::getParam("fb_page_url") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('fb_page_width', Params::getParam("fb_page_width") ? Params::getParam("fb_page_width") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('fb_page_height', Params::getParam("fb_page_height") ? Params::getParam("fb_page_height") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('fb_show_faces', Params::getParam("fb_show_faces") ? Params::getParam("fb_show_faces") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('show_page_posts', Params::getParam("show_page_posts") ? Params::getParam("show_page_posts") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('hide_page_cover', Params::getParam("hide_page_cover") ? Params::getParam("hide_page_cover") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('use_small_header', Params::getParam("use_small_header") ? Params::getParam("use_small_header") : '0', 'fb_page_plugin', 'STRING');
        osc_set_preference('adapt_container_width', Params::getParam("adapt_container_width") ? Params::getParam("adapt_container_width") : '0', 'fb_page_plugin', 'STRING');
        osc_add_flash_ok_message(__('Facebook page plugin has been updated', 'fb_page_plugin'), 'admin');
        osc_redirect_to(osc_admin_render_plugin_url('fb_page_plugin/admin.php'));
    }
}
Exemple #25
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             switch (Params::getParam('bulk_actions')) {
                 case 'delete_all':
                     $ids = Params::getParam("id");
                     if ($ids != '') {
                         foreach ($ids as $id) {
                             osc_deleteResource($id);
                         }
                         $this->resourcesManager->deleteResourcesIds($ids);
                     }
                     osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
                     break;
                 default:
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=media");
             break;
         case 'delete':
             $ids = Params::getParam("id");
             if ($ids != '') {
                 foreach ($ids as $id) {
                     osc_deleteResource($id);
                 }
                 $this->resourcesManager->deleteResourcesIds($ids);
             }
             osc_add_flash_ok_message(_m('Resource deleted'), 'admin');
             $this->redirectTo(osc_admin_base_url(true) . "?page=media");
             break;
         default:
             $this->doView('media/index.php');
     }
 }
Exemple #26
0
    case "UNFOLLOW":
        if (osc_is_web_user_logged_in()) {
            $user_id = osc_logged_user_id();
            $seller_id = Params::getParam("seller-id");
            $return_url = Params::getParam("return_url");
            nc_osc_delete_follow($user_id, $seller_id);
            header('Location:' . htmlspecialchars_decode($return_url));
        }
        break;
    case "ADD-WATCHLIST":
        if (osc_is_web_user_logged_in()) {
            $user_id = osc_logged_user_id();
            $item_id = Params::getParam("item_id");
            $return_url = Params::getParam("return_url");
            nc_osc_add_watchllist($user_id, $item_id);
            $aItem = Item::newInstance()->findByPrimaryKey($item_id);
            $item_title = $aItem['s_title'];
            osc_add_flash_ok_message($item_title . " is added to your watch list.");
            header('Location:' . htmlspecialchars_decode($return_url));
        }
        break;
    case "REMOVE-WATCHLIST":
        if (osc_is_web_user_logged_in()) {
            $user_id = osc_logged_user_id();
            $item_id = Params::getParam("item_id");
            $return_url = Params::getParam("return_url");
            nc_osc_remove_watchlist($user_id, $item_id);
            header('Location:' . htmlspecialchars_decode($return_url));
        }
        break;
}
Exemple #27
0
        public function send_friend()
        {
            // get data for this function
            $aItem = $this->prepareDataForFunction( 'send_friend' );

            $item       = $aItem['item'];
            $s_title    = $aItem['s_title'];
            View::newInstance()->_exportVariableToView('item', $item);

            osc_run_hook('hook_email_send_friend', $aItem);
            $item_url   = osc_item_url();
            $item_url = '<a href="'.$item_url.'" >'.$item_url.'</a>';
            Params::setParam('item_url', $item_url );
            osc_add_flash_ok_message( sprintf(_m('We just sent your message to %s'), $aItem['friendName']) );
            return true;
        }
Exemple #28
0
<?php

$num_ads = '';
if (Params::getParam('num_ads') != '') {
    $num_ads = Params::getParam('num_ads');
} else {
    $num_ads = popular_ads_num_ads();
}
if (Params::getParam('option') == 'update') {
    osc_set_preference('popularads_num_ads', $num_ads, 'plugin-popular_ads', 'INTEGER');
    osc_add_flash_ok_message(__('Number of ads to display successfully updated'), 'admin');
    echo '<script>location.href="' . osc_admin_render_plugin_url('popular_ads/admin_config.php') . '"</script>';
}
?>



<div style="border: 5px solid #ccc; padding:10px; background: #eee;
	    -moz-border-radius:20px;
	    -webkit-border-radius:20px;
	    border-radius: 20px;">

        <fieldset style="border-color:#ccc;">
	    <legend><h2>Popular Ads - Configure</h2></legend>
There is currently only one option that needs to be set for this plugin, and that is the number of popular ads you wish to display.
<br><br>
How are popular ads determined? - They are based on the total number of active item/ad views. That means an item <i>must</i> be active in order to be included.
<br><br>

    <form name="adexpiration" action="<?php 
echo osc_admin_base_url(true);
Exemple #29
0
    }
    unset($aAlerts);
}
if (osc_version() < 350) {
    osc_set_preference('marketURL', 'http://market.osclass.org/api/v2/');
    osc_set_preference('marketAPIConnect', '');
    osc_set_preference('marketCategories', '');
    osc_set_preference('marketDataUpdate', 0);
}
if (osc_version() < 352) {
    osc_set_preference('marketURL', 'http://market.osclass.org/api/v2/');
}
osc_changeVersionTo(360);
if (!defined('IS_AJAX') || !IS_AJAX) {
    if (empty($aMessages)) {
        osc_add_flash_ok_message(_m('Osclass has been updated successfully. <a href="http://forums.osclass.org/">Need more help?</a>'), 'admin');
        echo '<script type="text/javascript"> window.location = "' . osc_admin_base_url(true) . '?page=tools&action=version"; </script>';
    } else {
        echo '<div class="well ui-rounded-corners separate-top-medium">';
        echo '<p>' . __('Osclass &raquo; Updated correctly') . '</p>';
        echo '<p>' . __('Osclass has been updated successfully. <a href="http://forums.osclass.org/">Need more help?</a>') . '</p>';
        foreach ($aMessages as $msg) {
            echo "<p>" . $msg . "</p>";
        }
        echo "</div>";
    }
}
/**
 * Convert alerts < 2.4, updating s_search with json encoded to based64.
 *
 * @param string $alert base64+serialized
Exemple #30
0
<?php

if (!defined('ABS_PATH')) {
    exit('ABS_PATH is not loaded. Direct access is not allowed.');
}
if (Params::getParam('plugin_action') == 'done') {
    butler_cron();
    // HACK : This will make possible use of the flash messages ;)
    ob_get_clean();
    osc_add_flash_ok_message(__('Butler has cleaned your listings and users', 'butler'), 'admin');
    osc_redirect_to(osc_route_admin_url('butler-admin-stats'));
}
?>

<div id="general-setting">
    <div id="general-settings">
        <h2 class="render-title"><?php 
_e('Butler settings', 'butler');
?>
</h2>
        <ul id="error_list"></ul>
        <form name="payment_pro_form" action="<?php 
echo osc_admin_base_url(true);
?>
" method="post">
            <input type="hidden" name="page" value="plugins" />
            <input type="hidden" name="action" value="renderplugin" />
            <input type="hidden" name="route" value="butler-admin-stats" />
            <input type="hidden" name="plugin_action" value="done" />
            <fieldset>
                <div class="form-horizontal">