Exemplo n.º 1
0
 /**
  * Check recursively to see if a directory exists, if it doesn't attempt to create it
  *
  * @param string $dir The directory path
  * @param bool $index Whether or not to add an index.hmtl file in the directory
  * @return bool True on success
  */
 public static function CheckDir($dir, $index = true)
 {
     global $config;
     if (!file_exists($dir)) {
         $parent = common::DirName($dir);
         gpFiles::CheckDir($parent, $index);
         //ftp mkdir
         if (isset($config['useftp'])) {
             if (!gpFiles::FTP_CheckDir($dir)) {
                 return false;
             }
         } else {
             if (!@mkdir($dir, gp_chmod_dir)) {
                 return false;
             }
             @chmod($dir, gp_chmod_dir);
             //some systems need more than just the 0755 in the mkdir() function
         }
         // make sure there's an index.html file
         // only check if we just created the directory, we don't want to keep creating an index.html file if a user deletes it
         if ($index && gp_dir_index) {
             $indexFile = $dir . '/index.html';
             if (!file_exists($indexFile)) {
                 //not using gpFiles::Save() so we can avoid infinite looping (it's safe since we already know the directory exists and we're not concerned about the content)
                 file_put_contents($indexFile, '<html></html>');
                 @chmod($indexFile, gp_chmod_file);
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
    static function Install_DataFiles_New($destination = false, $config = array(), $base_install = true)
    {
        global $langmessage;
        if ($destination === false) {
            $destination = $GLOBALS['dataDir'];
        }
        //set config variables
        //$config = array(); //because of ftp values
        $gpLayouts = array();
        //use bootswatch theme if server has enough memory
        $gpLayouts['default']['theme'] = 'Bootswatch_Flatly/4_Sticky_Footer';
        $gpLayouts['default']['label'] = 'Bootswatch_Flatly/4_Sticky_Footer';
        if (@ini_set('memory_limit', '96M') === false) {
            $limit = ini_get('memory_limit');
            $limit = common::getByteValue($limit);
            if ($limit < 100663296) {
                $gpLayouts['default']['theme'] = 'Three_point_5/Shore';
                $gpLayouts['default']['label'] = 'Three_point_5/Shore';
            }
        }
        $gpLayouts['default']['color'] = '#93c47d';
        $_config['toemail'] = $_POST['email'];
        $_config['gpLayout'] = 'default';
        $_config['title'] = Install_Tools::Install_Title();
        $_config['keywords'] = CMS_NAME . ' , Easy CMS, Content Management, PHP, Free CMS, Website builder, Open Source';
        $_config['desc'] = 'A new ' . CMS_NAME . ' installation. You can change your site\'s description in the configuration.';
        $_config['timeoffset'] = '0';
        $_config['langeditor'] = 'inherit';
        $_config['dateformat'] = '%m/%d/%y - %I:%M %p';
        $_config['gpversion'] = gpversion;
        $_config['passhash'] = 'sha512';
        $_config['gpuniq'] = common::RandomString(20);
        $_config['combinecss'] = Install_Tools::BooleanValue('combinecss', true);
        $_config['combinejs'] = Install_Tools::BooleanValue('combinejs', true);
        $_config['etag_headers'] = Install_Tools::BooleanValue('etag_headers', true);
        $_config['language'] = 'en';
        $config += $_config;
        //directories
        gpFiles::CheckDir($destination . '/data/_uploaded/image');
        gpFiles::CheckDir($destination . '/data/_uploaded/media');
        gpFiles::CheckDir($destination . '/data/_uploaded/file');
        gpFiles::CheckDir($destination . '/data/_uploaded/flash');
        gpFiles::CheckDir($destination . '/data/_sessions');
        // gp_index
        $new_index = array();
        $new_index['Home'] = 'a';
        $new_index['Heading_Page'] = 'b';
        $new_index['Help_Videos'] = 'c';
        $new_index['Child_Page'] = 'd';
        $new_index['More'] = 'e';
        $new_index['About'] = 'f';
        $new_index['Contact'] = 'special_contact';
        $new_index['Site_Map'] = 'special_site_map';
        $new_index['Galleries'] = 'special_galleries';
        $new_index['Missing'] = 'special_missing';
        $new_index['Search'] = 'special_gpsearch';
        //	gpmenu
        $new_menu = array();
        $new_menu['a'] = array('level' => 0);
        $new_menu['b'] = array('level' => 0);
        $new_menu['c'] = array('level' => 1);
        $new_menu['d'] = array('level' => 1);
        $new_menu['e'] = array('level' => 0);
        $new_menu['f'] = array('level' => 1);
        $new_menu['special_contact'] = array('level' => 1);
        //	links
        $new_titles = array();
        $new_titles['a']['label'] = 'Home';
        $new_titles['a']['type'] = 'text';
        $new_titles['b']['label'] = 'Heading Page';
        $new_titles['b']['type'] = 'text';
        $new_titles['c']['label'] = 'Help Videos';
        $new_titles['c']['type'] = 'text';
        $new_titles['d']['label'] = 'Child Page';
        $new_titles['d']['type'] = 'text';
        $new_titles['e']['label'] = 'More';
        $new_titles['e']['type'] = 'text';
        $new_titles['f']['label'] = 'About';
        $new_titles['f']['type'] = 'text';
        $new_titles['special_contact']['lang_index'] = 'contact';
        $new_titles['special_contact']['type'] = 'special';
        $new_titles['special_site_map']['lang_index'] = 'site_map';
        $new_titles['special_site_map']['type'] = 'special';
        $new_titles['special_galleries']['lang_index'] = 'galleries';
        $new_titles['special_galleries']['type'] = 'special';
        $new_titles['special_missing']['label'] = 'Missing';
        $new_titles['special_missing']['type'] = 'special';
        $new_titles['special_gpsearch']['label'] = 'Search';
        $new_titles['special_gpsearch']['type'] = 'special';
        $pages = array();
        $pages['gp_index'] = $new_index;
        $pages['gp_menu'] = $new_menu;
        $pages['gp_titles'] = $new_titles;
        $pages['gpLayouts'] = $gpLayouts;
        echo '<li>';
        if (!gpFiles::SaveData($destination . '/data/_site/pages.php', 'pages', $pages)) {
            echo '<span class="failed">';
            //echo 'Could not save pages.php';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'pages.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        //echo 'Pages.php saved.';
        echo sprintf($langmessage['_SAVED'], 'pages.php');
        echo '</span>';
        echo '</li>';
        // Home
        $content = '<h2>Welcome!</h2>
		<p>Welcome to your new ' . CMS_NAME . ' powered website. Now that ' . CMS_NAME . ' is installed, you can start editing the content and customizing your site.</p>
		<h3>Getting Started</h3>
		<p>You are currently viewing the default home page of your website. Here\'s a quick description of how to edit this page.</p>
		<ol>
		<li>First make sure you&#39;re ' . Install_Tools::Install_Link_Content('Admin', 'logged in', 'file=Home') . '.</li>
		<li>Then, to edit this page, click the &quot;Edit&quot; link that appears when you move your mouse over the content.</li>
		<li>Make your edits, click &quot;Save&quot; and you&#39;re done!</li>
		</ol>
		<h3>More Options</h3>
		<ul>
		<li>Adding, renaming, deleting and organising your pages can all be done in the ' . Install_Tools::Install_Link_Content('Admin_Menu', 'Page Manager') . '.</li>
		<li>Choose from a ' . Install_Tools::Install_Link_Content('Admin_Theme_Content', 'variety of themes') . ' to give your site a custom look.</li>
		<li>Then, you can ' . Install_Tools::Install_Link_Content('Admin_Theme_Content', 'add, remove and rearrange', 'cmd=editlayout') . ' the content of your site without editing the html.</li>
		<li>Take a look at the Administrator Toolbar to access all the features of ' . CMS_NAME . '.</li>
		</ul>
		<h3>Online Resources</h3>
		<p>' . CMS_READABLE_DOMAIN . ' has a number of resources to help you do even more.</p>
		<ul>
		<li>Find more community developed <a href="' . CMS_DOMAIN . '/Themes" title="' . CMS_NAME . ' Themes">themes</a> and <a href="' . CMS_DOMAIN . '/Plugins" title="' . CMS_NAME . ' Plugin">plugins</a> to enhance your site.</li>
		<li>Get help in the <a href="' . CMS_DOMAIN . '/Forum" title="' . CMS_NAME . ' Forum">' . CMS_NAME . ' forum</a>.</li>
		<li>Show off your <a href="' . CMS_DOMAIN . '/Powered_by" title="Sites Using ' . CMS_NAME . '">' . CMS_NAME . ' powered site</a> or list your <a href="' . CMS_DOMAIN . '/Service_Provider" title="Businesses Using ' . CMS_NAME . '">' . CMS_NAME . ' related business</a>.</li>
		</ul>';
        self::NewTitle($destination, 'Home', $content, $config, $new_index);
        // Heading Page
        $content = '<h1>A Heading Page</h1>
		<ul><li>' . Install_Tools::Install_Link_Content('Help_Videos', 'Help Videos') . '</li>
		<li>' . Install_Tools::Install_Link_Content('Child_Page', 'Child Page') . '</li>
		</ul>';
        self::NewTitle($destination, 'Heading_Page', $content, $config, $new_index);
        // Help Videos
        $content = '<h1>Help Videos</h1>
		<p>Video tutorials are often a fast and easy way to learn new things quickly.
		We now have an English version and Deutsch (German) available below.
		If you make a video tutorial for ' . CMS_NAME . ', <a href="' . CMS_DOMAIN . '/Contact">let us know</a>, and we\'ll make sure it\'s included in our list.
		</p>
		<p>And as always, to edit this page, just click the "Edit" button while logged in.</p>

		<h2>Português</h2>
		<p><iframe width="640" height="360" src="http://www.youtube.com/embed/KCnGpUzYTbQ" frameborder="0" allowfullscreen></iframe></p>

		<h2>Deutsch</h2>
		<p>Created by <a href="' . CMS_DOMAIN . '/Service_Provider?id=57" title="IT Ricther on ' . CMS_READABLE_DOMAIN . '">IT Richter</a></p>
		<p><iframe width="640" height="360" src="http://www.youtube.com/embed/04cNgR1EiFY" frameborder="0" allowfullscreen></iframe></p>';
        self::NewTitle($destination, 'Help_Videos', $content, $config, $new_index);
        // Child Page
        $content = '<h1>A Child Page</h1><p>This was created as a subpage of your <em>Help Videos</em> . You can easily change the arrangement of all your pages using the ' . Install_Tools::Install_Link_Content('Admin_Menu', 'Page Manager') . '.</p>';
        self::NewTitle($destination, 'Child_Page', $content, $config, $new_index);
        // More
        $content = '<h1>More</h1>
		<ul><li>' . Install_Tools::Install_Link_Content('About', 'About') . '</li>
		<li>' . Install_Tools::Install_Link_Content('Contact', 'Contact') . '</li>
		</ul>';
        self::NewTitle($destination, 'More', $content, $config, $new_index);
        // About
        $content = '<h1>About ' . CMS_NAME . '</h1><p><a href="' . CMS_DOMAIN . '" title="' . CMS_READABLE_DOMAIN . '">' . CMS_NAME . '</a> is a complete Content Management System (CMS) that can help you create rich and flexible web sites with a simple and easy to use interface.</p>
		<h2>' . CMS_NAME . ' How To</h2>
		<p>Learn how to <a href="' . CMS_DOMAIN . '/Docs/Main/Admin" title="' . CMS_NAME . ' File Management">manage your files</a>,
		<a href="' . CMS_DOMAIN . '/Docs/Main/Creating%20Galleries" title="Creating Galleries in ' . CMS_NAME . '">create galleries</a> and more in the
		<a href="' . CMS_DOMAIN . '/Docs/index.php/" title="' . CMS_NAME . ' Documentation">' . CMS_NAME . ' Documentation</a>.
		</p>

		<h2>' . CMS_NAME . ' Features</h2>
		<ul>
		<li>True WYSIWYG (Using CKEditor)</li>
		<li>Galleries (Using ColorBox)</li>
		<li>SEO Friendly Links</li>
		<li>Free and Open Source (GPL)</li>
		<li>Runs on PHP</li>
		<li>File Upload Manager</li>
		<li>Drag \'n Drop Theme Content</li>
		<li>Deleted File Trash Can</li>
		<li>Multiple User Administration</li>
		<li>Flat File Storage</li>
		<li>Fast Page Loading</li>
		<li>Fast and Easy Installation</li>
		<li>reCaptcha for Contact Form</li>
		<li>HTML Tidy (when available)</li>
		</ul>';
        self::NewTitle($destination, 'About', $content, $config, $new_index);
        //Side_Menu
        $file = $destination . '/data/_extra/Side_Menu.php';
        $content = '<h3>Join the ' . CMS_NAME . ' Community</h3>
		<p>Visit ' . CMS_READABLE_DOMAIN . ' to access the many <a href="' . CMS_DOMAIN . '/Resources" title="' . CMS_NAME . ' Community Resources">available resources</a> to help you get the most out of our CMS.</p>
		<ul>
		<li><a href="' . CMS_DOMAIN . '/Themes" title="' . CMS_NAME . ' Themes">Download Themes</a></li>
		<li><a href="' . CMS_DOMAIN . '/Plugins" title="' . CMS_NAME . ' Plugin">Download Plugins</a></li>
		<li><a href="' . CMS_DOMAIN . '/Forum" title="' . CMS_NAME . ' Forum">Get Help in the Forum</a></li>
		<li><a href="' . CMS_DOMAIN . '/Powered_by" title="Sites using ' . CMS_NAME . '">Show off Your Site</a></li>
		<li><a href="' . CMS_DOMAIN . '/Resources" title="' . CMS_NAME . ' Community Resources">And Much More...</a></li>
		</ul>
		<p class="sm">(Edit this content by clicking &quot;Edit&quot;, it&#39;s that easy!)</p>';
        self::NewExtra($file, $content);
        //Header
        $file = $destination . '/data/_extra/Header.php';
        $content = '<h1>' . $config['title'] . '</h1>
		<h4>' . 'The Fast and Easy CMS' . '</h4>';
        self::NewExtra($file, $content);
        //Footer
        $file = $destination . '/data/_extra/Footer.php';
        $content = '<h3><a href="' . CMS_DOMAIN . '/Our_CMS" title="Features of Our CMS">' . CMS_NAME . ' Features</a></h3>
		<p>Easy to use True WYSIWYG Editing.</p>
		<p>Flat-file data storage and advanced resource management for fast websites.</p>
		<p>Community driven development</p>
		<p><a href="' . CMS_DOMAIN . '/Our_CMS" title="Features of Our CMS">And More...</a></p>
		<p>If you like ' . CMS_NAME . ', then you might also like
		<a href="http://lessphp.gpeasy.com" title="A Less to CSS compiler based on the official lesscss project">Less.php</a>,
		<a href="http://whatcms.org" title="What CMS? Find out what CMS a site is using">WhatCMS.org</a> and
		<a href="http://whichcms.org" title="Which CMS? Find out which CMS has the features you\'re looking for.">WhichCMS.org</a>.
		</p>';
        self::NewExtra($file, $content);
        //Another example area
        $file = $destination . '/data/_extra/Lorem.php';
        $content = '<h3>Heading</h3>
		<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>';
        self::NewExtra($file, $content);
        //contact html
        $file = $destination . '/data/_extra/Contact.php';
        self::NewExtra($file, '<h2>Contact Us</h2><p>Use the form below to contact us, and be sure to enter a valid email address if you want to hear back from us.</p>');
        //users
        echo '<li>';
        $user_info = array();
        $user_info['password'] = common::hash($_POST['password'], 'sha512');
        $user_info['passhash'] = 'sha512';
        $user_info['granted'] = 'all';
        $user_info['editing'] = 'all';
        $user_info['email'] = $_POST['email'];
        $users = array();
        $username = $_POST['username'];
        //log user in here to finish user_info
        if ($base_install) {
            includeFile('tool/sessions.php');
            gp_defined('gp_session_cookie', gpsession::SessionCookie($config['gpuniq']));
            gpsession::create($user_info, $username, $sessions);
        }
        $users[$username] = $user_info;
        if (!gpFiles::SaveData($destination . '/data/_site/users.php', 'users', $users)) {
            echo '<span class="failed">';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'users.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        echo sprintf($langmessage['_SAVED'], 'users.php');
        echo '</span>';
        echo '</li>';
        //save config
        //not using SaveConfig() because $config is not global here
        echo '<li>';
        $config['file_count'] = self::$file_count;
        if (!gpFiles::SaveData($destination . '/data/_site/config.php', 'config', $config)) {
            echo '<span class="failed">';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'config.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        echo sprintf($langmessage['_SAVED'], 'config.php');
        echo '</span>';
        echo '</li>';
        if ($base_install) {
            Install_Tools::InstallHtaccess($destination, $config);
        }
        gpFiles::Unlock('write', gp_random);
        return true;
    }
Exemplo n.º 3
0
 /**
  *	Save a backup of the file
  *
  */
 function SaveBackup()
 {
     global $dataDir;
     $dir = $dataDir . '/data/_backup/pages/' . $this->gp_index;
     gpFiles::CheckDir($dir);
     $time = time();
     if (isset($_REQUEST['revision']) && is_numeric($_REQUEST['revision'])) {
         $time = $_REQUEST['revision'];
     }
     $contents = gpFiles::GetRaw($this->file);
     //backup file name
     $len = strlen($contents);
     $backup_file = $dir . '/' . $time . '.' . $len;
     if (isset($this->file_stats['username']) && $this->file_stats['username']) {
         $backup_file .= '.' . $this->file_stats['username'];
     }
     //compress
     if (function_exists('gzencode') && function_exists('readgzfile')) {
         $backup_file .= '.gze';
         $contents = gzencode($contents, 9);
     }
     gpFiles::Save($backup_file, $contents);
     $this->CleanBackupFolder();
 }
Exemplo n.º 4
0
 /**
  * Create a resized image of the file at $src_relative
  *
  */
 static function CreateImage($src_relative, $width, $height)
 {
     global $dataDir;
     $src_path = $dataDir . '/data/_uploaded' . $src_relative;
     if (!file_exists($src_path)) {
         return false;
     }
     //compare to actual size
     includeFile('tool/Images.php');
     $src_img = thumbnail::getSrcImg($src_path);
     if (!$src_img) {
         return false;
     }
     //Original Size
     $actual_w = imagesx($src_img);
     $actual_h = imagesy($src_img);
     if ($actual_w <= $width && $actual_h <= $height) {
         return false;
     }
     $info = gp_resized::ImageInfo($src_relative, $width, $height);
     if (!$info) {
         return false;
     }
     $dest_index = $info['index'];
     if (!$dest_index) {
         $dest_index = gp_resized::NewIndex();
     }
     $dest_path = $dataDir . '/data/_resized/' . $dest_index . '/' . $info['name'];
     $exists_before = file_exists($dest_path);
     //make sure the folder exists
     if (!gpFiles::CheckDir(common::DirName($dest_path))) {
         return false;
     }
     //create new resized image
     if (!thumbnail::createImg($src_img, $dest_path, 0, 0, 0, 0, $width, $height, $actual_w, $actual_h)) {
         return false;
     }
     //not needed if the resized image is larger than the original
     if (filesize($dest_path) > filesize($src_path)) {
         if (!$exists_before) {
             unlink($dest_path);
         }
         return false;
     }
     $data['index'] = $dest_index;
     $data['w'] = $width;
     $data['h'] = $height;
     $data['img'] = $src_relative;
     return $data;
 }
Exemplo n.º 5
0
 /**
  *  Performs actions after changes are made to files in elFinder
  *
  */
 static function FinderChange($cmd, $result, $args, $elfinder)
 {
     global $dataDir, $config;
     includeFile('image.php');
     gp_resized::SetIndex();
     $base_dir = $dataDir . '/data/_uploaded';
     $thumb_dir = $dataDir . '/data/_uploaded/image/thumbnails';
     admin_uploaded::SetRealPath($result, $elfinder);
     switch ($cmd) {
         case 'rename':
             admin_uploaded::RenameResized($result['removed'][0], $result['added'][0]);
             break;
         case 'rm':
             admin_uploaded::RemoveResized($result['removed']);
             break;
         case 'paste':
             admin_uploaded::MoveResized($result['removed'], $result['added']);
             break;
             //check the image size
         //check the image size
         case 'upload':
             admin_uploaded::MaxSize($result['added']);
             break;
     }
     //removed files first
     //	- Remove associated thumbnail
     if (isset($result['removed']) && count($result['removed']) > 0) {
         foreach ($result['removed'] as $removed) {
             $removed_path = $removed['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $removed_path) . '.jpg';
             if (file_exists($thumb_path)) {
                 unlink($thumb_path);
             }
         }
     }
     //addded files
     if (isset($result['added']) && count($result['added']) > 0) {
         foreach ($result['added'] as $added) {
             $added_path = $added['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $added_path) . '.jpg';
             gpFiles::CheckDir($thumb_dir);
             thumbnail::createSquare($added_path, $thumb_path, $config['maxthumbsize']);
             gpPlugin::Action('FileUploaded', $added_path);
         }
     }
     //changed files (resized)
     if (isset($result['changed']) && count($result['changed']) > 0) {
         foreach ($result['changed'] as $changed) {
             $changed_path = $changed['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $changed_path) . '.jpg';
             gpFiles::CheckDir($thumb_dir);
             thumbnail::createSquare($changed_path, $thumb_path, $config['maxthumbsize']);
         }
     }
     gp_resized::SaveIndex();
     //debug
     /*
     $log_file = $dataDir.'/data/_temp/finder_log-all_vars.txt';
     $data = get_defined_vars();
     $content = print_r($data,true);
     gpFiles::Save($log_file,$content);
     */
 }
Exemplo n.º 6
0
    function Install_DataFiles_New($destination = false, $config, $base_install = true)
    {
        global $langmessage;
        if ($destination === false) {
            $destination = $GLOBALS['dataDir'];
        }
        //set config variables
        //$config = array(); //because of ftp values
        $gpLayouts = array();
        $gpLayouts['default']['theme'] = 'Light_Texture/Blue';
        $gpLayouts['default']['color'] = '#93c47d';
        $gpLayouts['default']['label'] = $langmessage['default'];
        $config['toemail'] = $_POST['email'];
        $config['gpLayout'] = 'default';
        $config['title'] = Install_Tools::Install_Title();
        $config['keywords'] = 'gpEasy CMS, Easy CMS, Content Management, PHP, Free CMS, Website builder, Open Source';
        $config['desc'] = 'A new gpEasy CMS installation. You can change your site\'s description in the configuration.';
        $config['timeoffset'] = '0';
        $config['langeditor'] = 'inherit';
        $config['dateformat'] = '%m/%d/%y - %I:%M %p';
        $config['gpversion'] = $GLOBALS['gpversion'];
        $config['shahash'] = function_exists('sha1');
        if (!isset($config['gpuniq'])) {
            $config['gpuniq'] = common::RandomString(20);
        }
        $config['combinecss'] = Install_Tools::BooleanValue('combinecss', true);
        $config['combinejs'] = Install_Tools::BooleanValue('combinejs', true);
        $config['etag_headers'] = Install_Tools::BooleanValue('etag_headers', true);
        //directories
        gpFiles::CheckDir($destination . '/data/_uploaded/image');
        gpFiles::CheckDir($destination . '/data/_uploaded/media');
        gpFiles::CheckDir($destination . '/data/_uploaded/file');
        gpFiles::CheckDir($destination . '/data/_uploaded/flash');
        gpFiles::CheckDir($destination . '/data/_sessions');
        $content = '<h2>Welcome!</h2>
		<p>Welcome to your new gpEasy powered website. Now that gpEasy is installed, you can start editing the content and customising your site.</p>
		<h3>Getting Started</h3>
		<p>You are currently viewing the default home page of your website. Here\'s a quick description of how to edit this page.</p>
		<ol>
		<li>First make sure you&#39;re ' . Install_Tools::Install_Link_Content('Admin_Main', 'logged in', 'file=Home') . '.</li>
		<li>Then, to edit this page, click the &quot;Edit&quot; link that appears when you move your mouse over the content.</li>
		<li>Make your edits, click &quot;Save&quot; and you&#39;re done!</li>
		</ol>
		<h3>More Options</h3>
		<ul>
		<li>Adding, renaming, deleting and organising your pages can all be done in the ' . Install_Tools::Install_Link_Content('Admin_Menu', 'Page Manager') . '.</li>
		<li>Choose from a ' . Install_Tools::Install_Link_Content('Admin_Theme_Content', 'variety of themes') . ' to give your site a custom look.</li>
		<li>Then, you can ' . Install_Tools::Install_Link_Content('Admin_Theme_Content', 'add, remove and rearrange', 'cmd=editlayout') . ' the content of your site without editing the html.</li>
		<li>Take a look at the Administrator Toolbar to access all the features of gpEasy.</li>
		</ul>
		<h3>Online Resources</h3>
		<p>gpEasy.com has a number of resources to help you do even more with gpEasy.</p>
		<ul>
		<li>Find more community developed <a href="http://gpeasy.com/Special_Addon_Themes" title="gpEasy CMS Themes">themes</a> and <a href="http://gpeasy.com/Special_Addon_Plugins" title="gpEasy CMS Plugin">plugins</a> to enhance your site.</li>
		<li>Get help in the <a href="http://gpeasy.com/Special_Forum" title="gpEasy CMS Forum">gpEasy forum</a>.</li>
		<li>Show off your <a href="http://gpeasy.com/Special_Powered_by" title="Sites Using gpEasy CMS">gpEasy powered site</a> or list your <a href="http://gpeasy.com/Special_Service_Provider" title="Businesses Using gpEasy CMS">gpEasy related business</a>.</li>
		</ul>';
        gpFiles::NewTitle('Home', $content);
        gpFiles::NewTitle('Help_Videos', "<h1>Help Videos</h1>\n\t\t<p>Video tutorials are often a fast and easy way to learn new things quickly.\n\t\tSo far, we only have one in Deutsch (German) made by <a href=\"http://gpeasy.com/Special_Service_Provider?id=57\" title=\"IT Ricther on gpEasy.com\">IT Richter</a>.\n\t\tIf you make a video tutorial for gpEasy, <a href=\"http://gpeasy.com/Contact\">let us know</a>, and we'll make sure it's included in our list.\n\t\t</p>\n\t\t<p>And as always, to edit this page, just click the \"Edit\" button while logged in.</p>\n\t\t<h2>Deutsch</h2>\n\t\t<p><iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/04cNgR1EiFY\" frameborder=\"0\" allowfullscreen></iframe></p>\n\t\t");
        gpFiles::NewTitle('Child_Page', '<h1>A Child Page</h1><p>This was created as a subpage of your <em>Help Videos</em> . You can easily change the arrangement of all your pages using the ' . Install_Tools::Install_Link_Content('Admin_Menu', 'Page Manager') . '.</p>');
        gpFiles::NewTitle('About', '<h1>About gpEasy CMS</h1><p><a href="http://gpEasy.com" title="gpEasy.com">gp|Easy</a> is a complete Content Management System (CMS) that can help you create rich and flexible web sites with a simple and easy to use interface.</p>
		<h2>gpEasy CMS How To</h2>
		<p>Learn how to <a href="http://docs.gpeasy.com/Main/Admin" title="gpEasy File Management">manage your files</a>,
		<a href="http://docs.gpeasy.com/Main/Creating%20Galleries" title="Creating Galleries in gpEasy CMS">create galleries</a> and more in the
		<a href="http://docs.gpeasy.org/index.php/" title="gpEasy CMS Documentation">gpEasy Documentation</a>.
		</p>

		<h2>gpEasy CMS Features</h2>
		<ul>
		<li>True WYSIWYG (Using CKEditor)</li>
		<li>Galleries (Using ColorBox)</li>
		<li>SEO Friendly Links</li>
		<li>Free and Open Source (GPL)</li>
		<li>Runs on PHP</li>
		<li>File Upload Manager</li>
		<li>Drag \'n Drop Theme Content</li>
		<li>Deleted File Trash Can</li>
		<li>Multiple User Administration</li>
		<li>Flat File Storage</li>
		<li>Fast Page Loading</li>
		<li>Fast and Easy Installation</li>
		<li>reCaptcha for Contact Form</li>
		<li>HTML Tidy (when available)</li>
		</ul>
		<h2>If You Like gpEasy...</h2>
		<p>If you like gpEasy, then you might also like:</p>
		<ul>
		<li><a href="http://phpeasymin.com" title="Minimize JavaScript and CSS files easily">phpEasyMin.com</a> - Minimize multiple JavaScript and CSS files in one sweep.</li>
		</ul>');
        //Side_Menu
        $file = $destination . '/data/_extra/Side_Menu.php';
        $content = '<h3>Join the gpEasy Community</h3>
		<p>Visit gpEasy.com to access the many <a href="http://gpeasy.com/Special_Resources" title="gpEasy Community Resources">available resources</a> to help you get the most out of our CMS.</p>
		<ul>
		<li><a href="http://gpeasy.com/Special_Addon_Themes" title="gpEasy CMS Themes">Download Themes</a></li>
		<li><a href="http://gpeasy.com/Special_Addon_Plugins" title="gpEasy CMS Plugin">Download Plugins</a></li>
		<li><a href="http://gpeasy.com/Special_Forum" title="gpEasy CMS Forum">Get Help in the Forum</a></li>
		<li><a href="http://gpeasy.com/Special_Powered_by" title="Sites using gpEasy CMS">Show off Your Site</a></li>
		<li><a href="http://gpeasy.com/Special_Resources" title="gpEasy Community Resources">And Much More...</a></li>
		</ul>
		<p class="sm">(Edit this content by clicking &quot;Edit&quot;, it&#39;s that easy!)</p>';
        gpFiles::SaveFile($file, $content);
        //Header
        $file = $destination . '/data/_extra/Header.php';
        $contents = '<h1>' . Install_Tools::Install_Link('', $config['title']) . '</h1>';
        $contents .= '<h4>' . 'The Fast and Easy CMS' . '</h4>';
        gpFiles::SaveFile($file, $contents);
        //Footer
        $file = $destination . '/data/_extra/Footer.php';
        $content = '<h3><a href="http://gpeasy.com/Our_CMS" title="Features of Our CMS">gpEasy CMS Features</a></h3>
		<p>Easy to use True WYSIWYG Editing.</p>
		<p>Flat-file data storage and advanced resource management for fast websites.</p>
		<p>Community driven development</p>
		<p><a href="http://gpeasy.com/Our_CMS" title="Features of Our CMS">And More...</a></p>
		<p>If you like gpEasy, then you might also like <a href="http://phpeasymin.com" title="Minimize JavaScript and CSS files easily">phpEasyMin.com</a></p>
		';
        gpFiles::SaveFile($file, $content);
        //contact html
        $file = $destination . '/data/_extra/Contact.php';
        gpFiles::SaveFile($file, '<h2>Contact Us</h2><p>Use the form below to contact us, and be sure to enter a valid email address if you want to hear back from us.</p>');
        // gp_index
        $new_index = array();
        $new_index['Home'] = 'a';
        $new_index['Help_Videos'] = 'b';
        $new_index['Child_Page'] = 'c';
        $new_index['About'] = 'd';
        $new_index['Contact'] = 'special_contact';
        $new_index['Site_Map'] = 'special_site_map';
        $new_index['Galleries'] = 'special_galleries';
        $new_index['Missing'] = 'special_missing';
        //	gpmenu
        $new_menu = array();
        $new_menu['a'] = array('level' => 0);
        $new_menu['b'] = array('level' => 0);
        $new_menu['c'] = array('level' => 1);
        $new_menu['d'] = array('level' => 0);
        $new_menu['special_contact'] = array('level' => 1);
        //	links
        $new_titles = array();
        $new_titles['a']['label'] = 'Home';
        $new_titles['a']['type'] = 'text';
        $new_titles['b']['label'] = 'Help Videos';
        $new_titles['b']['type'] = 'text';
        $new_titles['c']['label'] = 'Child Page';
        $new_titles['c']['type'] = 'text';
        $new_titles['d']['label'] = 'About';
        $new_titles['d']['type'] = 'text';
        $new_titles['special_contact']['lang_index'] = 'contact';
        $new_titles['special_contact']['type'] = 'special';
        $new_titles['special_site_map']['lang_index'] = 'site_map';
        $new_titles['special_site_map']['type'] = 'special';
        $new_titles['special_galleries']['lang_index'] = 'galleries';
        $new_titles['special_galleries']['type'] = 'special';
        $new_titles['special_missing']['label'] = 'Missing';
        $new_titles['special_missing']['type'] = 'special';
        $pages = array();
        $pages['gp_index'] = $new_index;
        $pages['gp_menu'] = $new_menu;
        $pages['gp_titles'] = $new_titles;
        $pages['gpLayouts'] = $gpLayouts;
        echo '<li>';
        if (!gpFiles::SaveArray($destination . '/data/_site/pages.php', 'pages', $pages)) {
            echo '<span class="failed">';
            //echo 'Could not save pages.php';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'pages.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        //echo 'Pages.php saved.';
        echo sprintf($langmessage['_SAVED'], 'pages.php');
        echo '</span>';
        echo '</li>';
        //users
        echo '<li>';
        $user_info = array();
        $user_info['password'] = sha1(trim($_POST['password']));
        $user_info['granted'] = 'all';
        $user_info['editing'] = 'all';
        $user_info['email'] = $_POST['email'];
        $users = array();
        $username = $_POST['username'];
        //log user in here to finish user_info
        if ($base_install) {
            includeFile('tool/sessions.php');
            define('gp_session_cookie', common::SessionCookie($config['gpuniq']));
            gpsession::create($user_info, $username);
        }
        $users[$username] = $user_info;
        if (!gpFiles::SaveArray($destination . '/data/_site/users.php', 'users', $users)) {
            echo '<span class="failed">';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'users.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        echo sprintf($langmessage['_SAVED'], 'users.php');
        echo '</span>';
        echo '</li>';
        //save config
        //not using SaveConfig() because $config is not global here
        echo '<li>';
        if (!gpFiles::SaveArray($destination . '/data/_site/config.php', 'config', $config)) {
            echo '<span class="failed">';
            echo sprintf($langmessage['COULD_NOT_SAVE'], 'config.php');
            echo '</span>';
            echo '</li>';
            return false;
        }
        echo '<span class="passed">';
        echo sprintf($langmessage['_SAVED'], 'config.php');
        echo '</span>';
        echo '</li>';
        if ($base_install) {
            Install_Tools::InstallHtaccess($destination, $config);
        }
        return true;
    }
Exemplo n.º 7
0
 /**
  * Check recursively to see if a directory exists, if it doesn't attempt to create it
  *
  * @param string $dir The directory path
  * @param bool $index Whether or not to add an index.hmtl file in the directory
  * @return bool True on success
  */
 function CheckDir($dir, $index = true)
 {
     global $config, $checkFileIndex;
     if (!file_exists($dir)) {
         $parent = dirname($dir);
         gpFiles::CheckDir($parent, $index);
         //ftp mkdir
         if (isset($config['useftp'])) {
             if (!gpFiles::FTP_CheckDir($dir)) {
                 return false;
             }
         } else {
             if (!@mkdir($dir, gp_chmod_dir)) {
                 return false;
             }
             @chmod($dir, gp_chmod_dir);
             //some systems need more than just the 0755 in the mkdir() function
         }
     }
     //make sure there's an index.html file
     if ($index && $checkFileIndex) {
         $indexFile = $dir . '/index.html';
         if (!file_exists($indexFile)) {
             gpFiles::Save($indexFile, '<html></html>', false);
         }
     }
     return true;
 }
Exemplo n.º 8
0
 function write_package($dir, &$files)
 {
     global $langmessage;
     if (!gpFiles::CheckDir($dir)) {
         echo '<p class="gp_warning">';
         echo sprintf($langmessage['COULD_NOT_SAVE'], $folder);
         echo '</p>';
         return false;
     }
     //get archive root
     $archive_root = false;
     foreach ($files as $file) {
         if (strpos($file['filename'], '/Addon.ini') !== false) {
             $root = dirname($file['filename']);
             if (!$archive_root || strlen($root) < strlen($archive_root)) {
                 $archive_root = $root;
             }
         }
     }
     $archive_root_len = strlen($archive_root);
     foreach ($files as $file_info) {
         $filename = $file_info['filename'];
         if ($archive_root) {
             if (strpos($filename, $archive_root) !== 0) {
                 continue;
                 /*
                 					trigger_error('$archive_root not in path');
                 					echo '<p class="gp_warning">';
                 					echo $langmessage['error_unpacking'];
                 					echo '</p>';
                 					return false;
                 */
             }
             $filename = substr($filename, $archive_root_len);
         }
         $filename = '/' . trim($filename, '/');
         $full_path = $dir . '/' . $filename;
         if ($file_info['folder']) {
             $folder = $full_path;
         } else {
             $folder = dirname($full_path);
         }
         if (!gpFiles::CheckDir($folder)) {
             echo '<p class="gp_warning">';
             echo sprintf($langmessage['COULD_NOT_SAVE'], $folder);
             echo '</p>';
             return false;
         }
         if ($file_info['folder']) {
             continue;
         }
         if (!gpFiles::Save($full_path, $file_info['content'])) {
             echo '<p class="gp_warning">';
             echo sprintf($langmessage['COULD_NOT_SAVE'], $full_path);
             echo '</p>';
             return false;
         }
     }
     return true;
 }
Exemplo n.º 9
0
 /**
  * Save the comment data for a blog post
  *
  */
 public static function SaveCommentData($post_index, $data)
 {
     global $langmessage;
     // check directory
     $dir = self::$data_dir . '/comments';
     if (!gpFiles::CheckDir($dir)) {
         return false;
     }
     $commentDataFile = $dir . '/' . $post_index . '.txt';
     $dataTxt = serialize($data);
     if (!gpFiles::Save($commentDataFile, $dataTxt)) {
         return false;
     }
     // clean pre 1.7.4 files
     $commentDataFile = self::$data_dir . '/comments_data_' . $post_index . '.txt';
     if (file_exists($commentDataFile)) {
         unlink($commentDataFile);
     }
     SimpleBlogCommon::AStrSet('comment_counts', $post_index, count($data));
     SimpleBlogCommon::SaveIndex();
     SimpleBlogCommon::ClearCommentCache();
     return true;
 }
Exemplo n.º 10
0
 /**
  * Save the comment data for a blog post
  *
  */
 function SaveCommentData($post_index, $data)
 {
     global $langmessage;
     // check directory
     $dir = $this->addonPathData . '/comments';
     if (!gpFiles::CheckDir($dir)) {
         return false;
     }
     $commentDataFile = $dir . '/' . $post_index . '.txt';
     $dataTxt = serialize($data);
     if (!gpFiles::Save($commentDataFile, $dataTxt)) {
         return false;
     }
     // clean pre 1.7.4 files
     $commentDataFile = $this->addonPathData . '/comments_data_' . $post_index . '.txt';
     if (file_exists($commentDataFile)) {
         unlink($commentDataFile);
     }
     SimpleBlogCommon::AStrValue('comment_counts', $post_index, count($data));
     $this->SaveIndex();
     //clear comments cache
     $cache_file = $this->addonPathData . '/comments/cache.txt';
     if (file_exists($cache_file)) {
         unlink($cache_file);
     }
     return true;
 }
Exemplo n.º 11
0
 /**
  * Make Sure the trash folder exists
  * admin_trash::PrepFolder();
  */
 function PrepFolder()
 {
     global $dataDir;
     $trash_dir = $dataDir . '/data/_trash';
     gpFiles::CheckDir($trash_dir);
 }
Exemplo n.º 12
0
 /**
  * Write Archive
  *
  */
 function ExtractArchive($dir, $archive_path)
 {
     global $langmessage;
     // Unzip uses a lot of memory, but not this much hopefully
     @ini_set('memory_limit', '256M');
     includeFile('thirdparty/pclzip-2-8-2/pclzip.lib.php');
     $archive = new PclZip($archive_path);
     $archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
     if (!gpFiles::CheckDir($dir)) {
         $this->message(sprintf($langmessage['COULD_NOT_SAVE'], $folder));
         return false;
     }
     //get archive root
     $archive_root = false;
     foreach ($archive_files as $file) {
         if (strpos($file['filename'], '/Addon.ini') !== false) {
             $root = dirname($file['filename']);
             if (!$archive_root || strlen($root) < strlen($archive_root)) {
                 $archive_root = $root;
             }
         }
     }
     $archive_root_len = strlen($archive_root);
     foreach ($archive_files as $file_info) {
         $filename = $file_info['filename'];
         if ($archive_root) {
             if (strpos($filename, $archive_root) !== 0) {
                 continue;
             }
             $filename = substr($filename, $archive_root_len);
         }
         $filename = '/' . trim($filename, '/');
         $full_path = $dir . '/' . $filename;
         if ($file_info['folder']) {
             $folder = $full_path;
         } else {
             $folder = dirname($full_path);
         }
         if (!gpFiles::CheckDir($folder)) {
             $this->message(sprintf($langmessage['COULD_NOT_SAVE'], $folder));
             return false;
         }
         if ($file_info['folder']) {
             continue;
         }
         if (!gpFiles::Save($full_path, $file_info['content'])) {
             $this->message(sprintf($langmessage['COULD_NOT_SAVE'], $full_path));
             return false;
         }
     }
     return true;
 }
Exemplo n.º 13
0
 /**
  * Recursive copy folder
  *
  */
 function CopyAddonDir($fromDir, $toDir)
 {
     if (!gpFiles::CheckDir($toDir)) {
         return 'Copy failed: ' . $fromDir . ' to ' . $toDir;
     }
     $files = scandir($fromDir);
     if ($files === false) {
         return 'scandir failed: ' . $fromDir;
     }
     foreach ($files as $file) {
         if (strpos($file, '.') === 0) {
             continue;
         }
         $fullFrom = $fromDir . '/' . $file;
         $fullTo = $toDir . '/' . $file;
         //directories
         if (is_dir($fullFrom)) {
             $result = self::CopyAddonDir($fullFrom, $fullTo);
             if ($result !== true) {
                 return $result;
             }
             continue;
         }
         //files
         //If the destination file already exists, it will be overwritten.
         if (!copy($fullFrom, $fullTo)) {
             return 'Copy failed: ' . $fullFrom . ' to ' . $fullTo . ' (2)';
         }
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * Put the files in $file_list in the destination folder
  * If the second destination folder is set, use gpFiles methods
  *
  * @param array $file_list List of files
  * @param string $dest_rel The relative destination directory for $file_list
  * @param bool $gpfiles False to use $gp_filesystem for file replacement, True for gpFiles methods
  * @return bool
  */
 function PutFiles($file_list, $dest_rel, $gpfiles = false)
 {
     global $gp_filesystem, $langmessage, $dataDir;
     $dest_fs = $gp_filesystem->get_base_dir() . $dest_rel;
     if ($gpfiles) {
         $dest = $dataDir . $dest_rel;
     }
     //create destination
     if (!$gp_filesystem->mkdir($dest_fs)) {
         message($langmessage['revert_failed'] . ' Directory not created (0)');
         return false;
     }
     foreach ($file_list as $file_info) {
         $path =& $file_info['filename'];
         $flag = (int) $file_info['typeflag'];
         $full_fs = $dest_fs . $file_info['relative_path'];
         $full = false;
         if ($gpfiles) {
             $full = $dest . $file_info['relative_path'];
         }
         //create directories
         if ($flag === 5) {
             if ($full) {
                 if (!gpFiles::CheckDir($full, false)) {
                     message($langmessage['revert_failed'] . ' Directory not created (1)');
                     return false;
                 }
                 continue;
             }
             if (!$gp_filesystem->mkdir($full_fs)) {
                 message($langmessage['revert_failed'] . ' Directory not created (2)');
                 return false;
             }
             continue;
         }
         //create files
         if ($flag === 0) {
             $contents = $this->GetImportContents($path);
             if ($full) {
                 if (!gpFiles::Save($full, $contents)) {
                     message($langmessage['revert_failed'] . ' File not created (1)');
                     return false;
                 }
             }
             if (!$gp_filesystem->put_contents($full_fs, $contents)) {
                 message($langmessage['revert_failed'] . ' File not created (2)');
                 return false;
             }
             continue;
         }
         //symbolic link
         if ($flag === 2) {
             $target = $this->FixLink($file_info['link']);
             /*
              * This is too restrictive
              * Can't even check the new folders being created in case the target hasn't been prepared yet
              *
             if( !file_exists($target) ){
             	message($langmessage['revert_failed'].' Symlink target doesn\'t exist.');
             	return false;
             }
             */
             if (!symlink($target, $full)) {
                 message($langmessage['revert_failed'] . ' Symlink not created (1)');
                 return false;
             }
         }
     }
     return true;
 }
Exemplo n.º 15
0
 function CopyThemes($destination, $args = false)
 {
     global $rootDir;
     if ($args === false) {
         $args = $_POST;
     }
     //selection of themes
     if (!gpFiles::CheckDir($destination . '/themes')) {
         message('Failed to create <em>' . $destination . '/themes' . '</em>');
         return false;
     }
     $count = 0;
     foreach ($args['themes'] as $theme) {
         $target = $rootDir . '/themes/' . $theme;
         if (!file_exists($target)) {
             continue;
         }
         $name = $destination . '/themes/' . $theme;
         if ($this->Create_Symlink($target, $name)) {
             $count++;
         }
     }
     if ($count == 0) {
         message('Failed to populate <em>' . $destination . '/themes' . '</em>');
         return false;
     }
     return true;
 }
Exemplo n.º 16
0
 /**
  * Add an uploaded plugin
  *
  */
 function UploadPlugin()
 {
     global $langmessage, $dataDir;
     includeFile('admin/admin_uploaded.php');
     includeFile('thirdparty/pclzip-2-8-2/pclzip.lib.php');
     if (empty($_FILES['plugin'])) {
         message($langmessage['OOPS'] . ' (No File)');
         return;
     }
     $plugin_file = $_FILES['plugin'];
     if (strpos($plugin_file['name'], '.zip') === false) {
         message($langmessage['OOPS'] . ' (Not a zip file)');
         return;
     }
     // Unzip uses a lot of memory, but not this much hopefully
     @ini_set('memory_limit', '256M');
     $archive = new PclZip($plugin_file['tmp_name']);
     // get plugin name and check file types
     $plugin_name = false;
     $remove_path = '';
     $list = $archive->listContent();
     foreach ($list as $file) {
         //plugin name
         if (strpos($file['filename'], 'plugin.js') !== false) {
             $new_plugin_name = $this->FindPluginName($archive, $file);
             if (!$new_plugin_name) {
                 continue;
             }
             //use the most relevant plugin name
             $new_path = dirname($file['filename']);
             if (!$plugin_name || strlen($new_path) < strlen($remove_path)) {
                 $plugin_name = $new_plugin_name;
                 $remove_path = $new_path;
             }
         }
         //don't check extensions on folder
         if (isset($file['folder']) && $file['folder']) {
             continue;
         }
         if (!admin_uploaded::AllowedExtension($file['filename'], false)) {
             message($langmessage['OOPS'] . ' (File type not allowed:' . htmlspecialchars($file['filename']) . ')');
             return false;
         }
     }
     if (!$plugin_name) {
         message($langmessage['OOPS'] . ' (Unknown plugin name)');
         return;
     }
     //make sure plugin name isn't already in build_config
     if ($this->build_config && isset($this->build_config['plugins']) && isset($this->build_config['plugins'][$plugin_name]) && $this->build_config['plugins'][$plugin_name] > 0) {
         msg($langmessage['addon_key_defined'], '<i>' . $plugin_name . '</i>');
         return;
     }
     // check destination directory
     $destination = $dataDir . '/data/_ckeditor/' . $plugin_name;
     $temp_dir = false;
     if (file_exists($destination)) {
         $temp_dir = $destination . '_' . time();
         if (!rename($destination, $temp_dir)) {
             message($langmessage['OOPS'] . ' (Couldn\'t remove old plugin)');
             return;
         }
     } elseif (!gpFiles::CheckDir($destination)) {
         msg($destination);
         message($langmessage['OOPS'] . ' (Couldn\'t create plugin folder)');
         return;
     }
     //extract
     // extract
     $return = $archive->extract(PCLZIP_OPT_PATH, $destination, PCLZIP_OPT_REMOVE_PATH, $remove_path);
     if (!is_array($return)) {
         if ($temp_dir) {
             rename($temp_dir, $destination);
         }
         message($langmessage['OOPS'] . ' (Extract Failed)');
         return;
     }
     // save configuration
     if (!array_key_exists($plugin_name, $this->cke_config['plugins'])) {
         $this->cke_config['plugins'][$plugin_name] = array('installed' => time());
     }
     $this->cke_config['plugins'][$plugin_name]['updated'] = time();
     $this->SaveConfig();
     message($langmessage['SAVED']);
     // remove temporary
     if ($temp_dir) {
         gpFiles::RmAll($temp_dir);
     }
 }
Exemplo n.º 17
0
 function GalleryImages()
 {
     global $page, $dataDir, $langmessage;
     includeFile('admin/admin_uploaded.php');
     $page->ajaxReplace = array();
     if (isset($_GET['dir'])) {
         $dir_piece = $_GET['dir'];
     } elseif (isset($this->meta_data['gallery_dir'])) {
         $dir_piece = $this->meta_data['gallery_dir'];
     } else {
         $dir_piece = '/image';
     }
     $dir_piece = common::WinPath($dir_piece);
     $dir = $dataDir . '/data/_uploaded' . $dir_piece;
     $prev_piece = false;
     while ($dir_piece != '/' && !file_exists($dir)) {
         $prev_piece = $dir_piece;
         $dir = dirname($dir);
         $dir_piece = dirname($dir_piece);
     }
     //remember browse directory
     $this->meta_data['gallery_dir'] = $dir_piece;
     $this->SaveThis();
     //new directory?
     if ($prev_piece) {
         $prev_piece = gp_edit::CleanArg($prev_piece);
         $dir_piece = $prev_piece;
         $dir = $dataDir . '/data/_uploaded' . $prev_piece;
         if (!gpFiles::CheckDir($dir)) {
             message($langmessage['OOPS']);
             $dir = dirname($dir);
             $dir_piece = dirname($prev_piece);
         }
     }
     admin_uploaded::InlineList($dir, $dir_piece);
 }
Exemplo n.º 18
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.º 19
0
 /**
  * Create a thumbnail for the image at the path given by $original
  *
  */
 static function CreateThumbnail($original)
 {
     global $config, $dataDir;
     $prefix = $dataDir . '/data/_uploaded';
     $thumb_prefix = $dataDir . '/data/_uploaded/image/thumbnails';
     if (strpos($original, $thumb_prefix) !== false) {
         return;
     }
     if (strpos($original, $prefix) !== 0) {
         return;
     }
     $len = strlen($prefix);
     $thumb_path = substr($original, $len);
     $thumb_path = $thumb_prefix . $thumb_path;
     $thumb_dir = common::DirName($thumb_path);
     $thumb_path = $thumb_dir . '/' . basename($thumb_path) . '.jpg';
     gpFiles::CheckDir($thumb_dir);
     thumbnail::createSquare($original, $thumb_path, $config['maxthumbsize']);
 }