Example #1
0
function admin_footer_html() { ?>
    <div class="float-left">
        <?php printf(__('Thank you for using <a href="%s" target="_blank">Osclass</a>'), 'http://osclass.org/'); ?> -
        <a title="<?php _e('Documentation'); ?>" href="http://doc.osclass.org/" target="_blank"><?php _e('Documentation'); ?></a> &middot;
        <a title="<?php _e('Forums'); ?>" href="http://forums.osclass.org/" target="_blank"><?php _e('Forums'); ?></a> &middot;
        <a title="<?php _e('Feedback'); ?>" href="https://osclass.uservoice.com/" target="_blank"><?php _e('Feedback'); ?></a>
    </div>
    <div class="float-right">
        <strong>Osclass <?php echo preg_replace('|.0$|', '', OSCLASS_VERSION); ?></strong>
    </div>
    <a id="ninja" href="" class="ico ico-48 ico-dash-white"></a>
    <div class="clear"></div>
    <form id="donate-form" name="_xclick" action="https://www.paypal.com/in/cgi-bin/webscr" method="post" target="_blank">
       <input type="hidden" name="cmd" value="_donations">
       <input type="hidden" name="business" value="*****@*****.**">
       <input type="hidden" name="item_name" value="Osclass project">
       <input type="hidden" name="return" value="<?php echo osc_admin_base_url(); ?>">
       <input type="hidden" name="currency_code" value="USD">
       <input type="hidden" name="lc" value="US" />
    </form>
    <!-- javascript
    ================================================== -->
    <script type="text/javascript">
        var $ninja = $('#ninja');

        $ninja.click(function(){
            jQuery('#donate-form').submit();
            return false;
        });
    </script><?php
}
Example #2
0
function customHead()
{
    ?>
        <script type="text/javascript">
            $(document).ready(function(){
                if (typeof $.uniform != 'undefined') {
                    $('textarea, button,select, input:file').uniform();
                }

                <?php 
    if (Params::getParam('confirm') == 'true') {
        ?>
                    $('#output').show();
                    $('#tohide').hide();

                    $.get('<?php 
        echo osc_admin_base_url(true);
        ?>
?page=upgrade&action=upgrade-funcs' , function(data) {
                        $('#loading_immage').hide();
                        $('#result').append(data+"<br/>");
                    });
                <?php 
    }
    ?>
            });
        </script>
    <?php 
}
Example #3
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;
         default:
             //
             $this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
             $this->doView("categories/index.php");
     }
 }
Example #4
0
/**
 * Makes this plugin the first to be loaded.
 * - Bumps this plugin at the top of the active_plugins stack.
 */
function mdh_emailmagick_bump_me()
{
    if (OC_ADMIN) {
        // @legacy : ALWAYS remove this if active.
        if (osc_plugin_is_enabled("madhouse_utils/index.php")) {
            Plugins::deactivate("madhouse_utils/index.php");
        }
        // Sanitize & get the {PLUGIN_NAME}/index.php.
        $path = str_replace(osc_plugins_path(), '', osc_plugin_path(__FILE__));
        if (osc_plugin_is_installed($path)) {
            // Get the active plugins.
            $plugins_list = unserialize(osc_active_plugins());
            if (!is_array($plugins_list)) {
                return false;
            }
            // Remove $path from the active plugins list
            foreach ($plugins_list as $k => $v) {
                if ($v == $path) {
                    unset($plugins_list[$k]);
                }
            }
            // Re-add the $path at the beginning of the active plugins.
            array_unshift($plugins_list, $path);
            // Serialize the new active_plugins list.
            osc_set_preference('active_plugins', serialize($plugins_list));
            if (Params::getParam("page") === "plugins" && Params::getParam("action") === "enable" && Params::getParam("plugin") === $path) {
                //osc_redirect_to(osc_admin_base_url(true) . "?page=plugins");
            } else {
                osc_redirect_to(osc_admin_base_url(true) . "?" . http_build_query(Params::getParamsAsArray("get")));
            }
        }
    }
}
Example #5
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;
     }
 }
Example #6
0
/**
 * Send email to user when they get a new PM
 * 
 * @param integer $item
 * @param integer $offer_value 
 *
 * @dynamic tags
 *
 * '{RECIP_NAME}', '{SENDER_NAME}', '{WEB_URL}', '{WEB_TITLE}', '{PM_URL}', '{PM_SUBJECT}', '{PM_MESSAGE}'
 */
