Esempio n. 1
0
 function RunScript()
 {
     global $gp_index, $langmessage, $page;
     $scriptinfo = special_display::GetScriptInfo($this->requested);
     if ($scriptinfo === false) {
         switch ($this->requested) {
             case 'Special_ExtraJS':
                 $this->ExtraJS();
                 //dies
         }
         $this->Error_404($this->title);
         return;
     }
     $this->gp_index = $gp_index[$this->requested];
     $this->label = common::GetLabel($this->requested);
     $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', ' name="gpajax" ');
             $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), ' title="' . $langmessage['current_layout'] . '" name="gpabox"');
         }
         if (admin_tools::HasPermission('Admin_User')) {
             $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), ' title="' . $langmessage['permissions'] . '" name="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);
 }
Esempio n. 2
0
function ProtectCommand($cmd)
{
    global $protect_object, $gp_titles, $langmessage;
    if (!admin_tools::HasPermission('Admin_Protect')) {
        return;
    }
    switch ($cmd) {
        case 'passprotect':
        case 'rm_protection':
        case 'protect_page':
            break;
        default:
            return $cmd;
    }
    if (!isset($_POST['index']) || !isset($gp_titles[$_POST['index']])) {
        message($langmessage['OOPS']);
        return $cmd;
    }
    $index = $_POST['index'];
    $protect_object->IsProtected($index);
    return $protect_object->Admin($cmd, $index);
}
Esempio n. 3
0
 function Admin($cmd, $index)
 {
     global $gp_titles, $langmessage, $page;
     if (!admin_tools::HasPermission('Admin_Protect')) {
         return;
     }
     switch ($cmd) {
         case 'passprotect':
             $this->OptionsForm($index);
             return 'return';
         case 'rm_protection':
             $page->ajaxReplace = array();
             unset($this->config['pages'][$index]);
             if ($this->SaveConfig()) {
                 $this->is_protected = false;
                 message($langmessage['SAVED']);
             } else {
                 message($langmessage['OOPS']);
             }
             return $cmd;
         case 'protect_page':
             $page->ajaxReplace = array();
             $this->config['pages'][$index] = true;
             if ($this->SaveConfig()) {
                 $this->is_protected = true;
                 message($langmessage['SAVED']);
             } else {
                 message($langmessage['OOPS']);
             }
             return $cmd;
     }
     if ($this->is_protected) {
         message('Notice: This page is currently protected and can only be viewed by logged in users.');
     }
     return $cmd;
 }
Esempio n. 4
0
 function MenuSkeleton()
 {
     global $langmessage;
     /*
      * page options
      */
     echo '<b>' . $langmessage['page_options'] . '</b>';
     echo '<span>';
     $img = '<span class="menu_icon icon_page"></span>';
     echo '<a href="[url]" class="view_edit_link">' . $img . htmlspecialchars($langmessage['view/edit_page']) . '</a>';
     $img = '<span class="menu_icon page_edit_icon"></span>';
     echo $this->Link('Admin_Menu', $img . $langmessage['rename/details'], 'cmd=renameform&title=[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=[title]', ' title="' . $langmessage['Copy'] . '" name="gpabox"');
     if (admin_tools::HasPermission('Admin_User')) {
         $img = '<span class="menu_icon icon_user"></span>';
         echo $this->Link('Admin_Users', $img . $langmessage['permissions'], 'cmd=file_permissions&index=[key]', ' title="' . $langmessage['permissions'] . '" name="gpabox" ');
     }
     $img = '<span class="menu_icon cut_list_icon"></span>';
     echo $this->Link('Admin_Menu', $img . $langmessage['rm_from_menu'], 'cmd=hide&key=[key]', ' title="' . $langmessage['rm_from_menu'] . '" name="menupost" class="gpconfirm"');
     // gpajax
     $img = '<span class="menu_icon bin_icon"></span>';
     echo $this->Link('Admin_Menu', $img . $langmessage['delete'], 'cmd=trash&index=[key]', ' title="' . $langmessage['delete_page'] . '" name="menupost" class="gpconfirm not_special" ');
     echo '[options]';
     //replaced with the contents of gpPlugin::Action('MenuPageOptions',array($title,$menu_key,$menu_value,$layout_info));
     echo '</span>';
     //layout
     if ($this->is_main_menu) {
         echo '<b>' . $langmessage['layout'] . '</b>';
         echo '<span>';
         //has_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin_Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" name="gpabox" class="has_layout"');
         $img = '<span class="menu_icon undo_icon"></span>';
         echo $this->Link('Admin_Menu', $img . $langmessage['restore'], 'cmd=restorelayout&index=[key]', ' title="' . $langmessage['restore'] . '" name="postlink" class="has_layout"', 'restore');
         //no_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin_Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" name="gpabox" class="no_layout"');
         echo '</span>';
     }
     $this->InsertLinks();
     //file stats
     echo '<b>' . $langmessage['Page Info'] . '</b>';
     echo '<span>';
     echo '<a>' . $langmessage['Slug/URL'] . ': [title]</a>';
     echo '<a>' . $langmessage['Content Type'] . ': [types]</a>';
     echo '<a class="not_special">' . $langmessage['File Size'] . ': [size]</a>';
     echo '<a class="not_special">' . $langmessage['Modified'] . ': [mtime]</a>';
     echo '<a>Data Index: [key]</a>';
     echo '</span>';
 }
