function __construct($text)
 {
     parent::__construct($text);
     $this->dom_array = gpPlugin::Filter('Html_Output', array($this->dom_array));
     $this->Clean();
     $this->Rebuild();
 }
Exemple #2
0
 function gp_html_output($text)
 {
     $this->gp_html_parse($text);
     $this->dom_array = gpPlugin::Filter('Html_Output', array($this->dom_array));
     $this->Clean();
     $this->Rebuild();
 }
Exemple #3
0
 function Example_Ajax()
 {
     global $page, $addonRelativeCode;
     //prepare the page
     $page->head_js[] = $addonRelativeCode . 'static/02_script.js';
     $page->admin_js = true;
     //get request parameters and execute any commands
     $string = '';
     if (isset($_REQUEST['string'])) {
         $string = $_REQUEST['string'];
     }
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'randomstring':
             $string = common::RandomString(10);
             break;
     }
     //display the form
     echo '<h2>Example Ajax Requests</h2>';
     echo '<form method="post" action="' . $page->title . '">';
     echo 'Text: <input type="text" name="string" value="' . htmlspecialchars($string) . '" size="30" />';
     echo ' <input type="submit" class="gpajax" value="Post Form Asynchronosly" /> ';
     echo common::Link($page->title, 'Get Random String', 'cmd=randomstring', 'name="gpajax"');
     echo '</form>';
     //output the $_REQUEST variable
     echo '<h3>Request</h3>';
     echo showArray($_REQUEST);
     //plugin example navigation
     gpPlugin::incl('navigation.php');
     PluginExampleNavigation();
 }
Exemple #4
0
 /**
  * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist
  * @static
  *
  */
 static function Check()
 {
     global $page, $langmessage, $config, $dataDir;
     // if hooks return false, stop
     if (!gpPlugin::Filter('AntiSpam_Check', array(true))) {
         return false;
     }
     // if recaptcha inactive, stop
     if (!gp_recaptcha::hasRecaptcha()) {
         return true;
     }
     //prevent undefined index warnings if there is a bot
     $_POST += array('recaptcha_challenge_field' => '', 'recaptcha_response_field' => '');
     //includeFile('thirdparty/recaptchalib.php');
     require_once $dataDir . '/include/thirdparty/recaptchalib.php';
     $resp = recaptcha_check_answer($config['recaptcha_private'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
     if (!$resp->is_valid) {
         message($langmessage['INCORRECT_CAPTCHA']);
         //if( common::LoggedIn() ){
         //	message($langmessage['recaptcha_said'],$resp->error);
         //}
         return false;
     }
     return true;
 }
Exemple #5
0
 function Save()
 {
     global $langmessage;
     $theme =& $_POST['theme'];
     if (isset($this->themes[$theme])) {
         $this->config['theme'] = $theme;
     }
     if (gpPlugin::SaveConfig($this->config)) {
         message($langmessage['SAVED']);
     } else {
         message($langmessage['OOPS']);
     }
 }
 function GetContent()
 {
     $this->GetGpxContent();
     if (!empty($this->non_admin_content)) {
         echo '<div class="filetype-text cf">';
         //echo '<div id="gpx_content" class="filetype-text">'; //id="gpx_content" conflicts with admin content
         echo $this->non_admin_content;
         echo '</div>';
     }
     echo '<div id="gpAfterContent">';
     gpOutput::Get('AfterContent');
     gpPlugin::Action('GetContent_After');
     echo '</div>';
 }
Exemple #7
0
 function RunScript()
 {
     global $gp_index, $langmessage, $page;
     $scriptinfo = special_display::GetScriptInfo($this->title);
     if ($scriptinfo === false) {
         switch ($this->title) {
             case 'Special_ExtraJS':
                 $this->ExtraJS();
                 //dies
         }
         $this->Error_404($this->title);
         return;
     }
     $this->gp_index = $gp_index[$this->title];
     $this->TitleInfo = $scriptinfo;
     $menu_permissions = false;
     if (common::LoggedIn()) {
         $menu_permissions = admin_tools::HasPermission('Admin_Menu');
         if ($menu_permissions) {
             $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', 'data-cmd="gpajax"');
             $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), array('title' => $langmessage['current_layout'], 'data-cmd' => 'gpabox'));
         }
         if (admin_tools::HasPermission('Admin_User')) {
             $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox'));
         }
     }
     //allow addons to affect page actions and how a page is displayed
     $cmd = common::GetCommand();
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     if ($menu_permissions) {
         switch ($cmd) {
             // rename & details
             case 'renameform':
                 $this->RenameForm();
                 return;
             case 'renameit':
                 if ($this->RenameFile()) {
                     return;
                 }
                 break;
         }
     }
     $this->contentBuffer = special_display::ExecInfo($scriptinfo);
 }
