function AvailableList($show_options = true) { global $langmessage, $config; //search settings $this->searchPerPage = 10; $this->searchOrderOptions = array(); $this->searchOrderOptions['modified'] = $langmessage['Recently Updated']; $this->searchOrderOptions['rating_score'] = $langmessage['Highest Rated']; $this->searchOrderOptions['downloads'] = $langmessage['Most Downloaded']; $this->SearchOrder(); // get addon information for ordering admin_tools::VersionData($version_data); $version_data = $version_data['packages']; // combine remote addon information foreach ($this->avail_addons as $theme_id => $info) { if (isset($info['id'])) { $id = $info['id']; if (isset($version_data[$id])) { $info = array_merge($info, $version_data[$id]); $info['rt'] *= 5; } //use local rating if (isset($this->addonReviews[$id])) { $info['rt'] = $this->addonReviews[$id]['rating']; } } else { $info['rt'] = 6; //give local themes a high rating to make them appear first, rating won't actually display } $info += array('dn' => 0, 'rt' => 0); //modified time if (!isset($info['tm'])) { $info['tm'] = self::ModifiedTime($info['full_dir']); } $this->avail_addons[$theme_id] = $info; } // sort by uasort($this->avail_addons, array('admin_theme_content', 'SortUpdated')); switch ($this->searchOrder) { case 'downloads': uasort($this->avail_addons, array('admin_theme_content', 'SortDownloads')); break; case 'modified': uasort($this->avail_addons, array('admin_theme_content', 'SortRating')); uasort($this->avail_addons, array('admin_theme_content', 'SortUpdated')); break; case 'rating_score': default: uasort($this->avail_addons, array('admin_theme_content', 'SortRating')); break; } // pagination $this->searchMax = count($this->avail_addons); if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) { $this->searchPage = $_REQUEST['page']; } $start = $this->searchPage * $this->searchPerPage; $possible = array_slice($this->avail_addons, $start, $this->searchPerPage, true); if ($show_options) { $this->SearchOptions(); } // show themes echo '<div id="gp_avail_themes">'; foreach ($possible as $theme_id => $info) { $theme_label = str_replace('_', ' ', $info['name']); $version = ''; $id = false; if (isset($info['version'])) { $version = $info['version']; } if (isset($info['id']) && is_numeric($info['id'])) { $id = $info['id']; } $has_screenshot = file_exists($info['full_dir'] . '/screenshot.png'); //screenshot if ($has_screenshot) { echo '<div class="expand_child_click">'; echo '<b class="gp_theme_head">' . $theme_label . ' ' . $version . '</b>'; echo '<div style="background-image:url(\'' . common::GetDir($info['rel'] . '/screenshot.png') . '\')">'; } else { echo '<div>'; echo '<b class="gp_theme_head">' . $theme_label . ' ' . $version . '</b>'; echo '<div>'; } //options echo '<div class="gp_theme_options">'; //colors echo '<b>' . $langmessage['preview'] . '</b>'; echo '<ul>'; foreach ($info['colors'] as $color) { echo '<li>'; $q = 'cmd=preview&theme=' . rawurlencode($theme_id . '/' . $color) . $this->searchQuery; if ($this->searchPage) { $q .= '&page=' . $this->searchPage; } echo common::Link('Admin_Theme_Content/Available', str_replace('_', ' ', $color), $q); echo '</li>'; } echo '</ul>'; ob_start(); if ($id) { //more info echo '<li>' . $this->DetailLink('theme', $id, 'More Info...') . '</li>'; //support $forum_id = 1000 + $id; echo '<li><a href="' . addon_browse_path . '/Forum?show=f' . $forum_id . '" target="_blank">' . $langmessage['Support'] . '</a></li>'; //rating $rating = 0; if ($info['rt'] > 0) { $rating = $info['rt']; } echo '<li><span class="nowrap">' . $langmessage['rate'] . ' ' . $this->ShowRating($info['rel'], $rating) . '</span></li>'; //downloads if ($info['dn'] > 0) { echo '<li><span class="nowrap">Downloads: ' . number_format($info['dn']) . '</span></li>'; } } //last updated if ($info['tm'] > 0) { echo '<li><span class="nowrap">' . $langmessage['Modified'] . ': '; echo common::date($langmessage['strftime_datetime'], $info['tm']); echo '</span></li>'; } if ($info['is_addon']) { //delete $folder = $info['folder']; $title = sprintf($langmessage['generic_delete_confirm'], $theme_label); $attr = array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $title); echo '<li>' . common::Link('Admin_Theme_Content', $langmessage['delete'], 'cmd=deletetheme&folder=' . rawurlencode($folder), $attr) . '</li>'; //order if (isset($config['themes'][$folder]['order'])) { echo '<li>Order: ' . $config['themes'][$folder]['order'] . '</li>'; } } $options = ob_get_clean(); if (!empty($options)) { echo '<b>' . $langmessage['options'] . '</b>'; echo '<ul>'; echo $options; echo '</ul>'; } echo '</div></div>'; //remote upgrade if (gp_remote_themes && $id && isset(admin_tools::$new_versions[$id]) && version_compare(admin_tools::$new_versions[$id]['version'], $version, '>')) { $version_info = admin_tools::$new_versions[$id]; echo common::Link('Admin_Theme_Content', $langmessage['new_version'], 'cmd=remote_install&id=' . $id . '&name=' . rawurlencode($version_info['name'])); } echo '</div>'; } echo '</div>'; if ($show_options) { $this->SearchNavLinks(); } }
function FileInfo($file) { global $langmessage; $temp = explode('.', $file); if (count($temp) < 3) { return ''; } $info = array(); $info['ext'] = array_pop($temp); $info['bits'] = ''; if (count($temp) >= 3 && is_numeric($temp[0]) && is_numeric($temp[1])) { list($time, $exported, $rand) = $temp; $info['time'] = common::date($langmessage['strftime_datetime'], $time); $info['bits'] = $exported; foreach ($this->export_fields as $export_field) { $index = $export_field['index']; if (($exported & $index) == $index) { $info['exported'][] = $export_field['label']; } } if (empty($info['exported'])) { $info['exported'][] = 'Unknown'; } } else { $info['time'] = $file; $info['exported'][] = 'Unknown'; } return $info; }
/** * Display a form for uploading CKEditor plugins * */ function PluginForm() { global $langmessage, $page; echo '<form method="post" action="' . common::GetUrl($page->requested) . '" enctype="multipart/form-data">'; echo '<table class="bordered"><tr><th>' . $langmessage['name'] . '</th><th>' . $langmessage['Modified'] . '</th><th>' . $langmessage['options'] . '</th></tr>'; if (count($this->cke_config['plugins'])) { foreach ($this->cke_config['plugins'] as $plugin_name => $plugin_info) { echo '<tr><td>'; echo $plugin_name; echo '</td><td>'; echo common::date($langmessage['strftime_datetime'], $plugin_info['updated']); echo '</td><td>'; $attr = array('data-cmd' => 'postlink', 'class' => 'gpconfirm', 'title' => sprintf($langmessage['generic_delete_confirm'], $plugin_name)); echo common::Link($page->requested, $langmessage['delete'], 'cmd=rmplugin&plugin=' . rawurlencode($plugin_name), $attr); echo '</td></tr>'; } } echo '<tr><td>'; echo '<input type="hidden" name="cmd" value="upload_plugin" />'; echo '<input type="file" name="plugin" />'; echo '</td><td> '; echo '</td><td>'; echo ' <input type="submit" value="Install Plugin" />'; echo '</td></tr>'; echo '</table>'; echo '</form>'; //$this->build_config if ($this->build_config && isset($this->build_config['plugins'])) { $ordered = array(); $count = 0; foreach ($this->build_config['plugins'] as $plugin => $status) { if (!$status) { continue; } $char = strtoupper($plugin[0]); $ordered[$char][] = '<a href="http://ckeditor.com/addon/' . $plugin . '" target="_blank">' . ucfirst($plugin) . '</a>'; $count++; } //echo '<h3>'.$langmessage['Installed'].'</h3>'; echo '<p><br/></p>'; echo '<table class="bordered">'; echo '<tr><th colspan="2">' . $langmessage['Installed'] . ' (' . $count . ')</th></tr>'; foreach ($ordered as $char => $plugins) { echo '<tr><td>'; echo '<b>' . $char . '</b>'; echo '</td><td>'; echo implode(', ', $plugins); echo '</td></tr>'; } echo '</table>'; } }
/** * Display a form for uploading CKEditor plugins * */ function PluginForm() { global $langmessage, $page; echo '<form method="post" action="' . common::GetUrl($page->requested) . '" enctype="multipart/form-data">'; echo '<table class="bordered"><tr><th>' . $langmessage['name'] . '</th><th>' . $langmessage['Modified'] . '</th><th>' . $langmessage['options'] . '</th></tr>'; if (count($this->cke_config['plugins'])) { foreach ($this->cke_config['plugins'] as $plugin_name => $plugin_info) { echo '<tr><td>'; echo $plugin_name; echo '</td><td>'; echo common::date($langmessage['strftime_datetime'], $plugin_info['updated']); echo '</td><td>'; $attr = array('data-cmd' => 'postlink', 'class' => 'gpconfirm', 'title' => sprintf($langmessage['generic_delete_confirm'], $plugin_name)); echo common::Link($page->requested, $langmessage['delete'], 'cmd=rmplugin&plugin=' . rawurlencode($plugin_name), $attr); echo '</td></tr>'; } } echo '<tr><td>'; echo '<input type="hidden" name="cmd" value="upload_plugin" />'; echo '<input type="file" name="plugin" />'; echo '</td><td> '; echo '</td><td>'; echo ' <input type="submit" value="Install Plugin" />'; echo '</td></tr>'; echo '</table>'; echo '</form>'; }
function FileStats($key, $title, $is_special) { global $langmessage, $gp_titles; echo '<a>' . $langmessage['Slug/URL'] . ': ' . htmlspecialchars($title) . '</a>'; echo '<a>' . $langmessage['Content Type'] . ': ' . str_replace(',', ', ', $gp_titles[$key]['type']) . '</a>'; if (!$is_special) { $file = gpFiles::PageFile($title); $stats = @stat($file); if ($stats) { $mtime = $stats['mtime']; $size = $stats['size']; echo '<a>' . $langmessage['File Size'] . ': ' . admin_tools::FormatBytes($size) . '</a>'; echo '<a>' . $langmessage['Modified'] . ': ' . common::date($langmessage['strftime_datetime'], $mtime) . '</a>'; } } echo '<a>Data Index: ' . $key . '</a>'; }
function CheckStatus() { global $langmessage; $diff = time() - $this->data_timestamp; if ($this->data_timestamp > 0) { echo '<p>'; echo sprintf($langmessage['Software_updates_checked'], common::date($langmessage['strftime_datetime'], $this->data_timestamp)); echo '</p>'; } //one hour old if ($diff > 3600) { echo '<p>'; echo '<a href="?cmd=checkremote">' . $langmessage['Check Now'] . '</a>'; echo '</p>'; } }
/** * Display the contents of a past revision * */ function ViewRevision() { global $langmessage; $time = $_REQUEST['time']; $full_path = $this->BackupFile($time); if (!$full_path) { return false; } $file_sections = $file_stats = array(); //if it's a compressed file, we need an uncompressed version if (strpos($full_path, '.gze') !== false) { ob_start(); readgzfile($full_path); $contents = ob_get_clean(); $dir = common::DirName($full_path); $full_path = tempnam($dir, 'backup'); gpFiles::Save($full_path, $contents); $file_sections = gpFiles::Get($full_path, 'file_sections'); unlink($full_path); } else { $file_sections = gpFiles::Get($full_path, 'file_sections'); } $this->contentBuffer = section_content::Render($file_sections, $this->title, gpFiles::$last_stats); $date = common::date($langmessage['strftime_datetime'], $time); $message = sprintf($langmessage['viewing_revision'], $date); $message .= ' <br/> ' . common::Link($this->title, $langmessage['Restore this revision'], 'cmd=use_revision&time=' . $time, array('data-cmd' => 'cnreq')); $message .= ' ' . common::Link($this->title, $langmessage['Revision History'], 'cmd=view_history', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox')); message($message); }
/** * Display row * */ function SearchDisplayRow($title) { global $langmessage, $gpLayouts, $gp_index, $gp_menu; $title_index = $gp_index[$title]; $is_special = common::SpecialOrAdmin($title); $file = gpFiles::PageFile($title); $stats = @stat($file); $mtime = false; $size = false; $layout = admin_menu_tools::CurrentLayout($title_index); $layout_info = $gpLayouts[$layout]; if ($stats) { $mtime = $stats['mtime']; $size = $stats['size']; } echo '<tr><td>'; $label = common::GetLabel($title); echo common::Link($title, common::LabelSpecialChars($label)); //area only display on mouseover echo '<div><div>'; //style="position:absolute;bottom:0;left:10px;right:10px;" echo $this->Link('Admin_Menu', $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($title_index), array('title' => $langmessage['rename/details'], 'data-cmd' => 'gpajax')); echo $this->Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&index=' . urlencode($title_index), array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox')); echo '<span>'; echo $langmessage['layout'] . ': '; echo $this->Link('Admin_Menu', $layout_info['label'], 'cmd=layout&index=' . urlencode($title_index), array('title' => $langmessage['layout'], 'data-cmd' => 'gpabox')); echo '</span>'; if (!$is_special) { echo $this->Link('Admin_Menu', $langmessage['delete'], 'cmd=trash&index=' . urlencode($title_index), array('title' => $langmessage['delete_page'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm')); } gpPlugin::Action('MenuPageOptions', array($title, $title_index, false, $layout_info)); //stats if (gpdebug) { echo '<span>Data Index: ' . $title_index . '</span>'; } echo '</div> </div>'; //types echo '</td><td>'; $this->TitleTypes($title_index); //children 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']; } //size echo '</td><td>'; if ($size) { echo admin_tools::FormatBytes($size); } //modified echo '</td><td>'; if ($mtime) { echo common::date($langmessage['strftime_datetime'], $mtime); } echo '</td></tr>'; }
function RateForm() { global $config, $dirPrefix, $langmessage; //get appropriate variables $id = $this->addon_info['id']; if (isset($_REQUEST['rating'])) { $rating = $_REQUEST['rating']; } elseif (isset($this->addonReviews[$id])) { $rating = $this->addonReviews[$id]['rating']; } else { $rating = 5; } if (isset($_REQUEST['review'])) { $review = $_REQUEST['review']; } elseif (isset($this->addonReviews[$id])) { $review = $this->addonReviews[$id]['review']; } else { $review = ''; } echo '<h2>'; echo $this->addon_info['name'] . ' » ' . 'Rate'; echo '</h2>'; if (isset($this->addonReviews[$id])) { echo 'You posted the following review on ' . common::date($langmessage['strftime_date'], $this->addonReviews[$id]['time']); } //echo '<form action="'.common::GetUrl($this->scriptUrl,'cmd=rate&arg='.$this->addon_info['pass_arg']).'" method="post">'; echo '<form action="' . common::GetUrl($this->scriptUrl) . '" method="post">'; echo '<input type="hidden" name="arg" value="' . $this->addon_info['pass_arg'] . '"/>'; echo '<input type="hidden" name="cmd" value="rate" />'; echo '<table class="rating_table">'; echo '<tr><td>Rating</td><td>'; echo '<span class="rating">'; for ($i = 1; $i < 6; $i++) { $class = ''; if ($i > $rating) { $class = ' class="unset"'; } echo '<a data-rating="' . $i . '"' . $class . '></a>'; } echo '<input type="hidden" name="rating" value="' . htmlspecialchars($rating) . '" />'; echo '</span> '; echo '</td></tr>'; echo '<tr><td>Review</td><td>'; echo '<textarea name="review" cols="50" rows="7" class="gptextarea">'; echo htmlspecialchars($review); echo '</textarea>'; echo '</td></tr>'; echo '<tr><td>From</td><td>'; $host = $_SERVER['HTTP_HOST'] . $dirPrefix; echo '<input type="text" name="host" size="50" value="' . htmlspecialchars($host) . '" readonly="readonly" class="gpinput gpreadonly" />'; echo '<br/>'; echo '<input type="checkbox" name="show_site" value="hidden" /> Click to hide your site information on gpEasy.com.'; echo '</td></tr>'; echo '<tr><td></td><td>'; if (isset($this->addonReviews[$id])) { echo '<input type="submit" name="cmd" value="Update Review" class="gppost gpsubmit"/>'; } else { echo '<input type="submit" name="cmd" value="Send Review" class="gppost gpsubmit"/>'; } echo ' '; echo '<input type="submit" name="cmd" value="Cancel" class="admin_box_close gpcancel"/>'; echo '</td></tr>'; echo '</table>'; echo '</form>'; return true; }
/** * Display the contents of a past revision * */ public function ViewRevision() { global $langmessage; $time = $_REQUEST['time']; $full_path = $this->BackupFile($time); if (is_null($full_path)) { return false; } //if it's a compressed file, we need an uncompressed version if (strpos($full_path, '.gze') !== false) { ob_start(); readgzfile($full_path); $contents = ob_get_clean(); $dir = common::DirName($full_path); $full_path = tempnam($dir, 'backup') . '.php'; gpFiles::Save($full_path, $contents); $file_sections = gpFiles::Get($full_path, 'file_sections'); unlink($full_path); } else { $file_sections = gpFiles::Get($full_path, 'file_sections'); } $this->contentBuffer = section_content::Render($file_sections, $this->title, gpFiles::$last_stats); $date = common::date($langmessage['strftime_datetime'], $time); $message = sprintf($langmessage['viewing_revision'], $date); $message .= ' <span class="msg_buttons">'; $message .= common::Link($this->title, $langmessage['Restore this revision'], 'cmd=UseRevision&time=' . $time, array('data-cmd' => 'cnreq')); $message .= common::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox', 'class' => 'msg_view_history')); $message .= '</span>'; msg($message); }