function new_pm_email($pm_info)
{
    $mPages = new Page();
    $aPage = $mPages->findByInternalName('email_PM_alert');
    $locale = osc_current_user_locale();
    $content = array();
    if (isset($aPage['locale'][$locale]['s_title'])) {
        $content = $aPage['locale'][$locale];
    } else {
        $content = current($aPage['locale']);
    }
    if ($pm_info['sender_id'] == 0) {
        $sender_name = pmAdmin();
    } else {
        $pm_senderData = User::newInstance()->findByPrimaryKey($pm_info['sender_id']);
        $sender_name = $pm_senderData['s_name'];
    }
    if ($pm_info['recip_id'] == 0) {
        $pm_url = osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=osclass_pm/admin-send.php?userId=' . $pm_info['sender_id'] . '&mType=adminQuote&messId=' . $pm_info['pm_id'];
        $pm_name = pmAdmin();
        $pm_recipData['s_email'] = osc_contact_email();
    } else {
        $pm_url = osc_base_url(true) . '?page=custom&file=osclass_pm/user-send.php?userId=' . $pm_info['sender_id'] . '&mType=quote&messId=' . $pm_info['pm_id'];
        $pm_recipData = User::newInstance()->findByPrimaryKey($pm_info['recip_id']);
        $pm_name = $pm_recipData['s_name'];
    }
    $pm_url = '<a href="' . $pm_url . '" >' . $pm_url . '</a>';
    $words = array();
    $words[] = array('{RECIP_NAME}', '{SENDER_NAME}', '{WEB_URL}', '{WEB_TITLE}', '{PM_URL}', '{PM_SUBJECT}', '{PM_MESSAGE}', '[quote]', '[/quote]', '[quoteAuthor]', '[/quoteAuthor]');
    $words[] = array($pm_name, $sender_name, osc_base_url(), osc_page_title(), $pm_url, $pm_info['pm_subject'], nl2br($pm_info['pm_message']), '<div class="messQuote">', '</div>', '<div class="quoteAuthor">', '</div>');
    $title = osc_mailBeauty($content['s_title'], $words);
    $body = osc_mailBeauty($content['s_text'], $words);
    $emailParams = array('subject' => $title, 'to' => $pm_recipData['s_email'], 'to_name' => $pm_name, 'body' => $body, 'alt_body' => $body);
    osc_sendMail($emailParams);
}
Example #7
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_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');
     }
 }
Example #8
0
 private function processData($pages)
 {
     if (!empty($pages)) {
         $prefLocale = osc_current_user_locale();
         foreach ($pages as $aRow) {
             $row = array();
             $content = array();
             if (isset($aRow['locale'][$prefLocale]) && !empty($aRow['locale'][$prefLocale]['s_title'])) {
                 $content = $aRow['locale'][$prefLocale];
             } else {
                 $content = current($aRow['locale']);
             }
             // -- options --
             $options = array();
             View::newInstance()->_exportVariableToView('page', $aRow);
             $options[] = '<a href="' . osc_static_page_url() . '" target="_blank">' . __('View page') . '</a>';
             $options[] = '<a href="' . osc_admin_base_url(true) . '?page=pages&amp;action=edit&amp;id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>';
             if (!$aRow['b_indelible']) {
                 $options[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=pages&amp;action=delete&amp;id=' . $aRow['pk_i_id'] . '&amp;' . osc_csrf_token_url() . '">' . __('Delete') . '</a>';
             }
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             $row['bulkactions'] = '<input type="checkbox" name="id[]"" value="' . $aRow['pk_i_id'] . '"" />';
             $row['internal_name'] = $aRow['s_internal_name'] . $actions;
             $row['title'] = $content['s_title'];
             $row['order'] = '<div class="order-box">' . $aRow['i_order'] . ' <img class="up" onclick="order_up(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_up.png') . '" alt="' . __('Up') . '" title="' . __('Up') . '" />  <img class="down" onclick="order_down(' . $aRow['pk_i_id'] . ');" src="' . osc_current_admin_theme_url('images/arrow_down.png') . '" alt="' . __('Down') . '" title="' . __('Down') . '" /></div>';
             $row = osc_apply_filter('pages_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
Example #9
0
 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             Session::newInstance()->_drop('adminId');
             Session::newInstance()->_drop('adminUserName');
             Session::newInstance()->_drop('adminName');
             Session::newInstance()->_drop('adminEmail');
             Session::newInstance()->_drop('adminLocale');
             Cookie::newInstance()->pop('oc_adminId');
             Cookie::newInstance()->pop('oc_adminSecret');
             Cookie::newInstance()->pop('oc_adminLocale');
             Cookie::newInstance()->set();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numAdmins", Admin::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView("numItemsSpam", Item::newInstance()->totalItems(null, 'SPAM'));
             $this->_exportVariableToView("numItemsBlock", Item::newInstance()->totalItems(null, 'DISABLED'));
             $this->_exportVariableToView("numItemsInactive", Item::newInstance()->totalItems(null, 'INACTIVE'));
             $this->_exportVariableToView("numItemsPerCategory", osc_get_non_empty_categories());
             $this->_exportVariableToView("newsList", osc_listNews());
             $this->_exportVariableToView("comments", ItemComment::newInstance()->getLastComments(5));
             //calling the view...
             $this->doView('main/index.php');
     }
 }
Example #10
0
 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');
             }
         }
     }
 }