Exemple #8
0
 function RunScript()
 {
     global $gp_index, $langmessage, $page;
     $scriptinfo = special_display::GetScriptInfo($this->title);
     if ($scriptinfo === false) {
         switch ($this->title) {
             case 'Special_ExtraJS':
                 $this->ExtraJS();
                 //dies
         }
         $this->Error_404($this->title);
         return;
     }
     $this->gp_index = $gp_index[$this->title];
     $this->TitleInfo = $scriptinfo;
     if (!$this->CheckVisibility()) {
         return false;
     }
     //allow addons to affect page actions and how a page is displayed
     $cmd = common::GetCommand();
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     if (common::LoggedIn()) {
         $menu_permissions = admin_tools::HasPermission('Admin_Menu');
         if ($menu_permissions) {
             switch ($cmd) {
                 // rename & details
                 case 'renameform':
                     $this->RenameForm();
                     return;
                 case 'renameit':
                     if ($this->RenameFile()) {
                         return;
                     }
                     break;
                 case 'ToggleVisibility':
                     $this->ToggleVisibility();
                     break;
             }
         }
         $this->AdminLinks();
     }
     $this->contentBuffer = special_display::ExecInfo($scriptinfo);
 }
Exemple #9
0
 function Example_Map()
 {
     global $page, $addonRelativeCode;
     //add css and js to <head>
     $page->head .= '<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />';
     $page->head .= '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script>';
     $page->head .= '<script type="text/javascript" src="' . $addonRelativeCode . '/static/01_script.js"></script>';
     //html contents of the page
     echo '<h2>Display a Google Map With Directions</h2>';
     echo '<div id="input">';
     echo '<input id="map_address" type="textbox" value="starting point" />';
     echo '<input type="button" value="calculate route" id="calc_route_button" />';
     echo '</div>';
     echo '<div id="directionsPanel" style="float:right;width:300px;"></div>';
     echo '<div id="map_canvas" style="width:500px;height:500px;"></div>';
     //plugin example navigation
     gpPlugin::incl('navigation.php');
     PluginExampleNavigation();
 }
Exemple #10
0
 /**
  * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist
  * @static
  *
  */
 static function Check()
 {
     global $page, $langmessage, $config, $dataDir;
     // if hooks return false, stop
     if (!gpPlugin::Filter('AntiSpam_Check', array(true))) {
         return false;
     }
     // if recaptcha inactive, stop
     if (!gp_recaptcha::hasRecaptcha()) {
         return true;
     }
     if (empty($_POST['g-recaptcha-response'])) {
         return false;
     }
     require_once $dataDir . '/include/thirdparty/recaptcha/autoload.php';
     if (!ini_get('allow_url_fopen')) {
         // allow_url_fopen = Off
         $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private'], new \ReCaptcha\RequestMethod\SocketPost());
     } else {
         // allow_url_fopen = On
         $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private']);
     }
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $ip);
     if (!$resp->isSuccess()) {
         //$error_codes = $resp->getErrorCodes();
         //error_log();
         msg($langmessage['INCORRECT_CAPTCHA']);
         return false;
     }
     return true;
 }
Exemple #11
0
<?php

