Exemplo n.º 1
0
 public function SessionStart()
 {
     common::GetConfig();
     $username = '******';
     $users = gpFiles::Get('_site/users');
     $userinfo = $users[$username];
     $session_id = gpsession::create($userinfo, $username, $sessions);
     $logged_in = gpsession::start($session_id, $sessions);
     self::AssertTrue($logged_in, 'Not Logged In');
 }
Exemplo n.º 2
0
 function SaveAddonData()
 {
     $addonData = array();
     while (count($this->addonHistory) > 30) {
         array_shift($this->addonHistory);
     }
     $addonData['history'] = $this->addonHistory;
     $addonData['reviews'] = $this->addonReviews;
     return gpFiles::SaveArray($this->dataFile, 'addonData', $addonData);
 }
Exemplo n.º 3
0
 function SaveContent()
 {
     global $langmessage;
     $content =& $_POST['content'];
     gpFiles::cleanText($content);
     $this->config['content'] = $content;
     if ($this->SaveConfig()) {
         message($langmessage['SAVED']);
     } else {
         message($langmessage['OOPS']);
     }
 }
Exemplo n.º 4
0
 function SaveAddonData()
 {
     if (!isset($this->dataFile)) {
         trigger_error('dataFile not set');
         return;
     }
     $addonData = array();
     while (count($this->addonHistory) > 30) {
         array_shift($this->addonHistory);
     }
     $addonData['history'] = $this->addonHistory;
     $addonData['reviews'] = $this->addonReviews;
     return gpFiles::SaveData($this->dataFile, 'addonData', $addonData);
 }
Exemplo n.º 5
0
 private function saveSettings()
 {
     global $langmessage;
     $this->updateSetting('wysiwygDelay');
     $this->updateBooleanSetting('wysiwygEnabled');
     $this->updateBooleanSetting('markupEscaped');
     $this->updateBooleanSetting('breaksEnabled');
     $this->updateBooleanSetting('urlsLinked');
     if (gpFiles::SaveArray($this->conf, 'settings', $this->settings)) {
         message($langmessage['SAVED']);
         return;
     }
     message($langmessage['OOPS']);
     $this->settings = $_POST;
 }
Exemplo n.º 6
0
 /**
  * Get The Image
  *
  */
 function Child($title)
 {
     global $dirPrefix;
     $file = gpFiles::PageFile($title);
     $file_sections = $file_stats = array();
     ob_start();
     require $file;
     ob_get_clean();
     if (!is_array($file_sections)) {
         return;
     }
     //get the image
     $content = section_content::Render($file_sections, $title, $file_stats);
     $img_pos = strpos($content, '<img');
     if ($img_pos === false) {
         return;
     }
     $src_pos = strpos($content, 'src=', $img_pos);
     if ($src_pos === false) {
         return;
     }
     $src = substr($content, $src_pos + 4);
     $quote = $src[0];
     if ($quote != '"' && $quote != "'") {
         return;
     }
     $src_pos = strpos($src, $quote, 1);
     $src = substr($src, 1, $src_pos - 1);
     // check for resized image, get original source if img is resized
     if (strpos($src, 'image.php') !== false && strpos($src, 'img=') !== false) {
         $src = $dirPrefix . '/data/_uploaded/' . urldecode(substr($src, strpos($src, 'img=') + 4));
     }
     $thumb_path = common::ThumbnailPath($src);
     $img_pos2 = strpos($content, '>', $img_pos);
     $img = substr($content, $img_pos, $img_pos2 - $img_pos + 1);
     echo '<li>';
     echo '<img src="' . $thumb_path . '"/>';
     //echo $img;
     $label = common::GetLabel($title);
     echo common::Link($title, $label);
     echo '</li>';
 }
Exemplo n.º 7
0
 function SaveConfig()
 {
     global $langmessage;
     $format = htmlspecialchars($_POST['date_format']);
     if (@date($format)) {
         $this->config['date_format'] = $format;
     }
     $this->config['commenter_website'] = (string) $_POST['commenter_website'];
     if (isset($_POST['comment_captcha'])) {
         $this->config['comment_captcha'] = true;
     } else {
         $this->config['comment_captcha'] = false;
     }
     if (!gpFiles::SaveArray($this->config_file, 'config', $this->config)) {
         message($langmessage['OOPS']);
         return false;
     }
     message($langmessage['SAVED']);
     return true;
 }
