示例#1
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');
             }
         }
     }
 }
示例#2
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');
     }
 }
示例#3
0
文件: header.php 项目: naneri/Osclass
function add_market_jsvariables()
{
    $marketPage = Params::getParam("mPage");
    $version_length = strlen(osc_version());
    $main_version = substr(osc_version(), 0, $version_length - 2) . "." . substr(osc_version(), $version_length - 2, 1);
    if ($marketPage >= 1) {
        $marketPage--;
    }
    $action = Params::getParam("action");
    $js_lang = array('by' => __('by'), 'ok' => __('Ok'), 'error_item' => __('There was a problem, try again later please'), 'wait_download' => __('Please wait until the download is completed'), 'downloading' => __('Downloading'), 'close' => __('Close'), 'download' => __('Download'), 'update' => __('Update'), 'last_update' => __('Last update'), 'downloads' => __('Downloads'), 'requieres_version' => __('Requires at least'), 'compatible_with' => __('Compatible up to'), 'screenshots' => __('Screenshots'), 'preview_theme' => __('Preview theme'), 'download_manually' => __('Download manually'), 'buy' => __('Buy'), 'proceed_anyway' => sprintf(__('Warning! This package is not compatible with your current version of Osclass (%s)'), $main_version), 'sure' => __('Are you sure?'), 'proceed_anyway_btn' => __('Ok, proceed anyway'), 'not_compatible' => sprintf(__('Warning! This theme is not compatible with your current version of Osclass (%s)'), $main_version), 'themes' => array('download_ok' => __('The theme has been downloaded correctly, proceed to activate or preview it.')), 'plugins' => array('download_ok' => __('The plugin has been downloaded correctly, proceed to install and configure.')), 'languages' => array('download_ok' => __('The language has been downloaded correctly, proceed to activate.')));
    ?>
        <script type="text/javascript">
            var theme = window.theme || {};
            theme.adminBaseUrl  = "<?php 
    echo osc_admin_base_url(true);
    ?>
";
            theme.marketAjaxUrl = "<?php 
    echo osc_admin_base_url(true);
    ?>
?page=ajax&action=market&<?php 
    echo osc_csrf_token_url();
    ?>
";
            theme.marketCurrentURL = "<?php 
    echo osc_admin_base_url(true);
    ?>
?page=market&action=<?php 
    echo Params::getParam('action');
    ?>
";
            theme.themUrl       = "<?php 
    echo osc_current_admin_theme_url();
    ?>
";
            theme.langs         = <?php 
    echo json_encode($js_lang);
    ?>
;
            theme.CSRFToken     = "<?php 
    echo osc_csrf_token_url();
    ?>
";

            var osc_market = {};
            osc_market.main_version = <?php 
    echo $main_version;
    ?>
;

        </script>
        <?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');
        }