defined('is_running') or die('Not an entry point...');
gpPlugin::Incl('Common.php');
class MultiLang_Admin extends MultiLang_Common
{
    protected $cmds = array();
    //executable commands
    public function __construct()
    {
        global $config;
        $config += array('menus' => array());
        parent::__construct();
        $this->AddResources();
        $this->cmds['TitleSettingsSave'] = '';
        $this->cmds['TitleSettings'] = '';
        $this->cmds['RemoveTitle'] = 'TitleSettings';
        $this->cmds['NotTranslated'] = '';
        $this->cmds['SaveLanguages'] = 'SelectLanguages';
        $this->cmds['SelectLanguages'] = '';
        $this->cmds['PrimaryLanguage'] = '';
        $this->cmds['PrimaryLanguageSave'] = 'DefaultDisplay';
        $this->cmds['AllTitles'] = '';
        $cmd = common::GetCommand();
        $this->RunCommands($cmd);
    }
    /**
     * Run Commands
     * See \gp\Base::RunCommands() (available in TS 5.0)
     *
     */
Exemple #12
0
 function GetContent()
 {
     $this->GetGpxContent();
     echo '<div id="gpAfterContent">';
     gpOutput::Get('AfterContent');
     gpPlugin::Action('GetContent_After');
     echo '</div>';
 }
<?php

defined('is_running') or die('Not an entry point...');
gpPlugin::incl('SimpleBlogCommon.php', 'require_once');
class SimpleBlogCategories
{
    function SimpleBlogCategories()
    {
        global $addonPathData;
        SimpleBlogCommon::AddCSS();
        $gadget_file = $addonPathData . '/gadget_categories.php';
        $content = '';
        if (file_exists($gadget_file)) {
            $content = file_get_contents($gadget_file);
        }
        //fix edit links
        if (strpos($content, 'simple_blog_gadget_label')) {
            new SimpleBlogCommon();
            $content = file_get_contents($gadget_file);
        }
        if (empty($content)) {
            return;
        }
        echo '<div class="simple_blog_gadget"><div>';
        echo '<span class="simple_blog_gadget_label">';
        echo gpOutput::GetAddonText('Categories');
        echo '</span>';
        echo $content;
        echo '</div></div>';
    }
}
 /**
  * Add syntax highlighting to the page
  * Check for <pre class="brush:jscript;">.. php...
  * Add the appropriate js and css files
  *
  */
 static function CheckContent()
 {
     global $page, $addonRelativeCode;
     $content = ob_get_contents();
     $avail_brushes['css'] = 'shBrushCss.js';
     $avail_brushes['diff'] = 'shBrushDiff.js';
     $avail_brushes['ini'] = 'shBrushIni.js';
     $avail_brushes['jscript'] = 'shBrushJScript.js';
     $avail_brushes['php'] = 'shBrushPhp.js';
     $avail_brushes['plain'] = 'shBrushPlain.js';
     $avail_brushes['sql'] = 'shBrushSql.js';
     $avail_brushes['xml'] = 'shBrushXml.js';
     $brushes = array();
     preg_match_all('#<pre[^<>]*>#', $content, $matches);
     if (!count($matches)) {
         return;
     }
     foreach ($matches[0] as $match) {
         preg_match('#class=[\'"]([^\'"]+)[\'"]#', $match, $classes);
         if (!isset($classes[1])) {
             continue;
         }
         preg_match('#brush:([^;\'"]+)[;"\']?#', $match, $type);
         if (!isset($type[1])) {
             continue;
         }
         $type = strtolower(trim($type[1]));
         if (!isset($avail_brushes[$type])) {
             continue;
         }
         $brushes[] = $avail_brushes[$type];
     }
     if (!count($brushes)) {
         return;
     }
     $config = gpPlugin::GetConfig();
     $theme =& $config['theme'];
     $page->head .= "\n\n";
     $page->head .= '<link rel="stylesheet" type="text/css" href="' . $addonRelativeCode . '/syntaxhighlighter/styles/shCore.css" />' . "\n";
     $css_file = 'shThemeDefault.css';
     switch ($theme) {
         case 'django':
             $css_file = 'shThemeDjango.css';
             break;
         case 'eclipse':
             $css_file = 'shThemeEclipse.css';
             break;
         case 'emacs':
             $css_file = 'shThemeEmacs.css';
             break;
         case 'fadetogrey':
             $css_file = 'shThemeFadeToGrey.css';
             break;
         case 'midnight':
             $css_file = 'shThemeMidnight.css';
             break;
         case 'rdark':
             $css_file = 'shThemeRDark.css';
             break;
         case 'none':
             $css_file = false;
             break;
     }
     if ($css_file) {
         $page->head .= '<link rel="stylesheet" type="text/css" href="' . $addonRelativeCode . '/syntaxhighlighter/styles/' . $css_file . '" />' . "\n";
     }
     $page->head .= '<script language="javascript" type="text/javascript" src="' . $addonRelativeCode . '/syntaxhighlighter/scripts/shCore.js"></script>' . "\n";
     foreach ($brushes as $brush) {
         $page->head .= '<script language="javascript" type="text/javascript" src="' . $addonRelativeCode . '/syntaxhighlighter/scripts/' . $brush . '"></script>' . "\n";
     }
     $page->jQueryCode .= "\nSyntaxHighlighter.all();\n";
 }
Exemple #15
0
 /**
  * Clean a slug posted by the user
  * @param string $slug The slug provided by the user
  * @return string
  * @since 2.4b5
  */
 static function PostedSlug($string, $from_label = false)
 {
     global $config;
     includeFile('tool/strings.php');
     $orig_string = $string;
     // Remove control characters
     $string = preg_replace('#[[:cntrl:]]#u', '', $string);
     // 	[\x00-\x1F\x7F]
     //illegal characters
     $string = str_replace(array('?', '*', ':', '|'), array('', '', '', ''), $string);
     //change known entities to their character equivalent
     $string = gp_strings::entity_unescape($string);
     //if it's from a label, remove any html
     if ($from_label) {
         $string = admin_tools::LabelHtml($string);
         $string = strip_tags($string);
         //after removing tags, unescape special characters
         $string = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $string);
     }
     // # character after unescape for entities and unescape of special chacters when $from_label is true
     $string = str_replace('#', '', $string);
     //slashes
     $string = admin_tools::SlugSlashes($string);
     $string = str_replace(' ', $config['space_char'], $string);
     return gpPlugin::Filter('PostedSlug', array($string, $orig_string, $from_label));
 }
