install.php
changeset 13 fdd6b9dd42c3
parent 12 c96a9b56f16c
child 16 64e0d3d4cf14
equal deleted inserted replaced
12:c96a9b56f16c 13:fdd6b9dd42c3
    49   $filename = __FILE__;
    49   $filename = __FILE__;
    50 }
    50 }
    51 
    51 
    52 define('ENANO_ROOT', dirname($filename));
    52 define('ENANO_ROOT', dirname($filename));
    53 
    53 
    54 function is_page($p) { return true; }
    54 function is_page($p)
       
    55 {
       
    56   return true;
       
    57 }
       
    58 
    55 require('includes/wikiformat.php');
    59 require('includes/wikiformat.php');
    56 require('includes/constants.php');
    60 require('includes/constants.php');
    57 require('includes/rijndael.php');
    61 require('includes/rijndael.php');
    58 require('includes/functions.php');
    62 require('includes/functions.php');
    59 
    63 
    60 //die('Key size: ' . AES_BITS . '<br />Block size: ' . AES_BLOCKSIZE);
    64 //die('Key size: ' . AES_BITS . '<br />Block size: ' . AES_BLOCKSIZE);
    61 
    65 
    62 if(!function_exists('wikiFormat')) {
    66 if(!function_exists('wikiFormat'))
    63 function wikiFormat($message, $filter_links = true) {
    67 {
    64   $wiki = & Text_Wiki::singleton('Mediawiki');
    68   function wikiFormat($message, $filter_links = true)
    65   $wiki->setRenderConf('Xhtml', 'code', 'css_filename', 'codefilename');
    69   {
    66   $wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
    70     $wiki = & Text_Wiki::singleton('Mediawiki');
    67   $result = $wiki->transform($message, 'Xhtml');
    71     $wiki->setRenderConf('Xhtml', 'code', 'css_filename', 'codefilename');
    68   
    72     $wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
    69   // HTML fixes
    73     $result = $wiki->transform($message, 'Xhtml');
    70   $result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
    74     
    71   $result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
    75     // HTML fixes
    72   $result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
    76     $result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
    73   
    77     $result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
    74   return $result;
    78     $result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
    75 }
    79     
       
    80     return $result;
       
    81   }
    76 }
    82 }
    77 
    83 
    78 global $failed, $warned;
    84 global $failed, $warned;
       
    85 
    79 $failed = false;
    86 $failed = false;
    80 $warned = false;
    87 $warned = false;
    81 function not($var) { if($var) return false; else return true; }
    88 
       
    89 function not($var)
       
    90 {
       
    91   if($var)
       
    92   {
       
    93     return false;
       
    94   } 
       
    95   else
       
    96   {
       
    97     return true;
       
    98   }
       
    99 }
       
   100 
    82 function run_test($code, $desc, $extended_desc, $warn = false)
   101 function run_test($code, $desc, $extended_desc, $warn = false)
    83 {
   102 {
    84   global $failed, $warned;
   103   global $failed, $warned;
    85   static $cv = true;
   104   static $cv = true;
    86   $cv = not($cv);
   105   $cv = not($cv);
  1040       }
  1059       }
  1041       
  1060       
  1042       echo 'done!<br />Writing configuration files...';
  1061       echo 'done!<br />Writing configuration files...';
  1043       if($_POST['urlscheme']=='tiny')
  1062       if($_POST['urlscheme']=='tiny')
  1044       {
  1063       {
  1045         $ht = fopen(dirname(__FILE__).'/.htaccess', 'a+');
  1064         $ht = fopen(ENANO_ROOT.'/.htaccess', 'a+');
  1046         if(!$ht) err('Error opening file .htaccess for writing');
  1065         if(!$ht) err('Error opening file .htaccess for writing');
  1047         fwrite($ht, '
  1066         fwrite($ht, '
  1048 RewriteEngine on
  1067 RewriteEngine on
  1049 RewriteCond %{REQUEST_FILENAME} !-d
  1068 RewriteCond %{REQUEST_FILENAME} !-d
  1050 RewriteCond %{REQUEST_FILENAME} !-f
  1069 RewriteCond %{REQUEST_FILENAME} !-f
  1068 define(\'ENANO_INSTALLED\', \'true\');
  1087 define(\'ENANO_INSTALLED\', \'true\');
  1069 }
  1088 }
  1070 $crypto_key = \''.$privkey.'\';
  1089 $crypto_key = \''.$privkey.'\';
  1071 ?>';
  1090 ?>';
  1072 
  1091 
  1073       $cf_handle = fopen(dirname(__FILE__).'/config.php', 'w');
  1092       $cf_handle = fopen(ENANO_ROOT.'/config.php', 'w');
  1074       if(!$cf_handle) err('Couldn\'t open file config.php for writing');
  1093       if(!$cf_handle) err('Couldn\'t open file config.php for writing');
  1075       fwrite($cf_handle, $config_file);
  1094       fwrite($cf_handle, $config_file);
  1076       fclose($cf_handle);
  1095       fclose($cf_handle);
  1077       
  1096       
  1078       echo 'done!<br />Initializing logs...';
  1097       echo 'done!<br />Initializing logs...';