Esempio n. 5
0
 static function ShowEditLink($permission = false)
 {
     global $GP_NESTED_EDIT;
     if ($permission) {
         return !$GP_NESTED_EDIT && common::LoggedIn() && admin_tools::HasPermission($permission);
     }
     return !$GP_NESTED_EDIT && common::LoggedIn();
 }
Esempio n. 6
0
 /**
  * Plugin option links
  *
  */
 function OptionLinks($addon_key, $addon_config, $format = false)
 {
     global $langmessage;
     $list = array();
     if (!isset($addon_config['is_theme']) || !$addon_config['is_theme']) {
         //editable text
         if (isset($addon_config['editable_text']) && admin_tools::HasPermission('Admin_Theme_Content')) {
             $list[] = common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon=' . urlencode($addon_key), array('title' => urlencode($langmessage['editable_text']), 'data-cmd' => 'gpabox'));
         }
         //upgrade link
         if (isset($addon_config['upgrade_from'])) {
             //$list[] = common::Link('Admin_Addons',$langmessage['upgrade'],'cmd=LocalInstall&source='.$addon_config['upgrade_from'],array('data-cmd'=>'creq'));
             $list[] = '<a href="?cmd=LocalInstall&source=' . rawurlencode($addon_config['upgrade_from']) . '" data-cmd="creq">' . $langmessage['upgrade'] . '</a>';
         }
         //uninstall
         $list[] = common::Link('Admin_Addons', $langmessage['uninstall'], 'cmd=uninstall&addon=' . rawurlencode($addon_key), 'data-cmd="gpabox"');
         //version
         if (!empty($addon_config['version'])) {
             $list[] = '<a>' . $langmessage['Your_version'] . ' ' . $addon_config['version'] . '</a>';
         }
         //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);
             $list[] = '<span>' . $label . '</span>';
         }
         echo $this->FormatList($list, $langmessage['options'], $format);
         return;
     }
     //show list of themes using these addons
     foreach ($gpLayouts as $layout_id => $layout_info) {
         if (!isset($layout_info['addon_key']) || $layout_info['addon_key'] !== $addon_key) {
             continue;
         }
         $item = '<span><span class="layout_color_id" style="background:' . $layout_info['color'] . '"></span> ';
         $item .= common::Link('Admin_Theme_Content', $layout_info['label']);
         $item .= ' ( ';
         $item .= common::Link('Admin_Theme_Content/' . $layout_id, $langmessage['edit']);
         $item .= ' )</span>';
         $list[] = $item;
     }
     echo $this->FormatList($list, $langmessage['layouts'], $format);
 }
Esempio n. 7
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();
 }
Esempio n. 8
0
 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>';
 }
