<link href="admin.css" rel="stylesheet" type="text/css" />
<div class="plugin-page">
	<div class="col5">
		<?php 
$pluginInfo = osc_plugin_get_info('nm_copypaste_plugin/index.php');
?>
        <div class="form-container">
        <h2 class="render-title"><?php 
_e('Nomore Copy/Paste Settings', 'nm_copypaste_plugin');
?>
</h2>
        <form action="<?php 
echo osc_admin_render_plugin_url('nm_copypaste_plugin/admin/settings.php');
?>
" class="form-horizontal" method="post">
          <input type="hidden" name="nomoreoption" value="nomoresettings" />
          <fieldset>
          <div class="control-group">
            <label class="control-label"><strong><?php 
_e('Enter field id/class name to disable paste option', 'nm_copypaste_plugin');
?>
</strong></label>
            <div class="controls">
                <textarea rows="6" name="nm_id"><?php 
echo osc_esc_html(dd_nm_id());
?>
</textarea>
            </div>
            <span class="help"><?php 
_e('Add more id/class names by adding comma', 'nm_copypaste_plugin');
?>
示例#2
0
function _osc_check_plugins_update()
{
    $total = 0;
    $array = array();
    $array_downloaded = array();
    $plugins = Plugins::listAll();
    foreach ($plugins as $plugin) {
        $info = osc_plugin_get_info($plugin);
        if (osc_check_plugin_update(@$info['plugin_update_uri'], @$info['version'])) {
            $array[] = @$info['plugin_update_uri'];
            $total++;
        } else {
        }
        $array_downloaded[] = @$info['plugin_update_uri'];
    }
    osc_set_preference('plugins_to_update', json_encode($array));
    osc_set_preference('plugins_downloaded', json_encode($array_downloaded));
    osc_set_preference('plugins_update_count', $total);
    osc_set_preference('plugins_last_version_check', time());
    osc_reset_preferences();
    return $total;
}
<?php