Exemple #16
0
<?php

defined('is_running') or die('Not an entry point...');
gpPlugin::Incl('Languages.php');
class MultiLang_Common
{
    var $config_file;
    var $config;
    var $lists = array();
    var $titles = array();
    var $langs = array();
    var $lang;
    var $language;
    function Init()
    {
        global $addonPathData, $config, $ml_languages;
        $this->config_file = $addonPathData . '/config.php';
        $this->lang = $config['language'];
        $this->GetData();
    }
    function GetData()
    {
        global $ml_languages;
        $config = array();
        if (file_exists($this->config_file)) {
            require $this->config_file;
        }
        $config += array('titles' => array(), 'lists' => array(), 'langs' => array());
        $this->config = $config;
        $this->FixConfig();
        $this->lists = $this->config['lists'];
 /**
  * Return formatted content for the $section_data
  * @return string
  *
  */
 static function SectionToContent($section_data, $section_num)
 {
     $section_data = gpPlugin::Filter('SectionToContent', array($section_data, $section_num));
     switch ($section_data['type']) {
         case 'text':
             return self::TextContent($section_data['content']);
         case 'include':
             return self::IncludeContent($section_data);
         case 'gallery':
             common::ShowingGallery();
             return $section_data['content'];
     }
     return $section_data['content'];
 }
Exemple #18
0
 /**
  * Outputs the sitemap link, admin login/logout link, powered by link, admin html and messages
  * @static
  */
 static function GetAdminLink()
 {
     global $config, $langmessage, $page;
     if (!isset($config['showsitemap']) || $config['showsitemap']) {
         echo ' <span class="sitemap_link">';
         echo common::Link('Special_Site_Map', $langmessage['site_map']);
         echo '</span>';
     }
     if (!isset($config['showlogin']) || $config['showlogin']) {
         echo ' <span class="login_link">';
         if (common::LoggedIn()) {
             echo common::Link($page->title, $langmessage['logout'], 'cmd=logout', array('data-cmd' => 'creq', 'rel' => 'nofollow'));
         } else {
             echo common::Link('Admin', $langmessage['login'], 'file=' . rawurlencode($page->title), ' rel="nofollow" data-cmd="login"');
         }
         echo '</span>';
     }
     if (!isset($config['showgplink']) || $config['showgplink']) {
         echo ' <span id="powered_by_link">';
         echo 'Powered by <a href="http://gpEasy.com" title="A Free and Easy CMS in PHP" target="_blank">gp|Easy CMS</a>';
         echo '</span>';
     }
     gpPlugin::Action('GetAdminLink');
     echo GetMessages();
     //global $gpLayouts;
     //echo pre($gpLayouts);
     //$included = get_included_files();
     //echo pre($included);
 }
Exemple #19
0
 static function InlineEdit($section_data)
 {
     $section_data += array('type' => '', 'content' => '');
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($type) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
         case 'image':
             echo 'var gp_blank_img = ' . gpAjax::quote(common::GetDir('/include/imgs/blank.gif')) . ';';
             $scripts[] = '/include/js/jquery.auto_upload.js';
             $scripts[] = '/include/js/inline_edit/image_common.js';
             $scripts[] = '/include/js/inline_edit/image_edit.js';
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     self::SendScripts($scripts);
     //replace resized images with their originals
     if (isset($section_data['resized_imgs']) && is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
Exemple #20
0
 static function RenameFileWorker($title)
 {
     global $langmessage, $dataDir, $gp_index;
     //use new_label or new_title
     if (isset($_POST['new_title'])) {
         $new_title = admin_tools::PostedSlug($_POST['new_title']);
     } else {
         $new_title = admin_tools::LabelToSlug($_POST['new_label']);
     }
     //title unchanged
     if ($new_title == $title) {
         return $title;
     }
     $special_file = false;
     if (common::SpecialOrAdmin($title)) {
         $special_file = true;
     }
     if (!admin_tools::CheckTitle($new_title, $message)) {
         msg($message);
         return false;
     }
     $old_gp_index = $gp_index;
     //re-index: make the new title point to the same data index
     $old_file = gpFiles::PageFile($title);
     $file_index = $gp_index[$title];
     unset($gp_index[$title]);
     $gp_index[$new_title] = $file_index;
     //rename the php file
     if (!$special_file) {
         $new_file = gpFiles::PageFile($new_title);
         //we don't have to rename files if we're using the index naming convention. See gpFiles::PageFile() for more info
         if ($new_file == $old_file) {
             //if the file being renamed doesn't use the index naming convention, then we'll still need to rename it
         } elseif (!rename($old_file, $new_file)) {
             msg($langmessage['OOPS'] . ' (N3)');
             $gp_index = $old_gp_index;
             return false;
         }
         //gallery rename
         includeFile('special/special_galleries.php');
         special_galleries::RenamedGallery($title, $new_title);
     }
     //create a 301 redirect
     if (isset($_POST['add_redirect']) && $_POST['add_redirect'] == 'add') {
         includeFile('admin/admin_missing.php');
         admin_missing::AddRedirect($title, $new_title);
     }
     gpPlugin::Action('RenameFileDone', array($file_index, $title, $new_title));
     return $new_title;
 }
Exemple #21
0
 /**
  * Clean a string of html that may be used as file content
  *
  * @param string $text The string to be cleansed. Passed by reference
  */
 public static function CleanText(&$text)
 {
     includeFile('tool/editing.php');
     gp_edit::tidyFix($text);
     gpFiles::rmPHP($text);
     gpFiles::FixTags($text);
     $text = gpPlugin::Filter('CleanText', array($text));
 }
Exemple #22
0
 function PluginPanelGroup($addon_key, $info)
 {
     global $langmessage, $gpLayouts;
     $addon_config = gpPlugin::GetAddonConfig($addon_key);
     $addon_config += $info;
     //merge the upgrade info
     echo '<div class="panelgroup" id="panelgroup_' . md5($addon_key) . '">';
     echo '<h3>';
     echo common::Link('Admin_Addons/' . admin_tools::encode64($addon_key), $addon_config['name']);
     echo '</h3>';
     echo '<div class="panelgroup2">';
     echo '<ul class="submenu">';
     $this->AddonPanelGroup($addon_key);
     $this->OptionLinks($addon_key, $addon_config);
     echo '</ul>';
     $this->UpgradeLinks($addon_config);
     echo '</div>';
     echo '</div>';
 }
Exemple #23
0
 /**
  * Find the requested admin script and execute it if the user has permissions to view it
  *
  */
 function RunAdminScript()
 {
     global $dataDir, $langmessage;
     //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234
     $parts = explode('/', $this->requested);
     do {
         $request_string = implode('/', $parts);
         $scriptinfo = false;
         $scripts = admin_tools::AdminScripts();
         if (isset($scripts[$request_string])) {
             $scriptinfo = $scripts[$request_string];
             if (admin_tools::HasPermission($request_string)) {
                 if (isset($scriptinfo['addon'])) {
                     gpPlugin::SetDataFolder($scriptinfo['addon']);
                 }
                 admin_display::OrganizeFrequentScripts($request_string);
                 if (isset($scriptinfo['script'])) {
                     require $dataDir . $scriptinfo['script'];
                 }
                 if (isset($scriptinfo['class'])) {
                     new $scriptinfo['class']();
                 }
                 gpPlugin::ClearDataFolder();
                 return;
             } else {
                 message($langmessage['not_permitted']);
                 $parts = array();
             }
         } elseif (count($scripts) > 0) {
             //check case
             $case_check = array_keys($scripts);
             $case_check = array_combine($case_check, $case_check);
             $case_check = array_change_key_case($case_check, CASE_LOWER);
             $lower = strtolower($request_string);
             if (isset($case_check[$lower])) {
                 $location = common::GetUrl($case_check[$lower], '', false);
                 common::Redirect($location);
             }
         }
         //these are here because they should be available to everyone
         switch ($request_string) {
             case 'Admin_Browser':
                 includeFile('admin/admin_browser.php');
                 new admin_browser();
                 return;
             case 'Admin_Preferences':
                 includeFile('admin/admin_preferences.php');
                 new admin_preferences();
                 return;
             case 'Admin_About':
                 includeFile('admin/admin_about.php');
                 new admin_about();
                 return;
             case 'Admin_Finder':
                 includeFile('thirdparty/elfinder/connector.php');
                 return;
         }
     } while (array_pop($parts));
     $this->AdminPanel();
 }
 function PluginPanelGroup($addon_key, $info)
 {
     global $config, $langmessage, $gpLayouts;
     $addon_config = gpPlugin::GetAddonConfig($addon_key);
     $addon_config += $info;
     //merge the upgrade info
     echo '<div class="panelgroup" id="panelgroup_' . md5($addon_key) . '">';
     $label = '<i class="gpicon_plug"></i>' . $addon_config['name'];
     echo common::Link('Admin_Addons/' . admin_tools::encode64($addon_key), $label);
     echo '<div class="panelgroup2">';
     echo '<ul class="submenu">';
     $this->AddonPanelGroup($addon_key, $addon_config);
     //options
     if (!isset($addon_config['is_theme']) || !$addon_config['is_theme']) {
         echo '<li class="expand_child_click">';
         echo '<a>' . $langmessage['options'] . '</a>';
         echo '<ul>';
         //editable text
         if (isset($config['addons'][$addon_key]['editable_text']) && admin_tools::HasPermission('Admin_Theme_Content')) {
             echo '<li>';
             echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon=' . urlencode($addon_key), array('title' => urlencode($langmessage['editable_text']), 'data-cmd' => 'gpabox'));
             echo '</li>';
         }
         //upgrade link
         if (isset($addon_config['upgrade_from'])) {
             echo '<li>';
             echo common::Link('Admin_Addons', $langmessage['upgrade'], 'cmd=local_install&source=' . $addon_config['upgrade_from'], array('data-cmd' => 'creq'));
             echo '</li>';
         }
         //uninstall
         echo '<li>';
         echo common::Link('Admin_Addons', $langmessage['uninstall'], 'cmd=uninstall&addon=' . rawurlencode($addon_key), 'data-cmd="gpabox"');
         echo '</li>';
         //version
         if (!empty($addon_config['version'])) {
             echo '<li><a>' . $langmessage['Your_version'] . ' ' . $addon_config['version'] . '</a></li>';
         }
         //rating
         if (isset($addon_config['id']) && is_numeric($addon_config['id'])) {
             $id = $addon_config['id'];
             $rating = 5;
             if (isset($this->addonReviews[$id])) {
                 $rating = $this->addonReviews[$id]['rating'];
             }
             $label = $langmessage['rate_this_addon'] . ' ' . $this->ShowRating($id, $rating);
             echo '<li><span>' . $label . '</span></li>';
         }
         echo '</ul></li>';
     } else {
         //show list of themes using these addons
         echo '<li class="expand_child_click">';
         echo '<a>' . $langmessage['layouts'] . '</a>';
         echo '<ul>';
         foreach ($gpLayouts as $layout_id => $layout_info) {
             if (!isset($layout_info['addon_key']) || $layout_info['addon_key'] !== $addon_key) {
                 continue;
             }
             echo '<li>';
             echo '<span>';
             echo '<span class="layout_color_id" style="background:' . $layout_info['color'] . '"></span> ';
             echo common::Link('Admin_Theme_Content', $layout_info['label']);
             echo ' ( ';
             echo common::Link('Admin_Theme_Content/' . $layout_id, $langmessage['edit']);
             echo ' )';
             echo '</span>';
             //echo '<a>';
             //echo $layout_info['label'];
             //echo '</a>';
             //echo pre($layout_info);
             echo '</li>';
         }
         echo '</ul>';
         echo '</li>';
     }
     echo '</ul>';
     //upgrade gpeasy.com
     if (isset($addon_config['id']) && isset(admin_tools::$new_versions[$addon_config['id']])) {
         $version_info = admin_tools::$new_versions[$addon_config['id']];
         echo '<div class="gp_notice">';
         echo '<a href="' . addon_browse_path . '/Plugins?id=' . $addon_config['id'] . '" data-cmd="remote">';
         echo $langmessage['new_version'];
         echo ' &nbsp; ' . $version_info['version'] . ' (gpEasy.com)</a>';
         echo '</div>';
     }
     //upgrade local
     if (isset($addon_config['upgrade_from']) && isset($addon_config['upgrade_version'])) {
         if (version_compare($addon_config['upgrade_version'], $addon_config['version'], '>')) {
             echo '<div class="gp_notice">';
             $label = $langmessage['new_version'] . ' &nbsp; ' . $addon_config['upgrade_version'];
             echo common::Link('Admin_Addons', $label, 'cmd=local_install&source=' . $addon_config['upgrade_from'], array('data-cmd' => 'creq'));
             echo '</div>';
         }
     }
     echo '</div>';
     echo '</div>';
 }
Exemple #25
0
 /**
  * Reset global path variables
  */
 static function ClearDataFolder()
 {
     global $addonDataFolder, $addonCodeFolder;
     //deprecated
     global $addonRelativeCode, $addonRelativeData, $addonPathData, $addonPathCode, $addonFolderName, $addon_current_id, $addon_current_version;
     self::$current = array();
     $addonFolderName = false;
     $addonDataFolder = false;
     $addonCodeFolder = false;
     $addonRelativeCode = $addonRelativeData = $addonPathData = $addonPathCode = $addon_current_id = $addon_current_version = false;
     //Make the most recent addon folder or addon id in the stack the current addon
     if (count(self::$stack) > 0) {
         $info = array_pop(self::$stack);
         if ($info['folder']) {
             gpPlugin::SetDataFolder($info['folder']);
         } elseif ($info['id']) {
             $addon_current_id = $info['id'];
         }
     }
 }
Exemple #26
0
 function SearchDisplay()
 {
     global $langmessage, $gpLayouts, $gp_index, $gp_menu;
     $Inherit_Info = admin_menu_tools::Inheritance_Info();
     switch ($this->curr_menu_id) {
         case 'search':
             $show_list = $this->GetSearchList();
             break;
         case 'all':
             $show_list = array_keys($gp_index);
             break;
         case 'hidden':
             $show_list = $this->GetAvailable();
             break;
         case 'nomenus':
             $show_list = $this->GetNoMenus();
             break;
     }
     $show_list = array_values($show_list);
     //to reset the keys
     $show_list = array_reverse($show_list);
     //show newest first
     $max = count($show_list);
     while ($this->search_page * $this->search_max_per_page > $max) {
         $this->search_page--;
     }
     $start = $this->search_page * $this->search_max_per_page;
     $stop = min(($this->search_page + 1) * $this->search_max_per_page, $max);
     ob_start();
     echo '<div class="gp_search_links">';
     echo '<span class="showing">';
     echo sprintf($langmessage['SHOWING'], $start + 1, $stop, $max);
     echo '</span>';
     if ($start !== 0 || $stop < $max) {
         for ($i = 0; $i * $this->search_max_per_page < $max; $i++) {
             $class = '';
             if ($i == $this->search_page) {
                 $class = ' class="current"';
             }
             echo $this->Link('Admin_Menu', $i + 1, 'page=' . $i, 'name="gpajax"' . $class);
         }
     }
     echo $this->Link('Admin_Menu', $langmessage['create_new_file'], 'cmd=add_hidden', ' title="' . $langmessage['create_new_file'] . '" name="gpajax"');
     echo '</div>';
     $links = ob_get_clean();
     echo $links;
     echo '<table class="bordered">';
     echo '<thead>';
     echo '<tr><th>';
     echo $langmessage['file_name'];
     echo '</th><th>';
     echo $langmessage['Child Pages'];
     echo '</th>';
     echo '</tr>';
     echo '</thead>';
     echo '<tbody>';
     if (count($show_list) > 0) {
         for ($i = $start; $i < $stop; $i++) {
             $title = $show_list[$i];
             $title_index = $gp_index[$title];
             echo '<tr><td>';
             $label = common::GetLabel($title);
             echo common::Link($title, common::LabelSpecialChars($label));
             //area only display on mouseover
             echo '<div>';
             echo '<b>Options:</b>';
             $img = '<span class="menu_icon page_edit_icon"></span>';
             echo $this->Link('Admin_Menu', $img . $langmessage['rename/details'], 'cmd=renameform&title=' . urlencode($title), ' title="' . $langmessage['rename/details'] . '" name="gpajax" ');
             $img = '<span class="menu_icon copy_icon"></span>';
             echo $this->Link('Admin_Menu', $img . $langmessage['Copy'], 'cmd=copypage&title=' . urlencode($title), ' title="' . $langmessage['Copy'] . '" name="gpabox"');
             $layout = admin_menu_tools::CurrentLayout($title_index);
             $layout_info = $gpLayouts[$layout];
             $img = '<span style="background-color:' . $layout_info['color'] . ';" class="layout_icon"></span>';
             echo $this->Link('Admin_Menu', $img . $layout_info['label'], 'cmd=layout&index=' . urlencode($title_index), ' title="' . $langmessage['layout'] . '" name="gpabox"');
             $is_special = common::SpecialOrAdmin($title);
             if (!$is_special) {
                 $img = '<span class="menu_icon bin_icon"></span>';
                 echo $this->Link('Admin_Menu', $img . $langmessage['delete'], 'cmd=trash&index=' . urlencode($title_index), ' title="' . $langmessage['delete_page'] . '" name="menupost" class="gpconfirm" ');
             }
             gpPlugin::Action('MenuPageOptions', array($title, $title_index, false, $layout_info));
             //stats
             echo '<br/>';
             echo '<b>' . $langmessage['Page Info'] . ':</b>';
             $this->FileStats($title_index, $title, $is_special);
             echo '</div>';
             echo '</td><td>';
             if (isset($Inherit_Info[$title_index]) && isset($Inherit_Info[$title_index]['children'])) {
                 echo $Inherit_Info[$title_index]['children'];
             } elseif (isset($gp_menu[$title_index])) {
                 echo '0';
             } else {
                 echo $langmessage['Not In Main Menu'];
             }
             echo '</td></tr>';
         }
     }
     echo '</tbody>';
     echo '</table>';
     if (count($show_list) == 0) {
         echo '<p>';
         echo $langmessage['Empty'];
         echo '</p>';
     }
     echo '<br/>';
     echo $links;
 }
 function UpdateAddon($addon)
 {
     if (!function_exists('OnTextChange')) {
         return;
     }
     gpPlugin::SetDataFolder($addon);
     OnTextChange();
     gpPlugin::ClearDataFolder();
 }
Exemple #28
0
 function Confirm_Uninstall()
 {
     global $config, $langmessage, $dataDir, $gp_titles, $gp_menu, $gp_index;
     $addon =& $_POST['addon'];
     if (!isset($config['addons'][$addon])) {
         message($langmessage['OOPS']);
         return;
     }
     $order = false;
     if (isset($config['addons'][$addon]['order'])) {
         $order = $config['addons'][$addon]['order'];
     }
     //tracking
     $history = array();
     $history['name'] = $config['addons'][$addon]['name'];
     $history['action'] = 'uninstalled';
     if (isset($config['addons'][$addon]['id'])) {
         $history['id'] = $config['addons'][$addon]['id'];
     }
     unset($config['addons'][$addon]);
     //remove links
     $installedGadgets = $this->GetInstalledComponents($config['gadgets'], $addon);
     $this->RemoveFromHandlers($installedGadgets);
     //remove from gp_index, gp_menu
     $installedLinks = $this->GetInstalledComponents($gp_titles, $addon);
     foreach ($installedLinks as $index) {
         if (isset($gp_menu[$index])) {
             unset($gp_menu[$index]);
         }
         $title = common::IndexToTitle($index);
         if ($title) {
             unset($gp_index[$title]);
         }
     }
     $this->RemoveFromConfig($config['gadgets'], $addon);
     $this->RemoveFromConfig($config['admin_links'], $addon);
     $this->RemoveFromConfig($gp_titles, $addon);
     $this->CleanHooks($addon);
     if (!admin_tools::SaveAllConfig()) {
         message($langmessage['OOPS']);
         $this->Uninstall();
         return false;
     }
     /*
      * Delete the data folders
      */
     $installFolder = $dataDir . '/data/_addoncode/' . $addon;
     if (file_exists($installFolder)) {
         gpFiles::RmAll($installFolder);
     }
     $data_folder_name = gpPlugin::GetDataFolder($addon);
     $dataFolder = $dataDir . '/data/_addondata/' . $data_folder_name;
     if (file_exists($dataFolder)) {
         gpFiles::RmAll($dataFolder);
     }
     /*
      * Record the history
      */
     $history['time'] = time();
     $this->addonHistory[] = $history;
     $this->SaveAddonData();
     if ($order) {
         $img_path = common::IdUrl('ci');
         common::IdReq($img_path);
     }
     message($langmessage['SAVED']);
 }
 function RunQuery()
 {
     if (!empty($_REQUEST['q'])) {
         $this->SearchPattern();
         $this->SearchPages();
         gpPlugin::Action('Search', array($this));
     }
     $this->ShowResults();
 }
Exemple #30
0
 /**
  * Make sure the file is a css or js file and that it exists
  * @static
  */
 static function CheckFile(&$file)
 {
     global $dataDir;
     $comment_start = '<!--';
     $comment_end = '-->';
     $file = gp_combine::TrimQuery($file);
     if (empty($file)) {
         return false;
     }
     //translate addon paths
     $pos = strpos($file, '/data/_addoncode/');
     if ($pos !== false) {
         $file_parts = substr($file, $pos + 17);
         $file_parts = explode('/', $file_parts);
         $addon_key = array_shift($file_parts);
         $addon_config = gpPlugin::GetAddonConfig($addon_key);
         if ($addon_config) {
             $file = $addon_config['code_folder_rel'] . '/' . implode('/', $file_parts);
         }
     }
     //remove null charachters
     $file = gpFiles::NoNull($file);
     //require .js or .css
     $test = strtolower($file);
     if (substr($test, -3) != '.js' && substr($test, -4) != '.css' && substr($test, -5) != '.less') {
         echo "\n{$comment_start} File Not CSS, LESS or JS {$file} {$comment_end}\n";
         return false;
     }
     //paths that have been urlencoded
     if (strpos($file, '%') !== false) {
         $decoded_file = rawurldecode($file);
         if ($full_path = gp_combine::CheckFileSub($decoded_file)) {
             $file = $decoded_file;
             return $full_path;
         }
     }
     //paths that have not been encoded
     if ($full_path = gp_combine::CheckFileSub($file)) {
         return $full_path;
     }
     echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n";
     return false;
 }