Esempio n. 9
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)) {
                 admin_display::OrganizeFrequentScripts($request_string);
                 gpOutput::ExecInfo($scriptinfo);
                 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], http_build_query($_GET), 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':
                 $this->label = $langmessage['Preferences'];
                 includeFile('admin/admin_preferences.php');
                 new admin_preferences();
                 return;
             case 'Admin_About':
                 $this->label = 'About gpEasy';
                 includeFile('admin/admin_about.php');
                 new admin_about();
                 return;
             case 'Admin_Finder':
                 if (admin_tools::HasPermission('Admin_Uploaded')) {
                     includeFile('thirdparty/finder/connector.php');
                     return;
                 }
                 break;
         }
         array_pop($parts);
     } while (count($parts));
     $this->AdminPanel();
 }
Esempio n. 10
0
 /**
  * Output html for the menu editing options displayed for selected titles
  *
  */
 function MenuSkeleton()
 {
     global $langmessage;
     //page options
     echo '<b>' . $langmessage['page_options'] . '</b>';
     echo '<span>';
     $img = '<span class="menu_icon icon_page"></span>';
     echo '<a href="[url]" class="view_edit_link not_multiple">' . $img . htmlspecialchars($langmessage['view/edit_page']) . '</a>';
     $img = '<span class="menu_icon page_edit_icon"></span>';
     $attrs = array('title' => $langmessage['rename/details'], 'data-cmd' => 'gpajax', 'class' => 'not_multiple');
     echo $this->Link('Admin_Menu', $img . $langmessage['rename/details'], 'cmd=renameform&index=[key]', $attrs);
     $img = '<span class="menu_icon icon_vis"></span>';
     $q = 'cmd=ToggleVisibility&index=[key]';
     $label = $langmessage['Visibility'] . ': ' . $langmessage['Private'];
     $attrs = array('title' => $label, 'data-cmd' => 'gpajax', 'class' => 'vis_private');
     echo $this->Link('Admin_Menu', $img . $label, $q, $attrs);
     $label = $langmessage['Visibility'] . ': ' . $langmessage['Public'];
     $attrs = array('title' => $label, 'data-cmd' => 'gpajax', 'class' => 'vis_public not_multiple');
     $q .= '&visibility=private';
     echo $this->Link('Admin_Menu', $img . $label, $q, $attrs);
     $img = '<span class="menu_icon icon_history"></span>';
     echo '<a href="[url]?cmd=ViewHistory" class="view_edit_link not_multiple not_special" data-cmd="gpabox">' . $img . htmlspecialchars($langmessage['Revision History']) . '</a>';
     $img = '<span class="menu_icon copy_icon"></span>';
     $attrs = array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox', 'class' => 'not_multiple');
     echo $this->Link('Admin_Menu', $img . $langmessage['Copy'], 'cmd=copypage&index=[key]', $attrs);
     if (admin_tools::HasPermission('Admin_User')) {
         $img = '<span class="menu_icon icon_user"></span>';
         $attrs = array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox');
         echo $this->Link('Admin_Users', $img . $langmessage['permissions'], 'cmd=file_permissions&index=[key]', $attrs);
     }
     $img = '<span class="menu_icon cut_list_icon"></span>';
     $attrs = array('title' => $langmessage['rm_from_menu'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm');
     echo $this->Link('Admin_Menu', $img . $langmessage['rm_from_menu'], 'cmd=hide&index=[key]', $attrs);
     $img = '<span class="menu_icon bin_icon"></span>';
     $attrs = array('title' => $langmessage['delete_page'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm not_special');
     echo $this->Link('Admin_Menu', $img . $langmessage['delete'], 'cmd=trash&index=[key]', $attrs);
     echo '[opts]';
     //replaced with the contents of gpPlugin::Action('MenuPageOptions',array($title,$menu_key,$menu_value,$layout_info));
     echo '</span>';
     //layout
     if ($this->is_main_menu) {
         echo '<div class="not_multiple">';
         echo '<b>' . $langmessage['layout'] . '</b>';
         echo '<span>';
         //has_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin_Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" data-cmd="gpabox" class="has_layout"');
         $img = '<span class="menu_icon undo_icon"></span>';
         echo $this->Link('Admin_Menu', $img . $langmessage['restore'], 'cmd=restorelayout&index=[key]', array('data-cmd' => 'postlink', 'title' => $langmessage['restore'], 'class' => 'has_layout'), 'restore');
         //no_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin_Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" data-cmd="gpabox" class="no_layout"');
         echo '</span>';
         echo '</div>';
     }
     $this->InsertLinks();
     //file stats
     echo '<div>';
     echo '<b>' . $langmessage['Page Info'] . '</b>';
     echo '<span>';
     echo '<a class="not_multiple">' . $langmessage['Slug/URL'] . ': [title]</a>';
     echo '<a class="not_multiple">' . $langmessage['Content Type'] . ': [types]</a>';
     echo '<a class="not_special only_multiple">' . sprintf($langmessage['%s Pages'], '[files]') . '</a>';
     echo '<a class="not_special">' . $langmessage['File Size'] . ': [size]</a>';
     echo '<a class="not_special not_multiple">' . $langmessage['Modified'] . ': [mtime]</a>';
     echo '<a class="not_multiple">Data Index: [key]</a>';
     echo '</span>';
     echo '</div>';
 }
Esempio n. 11
0
 /**
  * Notify the admin if there have been any fatal errors
  *
  */
 static function FatalNotices()
 {
     global $dataDir, $page;
     if (!admin_tools::HasPermission('Admin_Errors')) {
         return;
     }
     if (is_object($page) && property_exists($page, 'title') && strpos($page->title, 'Admin_Errors') !== false) {
         return;
     }
     $dir = $dataDir . '/data/_site';
     $files = scandir($dir);
     $has_fatal = false;
     foreach ($files as $file) {
         if (strpos($file, 'fatal_') === false) {
             continue;
         }
         $full_path = $dir . '/' . $file;
         $info_hash = md5_file($full_path);
         if (isset(gpOutput::$fatal_notices[$info_hash])) {
             continue;
         }
         $has_fatal = true;
         break;
     }
     if (!$has_fatal) {
         return;
     }
     $msg = 'Warning: One or more components have caused fatal errors and have been disabled. ' . common::Link('Admin_Errors', 'More Information');
     msg($msg);
 }
Esempio n. 12
0
 function RunScript()
 {
     global $langmessage, $page;
     $cmd = common::GetCommand();
     //prevent overwriting the content to maintain overlay editin links
     //$page->ajaxReplace = array();
     if (!$this->SetVars()) {
         return;
     }
     $this->GetFile();
     //original alpha versions of 1.8 didn't maintain the file_type
     if (!isset($this->meta_data['file_type'])) {
         $this->ResetFileTypes();
     }
     //admin toolbar links
     $menu_permissions = admin_tools::HasPermission('Admin_Menu');
     $can_edit = admin_tools::CanEdit($this->gp_index);
     if ($menu_permissions) {
         $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', 'data-cmd="gpajax"');
         // Having the layout link here complicates things.. would need layout link for special pages
         $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'));
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&redir=redir&index=' . urlencode($this->gp_index), array('title' => $langmessage['Copy'], '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'));
     }
     if ($can_edit) {
         $page->admin_links[] = common::Link($this->title, $langmessage['Revision History'], 'cmd=view_history', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox'));
     }
     if ($menu_permissions) {
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['delete_file'], 'cmd=trash_page&index=' . urlencode($this->gp_index), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_page'], 'class' => 'gpconfirm'));
     }
     //allow addons to effect page actions and how a page is displayed
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     //admin actions
     if ($menu_permissions) {
         switch ($cmd) {
             // rename & details
             case 'renameform':
                 $this->RenameForm();
                 return;
             case 'renameit':
                 if ($this->RenameFile()) {
                     return;
                 }
                 break;
         }
     }
     //file editing actions
     if ($can_edit) {
         switch ($cmd) {
             case 'rawcontent':
                 $this->RawContent();
                 break;
                 /* gallery/image editing */
             /* gallery/image editing */
             case 'gallery_folder':
             case 'gallery_images':
                 $this->GalleryImages();
                 return;
             case 'new_dir':
                 $this->contentBuffer = gp_edit::NewDirForm();
                 return;
                 /* inline editing */
             /* inline editing */
             case 'save':
             case 'save_inline':
             case 'preview':
             case 'inlineedit':
             case 'include_dialog':
                 $this->SectionEdit($cmd);
                 return;
             case 'image_editor':
                 gp_edit::ImageEditor();
                 return;
                 /* Manage section */
             /* Manage section */
             case 'ManageSections':
                 $this->ManageSections();
                 //dies
             //dies
             case 'NewSectionContent':
                 $this->NewSectionContent();
                 return;
             case 'NewNestedSection':
                 $this->NewNestedSection();
                 return;
             case 'SaveSections':
                 $this->SaveSections();
                 return;
                 /* revision history */
             /* revision history */
             case 'view_revision':
                 $this->ViewRevision();
                 return;
             case 'use_revision':
                 $this->UseRevision();
                 break;
             case 'view_history':
                 $this->ViewHistory();
                 return;
         }
     }
     $this->contentBuffer = $this->GenerateContent_Admin();
 }
Esempio n. 13
0
 function RunScript()
 {
     global $langmessage, $page;
     $cmd = common::GetCommand();
     //prevent overwriting the content to maintain overlay editin links
     //$page->ajaxReplace = array();
     if (!$this->SetVars()) {
         return;
     }
     $this->GetFile();
     //original alpha versions of 1.8 didn't maintain the file_type
     if (!isset($this->meta_data['file_type'])) {
         $this->ResetFileTypes();
     }
     //admin toolbar links
     $menu_permissions = admin_tools::HasPermission('Admin_Menu');
     $can_edit = admin_tools::CanEdit($this->gp_index);
     if ($menu_permissions) {
         $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', ' name="gpajax" ');
         // Having the layout link here complicates things.. would need layout link for special pages
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), ' title="' . $langmessage['current_layout'] . '" name="gpabox"');
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&redir=redir&title=' . urlencode($this->title), ' title="' . $langmessage['Copy'] . '" name="gpabox"');
     }
     if (admin_tools::HasPermission('Admin_User')) {
         $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), ' title="' . $langmessage['permissions'] . '" name="gpabox" ');
     }
     if ($menu_permissions) {
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['delete_file'], 'cmd=trash_page&index=' . urlencode($this->gp_index), ' title="' . $langmessage['delete_page'] . '" name="postlink" class="gpconfirm" ');
     }
     //allow addons to effect page actions and how a page is displayed
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     //admin actions
     if ($menu_permissions) {
         switch ($cmd) {
             // rename & details
             case 'renameform':
                 $this->RenameForm();
                 return;
             case 'renameit':
                 if ($this->RenameFile()) {
                     return;
                 }
                 break;
         }
     }
     //file editing actions
     if ($can_edit) {
         switch ($cmd) {
             case 'new_dir':
                 $this->NewDirForm();
                 return;
                 //section editing
             //section editing
             case 'move_up':
                 $this->MoveUp();
                 break;
             case 'new_section':
                 $this->NewSectionPrompt();
                 return;
             case 'add_section':
                 $this->AddNewSection();
                 break;
             case 'rm_section':
                 $this->RmSection();
                 break;
             case 'save':
                 $this->SaveSection();
                 return;
             case 'rawcontent':
                 $this->RawContent();
                 break;
                 /* gallery editing */
             /* gallery editing */
             case 'gallery_images':
                 $this->GalleryImages();
                 return;
                 /* include editing */
             /* include editing */
             case 'preview':
                 $this->PreviewSection();
                 return;
             case 'include_dialog':
                 $this->IncludeDialog();
                 return;
                 /* inline editing */
             /* inline editing */
             case 'inlineedit':
                 $this->InlineEdit();
                 die;
         }
     }
     $this->contentBuffer = editing_page::GenerateContent_Admin();
 }