Example #11
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");
     }
 }
Example #12
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;
     }
 }
Example #13
0
 private function setCurrentThemeUrl()
 {
     if ($this->theme_exists) {
         $this->theme_url = osc_admin_base_url() . 'themes/' . $this->theme . '/';
     } else {
         $this->theme_url = osc_admin_base_url() . 'gui/';
     }
 }
Example #14
0
function customHead()
{
    $all = osc_get_preference('location_todo');
    if ($all == '') {
        $all = 0;
    }
    $worktodo = LocationsTmp::newInstance()->count();
    ?>
        <script type="text/javascript">
            function reload() {
                window.location = '<?php 
    echo osc_admin_base_url(true) . '?page=tools&action=locations';
    ?>
';
            }

            function ajax_() {
                $.ajax({
                    type: "POST",
                    url: '<?php 
    echo osc_admin_base_url(true);
    ?>
?page=ajax&action=location_stats&<?php 
    echo osc_csrf_token_url();
    ?>
',
                    dataType: 'json',
                    success: function(data) {
                        if(data.status=='done') {
                            $('span#percent').html(100);
                        }else{
                            var pending = data.pending;
                            var all = <?php 
    echo osc_esc_js($all);
    ?>
;
                            var percent = parseInt( ((all-pending)*100) / all );
                            $('span#percent').html(percent);
                            ajax_();
                        }
                    }
                });
            }

            $(document).ready(function(){
                if(<?php 
    echo $worktodo;
    ?>
> 0) {
                    ajax_();
                }
            });
        </script>
        <?php 
}
Example #15
0
 private function processData($comments)
 {
     if (!empty($comments)) {
         $csrf_token_url = osc_csrf_token_url();
         foreach ($comments as $aRow) {
             $row = array();
             $options = array();
             $options_more = array();
             View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($aRow['fk_i_item_id']));
             if ($aRow['b_enabled']) {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=DISABLE">' . __('Block') . '</a>';
             } else {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ENABLE">' . __('Unblock') . '</a>';
             }
             $options_more[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=comments&amp;action=delete&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_delete">' . __('Delete') . '</a>';
             $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=comment_edit&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_edit">' . __('Edit') . '</a>';
             if ($aRow['b_active']) {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=INACTIVE">' . __('Deactivate') . '</a>';
             } else {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ACTIVE">' . __('Activate') . '</a>';
             }
             // more actions
             $moreOptions = '<li class="show-more">' . PHP_EOL . '<a href="#" class="show-more-trigger">' . __('Show more') . '...</a>' . PHP_EOL . '<ul>' . PHP_EOL;
             foreach ($options_more as $actual) {
                 $moreOptions .= '<li>' . $actual . "</li>" . PHP_EOL;
             }
             $moreOptions .= '</ul>' . PHP_EOL . '</li>' . PHP_EOL;
             // create list of actions
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $auxOptions .= $moreOptions;
             $auxOptions .= '</ul>' . PHP_EOL;
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             $status = $this->get_row_status($aRow);
             $row['status-border'] = '';
             $row['status'] = $status['text'];
             $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" />';
             if (empty($aRow['s_author_name'])) {
                 $user = User::newInstance()->findByPrimaryKey($aRow['fk_i_user_id']);
                 $aRow['s_author_name'] = $user['s_email'];
             }
             $row['author'] = $aRow['s_author_name'] . ' (<a target="_blank" href="' . osc_item_url() . '">' . osc_item_title() . '</a>)' . $actions;
             $row['comment'] = $aRow['s_body'];
             $row['date'] = osc_format_date($aRow['dt_pub_date']);
             $row = osc_apply_filter('comments_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
Example #16
0
 private function processData($alerts)
 {
     if (!empty($alerts) && !empty($alerts['alerts'])) {
         $csrf_token_url = osc_csrf_token_url();
         foreach ($alerts['alerts'] as $aRow) {
             $row = array();
             $options = array();
             // first column
             $row['bulkactions'] = '<input type="checkbox" name="alert_id[]" value="' . $aRow['pk_i_id'] . '" /></div>';
             $options[] = '<a onclick="return delete_alert(\'' . $aRow['pk_i_id'] . '\');" href="#">' . __('Delete') . '</a>';
             if ($aRow['b_active'] == 1) {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=status_alerts&amp;alert_id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;status=0" >' . __('Deactivate') . '</a>';
             } else {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=status_alerts&amp;alert_id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;status=1" >' . __('Activate') . '</a>';
             }
             $options = osc_apply_filter('actions_manage_alerts', $options, $aRow);
             // create list of actions
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $auxOptions .= '</ul>' . PHP_EOL;
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             // second column
             $row['email'] = '<a href="' . osc_admin_base_url(true) . '?page=items&userId=">' . $aRow['s_email'] . '</a>' . $actions;
             // third row
             $pieces = array();
             $conditions = osc_get_raw_search((array) json_decode($aRow['s_search'], true));
             if (isset($conditions['sPattern']) && $conditions['sPattern'] != '') {
                 $pieces[] = sprintf(__("<b>Pattern:</b> %s"), $conditions['sPattern']);
             }
             if (isset($conditions['aCategories']) && !empty($conditions['aCategories'])) {
                 $l = min(count($conditions['aCategories']), 4);
                 $cat_array = array();
                 for ($c = 0; $c < $l; $c++) {
                     $cat_array[] = $conditions['aCategories'][$c];
                 }
                 if (count($conditions['aCategories']) > $l) {
                     $cat_array[] = '<a href="#" class="more-tooltip" categories="' . osc_esc_html(implode(", ", $conditions['aCategories'])) . '" >' . __("...More") . '</a>';
                 }
                 $pieces[] = sprintf(__("<b>Categories:</b> %s"), implode(", ", $cat_array));
             }
             $row['alert'] = implode($pieces, ", ");
             // fourth row
             $row['date'] = osc_format_date($aRow['dt_date']);
             $row = osc_apply_filter('alerts_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
Example #17
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;
     }
 }
Example #18
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;
     }
 }
Example #19
0
function customPageHeader()
{
    ?>
        <h1><?php 
    _e('Manage Media');
    ?>
            <a href="<?php 
    echo osc_admin_base_url(true) . '?page=settings&action=media';
    ?>
" class="btn ico ico-32 ico-engine float-right"></a>
            <a href="#" class="btn ico ico-32 ico-help float-right"></a>
        </h1>
<?php 
}
Example #20
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");
     }
 }
Example #21
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;
     }
 }