function qrcode_admin_menu()
{
    if (osc_version() < 320) {
        echo '<h3><a href="#">QR Code</a></h3>
            <ul>
                <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'conf.php') . '">&raquo; ' . __('Settings', 'qrcode') . '</a></li>
                <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'help.php') . '">&raquo; ' . __('Help', 'qrcode') . '</a></li>
            </ul>';
    } else {
        osc_add_admin_submenu_divider('plugins', 'QR Codes', 'qrcode_divider', 'administrator');
        osc_add_admin_submenu_page('plugins', __('QR Settings', 'qrcode'), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'conf.php'), 'qrcode_settings', 'administrator');
        osc_add_admin_submenu_page('plugins', __('QR Help', 'qrcode'), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'help.php'), 'qrcode_help', 'administrator');
    }
}
示例#6
0
function contact_counter_admin_menu()
{
    if (osc_version() < 320) {
        echo '<h3><a href="#">' . __('Contact counter', 'contact_counter') . '</a></h3>
            <ul>
                <li><a href="' . osc_admin_configure_plugin_url("contact_counter/admin/stats.php") . '">&raquo; ' . __('Contact stats', 'contact_counter') . '</a></li>
                <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'admin/help.php') . '">&raquo; ' . __('Help', 'contact_counter') . '</a></li>
            </ul>';
    } else {
        osc_add_admin_submenu_page('stats', __('View contact stats', 'contact_counter'), osc_route_admin_url('stats-contact-counter', array('id' => '')), '', 'administrator');
        osc_add_admin_submenu_divider('plugins', __('Contact counter', 'contact_counter'), 'contact_counter');
        osc_add_admin_submenu_page('plugins', __('Help', 'contact_counter'), osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'admin/help.php'), 'contact_counter_help', 'administrator');
    }
}
示例#7
0
function digitalgoods_admin_menu()
{
    if (osc_version() < 320) {
        echo '<h3><a href="#">Digital Goods</a></h3>
            <ul>
                <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'admin/conf.php') . '">&raquo; ' . __('Settings', 'digitalgoods') . '</a></li>
                <li><a href="' . osc_admin_configure_plugin_url("digitalgoods/index.php") . '">&raquo; ' . __('Configure categories', 'digitalgoods') . '</a></li>
                <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'admin/stats.php') . '">&raquo; ' . __('Stats', 'digitalgoods') . '</a></li>
            </ul>';
    } else {
        osc_add_admin_submenu_divider('plugins', 'Digital Goods', 'digitalgoods_divider', 'administrator');
        osc_add_admin_submenu_page('plugins', __('Settings', 'digitalgoods'), osc_route_admin_url('digitalgoods-admin-conf'), 'digitalgoods_settings', 'administrator');
        osc_add_admin_submenu_page('plugins', __('Configure categories', 'digitalgoods'), osc_admin_configure_plugin_url("digitalgoods/index.php"), 'digitalgoods_categories', 'administrator');
        osc_add_admin_submenu_page('plugins', __('File stats', 'digitalgoods'), osc_route_admin_url('digitalgoods-admin-stats'), 'digitalgoods_stats', 'administrator');
    }
}
示例#8
0
foreach ($perms as $k => $v) {
    @chmod($k, $v);
}
if ($ok) {
    ?>
            $(function() {
                var steps_div = document.getElementById('steps_div') ;
                steps_div.style.display = '';
                var steps = document.getElementById('steps') ;
                var version = <?php 
    echo osc_version();
    ?>
 ;
                var fileToUnzip = '';
                steps.innerHTML += "<?php 
    printf(__('Checking for updates (Current version %s)'), osc_version());
    ?>
" ;

                $.getJSON("http://www.osclass.org/latest_version.php?callback=?", function(data) {
                    if(data.version <= version) {
                        steps.innerHTML += "<?php 
    _e('Congratulations! Your OSClass installation is up to date!');
    ?>
";
                    } else {
                        steps.innerHTML += "<?php 
    _e('New version to update:');
    ?>
 " + data.version + "<br/>" ;
                        <?php 
示例#9
0
        osc_set_preference('description_character_length', '5000', 'osclass', 'INTEGER');
    }

	if(osc_version() < 340) {
		$comm->query(sprintf("ALTER TABLE `%st_widget` ADD INDEX `idx_s_description` (`s_description`);", DB_TABLE_PREFIX));
        osc_set_preference('force_jpeg', '0', 'osclass', 'BOOLEAN');

        @unlink(ABS_PATH . '.maintenance');

        // THESE LINES PROBABLY HIT LOW TIMEOUT SCRIPTS, RUN THE LAST OF THE UPGRADE PROCESS
        //osc_calculate_location_slug('country');
        //osc_calculate_location_slug('region');
        //osc_calculate_location_slug('city');
	}

    if(osc_version() < 343) {
        // update t_alerts - Save them in plain json instead of base64
        $mAlerts = Alerts::newInstance();
        $aAlerts = $mAlerts->findByType('HOURLY');
        foreach($aAlerts as $alert) {
            $s_search = base64_decode($alert['s_search']);
            if(stripos(strtolower($s_search), 'union select')!==false || stripos(strtolower($s_search), 't_admin')!==false) {
                $mAlerts->delete(array('pk_i_id' => $alert['pk_i_id']));
            } else {
                $mAlerts->update(array('s_search' => $s_search), array('pk_i_id' => $alert['pk_i_id']));
            }
        }
        unset($aAlerts);

        $aAlerts = $mAlerts->findByType('DAILY');
        foreach($aAlerts as $alert) {
示例#10
0
function fbc_check_logout()
{
    if (Params::getParam("page") == "main" && Params::getParam("action") == "logout" && osc_version() < 310) {
        OSCFacebook::newInstance()->resetCookies();
    }
}
示例#11
0
function osc_file_get_contents($url)
{
    require_once LIB_PATH . 'libcurlemu/libcurlemu.inc.php';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] . ' OSClass (v.' . osc_version() . ')');
    if (!defined('CURLOPT_RETURNTRANSFER')) {
        define('CURLOPT_RETURNTRANSFER', 1);
    }
    @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
示例#12
0
function register_user($user)
{
    $manager = User::newInstance();
    $input['s_name'] = $user['name'];
    $input['s_email'] = $user['email'];
    $input['s_password'] = sha1(osc_genRandomPassword());
    $input['dt_reg_date'] = date('Y-m-d H:i:s');
    $input['s_secret'] = osc_genRandomPassword();
    $email_taken = $manager->findByEmail($input['s_email']);
    if ($email_taken == null) {
        $manager->insert($input);
        $userID = $manager->dao->insertedId();
        $result = $manager->dao->replace();
        osc_run_hook('user_register_completed', $userID);
        $userDB = $manager->findByPrimaryKey($userID);
        if (osc_notify_new_user()) {
            osc_run_hook('hook_email_admin_new_user', $userDB);
        }
        if (osc_version() >= 310) {
            $manager->update(array('b_active' => '1', 's_username' => $userID), array('pk_i_id' => $userID));
        } else {
            $manager->update(array('b_active' => '1'), array('pk_i_id' => $userID));
        }
        insert_facebook_user_data($userID, $user['id']);
        osc_run_hook('hook_email_user_registration', $userDB);
        osc_run_hook('validate_user', $userDB);
        osc_add_flash_ok_message(sprintf(__('Your account has been created successfully', 'facebook'), osc_page_title()));
    }
}
示例#13
0
文件: utils.php 项目: naneri/Osclass
function osc_do_auto_upgrade()
{
    $data = osc_file_get_contents('http://osclass.org/latest_version_v1.php?callback=?');
    $data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
    $json = json_decode($data);
    $result['error'] = 0;
    if ($json->version > osc_version() && osc_check_dir_writable()) {
        osc_set_preference('update_core_json', $data);
        if (substr($json->version, 0, 1) != substr(osc_version(), 0, 1)) {
            // NEW BRANCH
            if (strpos(osc_auto_update(), 'branch') !== false) {
                osc_run_hook('before_auto_upgrade');
                $result = osc_do_upgrade();
                osc_run_hook('after_auto_upgrade', $result);
            }
        } else {
            if (substr($json->version, 1, 1) != substr(osc_version(), 1, 1)) {
                // MAJOR RELEASE
                if (strpos(osc_auto_update(), 'branch') !== false || strpos(osc_auto_update(), 'major') !== false) {
                    osc_run_hook('before_auto_upgrade');
                    $result = osc_do_upgrade();
                    osc_run_hook('after_auto_upgrade', $result);
                }
            } else {
                if (substr($json->version, 2, 1) != substr(osc_version(), 2, 1)) {
                    // MINOR RELEASE
                    if (strpos(osc_auto_update(), 'branch') !== false || strpos(osc_auto_update(), 'major') !== false || strpos(osc_auto_update(), 'minor') !== false) {
                        osc_run_hook('before_auto_upgrade');
                        $result = osc_do_upgrade();
                        osc_run_hook('after_auto_upgrade', $result);
                    }
                }
            }
        }
    } else {
        osc_set_preference('update_core_json', '');
    }
    osc_set_preference('last_version_check', time());
    if ($result['error'] == 0 || $result['error'] == 6) {
        osc_set_preference('update_core_json', '');
        if (strpos(osc_auto_update(), 'plugins') !== false) {
            $total = osc_check_plugins_update(true);
            if ($total > 0) {
                $elements = osc_get_preference('plugins_to_update');
                foreach ($elements as $element) {
                    if (osc_is_update_compatible('plugins', $element, $json->s_name)) {
                        osc_market('plugins', $element);
                    }
                }
            }
        }
        if (strpos(osc_auto_update(), 'themes') !== false) {
            $total = osc_check_themes_update(true);
            if ($total > 0) {
                $elements = osc_get_preference('themes_to_update');
                foreach ($elements as $element) {
                    if (osc_is_update_compatible('themes', $element, $json->s_name)) {
                        osc_market('themes', $element);
                    }
                }
            }
        }
        if (strpos(osc_auto_update(), 'languages') !== false) {
            $total = osc_check_languages_update(true);
            if ($total > 0) {
                $elements = osc_get_preference('languages_to_update');
                foreach ($elements as $element) {
                    if (osc_is_update_compatible('languages', $element, $json->s_name)) {
                        osc_market('languages', $element);
                    }
                }
            }
        }
    }
}
示例#14
0
        $s_search = base64_decode($alert['s_search']);
        if (stripos(strtolower($s_search), 'union select') !== false || stripos(strtolower($s_search), 't_admin') !== false) {
            $mAlerts->delete(array('pk_i_id' => $alert['pk_i_id']));
        } else {
            $mAlerts->update(array('s_search' => $s_search), array('pk_i_id' => $alert['pk_i_id']));
        }
    }
    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>";
示例#15
0
function get_item_price($item)
{
    $priceFromSession = Session::newInstance()->_getForm('price');
    if (count($item) == 0) {
        if (osc_version() >= 230) {
            $priceFromSession = osc_prepare_price($priceFromSession);
        }
        return $priceFromSession;
    }
    if ($priceFromSession != '') {
        if (osc_version() >= 230) {
            $priceFromSession = osc_prepare_price($priceFromSession);
        }
        return $priceFromSession;
    }
    if (osc_version() < 230) {
        return $item['f_price'];
    }
    return osc_prepare_price($item['i_price']);
}
示例#16
0
文件: plugins.php 项目: semul/Osclass
                        } else {
                            $(this).parent().parent().css('background-color', '#FFFFDF') ;
                        }
                    } else {
                        $(this).parent().parent().css('background-color', '#FFF0DF') ;
                    }
                }) ;
            });
        </script>
        <?php 
}
osc_add_hook('admin_header', 'customHead');
$iDisplayLength = __get('iDisplayLength');
$aData = __get('aPlugins');
$version_length = strlen(osc_version());
$main_version = substr(osc_version(), 0, $version_length - 2) . "." . substr(osc_version(), $version_length - 2, 1);
$tab_index = 0;
osc_current_admin_theme_path('parts/header.php');
?>
<div id="tabs" class="ui-osc-tabs ui-tabs-right">
    <ul>
        <?php 
