'','site_title'=>'My '.CMS_NAME,'email'=>''); echo ''.$langmessage['configuration'].''; echo ''.$langmessage['Website_Title'].''; echo ''.$langmessage['email_address'].''; echo ''.$langmessage['Admin_Username'].''; echo ''.$langmessage['Admin_Password'].''; echo ''.$langmessage['repeat_password'].''; } /** * Display optional configuration options for installation * - jquery source (local or google) * - hide gplink * */ static function Form_Configuration(){ global $langmessage; echo ''; echo ''.$langmessage['more_options'].'...'; echo ''; echo ''; //combinejs echo ''; echo $langmessage['combinejs']; echo ''; self::BooleanForm('combinejs',true); echo ''; //combinejs echo ''; echo $langmessage['combinecss']; echo ''; self::BooleanForm('combinecss',true); echo ''; //combinejs echo ''; echo $langmessage['etag_headers']; echo ''; self::BooleanForm('etag_headers',true); echo ''; echo ''; } /** * Display a checkbox for a boolean configuration option * * @param string $key The configuration key being displayed * @param bool $default The default value if it hasn't already been set by the user * */ static function BooleanForm($key,$default=true){ $checked = ''; if( self::BooleanValue($key,$default) ){ $checked = 'checked="checked"'; } echo ''; echo ''; } /** * Determine if the boolean configuration option is true or false * * @param string $key The configuration key * @param bool $default The default value if it hasn't already been set by the user */ static function BooleanValue($key,$default=true){ if( !isset($_POST[$key]) ){ return $default; } if( $_POST[$key] == 'true' ){ return true; } return false; } //based on the user supplied values, make sure we can go forward with the installation static function gpInstall_Check(){ global $langmessage; echo "\nInstall Check\n"; $_POST += array('username'=>'','site_title'=>'My '.CMS_NAME,'email'=>''); $passed = array(); $failed = array(); //Email Address if( !(bool)preg_match('/^[^@]+@[^@]+\.[^@]+$/', $_POST['email']) ){ $failed[] = $langmessage['invalid_email']; } //Password if( ($_POST['password']=="") || ($_POST['password'] !== $_POST['password1']) ){ $failed[] = $langmessage['invalid_password']; }else{ $passed[] = $langmessage['PASSWORDS_MATCHED']; } //Username $test = str_replace(array('.','_'),array(''),$_POST['username'] ); if( empty($test) || !ctype_alnum($test) ){ $failed[] = $langmessage['invalid_username']; }else{ $passed[] = $langmessage['Username_ok']; } if( count($passed) > 0 ){ foreach($passed as $message){ echo '
  • '; echo $message; echo '
  • '; } } if( count($failed) > 0 ){ foreach($failed as $message){ echo '
  • '; echo $message; echo '
  • '; } return false; } return true; } static function Install_Title(){ $_POST += array( 'site_title' => ''); $title = $_POST['site_title']; $title = htmlspecialchars($title); $title = trim($title); if( empty($title) ){ return 'My '.CMS_NAME; } return $title; } 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_Scss/Flatly'; $gpLayouts['default']['label'] = 'Bootswatch_Scss/Flatly'; $gpLayouts['default']['color'] = '#93c47d'; $_config['toemail'] = $_POST['email']; $_config['gpLayout'] = 'default'; $_config['title'] = self::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'] = \gp\tool::RandomString(20); $_config['combinecss'] = self::BooleanValue('combinecss',true); $_config['combinejs'] = self::BooleanValue('combinejs',true); $_config['etag_headers'] = self::BooleanValue('etag_headers',true); $_config['gallery_legacy_style'] = false; $_config['language'] = 'en'; $_config['addons'] = array(); $config += $_config; //directories \gp\tool\Files::CheckDir($destination.'/data/_uploaded/image'); \gp\tool\Files::CheckDir($destination.'/data/_uploaded/media'); \gp\tool\Files::CheckDir($destination.'/data/_uploaded/file'); \gp\tool\Files::CheckDir($destination.'/data/_uploaded/flash'); \gp\tool\Files::CheckDir($destination.'/data/_sessions'); // gp_index $new_index = array(); $new_index['Home'] = 'a'; $new_index['Heading_Page'] = 'b'; $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['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 '
  • '; if( !\gp\tool\Files::SaveData($destination.'/data/_site/pages.php','pages',$pages) ){ echo ''; //echo 'Could not save pages.php'; echo sprintf($langmessage['COULD_NOT_SAVE'],'pages.php'); echo ''; echo '
  • '; return false; } echo ''; //echo 'Pages.php saved.'; echo sprintf($langmessage['_SAVED'],'pages.php'); echo ''; echo ''; // Home $content = '

    Welcome to Your '.CMS_NAME.' Powered Site!

    Now that '.CMS_NAME.' is installed, you can start editing the content and customizing your site.

    Getting Started


    You are currently viewing the default home page of your website. Here\'s a quick description of how to edit this page.

    1. First make sure you're '.self::Install_Link_Content('Admin','logged in','file=Home').'.
    2. Then click the "Edit" link that appears when you move your mouse over the content.
    3. Your changes will be saved to a draft automatically. Click "Publish Draft" to make them live.

    More Options


    Online Resources


    '.CMS_READABLE_DOMAIN.' has a number of resources to help you do even more.

    Git Social


    There are many ways to contribute to our project:

    '; self::NewTitle( $destination, 'Home', $content, $config, $new_index); // Heading Page $content = '

    A Heading Page

  • '.self::Install_Link_Content('Child_Page','Child Page').'
  • '; self::NewTitle( $destination, 'Heading_Page',$content, $config, $new_index); // Child Page $content = '

    A Child Page

    You can easily change the arrangement of all your pages using the '.self::Install_Link_Content('Admin/Menu','Page Manager').'.

    '; self::NewTitle( $destination, 'Child_Page',$content, $config, $new_index); // More $content = '

    More

    '; self::NewTitle( $destination, 'More',$content, $config, $new_index); // About $content = '

    About '.CMS_NAME.'

    '.CMS_NAME.' 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.

    '.CMS_NAME.' How To

    Learn how to manage your files, create galleries and more in the '.CMS_NAME.' Documentation.

    '.CMS_NAME.' Features

    '; self::NewTitle( $destination, 'About',$content, $config, $new_index); //Side_Menu $file = $destination.'/data/_extra/Side_Menu/page.php'; $content = '

    Join the '.CMS_NAME.' Community

    Visit '.CMS_READABLE_DOMAIN.' to access the many available resources to help you get the most out of our CMS.

    (Edit this content by clicking "Edit", it's that easy!)

    '; self::NewExtra($file,$content); //Header $file = $destination.'/data/_extra/Header/page.php'; $content = '

    '.$config['title'].'

    '.'The Fast and Easy CMS'.'

    '; self::NewExtra($file,$content); //Footer $file = $destination.'/data/_extra/Footer/page.php'; $content = '

    '.CMS_NAME.' Features

    Easy to use True WYSIWYG Editing.

    Flat-file data storage and advanced resource management for fast websites.

    Community driven development

    And More...

    If you like '.CMS_NAME.', then you might also like Less.php, WhatCMS.org and WhichCMS.org.

    '; self::NewExtra($file,$content); //Another example area $file = $destination.'/data/_extra/Lorem/page.php'; $content = '

    Heading

    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.

    '; self::NewExtra($file,$content); //contact html $file = $destination.'/data/_extra/Contact/page.php'; self::NewExtra($file,'

    Contact Us

    Use the form below to contact us, and be sure to enter a valid email address if you want to hear back from us.

    '); //users echo '
  • '; $user_info = array(); $user_info['password'] = \gp\tool::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 ){ gp_defined('gp_session_cookie',\gp\tool\Session::SessionCookie($config['gpuniq'])); \gp\tool\Session::create($user_info, $username, $sessions); } $users[$username] = $user_info; if( !\gp\tool\Files::SaveData($destination.'/data/_site/users.php','users',$users) ){ echo ''; echo sprintf($langmessage['COULD_NOT_SAVE'],'users.php'); echo ''; echo '
  • '; return false; } echo ''; echo sprintf($langmessage['_SAVED'],'users.php'); echo ''; echo ''; //save config //not using SaveConfig() because $config is not global here echo '
  • '; $config['file_count'] = self::$file_count; if( !\gp\tool\Files::SaveData($destination.'/data/_site/config.php','config',$config) ){ echo ''; echo sprintf($langmessage['COULD_NOT_SAVE'],'config.php'); echo ''; echo '
  • '; return false; } echo ''; echo sprintf($langmessage['_SAVED'],'config.php'); echo ''; echo ''; if( $base_install ){ self::InstallHtaccess($destination,$config); } \gp\tool\Files::Unlock('write',gp_random); return true; } static function NewTitle( $dataDir, $title, $content, $config, $index ){ $file = $dataDir.'/data/_pages/'.substr($config['gpuniq'],0,7).'_'.$index[$title].'/page.php'; self::$file_count++; $file_sections = array(); $file_sections[0] = array( 'type' => 'text', 'content' => $content ); $meta_data = array( 'file_number' => self::$file_count, 'file_type' => 'text', ); return \gp\tool\Files::SaveData($file,'file_sections',$file_sections,$meta_data); } static function NewExtra($file, $content){ $extra_content = array(array('type'=>'text','content'=>$content)); return \gp\tool\Files::SaveData($file,'file_sections',$extra_content); } /** * attempt to create an htaccess file * .htaccess creation only works for base_installations because of the $dirPrefix variable * This is for the rewrite_rule and TestResponse() which uses AbsoluteUrl() * * @access public * @static * @since 1.7 * * @param string $destination The root path of the installation * @param array $config Current installation configuration */ static function InstallHtaccess($destination,$config){ global $install_ftp_connection, $dirPrefix; //only proceed with save if we can test the results if( \gp\tool\RemoteGet::Test() === false ){ return; } $GLOBALS['config']['homepath'] = false; //to prevent a warning from absoluteUrl() $file = $destination.'/.htaccess'; $original_contents = null; if( file_exists($file) ){ $original_contents = file_get_contents($file); } $contents = \gp\admin\Settings\Permalinks::Rewrite_Rules(true, $dirPrefix, $original_contents ); if( !isset($config['useftp']) ){ //echo 'not using ftp'; $fp = @fopen($file,'wb'); if( !$fp ){ return; } @fwrite($fp,$contents); fclose($fp); @chmod($file,0666); //return .htaccess to original state if( !\gp\admin\Settings\Permalinks::TestResponse() ){ if( $original_contents === false ){ unlink($file); }else{ $fp = @fopen($file,'wb'); if( $fp ){ @fwrite($fp,$original_contents); fclose($fp); } } } return; } //using ftp $file = $config['ftp_root'].'/.htaccess'; $temp = tmpfile(); if( !$temp ){ return false; } fwrite($temp, $contents); fseek($temp, 0); //Skip back to the start of the file being written to @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII ); fclose($temp); //return .htaccess to original state if( !\gp\admin\Settings\Permalinks::TestResponse() ){ if( $original_contents === false ){ @ftp_delete($install_ftp_connection, $file); }else{ $temp = tmpfile(); fwrite($temp,$original_contents); fseek($temp,0); @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII ); fclose($temp); } } } function GetPathInfo(){ $UsePathInfo = ( strpos( php_sapi_name(), 'cgi' ) === false ) && ( strpos( php_sapi_name(), 'apache2filter' ) === false ) && ( strpos( php_sapi_name(), 'isapi' ) === false ); return $UsePathInfo; } static function Install_Link_Content($href,$label,$query='',$attr=''){ $query = str_replace('&','&',$query); $href = str_replace('&','&',$href); if( !empty($query) ){ $query = '?'.$query; } return ''.$label.''; } }