$pluginInfo = osc_plugin_get_info('all_in_one/index.php');
$dao_preference = new Preference();
$show_links_footer = '';
if (Params::getParam('show_links_footer') != '') {
    $show_links_footer = Params::getParam('show_links_footer');
} else {
    $show_links_footer = osc_get_preference('allSeo_links_footer', 'plugin-all_in_one') != '' ? osc_get_preference('allSeo_links_footer', 'plugin-all_in_one') : '';
}
// check if delete command was not send for backlink
if (Params::getParam('what') == 'delete' and Params::getParam('link_id') != '') {
    $det = ModelSeoLink::newInstance()->getAttrByLinkId(Params::getParam('link_id'));
    if (ModelSeoLink::newInstance()->deleteLink(Params::getParam('link_id'))) {
        message_ok('Back Link with ID ' . Params::getParam('link_id') . ' and title <strong>' . $det['seo_title'] . '</strong> was successfully deleted!');
    } else {
        message_error('Error occurred while deleting BackLink with <strong>ID ' . Params::getParam('link_id') . '</strong>. Probably it was already deleted!');
    }
}
// check if delete command was not send for reciprocal link
if (Params::getParam('what') == 'delete_rec' and Params::getParam('link_id') != '') {
    $det = ModelSeoLink::newInstance()->getRecLinkById(Params::getParam('link_id'));
    if (ModelSeoLink::newInstance()->deleteLinkRec(Params::getParam('link_id'))) {
        message_ok('Reciprocal Link with ID ' . Params::getParam('link_id') . ' and placed on <strong>' . $det['seo_href_from'] . '</strong> was successfully deleted!');
    } else {
        message_error('Error occurred while deleting reciprocal link with <strong>ID ' . Params::getParam('link_id') . '</strong>. Probably it was already deleted!');
    }
}
// check if refresh status command was not send
if (Params::getParam('what') == 'refresh' and Params::getParam('link_id') != '') {
    $detail = ModelSeoLink::newInstance()->getRecLinkById(Params::getParam('link_id'));
	.form-container { border:2px solid #ddd; background:#fff; }
	.form-container h2 { margin:0; padding:10px 15px; background:#47639e; color:#fff;}
	.form-container fieldset { padding:15px; }
	.control-group { margin-bottom:15px; }
	.control-label { margin-bottom:5px; display:block; }
	.form-actions { margin-top:15px; margin-bottom:0;}
	.form-horizontal .form-actions { padding-left:15px;}
	.form-container input[type=text] { padding:10px; width:95%; }
	.form-container input[type=text].swidth { width:30%; }
	
	.clearfix { clear:both; }
</style>
<div class="plugin-page">
	<div class="col5">
		<?php 
$pluginInfo = osc_plugin_get_info('fb_page_plugin/index.php');
?>
        <div class="form-container">
        <h2 class="render-title"><?php 
_e('Facebook Page Plugin Help', 'fb_page_plugin');
?>
</h2>
        	
          
        </div>
	</div><!-- /Col5 -->
    
    <div class="col6">
    	<div class="promobox">
		<?php 
echo dd_fb_sidebar();
示例#5
0
function osc_check_plugins_update( $force = false )
{
    $total = 0;
    $array = array();
    $array_downloaded = array();
    // check if exist a new version each day
    if( (time() - osc_plugins_last_version_check()) > (24 * 3600) || $force ) {
        $plugins    = Plugins::listAll();
        foreach($plugins as $plugin) {
            $info = osc_plugin_get_info($plugin);
            if(osc_check_plugin_update(@$info['plugin_update_uri'], @$info['version'])) {
                $array[] = @$info['plugin_update_uri'];
                $total++;
            }else{
            }
            $array_downloaded[] = @$info['plugin_update_uri'];
        }

        osc_set_preference( 'plugins_to_update' , json_encode($array) );
        osc_set_preference( 'plugins_downloaded', json_encode($array_downloaded) );
        osc_set_preference( 'plugins_update_count', $total );
        osc_set_preference( 'plugins_last_version_check', time() );
        osc_reset_preferences();
    } else {
        $total = getPreference('plugins_update_count');
    }

    return $total;
}
示例#6
0
    $pmAdmin = Params::getParam('pmAdmin');
} else {
    $pmAdmin = pmAdmin() != '' ? pmAdmin() : '';
}
if (Params::getParam('option') == 'stepone') {
    $dao_preference->update(array("s_value" => $sendEmail), array("s_section" => "plugin-osclass_pm", "s_name" => "sendEmail"));
    $dao_preference->update(array("s_value" => $maxPm), array("s_section" => "plugin-osclass_pm", "s_name" => "maxPMs"));
    $dao_preference->update(array("s_value" => $deletePM), array("s_section" => "plugin-osclass_pm", "s_name" => "deletePM"));
    $dao_preference->update(array("s_value" => $pmBlocking), array("s_section" => "plugin-osclass_pm", "s_name" => "pmBlocking"));
    $dao_preference->update(array("s_value" => $pmDrafts), array("s_section" => "plugin-osclass_pm", "s_name" => "pmDrafts"));
    $dao_preference->update(array("s_value" => $pmSent), array("s_section" => "plugin-osclass_pm", "s_name" => "pmSent"));
    $dao_preference->update(array("s_value" => $pmAdmin), array("s_section" => "plugin-osclass_pm", "s_name" => "pmAdmin"));
    echo '<div style="text-align:center; font-size:22px; background-color:#00bb00;"><p>' . __('Settings Saved', 'osclass_pm') . '.</p></div>';
}
unset($dao_preference);
$pluginInfo = osc_plugin_get_info('osclass_pm/index.php');
//print_r(osc_plugin_get_info('osclass_pm/index.php'));
?>

<form action="<?php 
osc_admin_base_url(true);
?>
" method="post">
    <input type="hidden" name="page" value="plugins" />
    <input type="hidden" name="action" value="renderplugin" />
    <input type="hidden" name="file" value="osclass_pm/admin.php" />
    <input type="hidden" name="option" value="stepone" />
    <div>
    <fieldset>
        <h2><?php 
_e('OSClass PM Settings', 'osclass_pm');
示例#7
0
                            '<option value="20">20</option>'+
                            '<option value="100">100</option>'+
                            '</select> <?php 
_e('entries');
?>
',
                            "sSearch": '<span class="ui-icon ui-icon-search" style="display: inline-block;"></span>'
                     },
                    "sPaginationType": "full_numbers",
                    "aaData": [

                        <?php 
foreach ($plugins as $p) {
    ?>
                        <?php 
    $p_info = osc_plugin_get_info($p);
    ?>
                        <?php 
    osc_plugin_is_installed($p) ? $installed = 1 : ($installed = 0);
    ?>
                            [
                                "<input type='hidden' name='installed' value='<?php 
    echo $installed;
    ?>
' /><input type='checkbox' name='id[]' value='<?php 
    echo $p;
    ?>
' />",
                                "<?php 
    echo $p_info['plugin_name'];
    ?>
示例#8
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/>.
 */
$aPlugin = __get('plugins');
$active_plugins = osc_get_plugins();
$aData = array();
foreach ($aPlugin as $plugin) {
    $row = array();
    $pInfo = osc_plugin_get_info($plugin);
    // prepare row 1
    $installed = 0;
    if (osc_plugin_is_installed($plugin)) {
        $installed = 1;
    }
    $enabled = 0;
    if (osc_plugin_is_enabled($plugin)) {
        $enabled = 1;
    }
    // prepare row 4
    $sConfigure = '';
    if (isset($active_plugins[$plugin . '_configure'])) {
        $sConfigure = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=admin&amp;plugin=' . $pInfo['filename'] . '">' . __('Configure') . '</a>';
    }
    // prepare row 5
示例#9
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add':
             $this->doView("plugins/add.php");
             break;
         case 'add_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             }
             osc_csrf_check();
             $package = Params::getFiles("package");
             if (isset($package['size']) && $package['size'] != 0) {
                 $path = osc_plugins_path();
                 (int) ($status = osc_unzip_file($package['tmp_name'], $path));
             } else {
                 $status = 3;
             }
             switch ($status) {
                 case 0:
                     $msg = _m('The plugin folder is not writable');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 1:
                     $msg = _m('The plugin has been uploaded correctly');
                     osc_add_flash_ok_message($msg, 'admin');
                     break;
                 case 2:
                     $msg = _m('The zip file is not valid');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 3:
                     $msg = _m('No file was uploaded');
                     osc_add_flash_error_message($msg, 'admin');
                     $this->redirectTo(osc_admin_base_url(true) . "?page=plugins&action=add");
                     break;
                 case -1:
                 default:
                     $msg = _m('There was a problem adding the plugin');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             break;
         case 'install':
             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=plugins');
             }
             osc_csrf_check();
             $pn = Params::getParam('plugin');
             // set header just in case it's triggered some fatal error
             header("Location: " . osc_admin_base_url(true) . "?page=plugins&error=" . $pn, true, '302');
             $installed = Plugins::install($pn);
             if (is_array($installed)) {
                 switch ($installed['error_code']) {
                     case 'error_output':
                         osc_add_flash_error_message(sprintf(_m('The plugin generated %d characters of <strong>unexpected output</strong> during the installation'), strlen($installed['output'])), 'admin');
                         break;
                     case 'error_installed':
                         osc_add_flash_error_message(_m('Plugin is already installed'), 'admin');
                         break;
                     case 'error_file':
                         osc_add_flash_error_message(_m("Plugin couldn't be installed because their files are missing"), 'admin');
                         break;
                     case 'custom_error':
                         osc_add_flash_error_message(sprintf(_m("Plugin couldn't be installed because of: %s"), $installed['msg']), 'admin');
                         break;
                     default:
                         osc_add_flash_error_message(_m("Plugin couldn't be installed"), 'admin');
                         break;
                 }
             } else {
                 osc_add_flash_ok_message(_m('Plugin installed'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'uninstall':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::uninstall(Params::getParam("plugin"))) {
                 osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'enable':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::activate(Params::getParam('plugin'))) {
                 osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'disable':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::deactivate(Params::getParam('plugin'))) {
                 osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'admin':
             $plugin = Params::getParam("plugin");
             if ($plugin != "") {
                 Plugins::runHook($plugin . '_configure');
             }
             break;
         case 'admin_post':
             Plugins::runHook('admin_post');
             break;
         case 'renderplugin':
             $file = Params::getParam("file");
             if ($file != "") {
                 // We pass the GET variables (in case we have somes)
                 if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
                     $file = $match[1];
                     if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
                         for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
                             //$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
                             //$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
                             Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
                         }
                     }
                 } else {
                     $file = $_REQUEST['file'];
                 }
                 $this->_exportVariableToView("file", osc_plugins_path() . $file);
                 //osc_renderPluginView($file);
                 $this->doView("plugins/view.php");
             }
             break;
         case 'configure':
             $plugin = Params::getParam("plugin");
             if ($plugin != '') {
                 $plugin_data = Plugins::getInfo($plugin);
                 $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
                 $this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name']));
                 $this->_exportVariableToView("plugin_data", $plugin_data);
                 $this->doView("plugins/configuration.php");
             } else {
                 $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             }
             break;
         case 'configure_post':
             osc_csrf_check();
             $plugin_short_name = Params::getParam("plugin_short_name");
             $categories = Params::getParam("categories");
             if ($plugin_short_name != "") {
                 Plugins::cleanCategoryFromPlugin($plugin_short_name);
                 if (isset($categories)) {
                     Plugins::addToCategoryPlugin($categories, $plugin_short_name);
                 }
                 osc_add_flash_ok_message(_m('Configuration was saved'), 'admin');
                 $this->redirectTo(osc_get_http_referer());
             }
             osc_add_flash_error_message(_m('No plugin selected'), 'admin');
             $this->doView('plugins/index.php');
             break;
         case 'error_plugin':
             // force php errors and simulate plugin installation to show the errors in the iframe
             if (!OSC_DEBUG) {
                 error_reporting(E_ALL | E_STRICT);
             }
             @ini_set('display_errors', 1);
             include osc_plugins_path() . Params::getParam('plugin');
             Plugins::install(Params::getParam('plugin'));
             exit;
             break;
         default:
             //                    $marketError = Params::getParam('marketError');
             //                    $slug = Params::getParam('slug');
             //                    if($marketError!='') {
             //                        if($marketError == '0') { // no error installed ok
             //                            $extra = '<br/><br/><b>' . __('You only need to install and configure the plugin.') . '</b>';
             //                            osc_add_flash_ok_message( __('Everything was OK!') . ' ( ' . $slug . ' ) ' . $extra , 'admin');
             //                        } else {
             //                            osc_add_flash_error_message( __('Error occurred') . ' ' . $slug , 'admin');
             //                        }
             //                    }
             if (Params::getParam('checkUpdated') != '') {
                 osc_admin_toolbar_update_plugins(true);
             }
             if (Params::getParam('iDisplayLength') == '') {
                 Params::setParam('iDisplayLength', 10);
             }
             // ?
             $this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
             $p_iPage = 1;
             if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') >= 1) {
                 $p_iPage = Params::getParam('iPage');
             }
             Params::setParam('iPage', $p_iPage);
             $aPlugin = Plugins::listAll();
             $active_plugins = osc_get_plugins();
             // pagination
             $start = ($p_iPage - 1) * Params::getParam('iDisplayLength');
             $limit = Params::getParam('iDisplayLength');
             $count = count($aPlugin);
             $displayRecords = $limit;
             if ($start + $limit > $count) {
                 $displayRecords = $start + $limit - $count;
             }
             // --------------------------------------------------------
             $aData = array();
             $aInfo = array();
             $max = $start + $limit;
             if ($max > $count) {
                 $max = $count;
             }
             $aPluginsToUpdate = json_decode(getPreference('plugins_to_update'));
             $bPluginsToUpdate = is_array($aPluginsToUpdate) ? true : false;
             for ($i = $start; $i < $max; $i++) {
                 $plugin = $aPlugin[$i];
                 $row = array();
                 $pInfo = osc_plugin_get_info($plugin);
                 // prepare row 1
                 $installed = 0;
                 if (osc_plugin_is_installed($plugin)) {
                     $installed = 1;
                 }
                 $enabled = 0;
                 if (osc_plugin_is_enabled($plugin)) {
                     $enabled = 1;
                 }
                 // prepare row 2
                 $sUpdate = '';
                 // get plugins to update from t_preference
                 if ($bPluginsToUpdate) {
                     if (in_array(@$pInfo['plugin_update_uri'], $aPluginsToUpdate)) {
                         $sUpdate = '<a class="market_update market-popup" href="#' . htmlentities($pInfo['plugin_update_uri']) . '">' . __("There's a new update available") . '</a>';
                     }
                 }
                 // prepare row 4
                 $sConfigure = '';
                 if (isset($active_plugins[$plugin . '_configure'])) {
                     $sConfigure = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=admin&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Configure') . '</a>';
                 }
                 // prepare row 5
                 $sEnable = '';
                 if ($installed) {
                     if ($enabled) {
                         $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=disable&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Disable') . '</a>';
                     } else {
                         $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;
                             action=enable&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Enable') . '</a>';
                     }
                 }
                 // prepare row 6
                 $sInstall = '';
                 if ($installed) {
                     $sInstall = '<a onclick="javascript:return uninstall_dialog(\'' . $pInfo['filename'] . '\');" href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=uninstall&amp;
                             plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Uninstall') . '</a>';
                 } else {
                     $sInstall = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;
                         action=install&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Install') . '</a>';
                 }
                 $row[] = '<input type="hidden" name="installed" value="' . $installed . '" enabled="' . $enabled . '" />' . $pInfo['plugin_name'] . '<div>' . $sUpdate . '</div>';
                 $row[] = $pInfo['description'];
                 $row[] = $sUpdate != '' ? $sUpdate : '&nbsp;';
                 $row[] = $sConfigure != '' ? $sConfigure : '&nbsp;';
                 $row[] = $sEnable != '' ? $sEnable : '&nbsp;';
                 $row[] = $sInstall != '' ? $sInstall : '&nbsp;';
                 $aData[] = $row;
                 if (@$pInfo['plugin_update_uri'] != '') {
                     $aInfo[@$pInfo['plugin_update_uri']] = $pInfo;
                 } else {
                     $aInfo[$i] = $pInfo;
                 }
             }
             $array['iTotalRecords'] = $displayRecords;
             $array['iTotalDisplayRecords'] = count($aPlugin);
             $array['iDisplayLength'] = $limit;
             $array['aaData'] = $aData;
             $array['aaInfo'] = $aInfo;
             // --------------------------------------------------------
             $page = (int) Params::getParam('iPage');
             if (count($array['aaData']) == 0 && $page != 1) {
                 $total = (int) $array['iTotalDisplayRecords'];
                 $maxPage = ceil($total / (int) $array['iDisplayLength']);
                 $url = osc_admin_base_url(true) . '?' . $_SERVER['QUERY_STRING'];
                 if ($maxPage == 0) {
                     $url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
                     $this->redirectTo($url);
                 }
                 if ($page > 1) {
                     $url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
                     $this->redirectTo($url);
                 }
             }
             $this->_exportVariableToView('aPlugins', $array);
             $this->doView("plugins/index.php");
             break;
     }
 }
示例#10
0
 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add':
             $this->doView("plugins/add.php");
             break;
         case 'add_post':
             if (defined('DEMO')) {
                 osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             }
             osc_csrf_check();
             $package = Params::getFiles("package");
             if (isset($package['size']) && $package['size'] != 0) {
                 $path = osc_plugins_path();
                 (int) ($status = osc_unzip_file($package['tmp_name'], $path));
                 @unlink($package['tmp_name']);
             } else {
                 $status = 3;
             }
             switch ($status) {
                 case 0:
                     $msg = _m('The plugin folder is not writable');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 1:
                     $msg = _m('The plugin has been uploaded correctly');
                     osc_add_flash_ok_message($msg, 'admin');
                     break;
                 case 2:
                     $msg = _m('The zip file is not valid');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
                 case 3:
                     $msg = _m('No file was uploaded');
                     osc_add_flash_error_message($msg, 'admin');
                     $this->redirectTo(osc_admin_base_url(true) . "?page=plugins&action=add");
                     break;
                 case -1:
                 default:
                     $msg = _m('There was a problem adding the plugin');
                     osc_add_flash_error_message($msg, 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             break;
         case 'install':
             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=plugins');
             }
             osc_csrf_check();
             $pn = Params::getParam('plugin');
             // set header just in case it's triggered some fatal error
             header("Location: " . osc_admin_base_url(true) . "?page=plugins&error=" . $pn, true, '302');
             $installed = Plugins::install($pn);
             if (is_array($installed)) {
                 switch ($installed['error_code']) {
                     case 'error_output':
                         osc_add_flash_error_message(sprintf(_m('The plugin generated %d characters of <strong>unexpected output</strong> during the installation. Output: "%s"'), strlen($installed['output']), $installed['output']), 'admin');
                         break;
                     case 'error_installed':
                         osc_add_flash_error_message(_m('Plugin is already installed'), 'admin');
                         break;
                     case 'error_file':
                         osc_add_flash_error_message(_m("Plugin couldn't be installed because their files are missing"), 'admin');
                         break;
                     case 'custom_error':
                         osc_add_flash_error_message(sprintf(_m("Plugin couldn't be installed because of: %s"), $installed['msg']), 'admin');
                         break;
                     default:
                         osc_add_flash_error_message(_m("Plugin couldn't be installed"), 'admin');
                         break;
                 }
             } else {
                 osc_add_flash_ok_message(_m('Plugin installed'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'uninstall':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::uninstall(Params::getParam("plugin"))) {
                 osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'enable':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::activate(Params::getParam('plugin'))) {
                 osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'disable':
             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=plugins');
             }
             osc_csrf_check();
             if (Plugins::deactivate(Params::getParam('plugin'))) {
                 osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
             } else {
                 osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
             break;
         case 'admin':
             $plugin = Params::getParam("plugin");
             if ($plugin != "") {
                 osc_run_hook($plugin . '_configure');
             }
             break;
         case 'admin_post':
             osc_run_hook('admin_post');
             break;
         case 'renderplugin':
             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 {
                 // DEPRECATED: Disclosed path in URL is deprecated, use routes instead
                 // This will be REMOVED in 3.4
                 $file = Params::getParam('file');
                 // We pass the GET variables (in case we have somes)
                 if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
                     $file = $match[1];
                     if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
                         for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
                             Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
                         }
                     }
                 } else {
                     $file = Params::getParam('file');
                 }
             }
             osc_run_hook('renderplugin_controller');
             if (stripos($file, '../') === false && stripos($file, '..\\') === false && $file != "") {
                 $this->_exportVariableToView("file", osc_plugins_path() . $file);
                 $this->doView("plugins/view.php");
             }
             break;
         case 'configure':
             $plugin = Params::getParam("plugin");
             if ($plugin != '') {
                 $plugin_data = Plugins::getInfo($plugin);
                 $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
                 $this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name']));
                 $this->_exportVariableToView("plugin_data", $plugin_data);
                 $this->doView("plugins/configuration.php");
             } else {
                 $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             }
             break;
         case 'configure_post':
             osc_csrf_check();
             $plugin_short_name = Params::getParam("plugin_short_name");
             $categories = Params::getParam("categories");
             if ($plugin_short_name != "") {
                 Plugins::cleanCategoryFromPlugin($plugin_short_name);
                 if (isset($categories)) {
                     Plugins::addToCategoryPlugin($categories, $plugin_short_name);
                 }
                 osc_run_hook('plugin_categories_' . Params::getParam('plugin'), $categories);
                 osc_add_flash_ok_message(_m('Configuration was saved'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             }
             osc_add_flash_error_message(_m('No plugin selected'), 'admin');
             $this->doView('plugins/index.php');
             break;
         case 'delete':
             osc_csrf_check();
             $plugin = str_replace('/index.php', '', Params::getParam("plugin"));
             $path = preg_replace('([\\/]+)', '/', CONTENT_PATH . 'plugins/' . $plugin);
             if ($plugin != "" && strpos($plugin, '../') === false && strpos($plugin, '..\\') === false && $path != CONTENT_PATH . 'plugins/') {
                 if (osc_deleteDir($path)) {
                     osc_add_flash_ok_message(_m('The files were deleted'), 'admin');
                 } else {
                     osc_add_flash_error_message(sprintf(_m('There were an error deleting the files, please check the permissions of the files in %s'), $path . "/"), 'admin');
                 }
                 $this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
             }
             osc_add_flash_error_message(_m('No plugin selected'), 'admin');
             $this->doView('plugins/index.php');
             break;
         case 'error_plugin':
             // force php errors and simulate plugin installation to show the errors in the iframe
             if (!OSC_DEBUG) {
                 error_reporting(E_ALL | E_STRICT);
             }
             @ini_set('display_errors', 1);
             include osc_plugins_path() . Params::getParam('plugin');
             Plugins::install(Params::getParam('plugin'));
             exit;
             break;
         default:
             if (Params::getParam('checkUpdated') != '') {
                 osc_admin_toolbar_update_plugins(true);
             }
             if (Params::getParam('iDisplayLength') == '') {
                 Params::setParam('iDisplayLength', 25);
             }
             $this->_exportVariableToView('iDisplayLength', Params::getParam('iDisplayLength'));
             $p_iPage = 1;
             if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') >= 1) {
                 $p_iPage = Params::getParam('iPage');
             }
             Params::setParam('iPage', $p_iPage);
             $aPlugin = Plugins::listAll();
             $active_plugins = osc_get_plugins();
             // pagination
             $start = ($p_iPage - 1) * Params::getParam('iDisplayLength');
             $limit = Params::getParam('iDisplayLength');
             $count = count($aPlugin);
             $displayRecords = $limit;
             if ($start + $limit > $count) {
                 $displayRecords = $start + $limit - $count;
             }
             // --------------------------------------------------------
             $aData = array();
             $aInfo = array();
             $max = $start + $limit;
             if ($max > $count) {
                 $max = $count;
             }
             $aPluginsToUpdate = json_decode(osc_get_preference('plugins_to_update'));
             $bPluginsToUpdate = is_array($aPluginsToUpdate) ? true : false;
             for ($i = $start; $i < $max; $i++) {
                 $plugin = $aPlugin[$i];
                 $row = array();
                 $pInfo = osc_plugin_get_info($plugin);
                 // prepare row 1
                 $installed = 0;
                 if (osc_plugin_is_installed($plugin)) {
                     $installed = 1;
                 }
                 $enabled = 0;
                 if (osc_plugin_is_enabled($plugin)) {
                     $enabled = 1;
                 }
                 // prepare row 2
                 $sUpdate = '';
                 // get plugins to update from t_preference
                 if ($bPluginsToUpdate) {
                     if (in_array(@$pInfo['plugin_update_uri'], $aPluginsToUpdate)) {
                         $sUpdate = '<a class="market_update market-popup" href="#' . htmlentities($pInfo['plugin_update_uri']) . '">' . __("There's a new update available") . '</a>';
                     }
                 }
                 // prepare row 4
                 $sConfigure = '';
                 if (isset($active_plugins[$plugin . '_configure'])) {
                     $sConfigure = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=admin&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Configure') . '</a>';
                 }
                 // prepare row 5
                 $sEnable = '';
                 if ($installed) {
                     if ($enabled) {
                         $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=disable&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Disable') . '</a>';
                     } else {
                         $sEnable = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=enable&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Enable') . '</a>';
                     }
                 }
                 // prepare row 6
                 if ($installed) {
                     $sInstall = '<a onclick="javascript:return uninstall_dialog(\'' . $pInfo['filename'] . '\', \'' . $pInfo['plugin_name'] . '\');" href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=uninstall&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Uninstall') . '</a>';
                 } else {
                     $sInstall = '<a href="' . osc_admin_base_url(true) . '?page=plugins&amp;action=install&amp;plugin=' . $pInfo['filename'] . "&amp;" . osc_csrf_token_url() . '">' . __('Install') . '</a>';
                 }
                 $sDelete = '';
                 if (!$installed) {
                     $sDelete = '<a href="javascript:delete_plugin(\'' . $pInfo['filename'] . '\');" >' . __('Delete') . '</a>';
                 }
                 $sHelp = '';
                 if ($pInfo['support_uri'] != '') {
                     $sHelp = '<span class="plugin-support-icon plugin-tooltip" ><a target="_blank" href="' . osc_sanitize_url($pInfo['support_uri']) . '" ><img src="' . osc_current_admin_theme_url('images/question.png') . '" alt="' . osc_esc_html(__('Problems with this plugin? Ask for support.')) . '" ></a></span>';
                 }
                 $sSiteUrl = '';
                 if ($pInfo['plugin_uri'] != '') {
                     $sSiteUrl = ' | <a target="_blank" href="' . $pInfo['plugin_uri'] . '">' . __('Plugins Site') . '</a>';
                 }
                 if ($pInfo['author_uri'] != '') {
                     $sAuthor = __('By') . ' <a target="_blank" href="' . $pInfo['author_uri'] . '">' . $pInfo['author'] . '</a>';
                 } else {
                     $sAuthor = __('By') . ' ' . $pInfo['author'];
                 }
                 $row[] = '<input type="hidden" name="installed" value="' . $installed . '" enabled="' . $enabled . '" />' . $pInfo['plugin_name'] . $sHelp . '<div>' . $sUpdate . '</div>';
                 $row[] = $pInfo['description'] . '<br />' . __('Version:') . $pInfo['version'] . ' | ' . $sAuthor . $sSiteUrl;
                 $row[] = $sUpdate != '' ? $sUpdate : '&nbsp;';
                 $row[] = $sConfigure != '' ? $sConfigure : '&nbsp;';
                 $row[] = $sEnable != '' ? $sEnable : '&nbsp;';
                 $row[] = $sInstall != '' ? $sInstall : '&nbsp;';
                 $row[] = $sDelete != '' ? $sDelete : '&nbsp;';
                 $aData[] = $row;
                 if (@$pInfo['plugin_update_uri'] != '') {
                     $aInfo[@$pInfo['plugin_update_uri']] = $pInfo;
                 } else {
                     $aInfo[$i] = $pInfo;
                 }
             }
             $array['iTotalRecords'] = $displayRecords;
             $array['iTotalDisplayRecords'] = count($aPlugin);
             $array['iDisplayLength'] = $limit;
             $array['aaData'] = $aData;
             $array['aaInfo'] = $aInfo;
             // --------------------------------------------------------
             $page = (int) Params::getParam('iPage');
             if (count($array['aaData']) == 0 && $page != 1) {
                 $total = (int) $array['iTotalDisplayRecords'];
                 $maxPage = ceil($total / (int) $array['iDisplayLength']);
                 $url = osc_admin_base_url(true) . '?' . Params::getServerParam('QUERY_STRING', false, false);
                 if ($maxPage == 0) {
                     $url = preg_replace('/&iPage=(\\d)+/', '&iPage=1', $url);
                     $this->redirectTo($url);
                 }
                 if ($page > 1) {
                     $url = preg_replace('/&iPage=(\\d)+/', '&iPage=' . $maxPage, $url);
                     $this->redirectTo($url);
                 }
             }
             $this->_exportVariableToView('aPlugins', $array);
             $this->doView("plugins/index.php");
             break;
     }
 }