$aPluginsToUpdate = json_decode(getPreference('plugins_to_update'));
$bPluginsToUpdate = is_array($aPluginsToUpdate) ? true : false;
if ($bPluginsToUpdate && count($aPluginsToUpdate) > 0) {
    $tab_index = 1;
    ?>
        <li><a href="#update-plugins" onclick="window.location = '<?php 
    echo osc_admin_base_url(true) . '?page=plugins#update-plugins';
    ?>
'; return false; "><?php 
示例#17
0
文件: utils.php 项目: semul/Osclass
function osc_file_get_contents($url)
{
    if (testCurl()) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] . ' OSClass (v.' . osc_version() . ')');
        if (!defined('CURLOPT_RETURNTRANSFER')) {
            define('CURLOPT_RETURNTRANSFER', 1);
        }
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($ch);
        curl_close($ch);
    } else {
        if (testFsockopen()) {
            $data = download_fsockopen($url);
        }
    }
    return $data;
}
示例#18
0
    $comm->query("ALTER TABLE " . DB_TABLE_PREFIX . "t_country_stats ADD FOREIGN KEY (fk_c_country_code) REFERENCES " . DB_TABLE_PREFIX . "t_country (pk_c_code)");
    $comm->query("ALTER TABLE " . DB_TABLE_PREFIX . "t_item_location ADD FOREIGN KEY (fk_c_country_code) REFERENCES " . DB_TABLE_PREFIX . "t_country (pk_c_code)");
    $comm->query("ALTER TABLE " . DB_TABLE_PREFIX . "t_user ADD FOREIGN KEY (fk_c_country_code) REFERENCES " . DB_TABLE_PREFIX . "t_country (pk_c_code)");
    // hack
    $comm->query("SET FOREIGN_KEY_CHECKS = 1");
}
if (osc_version() < 241) {
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'use_imagick', '0', 'BOOLEAN')", DB_TABLE_PREFIX));
}
if (osc_version() < 300) {
    $comm->query(sprintf("ALTER TABLE %st_user DROP s_pass_answer", DB_TABLE_PREFIX));
    $comm->query(sprintf("ALTER TABLE %st_user DROP s_pass_question", DB_TABLE_PREFIX));
    osc_set_preference('marketURL', 'http://market.osclass.org/api/');
    osc_set_preference('marketAllowExternalSources', '0', 'BOOLEAN');
}
if (osc_version() < 310) {
    $comm->query(sprintf("ALTER TABLE  %st_pages ADD  `s_meta` TEXT NULL", DB_TABLE_PREFIX));
    $comm->query(sprintf("ALTER TABLE  %st_pages ADD  `b_link` TINYINT(1) NOT NULL DEFAULT 1", DB_TABLE_PREFIX));
    $comm->query(sprintf("UPDATE %st_alerts SET dt_date = '%s' ", DB_TABLE_PREFIX, date("Y-m-d H:i:s")));
    // remove files moved to controller folder
    @unlink(osc_base_path() . 'ajax.php');
    @unlink(osc_base_path() . 'contact.php');
    @unlink(osc_base_path() . 'custom.php');
    @unlink(osc_base_path() . 'item.php');
    @unlink(osc_base_path() . 'language.php');
    @unlink(osc_base_path() . 'login.php');
    @unlink(osc_base_path() . 'main.php');
    @unlink(osc_base_path() . 'page.php');
    @unlink(osc_base_path() . 'register.php');
    @unlink(osc_base_path() . 'search.php');
    @unlink(osc_base_path() . 'user-non-secure.php');
示例#19
0
function customHead()
{
    ?>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#steps_div").hide();
            });
        <?php 
    $perms = osc_save_permissions();
    $ok = osc_change_permissions();
    foreach ($perms as $k => $v) {
        @chmod($k, $v);
    }
    if ($ok) {
        ?>
            $(function() {
                var steps_div = document.getElementById('steps_div');
                steps_div.style.display = '';
                var steps = document.getElementById('steps');
                var version = <?php 
        echo osc_version();
        ?>
;
                var fileToUnzip = '';
                steps.innerHTML += '<?php 
        echo osc_esc_js(sprintf(__('Checking for updates (Current version %s)'), osc_version()));
        ?>
 ';

                $.getJSON("http://osclass.org/latest_version_v1.php?callback=?", function(data) {
                    if(data.version <= version) {
                        steps.innerHTML += '<?php 
        echo osc_esc_js(__('Congratulations! Your Osclass installation is up to date!'));
        ?>
';
                    } else {
                        steps.innerHTML += '<?php 
        echo osc_esc_js(__('New version to update:'));
        ?>
 ' + data.version + "<br />";
                        <?php 
        if (Params::getParam('confirm') == 'true') {
            ?>
                            steps.innerHTML += '<img id="loading_image" src="<?php 
            echo osc_current_admin_theme_url('images/loading.gif');
            ?>
" /><?php 
            echo osc_esc_js(__('Upgrading your Osclass installation (this could take a while):'));
            ?>
';

                            var tempAr = data.url.split('/');
                            fileToUnzip = tempAr.pop();
                            $.getJSON('<?php 
            echo osc_admin_base_url(true);
            ?>
?page=ajax&action=upgrade&<?php 
            echo osc_csrf_token_url();
            ?>
' , function(data) {
                                if(data.error==0 || data.error==6) {
                                    window.location = "<?php 
            echo osc_admin_base_url(true);
            ?>
?page=tools&action=version";
                                }
                                var loading_image = document.getElementById('loading_image');
                                loading_image.style.display = "none";
                                steps.innerHTML += data.message+"<br />";
                            });
                        <?php 
        } else {
            ?>
                            steps.innerHTML += '<input type="button" value="<?php 
            echo osc_esc_html(__('Upgrade'));
            ?>
" onclick="window.location.href=\'<?php 
            echo osc_admin_base_url(true);
            ?>
?page=tools&action=upgrade&confirm=true\';" />';
                        <?php 
        }
        ?>
                    }
                });
            });
        <?php 
    }
    ?>
        </script>
        <?php 
}
示例#20
0
function anr_admin_actions()
{
    if (Params::getParam('file') != 'nocaptcha_recaptcha/admin/admin.php' && Params::getParam('route') != 'anr-admin-settings') {
        return;
    }
    $submit = Params::getParam('anr-admin-settings-submit');
    if ($submit) {
        $flash_error = '';
        $site_key = Params::getParam('site_key');
        $secret_key = Params::getParam('secret_key');
        $language = Params::getParam('language');
        $theme = Params::getParam('theme');
        $error_message = Params::getParam('error_message');
        $loggedin_hide = Params::getParam('loggedin_hide');
        $no_js = Params::getParam('no_js');
        $login = Params::getParam('login');
        $registration = Params::getParam('registration');
        $new = Params::getParam('new');
        $contact = Params::getParam('contact');
        $contact_listing = Params::getParam('contact_listing');
        $send_friend = Params::getParam('send_friend');
        if (!$site_key) {
            $flash_error .= _m("Site Key empty.") . PHP_EOL;
        } else {
            osc_set_preference('site_key', $site_key, 'plugin-anr_nocaptcha');
        }
        if (!$secret_key) {
            $flash_error .= _m("Secret Key empty.") . PHP_EOL;
        } else {
            osc_set_preference('secret_key', $secret_key, 'plugin-anr_nocaptcha');
        }
        if ($theme == 'dark') {
            osc_set_preference('theme', 'dark', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('theme', 'light', 'plugin-anr_nocaptcha');
        }
        if (!$error_message) {
            $flash_error .= _m("Error message empty.") . PHP_EOL;
        } else {
            osc_set_preference('error_message', $error_message, 'plugin-anr_nocaptcha');
        }
        if ($loggedin_hide == '1') {
            osc_set_preference('loggedin_hide', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('loggedin_hide', '0', 'plugin-anr_nocaptcha');
        }
        if ($no_js == '1') {
            osc_set_preference('no_js', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('no_js', '0', 'plugin-anr_nocaptcha');
        }
        if ($login == '1') {
            osc_set_preference('login', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('login', '0', 'plugin-anr_nocaptcha');
        }
        if ($registration == '1') {
            osc_set_preference('registration', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('registration', '0', 'plugin-anr_nocaptcha');
        }
        if ($new == '1') {
            osc_set_preference('new', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('new', '0', 'plugin-anr_nocaptcha');
        }
        if ($contact == '1') {
            osc_set_preference('contact', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('contact', '0', 'plugin-anr_nocaptcha');
        }
        if ($contact_listing == '1') {
            osc_set_preference('contact_listing', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('contact_listing', '0', 'plugin-anr_nocaptcha');
        }
        if ($send_friend == '1') {
            osc_set_preference('send_friend', '1', 'plugin-anr_nocaptcha');
        } else {
            osc_set_preference('send_friend', '0', 'plugin-anr_nocaptcha');
        }
        osc_set_preference('language', $language, 'plugin-anr_nocaptcha');
        if ($flash_error) {
            osc_add_flash_error_message($flash_error, 'admin');
        } else {
            osc_add_flash_ok_message(__('Options has been updated', 'anr'), 'admin');
        }
        osc_reset_preferences();
        if (osc_version() < 320) {
            osc_redirect_to(osc_admin_render_plugin_url('nocaptcha_recaptcha/admin/admin.php'));
        } else {
            osc_redirect_to(osc_route_admin_url('anr-admin-settings'));
        }
    }
}
示例#21
0
function location_by_city()
{
    $country = Params::getParam('country');
    $city = Params::getParam('city');
    if ($country == '') {
        return false;
    }
    if ($city == '') {
        return false;
    }
    $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country&term=' . urlencode(implode(',', $country)) . '&install=true&version=' . osc_version());
    $countries = json_decode($countries_json);
    $manager_country = Country::newInstance();
    if (count($countries) == 0 && reportToOsclass()) {
        LogOsclassInstaller::instance()->error('Cannot get countries - ' . implode(',', $country), __FILE__ . "::" . __LINE__);
    }
    foreach ($countries as $c) {
        $manager_country->insert(array("pk_c_code" => $c->id, "fk_c_locale_code" => $c->locale_code, "s_name" => $c->name));
    }
    $manager_city = City::newInstance();
    $manager_region = Region::newInstance();
    foreach ($countries as $c) {
        $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&term=' . urlencode(implode(',', $city)));
        $cities = json_decode($cities_json);
        if (!isset($cities->error)) {
            foreach ($cities as $ci) {
                $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country=&id=' . $ci->region_id);
                $regions = json_decode($regions_json);
                if (count($regions) == 0 && reportToOsclass()) {
                    LogOsclassInstaller::instance()->error('Cannot get regions by - ' . $ci->region_id, __FILE__ . "::" . __LINE__);
                }
                foreach ($regions as $r) {
                    $manager_region->insert(array("pk_i_id" => $r->id, "fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                }
                $manager_city->insert(array("pk_i_id" => $ci->id, "fk_i_region_id" => $ci->region_id, "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
            }
        } else {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error('Cannot get cities by - ' . $c->name . ' - term ' . implode(',', $city), __FILE__ . "::" . __LINE__);
            }
            return '300';
        }
        unset($cities);
        unset($cities_json);
    }
    return '200';
}
示例#22
0
    foreach ($items as $item) {
        if ($item['f_price'] == null) {
            $sql = sprintf("UPDATE %st_item SET i_price = NULL WHERE pk_i_id = %d", DB_TABLE_PREFIX, $item['pk_i_id']);
        } else {
            $sql = sprintf("UPDATE %st_item SET i_price = %f WHERE pk_i_id = %d", DB_TABLE_PREFIX, 1000000 * $item['f_price'], $item['pk_i_id']);
        }
        $comm->query($sql);
    }
}
if (osc_version() < 234) {
    @unlink(osc_admin_base_path() . "upgrade.php");
    @unlink(osc_admin_base_path() . "/themes/modern/tools/upgrade-plugins.php");
    @unlink(osc_admin_base_path() . "upgrade-plugin.php");
}
osc_changeVersionTo(237);
if (osc_version() < 240) {
    // We no longer use s_what column in /*TABLE_PREFIX*/t_item_description
    $comm->query(sprintf('ALTER TABLE %st_item_description DROP COLUMN s_what', DB_TABLE_PREFIX));
    @unlink(osc_admin_base_path() . "/themes/modern/tools/images.php");
    // NEW REWRITE
    // Uncomment the unlink line prior to release
    //@unlink(osc_base_path()."generate_rules.php");
    osc_set_preference('rewrite_item_url', '{CATEGORIES}/{ITEM_TITLE}_{ITEM_ID}');
    osc_set_preference('rewrite_cat_url', '{CATEGORIES}/');
    osc_set_preference('rewrite_page_url', '{PAGE_SLUG}-p{PAGE_ID}');
    osc_set_preference('rewrite_search_url', 'search/');
    osc_set_preference('rewrite_search_country', 'country');
    osc_set_preference('rewrite_search_region', 'region');
    osc_set_preference('rewrite_search_city', 'city');
    osc_set_preference('rewrite_search_city_area', 'cityarea');
    osc_set_preference('rewrite_search_category', 'category');
示例#23
0
    // insert two new e-mail notifications
    $conn->osc_dbExec(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_alert_validation', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', 'Please validate your alert', '<p>Hi {USER_NAME},</p>\n<p>Please validate your alert registration by clicking on the following link: {VALIDATION_LINK}</p>\n<p>Thank you!</p>\n<p>Regards,</p>\n<p>{WEB_TITLE}</p>')", DB_TABLE_PREFIX, $conn->get_last_id()));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_comment_validated', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', '{WEB_TITLE} - Your comment has been approved', '<p>Hi {COMMENT_AUTHOR},</p>\n<p>Your comment has been approved on the following item: {ITEM_URL}</p>\n<p>Regards,</p>\n<p>{WEB_TITLE}</p>')", DB_TABLE_PREFIX, $conn->get_last_id()));
    osc_changeVersionTo(210);
}
if (osc_version() < 220) {
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_text', '', 'STRING')", DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_text_color', '', 'STRING')", DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_image','', 'STRING')", DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_place', 'centre', 'STRING')", DB_TABLE_PREFIX));
    osc_changeVersionTo(220);
}
osc_changeVersionTo(229);
if (osc_version() < 230) {
    $conn->osc_dbExec(sprintf("CREATE TABLE %st_item_description_tmp (\n    fk_i_item_id INT UNSIGNED NOT NULL,\n    fk_c_locale_code CHAR(5) NOT NULL,\n    s_title VARCHAR(100) NOT NULL,\n    s_description MEDIUMTEXT NOT NULL,\n    s_what VARCHAR(100) NULL,\n\n        PRIMARY KEY (fk_i_item_id, fk_c_locale_code),\n        INDEX (fk_i_item_id),\n        FOREIGN KEY (fk_i_item_id) REFERENCES %st_item (pk_i_id),\n        FOREIGN KEY (fk_c_locale_code) REFERENCES %st_locale (pk_c_code)\n) ENGINE=MyISAM DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX));
    $descriptions = $conn->osc_dbFetchResults("SELECT * FROM %st_item_description", DB_TABLE_PREFIX);
    foreach ($descriptions as $d) {
        $conn->osc_dbExec(sprintf("INSERT INTO %st_item_description_tmp (`fk_i_item_id` ,`fk_c_locale_code` ,`s_title` ,`s_description` ,`s_what`) VALUES ('%d',  '%s',  '%s',  '%s',  '%s')", DB_TABLE_PREFIX, $d['fk_i_item_id'], $d['fk_c_locale_code'], $d['s_title'], $d['s_description'], $d['s_what']));
    }
    $conn->osc_dbExec(sprintf("RENAME TABLE `%st_item_description` TO `%st_item_description_old`", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("RENAME TABLE `%st_item_description_tmp` TO `%st_item_description`", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("ALTER TABLE %st_item_description ADD FULLTEXT(s_description, s_title);", DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'installed_plugins', '%s', 'STRING')", DB_TABLE_PREFIX, osc_get_preference('active_plugins')));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'mailserver_pop', '', 'STRING')", DB_TABLE_PREFIX));
    $conn->osc_dbExec(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'use_imagick', '0', 'BOOLEAN')", DB_TABLE_PREFIX));
    $timezone = 'Europe/Madrid';
    if (ini_get('date.timezone') != '') {
        $timezone = ini_get('date.timezone');
    }
示例#24
0
                osc_set_preference('user', '0', 'voting', 'BOOLEAN');
            }
        }
    } else {
        osc_set_preference('item_voting', '0', 'voting', 'BOOLEAN');
    }
    /**
     * Save User form
     */
    $enable_user = Params::getParam('enable_user');
    if ($enable_user == 'on') {
        osc_set_preference('user_voting', '1', 'voting', 'BOOLEAN');
    } else {
        osc_set_preference('user_voting', '0', 'voting', 'BOOLEAN');
    }
    if (osc_version() < 300) {
        echo '<div style="text-align:center; font-size:22px; background-color:#00bb00;"><p>' . __('Congratulations. The plugin is now configured', 'voting') . '.</p></div>';
        osc_reset_preferences();
    } else {
        ob_get_clean();
        osc_add_flash_ok_message(__('Congratulations. The plugin is now configured', 'voting'), 'admin');
        osc_admin_render_plugin(osc_plugin_folder(__FILE__) . 'conf.php');
    }
}
?>

<div id="settings_form" style="padding-left: 15px; padding-right: 15px;">
    <div style="padding: 20px;">
        <div style="float: left; width: 100%;">
            <b style="font-size: 1.5em;"><?php 
_e('Items', 'voting');
示例#25
0
                $("#steps_div").hide();
            });
        <?php 
$perms = osc_save_permissions();
$ok = osc_change_permissions();
foreach ($perms as $k => $v) {
    @chmod($k, $v);
}
if ($ok) {
    ?>
            $(function() {
                var steps_div = document.getElementById('steps_div');
                steps_div.style.display = "";
                var steps = document.getElementById('steps');
                var version = <?php 
    echo osc_version();
    ?>
 ;
                var fileToUnzip = '';
                steps.innerHTML += "<?php 
    _e('Checking for updates', 'admin');
    ?>
" + " (Current version " + version + "): " ;

                $.getJSON("http://www.osclass.org/latest_version.php?callback=?", function(data) {
                    if(data.version <= version) {
                        steps.innerHTML += "<?php 
    _e('Congratulations! Your OSClass installation is up to date!', 'admin');
    ?>
";
                    } else {
示例#26
0
    }
}
function moreedit_admin_menu()
{
    echo '<h3><a href="#">More Edit Options</a></h3>
        <ul>
            <li><a href="' . osc_admin_render_plugin_url(osc_plugin_folder(__FILE__) . 'admin/conf.php') . '">&raquo; ' . __('More Options', 'moreedit') . '</a></li>
        </ul>';
}
function moreedit_init_admin_menu()
{
    osc_add_admin_submenu_divider('plugins', 'More edit plugin', 'moreedit_divider', 'administrator');
    osc_add_admin_submenu_page('plugins', __('More edit options', 'moreedit'), osc_route_admin_url('moreedit-conf'), 'moreedit_settings', 'administrator');
}
/**
 * ADD HOOKS
 */
osc_register_plugin(osc_plugin_path(__FILE__), 'moreedit_install');
osc_add_hook(osc_plugin_path(__FILE__) . "_uninstall", 'moreedit_uninstall');
if (osc_version() < 320) {
    osc_add_hook('admin_menu', 'moreedit_admin_menu');
} else {
    osc_add_route('moreedit-conf', 'moreedit/conf', 'moreedit/conf', osc_plugin_folder(__FILE__) . 'admin/conf.php');
    osc_add_hook('admin_menu_init', 'moreedit_init_admin_menu');
}
osc_add_hook('posted_item', 'moreedit_moderate_all');
osc_add_hook('edited_item', 'moreedit_moderate_edit');
osc_add_hook('posted_item', 'moreedit_posted_item');
osc_add_hook('edited_item', 'moreedit_edited_item');
osc_add_hook('post_item', 'moreedit_item_add');
osc_add_hook('init', 'moreedit_item_edit');
示例#27
0
function breadcrumbs_help()
{
    if (osc_version() < 320) {
        osc_admin_render_plugin(osc_plugin_path(dirname(__FILE__)) . '/help.php');
    } else {
        osc_redirect_to(osc_route_admin_url('breadcrumbs-admin-help'));
    }
}
示例#28
0
文件: ajax.php 项目: adrienrn/Osclass
 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format'))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'categories_order':
             // Save the order of the categories
             osc_csrf_check(false);
             $aIds = Params::getParam('list');
             $order = array();
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $cat) {
                 if (!isset($order[$cat['p']])) {
                     $order[$cat['p']] = 0;
                 }
                 $res = $catManager->update(array('fk_i_parent_id' => $cat['p'] == 'root' ? NULL : $cat['p'], 'i_position' => $order[$cat['p']]), array('pk_i_id' => $cat['c']));
                 if (is_bool($res) && !$res) {
                     $error = 1;
                 } else {
                     if ($res == 1) {
                         $aRecountCat[] = $cat['c'];
                     }
                 }
                 $order[$cat['p']] = $order[$cat['p']] + 1;
             }
             // update category stats
             foreach ($aRecountCat as $rId) {
                 osc_update_cat_stats_id($rId);
             }
             if ($error) {
                 $result = array('error' => __("An error occurred"));
             } else {
                 $result = array('ok' => __("Order saved"));
             }
             echo json_encode($result);
             break;
         case 'category_edit_iframe':
             $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id"), 'all'));
             if (count(Category::newInstance()->findSubcategories(Params::getParam("id"))) > 0) {
                 $this->_exportVariableToView('has_subcategories', true);
             } else {
                 $this->_exportVariableToView('has_subcategories', false);
             }
             $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/iframe.php");
             break;
         case 'field_categories_iframe':
             $selected = Field::newInstance()->categories(Params::getParam("id"));
             if ($selected == null) {
                 $selected = array();
             }
             $this->_exportVariableToView("selected", $selected);
             $this->_exportVariableToView("field", Field::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
             $this->doView("fields/iframe.php");
             break;
         case 'field_categories_post':
             osc_csrf_check(false);
             $error = 0;
             $field = Field::newInstance()->findByName(Params::getParam("s_name"));
             if (!isset($field['pk_i_id']) || isset($field['pk_i_id']) && $field['pk_i_id'] == Params::getParam("id")) {
                 // remove categories from a field
                 Field::newInstance()->cleanCategoriesFromField(Params::getParam("id"));
                 // no error... continue updating fields
                 if ($error == 0) {
                     $slug = Params::getParam("field_slug") != '' ? Params::getParam("field_slug") : Params::getParam("s_name");
                     $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($slug)));
                     $slug_k = 0;
                     while (true) {
                         $field = Field::newInstance()->findBySlug($slug);
                         if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                             break;
                         } else {
                             $slug_k++;
                             $slug = $slug_tmp . "_" . $slug_k;
                         }
                     }
                     // trim options
                     $s_options = '';
                     $aux = Params::getParam('s_options');
                     $aAux = explode(',', $aux);
                     foreach ($aAux as &$option) {
                         $option = trim($option);
                     }
                     $s_options = implode(',', $aAux);
                     $res = Field::newInstance()->update(array('s_name' => Params::getParam("s_name"), 'e_type' => Params::getParam("field_type"), 's_slug' => $slug, 'b_required' => Params::getParam("field_required") == "1" ? 1 : 0, 'b_searchable' => Params::getParam("field_searchable") == "1" ? 1 : 0, 's_options' => $s_options), array('pk_i_id' => Params::getParam("id")));
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                 }
                 // no error... continue inserting categories-field
                 if ($error == 0) {
                     $aCategories = Params::getParam("categories");
                     if (is_array($aCategories) && count($aCategories) > 0) {
                         $res = Field::newInstance()->insertCategories(Params::getParam("id"), $aCategories);
                         if (!$res) {
                             $error = 1;
                         }
                     }
                 }
                 // error while updating?
                 if ($error == 1) {
                     $message = __("An error occurred while updating.");
                 }
             } else {
                 $error = 1;
                 $message = __("Sorry, you already have a field with that name");
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"), 'text' => Params::getParam("s_name"), 'field_id' => Params::getParam("id"));
             }
             echo json_encode($result);
             break;
         case 'delete_field':
             osc_csrf_check(false);
             $res = Field::newInstance()->deleteByPrimaryKey(Params::getParam('id'));
             if ($res > 0) {
                 $result = array('ok' => __('The custom field has been deleted'));
             } else {
                 $result = array('error' => __('An error occurred while deleting'));
             }
             echo json_encode($result);
             break;
         case 'add_field':
             osc_csrf_check(false);
             $s_name = __('NEW custom field');
             $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($s_name)));
             $slug_k = 0;
             while (true) {
                 $field = Field::newInstance()->findBySlug($slug);
                 if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                     break;
                 } else {
                     $slug_k++;
                     $slug = $slug_tmp . "_" . $slug_k;
                 }
             }
             $fieldManager = Field::newInstance();
             $result = $fieldManager->insertField($s_name, 'TEXT', $slug, 0, '', array());
             if ($result) {
                 echo json_encode(array('error' => 0, 'field_id' => $fieldManager->dao->insertedId(), 'field_name' => $s_name));
             } else {
                 echo json_encode(array('error' => 1));
             }
             break;
         case 'enable_category':
             osc_csrf_check(false);
             $id = strip_tags(Params::getParam('id'));
             $enabled = Params::getParam('enabled') != '' ? Params::getParam('enabled') : 0;
             $error = 0;
             $result = array();
             $aUpdated = array();
             $mCategory = Category::newInstance();
             $aCategory = $mCategory->findByPrimaryKey($id);
             if ($aCategory == false) {
                 $result = array('error' => sprintf(__("No category with id %d exists"), $id));
                 echo json_encode($result);
                 break;
             }
             // root category
             if ($aCategory['fk_i_parent_id'] == '') {
                 $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
                 $mCategory->update(array('b_enabled' => $enabled), array('fk_i_parent_id' => $id));
                 $subCategories = $mCategory->findSubcategories($id);
                 $aIds = array($id);
                 $aUpdated[] = array('id' => $id);
                 foreach ($subCategories as $subcategory) {
                     $aIds[] = $subcategory['pk_i_id'];
                     $aUpdated[] = array('id' => $subcategory['pk_i_id']);
                 }
                 Item::newInstance()->enableByCategory($enabled, $aIds);
                 if ($enabled) {
                     $result = array('ok' => __('The category as well as its subcategories have been enabled'));
                 } else {
                     $result = array('ok' => __('The category as well as its subcategories have been disabled'));
                 }
                 $result['affectedIds'] = $aUpdated;
                 echo json_encode($result);
                 break;
             }
             // subcategory
             $parentCategory = $mCategory->findRootCategory($id);
             if (!$parentCategory['b_enabled']) {
                 $result = array('error' => __('Parent category is disabled, you can not enable that category'));
                 echo json_encode($result);
                 break;
             }
             $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
             if ($enabled) {
                 $result = array('ok' => __('The subcategory has been enabled'));
             } else {
                 $result = array('ok' => __('The subcategory has been disabled'));
             }
             $result['affectedIds'] = array(array('id' => $id));
             echo json_encode($result);
             break;
         case 'delete_category':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $error = 0;
             $categoryManager = Category::newInstance();
             $res = $categoryManager->deleteByPrimaryKey($id);
             if ($res > 0) {
                 $message = __('The categories have been deleted');
             } else {
                 $error = 1;
                 $message = __('An error occurred while deleting');
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"));
             }
             echo json_encode($result);
             break;
         case 'edit_category_post':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
             $fields['b_price_enabled'] = Params::getParam('b_price_enabled') != '' ? 1 : 0;
             $apply_changes_to_subcategories = Params::getParam('apply_changes_to_subcategories') == 1 ? true : false;
             $error = 0;
             $has_one_title = 0;
             $postParams = Params::getParamsAsArray();
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     if ($m[2] == 's_name') {
                         if ($v != "") {
                             $has_one_title = 1;
                             $aFieldsDescription[$m[1]][$m[2]] = $v;
                             $s_text = $v;
                         } else {
                             $aFieldsDescription[$m[1]][$m[2]] = NULL;
                             $error = 1;
                         }
                     } else {
                         $aFieldsDescription[$m[1]][$m[2]] = $v;
                     }
                 }
             }
             $l = osc_language();
             if ($error == 0 || $error == 1 && $has_one_title == 1) {
                 $categoryManager = Category::newInstance();
                 $res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
                 $categoryManager->updateExpiration($id, $fields['i_expiration_days'], $apply_changes_to_subcategories);
                 $categoryManager->updatePriceEnabled($id, $fields['b_price_enabled'], $apply_changes_to_subcategories);
                 if (is_bool($res)) {
                     $error = 2;
                 }
             }
             if ($error == 0) {
                 $msg = __("Category updated correctly");
             } else {
                 if ($error == 1) {
                     if ($has_one_title == 1) {
                         $error = 4;
                         $msg = __('Category updated correctly, but some titles are empty');
                     } else {
                         $msg = __('Sorry, including at least a title is mandatory');
                     }
                 } else {
                     if ($error == 2) {
                         $msg = __('An error occurred while updating');
                     }
                 }
             }
             echo json_encode(array('error' => $error, 'msg' => $msg, 'text' => $aFieldsDescription[$l]['s_name']));
             break;
         case 'custom':
             // Execute via AJAX custom file
             if (Params::existParam('route')) {
                 $routes = Rewrite::newInstance()->getRoutes();
                 $rid = Params::getParam('route');
                 $file = '../';
                 if (isset($routes[$rid]) && isset($routes[$rid]['file'])) {
                     $file = $routes[$rid]['file'];
                 }
             } else {
                 $file = Params::getParam("ajaxfile");
             }
             if ($file == '') {
                 echo json_encode(array('error' => 'no action defined'));
                 break;
             }
             // valid file?
             if (stripos($file, '../') !== false || stripos($file, '..\\') !== false) {
                 echo json_encode(array('error' => 'no valid file'));
                 break;
             }
             if (!file_exists(osc_plugins_path() . $file)) {
                 echo json_encode(array('error' => "file doesn't exist"));
                 break;
             }
             require_once osc_plugins_path() . $file;
             break;
         case 'test_mail':
             $title = sprintf(__('Test email, %s'), osc_page_title());
             $body = __("Test email") . "<br><br>" . osc_page_title();
             $emailParams = array('subject' => $title, 'to' => osc_contact_email(), 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'test_mail_template':
             // replace por valores por defecto
             $email = Params::getParam("email");
             $title = Params::getParam("title");
             $body = Params::getParam("body", false, false);
             $emailParams = array('subject' => $title, 'to' => $email, 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'order_pages':
             osc_csrf_check(false);
             $order = Params::getParam("order");
             $id = Params::getParam("id");
             if ($order != '' && $id != '') {
                 $mPages = Page::newInstance();
                 $actual_page = $mPages->findByPrimaryKey($id);
                 $actual_order = $actual_page['i_order'];
                 $array = array();
                 $condition = array();
                 $new_order = $actual_order;
                 if ($order == 'up') {
                     $page = $mPages->findPrevPage($actual_order);
                 } else {
                     if ($order == 'down') {
                         $page = $mPages->findNextPage($actual_order);
                     }
                 }
                 if (isset($page['i_order'])) {
                     $mPages->update(array('i_order' => $page['i_order']), array('pk_i_id' => $id));
                     $mPages->update(array('i_order' => $actual_order), array('pk_i_id' => $page['pk_i_id']));
                 }
             }
             break;
         case 'check_version':
             $data = osc_file_get_contents('http://osclass.org/latest_version_v1.php?callback=?');
             $data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
             $json = json_decode($data);
             if (isset($json->version)) {
                 if ($json->version > osc_version()) {
                     osc_set_preference('update_core_json', $data);
                     echo json_encode(array('error' => 0, 'msg' => __('Update available')));
                 } else {
                     osc_set_preference('update_core_json', '');
                     echo json_encode(array('error' => 0, 'msg' => __('No update available')));
                 }
                 osc_set_preference('last_version_check', time());
             } else {
                 // Latest version couldn't be checked (site down?)
                 osc_set_preference('last_version_check', time() - 82800);
                 // 82800 = 23 hours, so repeat check in one hour
                 echo json_encode(array('error' => 1, 'msg' => __('Version could not be checked')));
             }
             break;
         case 'check_languages':
             $total = _osc_check_languages_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
         case 'check_themes':
             $total = _osc_check_themes_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
         case 'check_plugins':
             $total = _osc_check_plugins_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check();
             $result = osc_do_upgrade();
             if (!defined('__FROM_CRON__') || !__FROM_CRON__) {
                 if ($result['error'] == 0) {
                     osc_add_flash_ok_message($result['message'], 'admin');
                 } else {
                     if ($result['error'] == 6) {
                         osc_add_flash_warning_message($result['message'], 'admin');
                     }
                 }
             }
             echo json_encode($result);
             break;
             /*******************************
              ** COMPLETE MARKET PROCESS **
              *******************************/
         /*******************************
          ** COMPLETE MARKET PROCESS **
          *******************************/
         case 'market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check(false);
             $result = osc_market(Params::getParam('section'), Params::getParam('code'));
             echo json_encode($result);
             break;
         case 'check_market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $section = Params::getParam('section');
             $code = Params::getParam('code');
             $data = array();
             /************************
              *** CHECK VALID CODE ***
              ************************/
             if ($code != '' && $section != '') {
                 if (stripos($code, "http://") === FALSE) {
                     // OSCLASS OFFICIAL REPOSITORY
                     $data = json_decode(osc_file_get_contents(osc_market_url($section, $code), array('api_key' => osc_market_api_connect())), true);
                 } else {
                     // THIRD PARTY REPOSITORY
                     if (osc_market_external_sources()) {
                         $data = json_decode(osc_file_get_contents($code), true);
                     } else {
                         echo json_encode(array('error' => 3, 'error_msg' => __('No external sources are allowed')));
                         break;
                     }
                 }
                 if (!isset($data['s_source_file']) || !isset($data['s_update_url'])) {
                     //$data = array('error' => 2, 'error_msg' => __('Invalid code'));
                 }
             } else {
                 $data = array('error' => 1, 'error_msg' => __('No code was submitted'));
             }
             echo json_encode($data);
             break;
         case 'market_data':
             $section = Params::getParam('section');
             $page = Params::getParam("mPage");
             $featured = Params::getParam("featured");
             $sort = Params::getParam("sort");
             $order = Params::getParam("order");
             // for the moment this value is static
             $length = 9;
             if ($page >= 1) {
                 $page--;
             }
             $url = osc_market_url($section) . "page/" . $page . '/';
             if ($length != '' && is_numeric($length)) {
                 $url .= 'length/' . $length . '/';
             }
             if ($sort != '') {
                 $url .= 'order/' . $sort;
                 if ($order != '') {
                     $url .= '/' . $order;
                 }
             }
             if ($featured != '') {
                 $url = osc_market_featured_url($section);
             }
             $data = array();
             $data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
             if (!isset($data[$section])) {
                 $data = array('error' => 1, 'error_msg' => __('No market data'));
             }
             echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';';
             break;
         case 'local_market':
             // AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST
             $marketPage = Params::getParam("mPage");
             if ($marketPage >= 1) {
                 $marketPage--;
             }
             $out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage, array('api_key' => osc_market_api_connect()));
             $array = json_decode($out, true);
             // do pagination
             $pageActual = $array['page'];
             $totalPages = ceil($array['total'] / $array['sizePage']);
             $params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5);
             // set pagination
             $pagination = new Pagination($params);
             $aux = $pagination->doPagination();
             $array['pagination_content'] = $aux;
             // encode to json
             echo json_encode($array);
             break;
         case 'market_connect':
             $json = osc_file_get_contents(osc_market_url() . 'connect/', array('s_email' => Params::getParam('s_email'), 's_password' => Params::getParam('s_password')));
             $data = json_decode($json, true);
             if ($data['error'] == 0) {
                 osc_set_preference('marketAPIConnect', $data['api_key']);
                 unset($data['api_key']);
                 $json = json_encode($data);
             }
             echo $json;
             break;
         case 'dashboardbox_market':
             $error = 0;
             // make market call
             $url = osc_get_preference('marketURL') . 'dashboardbox/';
             $content = '';
             if (false === ($json = @osc_file_get_contents($url))) {
                 $error = 1;
             } else {
                 $content = $json;
             }
             if ($error == 1) {
                 echo json_encode(array('error' => 1));
             } else {
                 // replace content with correct urls
                 $content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content);
                 $content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content);
                 echo json_encode(array('html' => $content));
             }
             break;
         case 'market_header':
             $error = 0;
             // make market call
             $url = osc_get_preference('marketURL') . 'market_header/';
             $content = '';
             if (false === ($json = @osc_file_get_contents($url))) {
                 $error = 1;
             } else {
                 $content = $json;
             }
             if ($error == 1) {
                 echo json_encode(array('error' => 1));
             } else {
                 echo json_encode(array('html' => $content));
             }
             break;
         case 'location_stats':
             osc_csrf_check(false);
             $workToDo = osc_update_location_stats();
             if ($workToDo > 0) {
                 $array['status'] = 'more';
                 $array['pending'] = $workToDo;
                 echo json_encode($array);
             } else {
                 $array['status'] = 'done';
                 echo json_encode($array);
             }
             break;
         case 'country_slug':
             $exists = Country::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'country' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'region_slug':
             $exists = Region::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'region' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'city_slug':
             $exists = City::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'city' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'error_permissions':
             echo json_encode(array('error' => __("You don't have the necessary permissions")));
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
     // clear all keep variables into session
     Session::newInstance()->_dropKeepForm();
     Session::newInstance()->_clearVariables();
 }
}
function voting_help_title($title)
{
    return __('Help', 'voting');
}
if (Params::getParam('page') == 'plugins' && strpos('voting/admin/conf.php', $file) === 0) {
    osc_add_filter('custom_plugin_title', 'voting_conf_title');
}
function voting_conf_title($title)
{
    return __('Configuration', 'voting');
}
/**
 * ADMIN MENU
 */