Example #22
0
    public function users_html_modal()
    {
        $page = Params::getParam('page');
        if ($page == 'users') {
            ?>
<!-- Form edit city -->
<div id="d_add_user_premium" class="lightbox_country location has-form-actions hide">
    <div style="padding: 14px;">
        <form action="<?php 
            echo osc_admin_base_url(true);
            ?>
" method="post" accept-charset="utf-8" id="d_add_city_form">
            <input type="hidden" name="page" value="settings" />
            <input type="hidden" name="action" value="locations" />
            <input type="hidden" name="type" value="add_city" />
            <input type="hidden" name="country_c_parent" value="" />
            <input type="hidden" name="country_parent" value="" />
            <input type="hidden" name="region_parent" value="" />
            <input type="hidden" name="ci_manual" value="1" />
            <input type="hidden" name="city_id" id="city_id" value="" />
            <table>
                <tr>
                    <td><?php 
            _e('City');
            ?>
: </td>
                    <td><input type="text" id="city" name="city" value="" /></td>
                </tr>
            </table>
            <div class="form-actions">
                <div class="wrapper">
                    <button class="btn btn-red close-dialog" ><?php 
            _e('Cancel');
            ?>
</button>
                    <button type="submit" class="btn btn-submit" ><?php 
            _e('Add city');
            ?>
</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- End form add city -->
			<?php 
        }
    }