Esempio n. 14
0
 /**
  * Generate admin toolbar links
  *
  */
 public function AdminLinks()
 {
     global $langmessage;
     $admin_links = $this->admin_links;
     $this->admin_links = array();
     if ($this->permission_menu) {
         $this->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', 'data-cmd="gpajax"');
         // Having the layout link here complicates things.. would need layout link for special pages
         $this->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'));
         //visibility
         $q = 'cmd=ToggleVisibility';
         $label = $langmessage['Visibility'] . ': ' . $langmessage['Private'];
         if (!$this->visibility) {
             $label = $langmessage['Visibility'] . ': ' . $langmessage['Public'];
             $q .= '&visibility=private';
         }
         $attrs = array('title' => $label, 'data-cmd' => 'creq');
         $this->admin_links[] = common::Link($this->title, $label, $q, $attrs);
         $this->admin_links[] = common::Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&redir=redir&index=' . urlencode($this->gp_index), array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox'));
     }
     if (admin_tools::HasPermission('Admin_User')) {
         $this->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox'));
     }
     if ($this->permission_edit) {
         $this->admin_links[] = common::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox'));
     }
     if ($this->permission_menu) {
         $this->admin_links[] = common::Link('Admin_Menu', $langmessage['delete_file'], 'cmd=trash_page&index=' . urlencode($this->gp_index), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_page'], 'class' => 'gpconfirm'));
     }
     $this->admin_links = array_merge($this->admin_links, $admin_links);
 }