if (osc_version() >= 300) {
    osc_add_hook('admin_menu_init', 'voting_init_admin_menu');
} else {
    osc_add_hook('admin_menu', 'voting_admin_menu');
}
function votingmenu()
{
    ?>
<style>
    .ico-voting_plugin {
        background-image: url('<?php 
    echo osc_base_url();
    ?>
oc-content/plugins/<?php 
    echo osc_plugin_folder(__FILE__);
    ?>
示例#30
0
 * of the GNU Affero General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
if (!defined('ABS_PATH')) {
    define('ABS_PATH', dirname(dirname(dirname(__FILE__))) . '/');
}
require_once ABS_PATH . 'oc-load.php';
// UPDATE DATABASE
if (!defined('AUTO_UPGRADE')) {
    if (file_exists(osc_lib_path() . 'osclass/installer/struct.sql')) {
        $sql = file_get_contents(osc_lib_path() . 'osclass/installer/struct.sql');
        $conn = getConnection();
        $conn->osc_updateDB(str_replace('/*TABLE_PREFIX*/', DB_TABLE_PREFIX, $sql));
    }
}
$version = osc_version();
Preference::newInstance()->update(array('s_value' => time()), array('s_section' => 'osclass', 's_name' => 'last_version_check'));
osc_changeVersionTo(203);
if (Params::getParam('action') == '') {
    require_once LIB_PATH . 'osclass/helpers/hErrors.php';
    $title = 'OSClass &raquo; Updated correctly';
    $message = 'OSClass has been updated successfully. <a href="http://forums.osclass.org/">Need more help?</a>';
    osc_die($title, $message);
}