install
[ class tree: install ] [ index: install ] [ all elements ]

Source for file install_checks.php

Documentation is available at install_checks.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package install
  5.  * @subpackage functions
  6.  * @author xing
  7.  */
  8.  
  9. // assign next step in installation process
  10. $gBitSmarty->assign'next_step'$step );
  11.  
  12. $check_settings check_settings();
  13.  
  14. $gBitSmarty->assign"error"$error );
  15. $gBitSmarty->assign"warning"$warning );
  16.  
  17. foreach$check_settings as $type => $checks {
  18.     $gBitSmarty->assign$type$checks );
  19. }
  20.  
  21. if!isset$_SERVER['HTTP_REFERER') ) {
  22.     $gBitSmarty->assign"http_referer_error"TRUE );
  23.     $error TRUE;
  24. }
  25.  
  26. /**
  27.  * check_settings
  28.  */
  29. function check_settings({
  30.     global $gBitSmarty$error$warning;
  31.     $config_file clean_file_pathempty$_SERVER['CONFIG_INC'BIT_ROOT_PATH.'config/kernel/config_inc.php' $_SERVER['CONFIG_INC');
  32.  
  33.     $i 0;
  34.     // required settings - if not met, are passed into the array $reqd
  35.     // PHP system checks
  36.     $phpvers '4.3.0';
  37.     ifphpversion($phpvers {
  38.         $required[$i]['note''<strong>PHP version</strong> should be greater than <strong>'.$phpvers.'</strong>.<br />Your installed version of PHP is <strong>'.phpversion().'</strong>.';
  39.         $required[$i]['passed'FALSE;
  40.     else {
  41.         $required[$i]['note''<strong>PHP version</strong> is greater than <strong>'.$phpvers.'</strong>.<br />Your installed version of PHP is <strong>'.phpversion().'</strong>.';
  42.         $required[$i]['passed'TRUE;
  43.     }
  44.  
  45.     // check file and directory permissisions
  46.     $i++;
  47.     if@file_exists$config_file && @bw_is_writeable$config_file ) ) {
  48.         $required[$i]['note''The Bitweaver configuration file is available and the file is writeable:<br /><code>'.$config_file.'</code>';
  49.         $required[$i]['passed'TRUE;
  50.     elseif@file_exists$config_file && !@bw_is_writeable$config_file ) ) {
  51.         $required[$i]['note''The Bitweaver configuration file is available but the file is not writeable. Please execute something like:<br /><code>chmod 777 '.$config_file.'</code>';
  52.         $required[$i]['passed'FALSE;
  53.     else {
  54.         $required[$i]['note''The Bitweaver configuration file is not available. Please execute something like:<br /><code>touch '.$config_file.';<br />chmod 777 '.$config_file.'</code>';
  55.         $required[$i]['passed'FALSE;
  56.     }
  57.     $i++;
  58.  
  59.     $dir_check array(
  60.         'storage' => defined'STORAGE_PKG_PATH' STORAGE_PKG_PATH BIT_ROOT_PATH.'storage',
  61.         'temp' => defined'TEMP_PKG_PATH' TEMP_PKG_PATH sys_get_temp_dir().'/bitweaver/'.$_SERVER['SERVER_NAME'],
  62.     );
  63.     foreach$dir_check as $name => $d {
  64.         // final attempt to create the required directories
  65.         @mkdir$d,0644 );
  66.         if@is_dir$d && bw_is_writeable$d ) ) {
  67.             $required[$i]['note'"The $name directory is available and it is writeable.<br /><code>$d</code>";
  68.             $required[$i]['passed'TRUE;
  69.         elseif@is_dir$d && !bw_is_writeable$d ) ) {
  70.             $required[$i]['note'"The $name directory is available but it is not writeable.<br />Please execute something like:<br /><code>chmod -R 777 $d</code>";
  71.             $required[$i]['passed'FALSE;
  72.         else {
  73.             $required[$i]['note'"The $name directory is not available and we cannot create it automaticalliy.<br />Please execute something like:<br /><code>mkdir -m 777 $d</code>";
  74.             $required[$i]['passed'FALSE;
  75.         }
  76.         $i++;
  77.     }
  78.     foreach$required as $r {
  79.         if!$r['passed'{
  80.             $error TRUE;
  81.         }
  82.     }
  83.  
  84.     // check extensions
  85.     $php_ext array(
  86.         'zlib'         => '<a class="external" href="http://www.zlib.net/">The zlib compression libraries</a> are used to pack and unpack compressed files such as .zip files.',
  87.         'gd'           => '<a class="external" href="http://www.boutell.com/gd/">GD Libraries</a> are used to manipulate images. Bitweaver uses these libraries to create thumbnails and convert images from one format to another. If you are running Red Hat or Fedora Core, you can try: <kbd>yum install php-gd</kbd>. The GD libaries are quite limited and <em>don\'t support</em> a number of image formats including <em>.bmp</em>. If you are planning on uploading and using a lot of images, we recommend you use one of the other image processors.',
  88.         'imagick'      => 'ImageMagick supports a multitude of different image and video formats and <em>can be used instead of the GD Libraries</em>. Using these libraries will allow you to upload most image formats without any difficulties. For installation help, please view <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
  89.         'magickwand'   => 'MagickWand is a newer PHP extension for ImageMagick. For installation help, please view Bitweaver\'s: <a class="external" href="http://www.bitweaver.org/wiki/ImageMagick">ImageMagick and MagickWand installation instructions</a> or visit the <a class="external" href="http://www.imagemagick.org">ImageMagick homepage</a>.',
  90. //        'eAccelerator' => '<a class="external" href="http://eaccelerator.net">eAccelerator</a> increases the efficiency of PHP by caching and optimising queries. Using this extension will greatly increase your server\'s performance and reduce the memory needed to run Bitweaver.',
  91. //        'ffmpeg'       => '<a class="external" href="http://ffmpeg-php.sourceforge.net/">ffmpeg-php</a> is an extension that will allow you to better process uploaded videos. This extension requires ffmpeg to be installed on your server as well.',
  92.     );
  93.     foreach$php_ext as $ext => $note {
  94.         $extensions[$ext]['note''The extension <strong>'.$ext.'</strong> is ';
  95.         ifextension_loaded$ext ) ) {
  96.             $extensions[$ext]['passed'TRUE;
  97.         else {
  98.             $extensions[$ext]['note'.= 'not ';
  99.             $extensions[$ext]['passed'FALSE;
  100.         }
  101.         $extensions[$ext]['note'.= 'available.<br />'.$note;
  102.     }
  103.  
  104.     // disable one of the imagick / magickwand warnings
  105.     if$extensions['magickwand']['passed'== TRUE && $extensions['imagick']['passed'== FALSE {
  106.         unset$extensions['imagick');
  107.     elseif$extensions['imagick']['passed'== TRUE && $extensions['magickwand']['passed'== FALSE {
  108.         unset$extensions['magickwand');
  109.     }
  110.  
  111.     // make sure we show the worning flag if there is a need for it
  112.     foreach$extensions as $info {
  113.         if!$info['passed'{
  114.             $warning TRUE;
  115.         }
  116.     }
  117.  
  118.     // output has to be verbose that we can catch the output of the shell_exec
  119.     // using --help, -h or --version should make applications output something to stdout - this is no guarantee though, bunzip2 doesn't...
  120.     $execs array(
  121.         'tar' => array(
  122.             'command'      => 'tar -xvf',
  123.             'dest_params'  => '-C',
  124.             'testfile'     => 'test.tar',
  125.             'note'         => '<strong>Tarball</strong> is a common archiving format on Linux and <a class="external" href="http://www.gnu.org/software/tar/">tar</a> is used to extract .tar files. For windows use <a class="external" href="http://gnuwin32.sourceforge.net/downlinks/libarchive.php">bsdtar</a> from gnuwin32 ( See <a class="external" href="http://www.bitweaver.org/wiki/Windows+installation+notes">Windows notes for installation help</a> ).',
  126.         ),
  127.         'bzip2' => array(
  128.             'command'      => 'tar -jvxf',
  129.             'dest_params'  => '-C',
  130.             'testfile'     => 'test.tar.bz2',
  131.             'note'         => '<strong>Bzip</strong> is a common compression format on Linux and <a class="external" href="http://www.bzip.org/">bzip2</a> is used to extract .bz2 and in combination with tar .tar.bz2 file. ( For windows see bsdtar above. )',
  132.         ),
  133.         'gzip' => array(
  134.             'command'      => 'tar -zvxf',
  135.             'dest_params'  => '-C',
  136.             'testfile'     => 'test.tar.gz',
  137.             'note'         => '<strong>Gzip</strong> is a common compression format on Linux and <a class="external" href="http://www.gnu.org/software/gzip/gzip.html">gzip</a> is used to extract .gz and in combination with tar .tar.gz file. ( For windows see bsdtar above. )',
  138.         ),
  139.         'unzip' => array(
  140.             'command'      => 'unzip -v',
  141.             'dest_params'  => '-d',
  142.             'testfile'     => 'test.zip',
  143.             'note'         => '<strong>Zip</strong> is a common compression format on all operating systems and <a class="external" href="http://www.info-zip.org/">unzip</a> is used to extract .zip files.',
  144.         ),
  145.         'unrar' => array(
  146.             'command'      => 'unrar x',
  147.             'dest_params'  => '',
  148.             'testfile'     => 'test.rar',
  149.             'note'         => '<strong>Rar</strong> is a common compression format on all operating systems and <a class="external" href="http://www.rarlab.com/rar_add.htm">unrar</a> is used to extract .rar files.',
  150.         ),
  151.         'gs' => array(
  152.             'command'      => 'gs --version',
  153.             'note'         => '<a class="external" href="http://www.cs.wisc.edu/~ghost/">GhostScript</a> is an interpreter for the PostScript language and for PDF and is used to create PDF previews when uploading PDF files to Fisheye. If you do not have this installed, previews of PDF files will not be generated on upload. If you have difficulties with GhostScript, please try installing a different version. Bitweaver was successfully tested with versions 7.5, 8.15.4, 8.5, 8.54. There where difficulties with version 8.1.',
  154.             'result'       => 'Your version of GhostScript: ',
  155.         ),
  156.         'graphviz' => array(
  157.             'command'      => 'dot -V',
  158.             'note'         => '<a class="external" href="http://www.graphviz.org/">Graphviz</a> is a way of representing structural information as diagrams of abstract graphs and networks and visualizing that representation. It is used by the {graphviz} Liberty plugin and you only need to install it if you intend to enable that plugin.<br /><em>The Pear::Image_Graphviz plugin is required as well.</em>',
  159.             'result'       => 'Your version of Graphviz: ',
  160.         ),
  161. //        'ffmpeg' => array(
  162. //            'command'      => 'ffmpeg',
  163. //            'note'         => '<a class="external" href="http://ffmpeg.mplayerhq.hu/">ffmpeg</a> is a hyper fast video and audio encoder that supports many common formats. If you are planning on uploading video and audio files, it\'s recommend that you install this application.',
  164. //        ),
  165. //        'unstuff' => array(
  166. //            'params'       => '-xf',
  167. //            'testfile'     => 'test.tar',
  168. //            'note'         => 'Unstuff is a common compression format on Mac and <strong>unstuff</strong> is used to extract .sit files.',
  169. //        ),
  170.     );
  171.     foreach$execs as $exe => $app {
  172.         $executables[$exe]['note''The application <strong>'.$exe.'</strong> is ';
  173.         if!empty$app['testfile'&& is_readable$file INSTALL_PKG_PATH.'testfiles/'.$app['testfile')) {
  174.             $command $app['command'].' "'.$file.'" '.$app['dest_params'].' "'.TEMP_PKG_PATH.'"';
  175.         else {
  176.             $command $app['command'];
  177.         }
  178.  
  179.         ifget_php_setting'safe_mode' == 'OFF' && $shellResults[$exeshell_exec$command .' 2> '.TEMP_PKG_PATH.'output' ) ) {
  180.             @unlinkTEMP_PKG_PATH.'test.txt' );
  181.             $executables[$exe]['passed'TRUE;
  182.         elseif $shellResults[$exejoin(""file(TEMP_PKG_PATH.'output')) ) {
  183.             if strpos$shellResults[$exe]'command' and strpos$shellResults[$exe]'not' ) ) {
  184.                 $executables[$exe]['note'.= 'not ';
  185.                 $executables[$exe]['passed'FALSE;
  186.                 $shellResults[$exe"";
  187.             else {
  188.                 @unlinkTEMP_PKG_PATH.'test.txt' );
  189.                 $executables[$exe]['passed'TRUE;
  190.             }
  191.         else {
  192.             $executables[$exe]['note'.= 'not ';
  193.             $executables[$exe]['passed'FALSE;
  194.         }
  195.         $executables[$exe]['note'.= 'available.<br />'.$app['note'];
  196.         if!empty$app['result'&& !empty$shellResults[$exe)) {
  197.             $executables[$exe]['note'.= '<br />'.$app['result'].'<strong>'.$shellResults[$exe].'</strong>';
  198.         }
  199.     }
  200.  
  201.  
  202.     // PEAR checks
  203.     $pears array(
  204.         'PEAR' => array(
  205.             'path'            => 'PEAR.php',
  206.             'note'            => 'This check indicates if PEAR is installed and available. To make use of PEAR extensions, you need to make sure that PEAR is installed and the include_path is set in your php.ini file.',
  207.         ),
  208.         'Auth' => array(
  209.             'path'            => 'Auth/Auth.php',
  210.             'note'            => 'This will allow you to use the PEAR::Auth package to authenticate users on your website.',
  211.             'install_command' => 'pear install --onlyreqdeps Auth;',
  212.         ),
  213.         'Text_Wiki' => array(
  214.             'path'            => 'Text/Wiki.php',
  215.             'note'            => 'Having PEAR::Text_Wiki installed will make more wiki format parsers available. The following parsers will be recognised and used: Text_Wiki_BBCode, Text_Wiki_Cowiki, Text_Wiki_Creole, Text_Wiki_Doku, Text_Wiki_Mediawiki, Text_Wiki_Tiki',
  216.             'install_command' => 'pear install --onlyreqdeps Text_Wiki_BBCode Text_Wiki_Cowiki Text_Wiki_Creole Text_Wiki_Doku Text_Wiki_Mediawiki Text_Wiki_Tiki;',
  217.         ),
  218.         'Text_Diff' => array(
  219.             'path'            => 'Text/Diff.php',
  220.             'note'            => 'PEAR::Text_Diff makes inline diffing of content available.',
  221.             'install_command' => 'pear install --onlyreqdeps Text_Diff;',
  222.         ),
  223.         'Image_Graphviz' => array(
  224.             'path'            => 'Image/GraphViz.php',
  225.             'note'            => 'Pear::Image_Graphviz makes the {graphviz} plugin available. With it you can draw maps of how your Wiki pages are linked to each other. This can be used for informational purposes or a site-map. It requires the application graphviz to be installed on your server as well.',
  226.             'install_command' => 'pear install --onlyreqdeps Image_Graphviz;',
  227.         ),
  228.         'HTMLPurifier' => array(
  229.             'path'            => 'HTMLPurifier.php',
  230.             'note'            => 'HTMLPurifier is an advanced system for defending against Cross Site Scripting (XSS) attacks and ensuring that all code on your site is standards compliant. It is highly recommended if you are going to allow HTML submission to your site. It is not required if you are only going to allow the input of a Wiki format like Tikiwiki or BBcode. You also need to enable it in the Liberty plugins administration after installation. See <a class="external" href="http://www.bitweaver.org/wiki/HTMLPurifier">http://www.bitweaver.org/wiki/HTMLPurifier</a> and <a class = "external" href = "http: // htmlpurifier.org">http://htmlpurifier.org</a> for more information.',
  231.             'install_command' => 'pear channel-discover htmlpurifier.org;<br />pear install hp/HTMLPurifier;',
  232.         ),
  233.         'HTTP_Download' => array(
  234.             'path'            => 'HTTP/Download.php',
  235.             'note'            => 'Treasury - the file manager of Bitweaver - can make use of PEAR::HTTP_Download to provide more reliable downloads and download resume support when using a download manager.',
  236.             'install_command' => 'pear install --alldeps HTTP_Download;',
  237.         ),
  238.     );
  239.  
  240.     foreach$pears as $pear => $info {
  241.         if$pear == 'PEAR' {
  242.             $pearexts[$pear]['note''<strong>'.$pear.'</strong> is ';
  243.         else {
  244.             $pearexts[$pear]['note''The extension <strong>PEAR::'.$pear.'</strong> is ';
  245.         }
  246.  
  247.         if@include_once$info['path')) {
  248.             $pearexts[$pear]['passed'TRUE;
  249.         else {
  250.             $pearexts[$pear]['note'.= 'not ';
  251.             $pearexts[$pear]['passed'FALSE;
  252.         }
  253.  
  254.         $pearexts[$pear]['original_note'$info['note'];
  255.         $pearexts[$pear]['note'.= 'available.<br />';
  256.         $pearexts[$pear]['note'.= $info['note'];
  257.  
  258.         if!empty$info['install_command'&& $pearexts[$pear]['passed'== FALSE {
  259.             $pearexts[$pear]['note'.= '<br /><em>Install using this command:</em><br /><code>'.$info['install_command'].'</code>';
  260.         }
  261.     }
  262.  
  263.     $i 0;
  264.     // recommended php toggles - these don't need explicit explanations on how to rectify them
  265.     // start with special cases
  266.     $recommended[$iarray'Memory Limit','memory_limit','shouldbe' => 'at least 16M''actual' => get_cfg_var'memory_limit' ) );
  267.     ifpreg_replace'/M/i','',get_cfg_var'memory_limit' ) ) 15 {
  268.         $recommended[$i]['passed'TRUE;
  269.     else {
  270.         $recommended[$i]['passed'FALSE;
  271.         $gBitSmarty->assign'memory_warning'TRUE );
  272.     }
  273.  
  274.     $i++;
  275.     // now continue with easy toggle checks
  276.     $php_rec_toggles array(
  277.         array'Safe Mode','safe_mode','shouldbe' => 'OFF'),
  278.         array'Display Errors','display_errors','shouldbe' => 'OFF' ),
  279.         array'File Uploads','file_uploads','shouldbe' => 'ON' ),
  280.         array'Magic Quotes GPC','magic_quotes_gpc','shouldbe' => 'OFF' ),
  281.         array'Magic Quotes Runtime','magic_quotes_runtime','shouldbe' => 'OFF' ),
  282.         array'Magic Quotes Sybase','magic_quotes_sybase','shouldbe' => 'OFF' ),
  283.         array'Register Globals','register_globals','shouldbe' => 'OFF' ),
  284.         array'Output Buffering','output_buffering','shouldbe' => 'OFF' ),
  285.         array'Session auto start','session.auto_start','shouldbe' => 'OFF' ),
  286.     );
  287.     foreach$php_rec_toggles as $php_rec_toggle {
  288.         $php_rec_toggle['actual'get_php_setting$php_rec_toggle[1);
  289.         ifget_php_setting$php_rec_toggle[1== $php_rec_toggle['shouldbe'{
  290.             $php_rec_toggle['passed'TRUE;
  291.         else {
  292.             $php_rec_toggle['passed'FALSE;
  293.         }
  294.         $recommended[$php_rec_toggle;
  295.         $i++;
  296.     }
  297.  
  298.     // settings that are useful to know about
  299.     $php_ini_gets array(
  300.         array'<strong>Maximum post size</strong> restricts the size of files uploaded using a form. <br />Recommended: at least <strong>8M</strong>.''post_max_size' ),
  301.         array'<strong>Upload max filesize</strong> is related to maximim post size and will also limit the size of uploads. <br />Recommended: at least <strong>8M</strong>.''upload_max_filesize' ),
  302.         array'<strong>Maximum execution time</strong> is related to time outs in PHP. It affects database upgrades and backups. <br />Recommended: <strong>60</strong>.''max_execution_time' ),
  303.     );
  304.     foreach$php_ini_gets as $php_ini_get {
  305.         $value ini_get$php_ini_get[1);
  306.         if$value == {
  307.             $value "On";
  308.         elseif$value == {
  309.             $value "Off";
  310.         }
  311.  
  312.         $show[$php_ini_get[1]] $php_ini_get[0]."<br /><strong>{$php_ini_get[1]}</strong> is set to <strong>$value</strong>";
  313.     }
  314.  
  315.     $res['required']    $required;
  316.     $res['extensions']  $extensions;
  317.     $res['executables'$executables;
  318.     $res['pearexts']    $pearexts;
  319.     $res['recommended'$recommended;
  320.     $res['show']        $show;
  321.     return $res;
  322. }
  323.  
  324. /**
  325.  * get_php_setting
  326.  */
  327. function get_php_setting$val {
  328.     $r ini_get$val == '1' );
  329.     return $r 'ON' 'OFF';
  330. }
  331. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:43 +0000 by phpDocumentor 1.5.0-lsces