Example #23
0
function customPageHeader()
{
    ?>
        <h1><?php 
    _e('Appearance');
    ?>
            <a href="#" class="btn ico ico-32 ico-help float-right"></a>
            <a href="<?php 
    echo osc_admin_base_url(true);
    ?>
?page=appearance&amp;action=add" class="btn btn-green ico ico-32 ico-add-white float-right"><?php 
    _e('Add theme');
    ?>
</a>
        </h1>
    <?php 
}
Example #24
0
function customPageHeader()
{
    ?>
        <h1><?php 
    _e('Settings');
    ?>
            <a href="#" class="btn ico ico-32 ico-help float-right"></a>
            <a href="<?php 
    echo osc_admin_base_url(true) . '?page=settings&action=currencies&type=add';
    ?>
" class="btn btn-green ico ico-32 ico-add-white float-right"><?php 
    _e('Add');
    ?>
</a>
        </h1>
<?php 
}
Example #25
0
function customPageHeader()
{
    ?>
        <h1><?php 
    _e('Settings');
    ?>
            <a href="#" class="btn ico ico-32 ico-help float-right"></a>
            <a href="<?php 
    echo osc_admin_base_url(true);
    ?>
?page=languages&amp;action=add" class="btn btn-green ico ico-32 ico-add-white float-right" ><?php 
    _e('Add language');
    ?>
</a>
        </h1>
<?php 
}
Example #26
0
    function customPageHeader() { ?>
            <h1><?php _e('Manage Plugins'); ?>
                <a href="#" class="btn ico ico-32 ico-help float-right"></a>
                <a href="<?php echo osc_admin_base_url(true); ?>?page=plugins&amp;action=add" class="btn btn-green ico ico-32 ico-add-white float-right"><?php _e('Add plugin'); ?></a>
            </h1>
        </div>
        <?php osc_show_flash_message('admin'); ?>
        <?php if( Params::getParam('error') != '' ) { ?>
            <!-- flash message -->
            <div class="flashmessage flashmessage-error" style="display:block">
                <?php _e("Plugin couldn't be installed because it triggered a <strong>fatal error</strong>"); ?>
                <a class="btn ico btn-mini ico-close">x</a>
                <iframe style="border:0;" width="100%" height="60" src="<?php echo osc_admin_base_url(true); ?>?page=plugins&amp;action=error_plugin&amp;plugin=<?php echo Params::getParam('error'); ?>"></iframe>
            <!-- /flash message -->
        <?php } ?>
<?php
    }
Example #27
0
function customPageHeader()
{
    ?>
        <h1><?php 
    _e('Manage Plugins');
    ?>
            <a href="#" class="btn ico ico-32 ico-help float-right"></a>
            <a href="<?php 
    echo osc_admin_base_url(true);
    ?>
?page=plugins&amp;action=add" class="btn btn-green ico ico-32 ico-add-white float-right"><?php 
    _e('Add plugin');
    ?>
</a>
        </h1>
<?php 
}
Example #28
0
function customHead()
{
    ?>
        <script type="text/javascript">
            jQuery(document).ready(function(){
                $('select[name="mailserver_type"]').bind('change', function(){
                    if( $(this).val() == 'gmail' ) {
                        $('input[name="mailserver_host"]').val('smtp.gmail.com');
                        $('input[name="mailserver_host"]').attr('readonly', true);
                        $('input[name="mailserver_port"]').val('465');
                        $('input[name="mailserver_port"]').attr('readonly', true);
                        $('input[name="mailserver_username"]').val('');
                        $('input[name="mailserver_password"]').val('');
                        $('input[name="mailserver_ssl"]').val('ssl');
                        $('input[name="mailserver_auth"]').attr('checked', true);
                        $('input[name="mailserver_pop"]').attr('checked', false);
                    } else {
                        $('input[name="mailserver_host"]').attr('readonly', false);
                        $('input[name="mailserver_port"]').attr('readonly', false);
                    }
                });

                $('#testMail').bind('click', function() {
                    $.ajax({
                        "url": "<?php 
    echo osc_admin_base_url(true);
    ?>
?page=ajax&action=test_mail",
                        "dataType": 'json',
                        success: function(data) {
                            $('#testMail_message p').html(data.html);
                            $('#testMail_message').css('display', 'block');
                            if( data.status == 1 ) {
                                $('#testMail_message').addClass('ok');
                            } else {
                                $('#testMail_message').addClass('error');
                            }
                        }
                    });
                });
            });
        </script>
        <?php 
}
Example #29
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");
     }
 }
Example #30
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;
     }
 }