Esempio n. 15
0
 /**
  * Generate admin toolbar links
  *
  */
 function AdminLinks()
 {
     global $langmessage, $page;
     $admin_links = $page->admin_links;
     $page->admin_links = array();
     $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'));
         $q = 'cmd=ToggleVisibility';
         $label = $langmessage['Visibility'] . ': ' . $langmessage['Private'];
         if (!$this->visibility) {
             $label = $langmessage['Visibility'] . ': ' . $langmessage['Public'];
             $q .= '&visibility=private';
         }
         $attrs = array('title' => $label, 'data-cmd' => 'creq');
         $page->admin_links[] = common::Link($this->title, $label, $q, $attrs);
     }
     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'));
     }
     $page->admin_links = array_merge($page->admin_links, $admin_links);
 }
Esempio n. 16
0
 function ShowAddon($addon = false)
 {
     global $config, $langmessage;
     if ($addon === false) {
         $addon =& $_REQUEST['addon'];
     }
     if (!isset($config['addons'][$addon])) {
         message($langmessage['OOPS'] . '(s1)');
         $this->Select();
         return;
     }
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'enable':
         case 'disable':
             $this->GadgetVisibility($addon, $cmd);
             break;
             /*
             			case 'changeinstall':
             				$this->ChangeInstallType($addon);
             			break;
             
             			case 'changeinstall_confirmed':
             				$this->ChangeInstallConfirmed($addon);
             			break;
             */
     }
     $this->FindForm();
     echo '<h2 class="hmargin">';
     echo common::Link('Admin_Addons', $langmessage['Manage Plugins']);
     echo ' &#187; ';
     echo $config['addons'][$addon]['name'];
     echo '</h2>';
     echo '<table class="bordered" style="width:90%">';
     //show Special Links
     $sublinks = admin_tools::GetAddonTitles($addon);
     if (!empty($sublinks)) {
         echo '<tr><th>';
         echo 'Special Links';
         echo '</th>';
         echo '<th>';
         echo $langmessage['options'];
         echo '</th></tr>';
         foreach ($sublinks as $linkName => $linkInfo) {
             echo '<tr><td>';
             echo common::Link($linkName, $linkInfo['label']);
             echo '</td>';
             echo '<td>';
             echo '-';
             echo '</td></tr>';
         }
     }
     //show Admin Links
     $sublinks = admin_tools::GetAddonComponents($config['admin_links'], $addon);
     if (!empty($sublinks)) {
         echo '<tr><th>';
         echo 'Admin Links';
         echo '</th>';
         echo '<th>';
         echo $langmessage['options'];
         echo '</th></tr>';
         foreach ($sublinks as $linkName => $linkInfo) {
             echo '<tr><td>';
             echo common::Link($linkName, $linkInfo['label']);
             echo '</td>';
             echo '<td>';
             echo '-';
             echo '</td></tr>';
         }
     }
     //show Gadgets
     $gadgets = admin_tools::GetAddonComponents($config['gadgets'], $addon);
     if (is_array($gadgets) && count($gadgets) > 0) {
         echo '<tr><th>';
         echo $langmessage['gadgets'];
         echo '</th>';
         echo '<th>';
         echo $langmessage['options'];
         echo '</th></tr>';
         foreach ($gadgets as $name => $value) {
             echo '<tr><td>';
             echo str_replace('_', ' ', $name);
             echo '</td><td>';
             if (isset($value['disabled'])) {
                 echo common::Link('Admin_Addons', $langmessage['enable'], 'cmd=enable&addon=' . $addon . '&gadget=' . rawurlencode($name), ' name="creq" ');
                 echo ' - ';
                 echo '<b>' . $langmessage['disabled'] . '</b>';
             } else {
                 echo ' <b>' . $langmessage['enabled'] . '</b>';
                 echo ' - ';
                 echo common::Link('Admin_Addons', $langmessage['disable'], 'cmd=disable&addon=' . $addon . '&gadget=' . rawurlencode($name), ' name="creq" ');
             }
             echo '</td></tr>';
         }
     }
     //editable text
     if (isset($config['addons'][$addon]['editable_text']) && admin_tools::HasPermission('Admin_Theme_Content')) {
         echo '<tr><th>';
         echo $langmessage['editable_text'];
         echo '</th>';
         echo '<th>';
         echo $langmessage['options'];
         echo '</th></tr>';
         echo '<tr><td>';
         echo $config['addons'][$addon]['editable_text'];
         echo '</td>';
         echo '<td>';
         echo common::Link('Admin_Theme_Content', $langmessage['edit'], 'cmd=addontext&addon=' . urlencode($addon), ' title="' . urlencode($langmessage['editable_text']) . '" name="gpabox" ');
         echo '</td></tr>';
     }
     //hooks
     $hooks = admin_addons::AddonHooks($addon);
     if (count($hooks) > 0) {
         echo '<tr><th>';
         echo 'Hooks';
         echo '</th>';
         echo '<th>';
         echo $langmessage['options'];
         echo '</th></tr>';
         foreach ($hooks as $name => $info) {
             echo '<tr><td>';
             echo str_replace('_', ' ', $name);
             echo '</td><td>';
             echo '&nbsp;';
             echo '</td></tr>';
         }
     }
     echo '</table>';
     if (!isset($config['addons'][$addon]['id'])) {
         return;
     }
     echo '<h3>' . $langmessage['rate_this_addon'] . '</h3>';
     $id = $config['addons'][$addon]['id'];
     if (isset($this->addonReviews[$id])) {
         $review =& $this->addonReviews[$id];
         $review += array('time' => time());
         echo 'You posted the following review on ' . date('M j, Y', $review['time']);
         echo '<table cellpadding="7">';
         echo '<tr>';
         echo '<td>';
         echo 'Rating';
         echo '</td>';
         echo '<td>';
         $this->ShowRating($id, $review['rating']);
         echo '</td>';
         echo '</tr>';
         echo '<tr>';
         echo '<td>';
         echo 'Review';
         echo '</td>';
         echo '<td>';
         echo nl2br(htmlspecialchars($review['review']));
         echo '</td>';
         echo '</tr>';
         echo '<tr>';
         echo '<td>';
         echo '</td>';
         echo '<td>';
         echo common::Link('Admin_Addons', 'Edit Review', 'cmd=rate&arg=' . $id);
         echo '</td>';
         echo '</tr>';
         echo '</table>';
     } else {
         echo '<table cellpadding="7">';
         echo '<tr>';
         echo '<td>';
         echo 'Rating';
         echo '</td>';
         echo '<td>';
         $this->ShowRating($id, 5);
         echo '</td>';
         echo '</tr>';
         echo '</table>';
     }
 }
Esempio n. 17
0
 /**
  * Return a formatted list of links associated with $addon
  * @return string
  */
 static function GetAddonSubLinks($addon = false)
 {
     global $config;
     $special_links = admin_tools::GetAddonTitles($addon);
     $admin_links = admin_tools::GetAddonComponents($config['admin_links'], $addon);
     $result = '';
     foreach ($special_links as $linkName => $linkInfo) {
         $result .= '<li>';
         $result .= common::Link($linkName, $linkInfo['label']);
         $result .= '</li>';
     }
     foreach ($admin_links as $linkName => $linkInfo) {
         if (admin_tools::HasPermission($linkName)) {
             $result .= '<li>';
             $result .= common::Link($linkName, $linkInfo['label']);
             $result .= '</li>';
         }
     }
     return $result;
 }
Esempio n. 18
0
 static function ShowEditLink($permission = false)
 {
     if ($permission) {
         return !gpOutput::$nested_edit && common::LoggedIn() && admin_tools::HasPermission($permission);
     }
     return !gpOutput::$nested_edit && common::LoggedIn();
 }