本文整理汇总了PHP中admin_tools类的典型用法代码示例。如果您正苦于以下问题:PHP admin_tools类的具体用法?PHP admin_tools怎么用?PHP admin_tools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了admin_tools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveConfig
function SaveConfig()
{
global $config, $langmessage;
$possible = $this->variables;
foreach ($possible as $key => $curr_possible) {
if ($curr_possible == 'boolean') {
if (isset($_POST[$key]) && $_POST[$key] == 'true') {
$config[$key] = true;
} else {
$config[$key] = false;
}
} elseif ($curr_possible == 'integer') {
if (isset($_POST[$key]) && is_numeric($_POST[$key])) {
$config[$key] = $_POST[$key];
}
} elseif (isset($_POST[$key])) {
$config[$key] = $_POST[$key];
}
}
$config['history_limit'] = min($config['history_limit'], gp_backup_limit);
if (!admin_tools::SaveConfig()) {
message($langmessage['OOPS']);
return false;
}
if (isset($_GET['gpreq']) && $_GET['gpreq'] == 'json') {
message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']);
} else {
message($langmessage['SAVED']);
}
}
示例2: GenerateOutput
function GenerateOutput()
{
global $langmessage, $page;
common::ShowingGallery();
echo '<h2>';
echo gpOutput::ReturnText('galleries');
echo '</h2>';
includeFile('admin/admin_tools.php');
$wrap = admin_tools::CanEdit($page->gp_index);
if ($wrap) {
echo gpOutput::EditAreaLink($edit_index, 'Admin_Galleries', $langmessage['edit']);
echo '<div class="editable_area cf" id="ExtraEditArea' . $edit_index . '">';
// class="edit_area" added by javascript
}
$image_text = gpOutput::ReturnText('image');
$images_text = gpOutput::ReturnText('images');
$list = '';
$shown = 0;
foreach ($this->galleries as $title => $info) {
//page is hidden
if (!$this->GalleryVisible($title, $info)) {
continue;
}
$count = '';
if (is_array($info)) {
$icon = $info['icon'];
if ($info['count'] == 1) {
$count = $info['count'] . ' ' . gpOutput::ReturnText('image');
} elseif ($info['count'] > 1) {
$count = $info['count'] . ' ' . gpOutput::ReturnText('images');
}
} else {
$icon = $info;
}
if (empty($icon)) {
continue;
}
$icon = rawurldecode($icon);
//prevent double encoding
if (strpos($icon, '/thumbnails/') === false) {
$thumbPath = common::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg');
} else {
$thumbPath = common::GetDir('/data/_uploaded' . $icon);
}
$label = common::GetLabel($title);
$title_attr = ' title="' . common::GetBrowserTitle($title) . '"';
$label_img = ' <img src="' . $thumbPath . '" alt=""/>';
$list .= '<li>' . common::Link($title, $label_img, '', $title_attr) . '<div>' . common::Link($title, $label, '', $title_attr) . '<p>' . $count . '</p>' . '</div>' . '</li>';
}
if (!empty($list)) {
echo '<ul class="gp_gallery gp_galleries">';
echo $list;
echo '</ul>';
}
if ($wrap) {
echo '</div>';
}
$this->PostSave();
}
示例3: ShowFiles
/**
* Show files in the cache
*
*/
function ShowFiles()
{
global $page, $langmessage;
$page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js';
$page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});';
if (!$this->all_files) {
return;
}
echo '<p>';
echo common::Link('Admin_Cache', 'Empty Cache', 'cmd=EmptyResourceCache', array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => 'Empty the resource cache?'));
echo '</p>';
echo '<table class="bordered tablesorter full_width">';
echo '<thead>';
echo '<tr><th>';
echo $langmessage['file_name'];
echo '</th><th>';
echo $langmessage['File Size'];
echo '</th><th>';
echo 'Touched';
echo '</th><th>';
echo $langmessage['options'];
echo '</th></tr>';
echo '</thead>';
$total_size = 0;
echo '<tbody>';
foreach ($this->all_files as $file) {
$full = $this->cache_dir . '/' . $file;
echo '<tr><td>';
echo '<a href="?cmd=ViewFile&file=' . rawurlencode($file) . '">';
echo $file;
echo '</a>';
echo '</td><td>';
$size = filesize($full);
echo '<span style="display:none">' . $size . '</span>';
echo admin_tools::FormatBytes($size);
$total_size += $size;
echo '</td><td>';
$elapsed = admin_tools::Elapsed(time() - filemtime($full));
echo sprintf($langmessage['_ago'], $elapsed);
echo '</td><td>';
echo common::Link('Admin_Cache', $langmessage['delete'], 'cmd=DeleteFile&file=' . rawurlencode($file), array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm']));
echo '</tr>';
}
echo '</tbody>';
//totals
echo '<tfoot>';
echo '<tr><td>';
echo number_format(count($this->all_files)) . ' Files';
echo '</td><td>';
echo admin_tools::FormatBytes($total_size);
echo '</td><td>';
echo '</tr>';
echo '</table>';
}
示例4: RunScript
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);
}
示例5: Toggle
/**
* Toggle the visibility of a page
*
*/
static function Toggle($index, $visibility = '')
{
global $gp_titles, $langmessage;
if (!isset($gp_titles[$index])) {
msg($langmessage['OOPS'] . ' (Invalid Request)');
return false;
}
if ($visibility == 'private') {
$gp_titles[$index]['vis'] = 'private';
} else {
unset($gp_titles[$index]['vis']);
}
if (!\admin_tools::SavePagesPHP()) {
msg($langmessage['OOPS'] . ' (VT1)');
return false;
}
return true;
}
示例6: Upgrade_234
/**
* Update the gp_index, gp_titles and menus so that special pages can be renamed
*
*/
function Upgrade_234()
{
global $gp_index, $gp_titles, $gp_menu, $config, $dataDir;
includeFile('tool/gpOutput.php');
$special_indexes = array();
$new_index = array();
$new_titles = array();
foreach ($gp_index as $title => $index) {
$info = $gp_titles[$index];
$type = common::SpecialOrAdmin($title);
if ($type === 'special') {
$special_indexes[$index] = strtolower($title);
$index = strtolower($title);
$info['type'] = 'special';
//some older versions didn't maintain this value well
}
$new_index[$title] = $index;
$new_titles[$index] = $info;
}
$gp_titles = $new_titles;
$gp_index = $new_index;
//update gp_menu
$gp_menu = $this->FixMenu($gp_menu, $special_indexes);
//save pages
if (!admin_tools::SavePagesPHP()) {
return;
}
$config['gpversion'] = '2.3.4';
admin_tools::SaveConfig();
//update alt menus
if (isset($config['menus']) && is_array($config['menus'])) {
foreach ($config['menus'] as $key => $value) {
$menu_file = $dataDir . '/data/_menus/' . $key . '.php';
if (gpFiles::Exists($menu_file)) {
$menu = gpOutput::GetMenuArray($key);
$menu = $this->FixMenu($menu, $special_indexes);
gpFiles::SaveData($menu_file, 'menu', $menu);
}
}
}
}
示例7: ProtectCommand
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);
}
示例8: Admin
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;
}
示例9: GetAddonSubLinks
/**
* 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;
}
示例10: ShowAddon
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 ' » ';
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>';
//.........这里部分代码省略.........
示例11: SetLayout
/**
* Assign a layout to the $title. Child pages without a layout assigned will inherit this setting
* @param string $title
*/
function SetLayout()
{
global $gp_index, $gp_titles, $langmessage, $gpLayouts;
$index = $_POST['index'];
$title = common::IndexToTitle($index);
if (!$title) {
message($langmessage['OOPS']);
return;
}
$this->title = $title;
$layout = $_POST['layout'];
if (!isset($gpLayouts[$layout])) {
message($langmessage['OOPS']);
return;
}
if (!common::verify_nonce('use_' . $layout)) {
message($langmessage['OOPS']);
return;
}
//unset, then reset if needed
unset($gp_titles[$index]['gpLayout']);
$currentLayout = display::OrConfig($index, 'gpLayout');
if ($currentLayout != $layout) {
$gp_titles[$index]['gpLayout'] = $layout;
}
if (!admin_tools::SavePagesPHP()) {
message($langmessage['OOPS'] . '(3)');
return false;
}
message($langmessage['SAVED']);
}
示例12: RemoteBrowse
/**
* Get addon data from gpEasy.com and display to user
*
*/
function RemoteBrowse()
{
global $langmessage, $config, $dataDir;
//search options
if (isset($_GET['search_option'])) {
$save = true;
switch ($_GET['search_option']) {
case 'version':
unset($config['search_version']);
break;
case 'noversion':
$config['search_version'] = false;
break;
default:
$save = false;
break;
}
if ($save) {
admin_tools::SaveConfig();
}
}
//make a list of installed addon id's
$this->installed_ids = array();
if (isset($config['addons']) && is_array($config['addons'])) {
foreach ($config['addons'] as $addon_info) {
if (isset($addon_info['id'])) {
$this->installed_ids[] = $addon_info['id'];
}
}
}
includeFile('tool/RemoteGet.php');
//search settings
$this->searchUrl = $this->path_remote;
$this->searchOrderOptions['rating_score'] = $langmessage['Highest Rated'];
$this->searchOrderOptions['downloads'] = $langmessage['Most Downloaded'];
$this->searchOrderOptions['modified'] = $langmessage['Recently Updated'];
$this->searchOrderOptions['created'] = $langmessage['Newest'];
$_GET += array('q' => '');
if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
$this->searchPage = $_REQUEST['page'];
}
//version specific search
$search_version = false;
if (!isset($config['search_version']) || $config['search_version']) {
$this->searchQuery .= '&ug=' . rawurlencode(gpversion);
$search_version = true;
}
if (!empty($_GET['q'])) {
$this->searchQuery .= '&q=' . rawurlencode($_GET['q']);
}
$this->SearchOrder();
$slug = 'Plugins';
if ($this->config_index == 'themes') {
$slug = 'Themes';
}
$src = addon_browse_path . '/' . $slug . '?cmd=remote&format=json&' . $this->searchQuery . '&page=' . $this->searchPage;
// format=json added 4.6b3
//check cache
$cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
$use_cache = false;
if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
$result = file_get_contents($cache_file);
$use_cache = true;
} else {
$result = gpRemoteGet::Get_Successful($src);
}
//no response
if (!$result) {
if ($use_cache) {
unlink($cache_file);
}
echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched') . '</p>';
return;
}
//serialized or json (serialized data may be cached)
if (strpos($result, 'a:') === 0) {
$data = unserialize($result);
} elseif (strpos($result, '{') === 0) {
$data = json_decode($result, true);
} else {
if ($use_cache) {
unlink($cache_file);
}
$debug = array();
$debug['Two'] = substr($result, 0, 2);
$debug['Twotr'] = substr(trim($result), 0, 2);
echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched', $debug) . '</p>';
return;
}
//not unserialized?
if (!is_array($data) || count($data) == 0) {
if ($use_cache) {
unlink($cache_file);
}
echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (F3)</p>';
return;
//.........这里部分代码省略.........
示例13: NewFileNumber
public static function NewFileNumber()
{
global $config;
includeFile('admin/admin_tools.php');
if (!isset($config['file_count'])) {
$config['file_count'] = 0;
}
$config['file_count']++;
admin_tools::SaveConfig();
return $config['file_count'];
}
示例14: RenameFileWorker
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;
}
示例15: AdminPanel
/**
* Show the default admin page
*
*/
function AdminPanel()
{
global $langmessage;
$cmd = common::GetCommand();
switch ($cmd) {
case 'embededcheck':
includeFile('tool/update.php');
new update_class('embededcheck');
return;
case 'autocomplete-titles':
$opts = array('var_name' => false);
echo gp_edit::AutoCompleteValues(false, $opts);
die;
}
$this->head_js[] = '/include/js/auto_width.js';
echo '<h2>' . $langmessage['administration'] . '</h2>';
echo '<div id="adminlinks2">';
admin_tools::AdminPanelLinks(false);
echo '</div>';
}