Exemplo n.º 8
0
 /**
  * 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);
             }
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Return the formatted content of the title
  *
  */
 public function TitleContent($title)
 {
     $file = gpFiles::PageFile($title);
     $file_sections = $file_stats = array();
     ob_start();
     require $file;
     ob_get_clean();
     if (!is_array($file_sections)) {
         return '';
     }
     //prevent infinite loops
     foreach ($file_sections as $key => $val) {
         if ($val['type'] == 'include') {
             unset($file_sections[$key]);
         }
     }
     if (!$file_sections) {
         return '';
     }
     $file_sections = array_values($file_sections);
     return section_content::Render($file_sections, $title, $file_stats);
 }
Exemplo n.º 10
0
 /**
  * Check page files for orphaned data files
  *
  */
 function CheckPageFiles()
 {
     global $dataDir, $gp_index;
     $pages_dir = $dataDir . '/data/_pages';
     $all_files = gpFiles::ReadDir($pages_dir, 'php');
     foreach ($all_files as $key => $file) {
         $all_files[$key] = $pages_dir . '/' . $file . '.php';
     }
     $page_files = array();
     foreach ($gp_index as $slug => $index) {
         $page_files[] = gpFiles::PageFile($slug);
     }
     $diff = array_diff($all_files, $page_files);
     if (!count($diff)) {
         return;
     }
     echo '<h2>Orphaned Data Files</h2>';
     echo '<p>The following data files appear to be orphaned and are most likely no longer needed. Before completely removing these files, we recommend backing them up first.</p>';
     echo '<table class="bordered"><tr><th>File</th></tr>';
     foreach ($diff as $file) {
         echo '<tr><td>' . $file . '</td></tr>';
     }
     echo '</table>';
 }
Exemplo n.º 11
0
 function SearchPage($pattern, $title, $index)
 {
     global $gp_menu;
     $full_path = gpFiles::PageFile($title);
     if (!file_exists($full_path)) {
         return;
     }
     //search hidden?
     if (!$this->search_config['search_hidden']) {
         if (!isset($gp_menu[$index])) {
             return;
         }
     }
     include $full_path;
     if (!isset($file_sections) || !is_array($file_sections)) {
         return;
     }
     $content = '';
     foreach ($file_sections as $section) {
         if (!isset($section['content'])) {
             continue;
         }
         if ($section['type'] == 'exec_php') {
             continue;
         }
         $content .= $section['content'] . ' ';
     }
     $this->findString($content, $pattern, $title);
 }
