lang = $_GET['lang']; setcookie('lang',$this->lang); }elseif( isset($_COOKIE['lang']) && isset($languages[$_COOKIE['lang']]) ){ $this->lang = $_COOKIE['lang']; } \gp\tool::GetLangFile('main.inc',$this->lang); // installation checks $this->CheckDataFolder(); $this->CheckPHPVersion(); $this->CheckEnv(); $this->CheckMemory(); $this->CheckImages(); $this->CheckArchives(); $this->CheckPath(); $this->CheckIndexHtml(); } public function Run(){ global $langmessage; echo '
'.$langmessage['Checking'].'... | '; echo ''.$langmessage['Status'].' | '; echo ''.$langmessage['Current_Value'].' | '; echo ''.$langmessage['Expected_Value'].' | '; echo '
---|---|---|---|
'; echo $row['checking']; echo ' | '; if( $row['can_install'] === 2 ){ $class = 'passed'; $label = 'Passed'; }elseif( $row['can_install'] === 1 ){ $class = 'passed_orange'; $label = 'Passed'; }elseif( $row['can_install'] === 0 ){ $class = 'passed_orange'; $label = 'Failed'; }else{ $class = 'passed_orange'; $label = 'Failed'; } if( !empty($row['label']) ){ $label = $row['label']; } echo ''.$label.' | '; echo ''.$row['curr_value'].' | '; echo ''.$row['expected'].' | '; echo '
'; echo \gp\tool::Link('',$langmessage['Refresh']); echo '
'; echo ''; echo sprintf($langmessage['Install_Fix'],''); echo '
'; } } public function SetStatus($checking, $can_install, $curr_value, $expected = '', $status_label = ''){ if( $can_install < $this->can_install ){ $this->can_install = $can_install; } $this->statuses[] = [ 'checking' => $checking, 'can_install' => $can_install, 'curr_value' => $curr_value, 'expected' => $expected, 'label' => $status_label ]; } /** * Check the data folder to see if it's writable * */ public function CheckDataFolder(){ global $dataDir,$langmessage; $folder = $dataDir.'/data'; if( strlen($folder) > 33 ){ $show = '...'.substr($folder,-30); }else{ $show = $folder; } $status = null; $class = 'passed'; $can_install = 2; if( !is_dir($folder)){ if( !@mkdir($folder) ){ $status = $langmessage['See_Below'].' (0)'; $this->can_write_data = false; } }elseif( !gp_is_writable($folder) ){ $status = $langmessage['See_Below'].' (1)'; $this->can_write_data = false; } if( $this->can_write_data ){ $current = $langmessage['Writable']; }else{ $current = $langmessage['Not Writable']; $can_install = 0; } $this->SetStatus( $show, $can_install, $current, $langmessage['Writable'], $status); } /** * Check the php version * */ private function CheckPHPVersion(){ global $langmessage; $version = phpversion(); $can_install = 2; if( version_compare($version,'8.0','<') ){ $can_install = -1; } $this->SetStatus($langmessage['PHP_Version'], $can_install, $version, '7.3+'); } /** * Check the env for server variables * */ private function CheckEnv(){ global $langmessage; //make sure $_SERVER['SCRIPT_NAME'] is set $checking = 'SCRIPT_NAME or PHP_SELF'; $can_install = 2; $expected = $langmessage['Set']; $curr = $langmessage['Set']; if( !\gp\tool::GetEnv('SCRIPT_NAME','index.php') && !\gp\tool::GetEnv('PHP_SELF','index.php') ){ $curr = $langmessage['Not_Set']; $can_install = -1; } $this->SetStatus($checking, $can_install, $curr, $expected); } /** * Check php's memory limit * LESS compilation uses a fair amount of memory */ private function CheckMemory(){ $checkValue = ini_get('memory_limit'); $expected = '16M+ or Adjustable'; $checking = 'Memory Limit'; // adjustable if( @ini_set('memory_limit','96M') !== false ){ $this->SetStatus( $checking, 2, $checkValue .' and adjustable', $expected); return; } // cant check memory if( !$checkValue ){ $this->SetStatus( $checking, 1, '???', $expected); return; } $byte_value = \gp\tool::getByteValue($checkValue); $mb_16 = \gp\tool::getByteValue('16M'); if( $byte_value > 100663296 ){ $this->SetStatus( $checking, 2, $checkValue, $expected); }elseif( $byte_value >= $mb_16 ){ $this->SetStatus( $checking, 1, $checkValue, $expected); }else{ $this->SetStatus( $checking, 0, $checkValue, $expected); } } /** * Very unlikely, ".php" cannot be in the directory name. see SetGlobalPaths() * */ public function CheckPath(){ global $langmessage; $dir = dirname(__FILE__); $checking = 'Install Directory'; $curr = str_replace('.php','.php',$dir); if( strpos($dir,'.php') === false ){ $this->SetStatus( $checking, 2, $curr ); return; } $this->SetStatus( $checking, 0, $curr , 'Rename your file structure so that directories do not use ".php".'); } /** * Warn user if there's an index.html file * */ public function CheckIndexHtml(){ global $langmessage, $dataDir; $show = 'Existing index.html'; $index = $dataDir.'/index.html'; if( file_exists($index) ){ $this->SetStatus( $show, 1, $index, $langmessage['index.html exists']); }else{ $this->SetStatus( $show, 2, '', ''); } } /** * Check for image manipulation functions * */ public function CheckImages(){ global $langmessage; $supported = array(); if( function_exists('imagetypes') ){ $supported_types = imagetypes(); if( $supported_types & IMG_JPG ){ $supported[] = 'jpg'; } if( $supported_types & IMG_PNG){ $supported[] = 'png'; } if( $supported_types & IMG_WBMP){ $supported[] = 'bmp'; } if( $supported_types & IMG_GIF){ $supported[] = 'gif'; } if( defined('IMG_WEBP') && ($supported_types & IMG_WEBP) ){ $supported[] = 'webp'; } } $checking = ''.$langmessage['image_functions'].''; $supported_string = implode(', ',$supported); if( count($supported) >= 4 ){ $this->SetStatus( $checking, 2, $supported_string); }elseif( count($supported) > 0 ){ $this->SetStatus( $checking, 1, $supported_string,'',$langmessage['partially_available']); }else{ $this->SetStatus( $checking, 1, $supported_string,'',$langmessage['unavailable']); } } /** * Check for archive processing capabilities * */ public function CheckArchives(){ global $langmessage; $supported = array(); if( class_exists('\ZipArchive') ){ $supported['zip'] = 'zip'; } if( class_exists('\PharData') ){ if( !defined('HHVM_VERSION') || !ini_get('phar.readonly') ){ if( function_exists('gzopen') ){ $supported['tgz'] = 'gzip'; } if( function_exists('bzopen') ){ $supported['tbz'] = 'bzip'; } $supported['tar'] = 'tar'; } } $checking = 'Archive Extensions'; $supported_string = implode(', ',$supported); if( count($supported) == 4 ){ $this->SetStatus( $checking, 2, $supported_string); }elseif( count($supported) > 0 ){ $this->SetStatus( $checking, 1, $supported_string, '', $langmessage['partially_available'] ); }else{ $this->SetStatus( $checking, 1, $supported_string, '', $langmessage['unavailable'] ); } } /** * Change the permissions of the data directory * */ public function FTP_Prepare(){ global $langmessage; echo ''; echo $langmessage['REFRESH_AFTER_CHANGE']; echo '
'; echo ''; echo $langmessage['manual_method']; echo ' |
---|
'; echo $langmessage['LINUX_CHOWN']; echo ' '; $owner = $this->GetPHPOwner(); if( is_null($owner) ){ echo 'chown ?? "'.$dataDir.'/data"'; echo 'Replace ?? with the owner uid of PHP on your server'; }else{ echo 'chown '.$owner.' "'.$dataDir.'/data"'; echo 'Note: "'.$owner.'" appears to be the owner uid of PHP on your server'; } echo ''; echo ' |
FTP |
'; echo $langmessage['MOST_FTP_CLIENTS']; echo ' '; echo 'Using your FTP client, we recommend the following steps to make the data directory writable '; echo '
|
'; echo $langmessage['Installer']; echo ' |
';
echo ' '; echo $langmessage['FTP_CHMOD']; echo ' '; $this->Form_FTPDetails(); echo ' |
'; echo 'For added security, you may delete the /include/install/install.php file from your server.'; echo '
'; } public function Form_Entry(){ global $langmessage; echo ''; } public function Install_Normal(){ global $langmessage; echo '