Exemplo n.º 12
0
 /**
  * Get addon data from gpEasy.com and display to user
  *
  */
 function RemoteBrowse()
 {
     global $langmessage, $config, $dataDir, $gpversion;
     //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');
     $orderby = array();
     $orderby['rating_score'] = $langmessage['Highest Rated'];
     $orderby['downloads'] = $langmessage['Most Downloaded'];
     $orderby['modified'] = $langmessage['Recently Updated'];
     $orderby['created'] = $langmessage['Newest'];
     $_GET += array('q' => '');
     $this->searchPage = 0;
     if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
         $this->searchPage = $_REQUEST['page'];
     }
     $this->searchQuery = 'cmd=remote';
     //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']);
     }
     if (isset($_GET['order']) && isset($orderby[$_GET['order']])) {
         $this->searchOrder = $_GET['order'];
         $this->searchQuery .= '&order=' . rawurlencode($_GET['order']);
     } else {
         reset($orderby);
         $this->searchOrder = key($orderby);
     }
     $slug = 'Special_Addon_Plugins';
     if ($this->config_index == 'themes') {
         $slug = 'Special_Addon_Themes';
     }
     $src = $GLOBALS['addonBrowsePath'] . '/' . $slug . '?' . $this->searchQuery . '&page=' . $this->searchPage;
     //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);
     }
     if (!$result) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f1)</p>';
         return;
     }
     if (strpos($result, 'a:') !== 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f2)</p>';
         return;
     }
     $data = unserialize($result);
     if (count($data) == 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f3)</p>';
         return;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->searchOffset = $this->searchPage * $this->searchPerPage;
     $this->FindForm();
     echo '<h2 class="hmargin">';
     echo common::Link($this->browser_path, $this->manage_label);
     echo ' <span>|</span> ';
     if (!empty($_GET['q'])) {
         echo common::Link($this->browser_path, $this->find_label, 'cmd=remote');
         echo ' &#187; ';
         echo htmlspecialchars($_GET['q']);
     } else {
         echo $this->find_label;
     }
     echo '</h2>';
     echo '<div class="gp_search_options">';
     $this->SearchNavLinks();
     echo '<div class="search_order">';
     foreach ($orderby as $key => $label) {
         if ($key === $this->searchOrder) {
             echo '<span>' . $label . '</span>';
         } else {
             echo common::Link($this->browser_path, $label, $this->searchQuery . '&order=' . $key);
         }
     }
     echo '</div></div>';
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             $this->DetailLink($row, '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             $this->DetailLink($row);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             //echo showArray($row);
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . $gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->browser_path, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' name="gpajax"');
     } else {
         echo common::Link($this->browser_path, $langmessage['On'], $this->searchQuery . '&search_option=version', ' name="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Exemplo n.º 13
0
 /**
  * Save the current configuration
  * If successful, reset the lists and titles variables
  */
 public function SaveConfig($refresh_msg = false)
 {
     global $langmessage;
     if (!gpFiles::SaveArray($this->config_file, 'config', $this->config)) {
         message($langmessage['OOPS']);
         return false;
     }
     $this->lists = $this->config['lists'];
     $this->titles = $this->config['titles'];
     if (count($this->config['langs'])) {
         $this->langs = $this->config['langs'];
     }
     if ($refresh_msg) {
         message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']);
     } else {
         message($langmessage['SAVED']);
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * Save the gpEasy configuration
  * @return bool
  *
  */
 static function SaveConfig()
 {
     global $config, $dataDir;
     if (!is_array($config)) {
         return false;
     }
     if (!isset($config['gpuniq'])) {
         $config['gpuniq'] = common::RandomString(20);
     }
     return gpFiles::SaveData($dataDir . '/data/_site/config.php', 'config', $config);
 }
Exemplo n.º 15
0
 /**
  * Retreive the data file for the current title and update the data if necessary
  *
  */
 function GetFile()
 {
     $this->file_sections = gpFiles::Get($this->file, 'file_sections');
     $this->meta_data = gpFiles::$last_meta;
     $this->fileModTime = gpFiles::$last_modified;
     $this->file_stats = gpFiles::$last_stats;
     if (count($this->file_sections) == 0) {
         $this->file_sections[0] = array('type' => 'text', 'content' => '<p>Oops, this page no longer has any content.</p>');
     }
 }
Exemplo n.º 16
0
 function ChangeInstallConfirmed(&$addonName)
 {
     global $dataDir, $langmessage;
     $installFolder = $dataDir . '/data/_addoncode/' . $addonName;
     $fromFolder = $dataDir . '/addons/' . $addonName;
     if (!file_exists($installFolder)) {
         message($langmessage['OOPS']);
         return;
     }
     if (!file_exists($fromFolder)) {
         message($langmessage['OOPS']);
         return;
     }
     if (is_link($installFolder)) {
         unlink($installFolder);
         if (!admin_addon_install::CopyAddonDir($fromFolder, $installFolder)) {
             message($langmessage['OOPS']);
             return;
         }
     } else {
         gpFiles::RmAll($installFolder);
         if (!symlink($fromFolder, $installFolder)) {
             message($langmessage['OOPS']);
             return;
         }
     }
     message('Install Type Changed');
 }
Exemplo n.º 17
0
 function GetUsers()
 {
     $this->users = gpFiles::Get('_site/users');
     //fix the editing value
     foreach ($this->users as $username => $userinfo) {
         $userinfo += array('granted' => '');
         admin_tools::EditingValue($userinfo);
         $this->users[$username] = $userinfo;
     }
 }
Exemplo n.º 18
0
 /**
  * Get a list of available addons
  *
  */
 function GetAvailAddons()
 {
     global $dataDir;
     $addonPath = $dataDir . '/addons';
     if (!file_exists($addonPath)) {
         message('Warning: The /addons folder "<em>' . $addonPath . '</em>" does not exist on your server.');
         return array();
     }
     $installed_path = $dataDir . '/data/_addoncode';
     $folders = gpFiles::ReadDir($addonPath, 1);
     $versions = array();
     $avail = array();
     foreach ($folders as $value) {
         $fullPath = $addonPath . '/' . $value;
         $info = $this->GetAvailInstall($fullPath);
         if (!$info) {
             continue;
         }
         $info['upgrade_key'] = admin_addons_tool::UpgradePath($info);
         $avail[$value] = $info;
         if (isset($info['Addon_Version']) && isset($info['Addon_Unique_ID'])) {
             $id = $info['Addon_Unique_ID'];
             $version = $info['Addon_Version'];
             if (!isset($versions[$id])) {
                 $versions[$id] = $version;
                 continue;
             }
             if (version_compare($versions[$id], $version, '<')) {
                 $versions[$id] = $version;
             }
         }
     }
     if (!gp_unique_addons) {
         return $avail;
     }
     //show only the most recent versions
     $temp = array();
     foreach ($avail as $key => $info) {
         if (!isset($info['Addon_Version']) || !isset($info['Addon_Unique_ID'])) {
             $temp[$key] = $info;
             continue;
         }
         $id = $info['Addon_Unique_ID'];
         $version = $info['Addon_Version'];
         if (version_compare($versions[$id], $version, '>')) {
             continue;
         }
         $temp[$key] = $info;
     }
     return $temp;
 }
Exemplo n.º 19
0
 /**
  * Perform a page copy
  *
  */
 function CopyPage()
 {
     global $gp_index, $gp_titles, $page, $langmessage;
     //existing page info
     $from_title = $_POST['from_title'];
     if (!isset($gp_index[$from_title])) {
         message($langmessage['OOPS_TITLE']);
         return false;
     }
     $from_index = $gp_index[$from_title];
     $info = $gp_titles[$from_index];
     //check the new title
     $title = $_POST['title'];
     $title = admin_tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         message($message);
         return false;
     }
     //get the existing content
     $from_file = gpFiles::PageFile($from_title);
     $contents = file_get_contents($from_file);
     //add to $gp_index first!
     $index = common::NewFileIndex();
     $gp_index[$title] = $index;
     $file = gpFiles::PageFile($title);
     if (!gpFiles::Save($file, $contents)) {
         message($langmessage['OOPS'] . ' (File not saved)');
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $info['type'];
     $gp_titles += $new_titles;
     if (!admin_tools::SavePagesPHP()) {
         message($langmessage['OOPS'] . ' (CP2)');
         return false;
     }
     message($langmessage['SAVED']);
     if (isset($_REQUEST['redir'])) {
         $url = common::AbsoluteUrl($title, '', true, false);
         $page->ajaxReplace[] = array('eval', '', 'window.setTimeout(function(){window.location="' . $url . '"},15000);');
         message(sprintf($langmessage['will_redirect'], common::Link_Page($title)));
     }
     return $index;
 }
Exemplo n.º 20
0
 function getPossible()
 {
     global $dataDir, $langmessage;
     $possible = $this->variables;
     //$langDir = $dataDir.'/include/thirdparty/fckeditor/editor/lang'; //fckeditor
     $langDir = $dataDir . '/include/thirdparty/ckeditor_34/lang';
     //ckeditor
     $possible['langeditor'] = gpFiles::readDir($langDir, 'js');
     unset($possible['langeditor']['_languages']);
     $possible['langeditor']['inherit'] = ' ' . $langmessage['default'];
     //want it to be the first in the list
     asort($possible['langeditor']);
     //recaptcha language
     $possible['recaptcha_language'] = array();
     $possible['recaptcha_language']['inherit'] = $langmessage['default'];
     $possible['recaptcha_language']['en'] = 'en';
     $possible['recaptcha_language']['nl'] = 'nl';
     $possible['recaptcha_language']['fr'] = 'fr';
     $possible['recaptcha_language']['de'] = 'de';
     $possible['recaptcha_language']['pt'] = 'pt';
     $possible['recaptcha_language']['ru'] = 'ru';
     $possible['recaptcha_language']['es'] = 'es';
     $possible['recaptcha_language']['tr'] = 'tr';
     //website language
     $possible['language'] = $this->GetPossibleLanguages();
     //jQuery
     $possible['jquery'] = array('local' => $langmessage['None'], 'google' => 'jQuery', 'jquery_ui' => 'jQuery & jQuery UI');
     //tidy
     if (function_exists('tidy_parse_string')) {
         $possible['HTML_Tidy'] = array('off' => $langmessage['Off'], '' => $langmessage['On']);
     } else {
         $possible['HTML_Tidy'] = array('' => 'Unavailable');
     }
     //
     $possible['require_email'] = array('none' => 'None', '' => 'Subject &amp; Message', 'email' => 'Subject, Message &amp; Email');
     //see xoopsmultimailer.php
     $possible['mail_method'] = array('mail' => 'PHP mail()', 'sendmail' => 'sendmail', 'smtp' => 'smtp', 'smtpauth' => 'SMTPAuth');
     gpSettingsOverride('configuration', $possible);
     return $possible;
 }
Exemplo n.º 21
0
 function SaveHeaderImage()
 {
     global $page, $dataDir, $dirPrefix, $langmessage;
     includeFile('tool/Images.php');
     $page->ajaxReplace = array();
     //source file
     $source_file_rel = $_REQUEST['file'];
     if (!empty($_REQUEST['src'])) {
         $source_file_rel = rawurldecode($_REQUEST['src']);
         if (!empty($dirPrefix)) {
             $len = strlen($dirPrefix);
             $source_file_rel = substr($source_file_rel, $len);
         }
     }
     $source_file_rel = '/' . ltrim($source_file_rel, '/');
     $source_file_full = $dataDir . $source_file_rel;
     if (!file_exists($source_file_full)) {
         message($langmessage['OOPS'] . ' (Source file not found)');
         return;
     }
     $src_img = thumbnail::getSrcImg($source_file_full);
     if (!$src_img) {
         message($langmessage['OOPS'] . ' (Couldn\'t create image [1])');
         return;
     }
     //size and position variables
     $orig_w = $width = imagesx($src_img);
     $orig_h = $height = imagesy($src_img);
     $posx = $posy = 0;
     if (isset($_REQUEST['posx']) && is_numeric($_REQUEST['posx'])) {
         $posx = $_REQUEST['posx'];
     }
     if (isset($_REQUEST['posy']) && is_numeric($_REQUEST['posy'])) {
         $posy = $_REQUEST['posy'];
     }
     if (isset($_REQUEST['width']) && is_numeric($_REQUEST['width'])) {
         $width = $_REQUEST['width'];
     }
     if (isset($_REQUEST['height']) && is_numeric($_REQUEST['height'])) {
         $height = $_REQUEST['height'];
     }
     //check to see if the image needs to be resized
     if ($posx == 0 && $posy == 0 && $width == $orig_w && $height == $orig_h) {
         $this->SetImage($source_file_rel, $width, $height);
         return;
     }
     //destination file
     $name = basename($source_file_rel);
     $parts = explode('.', $name);
     $type = array_pop($parts);
     if (count($parts) > 1) {
         $time_part = array_pop($parts);
         if (!ctype_digit($time_part)) {
             $parts[] = $time_part;
         }
     }
     $name = implode('.', $parts);
     $time = time();
     if (isset($_REQUEST['time']) && ctype_digit($_REQUEST['time'])) {
         $time = $_REQUEST['time'];
     }
     //$dest_img_rel = '/data/_uploaded/headers/'.$name.'.'.$time.'.'.$type;
     $dest_img_rel = '/data/_uploaded/headers/' . $name . '.' . $time . '.png';
     $dest_img_full = $dataDir . $dest_img_rel;
     //make sure the folder exists
     if (!gpFiles::CheckDir(dirname($dest_img_full))) {
         message($langmessage['OOPS'] . ' (Couldn\'t create directory)');
         return false;
     }
     if (!thumbnail::createImg($src_img, $dest_img_full, $posx, $posy, 0, 0, $orig_w, $orig_h, $orig_w, $orig_h, $width, $height)) {
         message($langmessage['OOPS'] . ' (Couldn\'t create image [2])');
         return;
     }
     if ($this->SetImage($dest_img_rel, $width, $height)) {
         includeFile('admin/admin_uploaded.php');
         admin_uploaded::CreateThumbnail($dest_img_full);
     }
 }
Exemplo n.º 22
0
 function SetExported()
 {
     $this->exported = gpFiles::ReadDir($this->export_dir, $this->all_extenstions);
     arsort($this->exported);
 }
Exemplo n.º 23
0
 static function NewExtra($file, $content)
 {
     $extra_content = array('type' => 'text', 'content' => $content);
     return gpFiles::SaveData($file, 'extra_content', $extra_content);
 }
Exemplo n.º 24
0
 public static function FTP_CheckDir($dir)
 {
     $conn_id = gpFiles::FTPConnect();
     $dir = gpFiles::ftpLocation($dir);
     if (!ftp_mkdir($conn_id, $dir)) {
         return false;
     }
     return ftp_site($conn_id, 'CHMOD 0777 ' . $dir);
 }
Exemplo n.º 25
0
 /**
  * Finalize theme removal
  *
  */
 function DeleteThemeConfirmed()
 {
     global $langmessage, $dataDir, $gpLayouts, $config;
     $gpLayoutsBefore = $gpLayouts;
     $can_delete = true;
     $theme_folder_name =& $_POST['folder'];
     $theme_folder = $dataDir . '/data/_themes/' . $theme_folder_name;
     if (empty($theme_folder_name) || !ctype_alnum($theme_folder_name) || !isset($config['themes'][$theme_folder_name])) {
         message($langmessage['OOPS']);
         return false;
     }
     $order = false;
     if (isset($config['themes'][$theme_folder_name]['order'])) {
         $order = $config['themes'][$theme_folder_name]['order'];
     }
     if (!$this->CanDeleteTheme($theme_folder_name, $message)) {
         message($message);
         return false;
     }
     //remove layouts
     foreach ($gpLayouts as $layout_id => $layout_info) {
         if (!isset($layout_info['is_addon']) || !$layout_info['is_addon']) {
             continue;
         }
         $layout_folder = dirname($layout_info['theme']);
         if ($layout_folder == $theme_folder_name) {
             $this->RmLayout($layout_id);
         }
     }
     //delete the folder
     $dir = $dataDir . '/data/_themes/' . $theme_folder_name;
     gpFiles::RmAll($dir);
     //remove from settings
     unset($config['themes'][$theme_folder_name]);
     if (admin_tools::SaveAllConfig()) {
         message($langmessage['SAVED']);
         if ($order) {
             $img_path = common::IdUrl('ci');
             common::IdReq($img_path);
         }
     } else {
         $gpLayouts = $gpLayoutsBefore;
         message($langmessage['OOPS'] . ' (s1)');
     }
 }
Exemplo n.º 26
0
 function SearchPage($title, $index)
 {
     global $gp_menu, $gp_titles;
     //search hidden?
     if (!$this->search_hidden && !isset($gp_menu[$index])) {
         return;
     }
     //private pages
     if (!common::LoggedIn()) {
         if (isset($gp_titles[$index]['vis'])) {
             return;
         }
     }
     $full_path = gpFiles::PageFile($title);
     $file_sections = gpFiles::Get($full_path, 'file_sections');
     if (!$file_sections) {
         return;
     }
     $content = section_content::Render($file_sections, $title, gpFiles::$last_stats);
     $label = common::GetLabel($title);
     $this->FindString($content, $label, $title);
 }
Exemplo n.º 27
0
 function SaveData()
 {
     global $langmessage, $addonPathData;
     if (!isset($_REQUEST['index'])) {
         return $langmessage['OOPS'] . ' - nothing to save!';
     }
     $index = $_REQUEST['index'];
     $configFile = $addonPathData . '/ec_pagedata.php';
     $pagedata = self::LoadData();
     if ($_REQUEST) {
         if (array_key_exists("datafilter", $_REQUEST)) {
             $_REQUEST["datafilter"] = array_diff($_REQUEST["datafilter"], array(''));
             $pagedata[$index]['datafilter'] = implode(",", $_REQUEST["datafilter"]);
         } else {
             $pagedata[$index]['datafilter'] = "";
         }
     }
     $pagedata[$index]['image_url'] = urlencode($_REQUEST['custom_img']);
     //save added opts
     $temp = new Catalog_Easy();
     $temp->getConfig();
     if (isset($temp->addon_name) and $temp->addon_name != "") {
         foreach ($temp->addon_name as $name) {
             $name = str_replace(' ', '_', $name);
             if (array_key_exists($name, $_REQUEST)) {
                 $pagedata[$index][$name] = $_REQUEST[$name];
             }
         }
     }
     if (gpFiles::SaveArray($configFile, 'pagedata', $pagedata)) {
         return $langmessage['SAVED'];
     } else {
         return $langmessage['OOPS'];
     }
 }
Exemplo n.º 28
0
 /**
  * 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;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->ShowHeader();
     $this->SearchOptions();
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             echo $this->DetailLink($row['type'], $row['id'], '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             echo $this->DetailLink($row['type'], $row['id']);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->searchUrl, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' data-cmd="gpajax"');
     } else {
         echo common::Link($this->searchUrl, $langmessage['On'], $this->searchQuery . '&search_option=version', ' data-cmd="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Exemplo n.º 29
0
 /**
  * Get current configuration settings
  *
  */
 function Init()
 {
     $this->config_file = '_ckeditor/config';
     $this->cke_config = gpFiles::Get($this->config_file, 'cke_config');
     //$this->cke_config 	+= array('custom_config'=>array());
     $this->cke_config += array('plugins' => array());
     $this->BuildConfig();
 }
Exemplo n.º 30
0
 /**
  * Convert a .less file to .css and include it in the page
  * @param mixed $less_files A strin or array of less filesThe absolute or relative path of the .less file
  *
  */
 static function CacheLess($less_files)
 {
     global $dataDir;
     //generage the name of the css file from the modified times and content length of each imported less file
     $files_hash = common::ArrayHash($less_files);
     $list_file = $dataDir . '/data/_cache/less_' . $files_hash . '.list';
     if (file_exists($list_file)) {
         $list = explode("\n", file_get_contents($list_file));
         //pop the etag
         $etag = array_pop($list);
         if (!ctype_alnum($etag)) {
             $list[] = $etag;
             $etag = false;
         }
         // generate an etag if needed or if logged in
         if (!$etag || common::LoggedIn()) {
             $etag = common::FilesEtag($list);
         }
         $compiled_name = 'less_' . $files_hash . '_' . $etag . '.css';
         $compiled_file = '/data/_cache/' . $compiled_name;
         if (file_exists($dataDir . $compiled_file)) {
             //msg('not using cache');
             return $compiled_file;
         }
     }
     $less_files = (array) $less_files;
     $compiled = gpOutput::ParseLess($less_files, $files_hash);
     if (!$compiled) {
         return false;
     }
     // generate the file name
     $etag = common::FilesEtag($less_files);
     $compiled_name = 'less_' . $files_hash . '_' . $etag . '.css';
     $compiled_file = '/data/_cache/' . $compiled_name;
     // save the cache
     // use the last line for the etag
     $less_files[] = $etag;
     $cache = implode("\n", $less_files);
     if (!gpFiles::Save($list_file, $cache)) {
         return false;
     }
     //save the css
     if (file_put_contents($dataDir . $compiled_file, $compiled)) {
         return $compiled_file;
     }
     return false;
 }