Changeset 3

Show
Ignore:
Timestamp:
2007-11-20 19:57:18 (5 years ago)
Author:
hannes
Message:

added configurable pathes for file system and webserver (ticket #1)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/admin/classes/pages/Settings.php

    r1 r3  
    3232    public function __construct() { 
    3333        global $LANG, $C, $F, $SETTINGS, $LANG; 
    34         global $commit, $newsqltype, $newsqlhost, $newsqluser, $newsqlpassword, $newdbname, $newdbtableprefix, $newforumname, $newslogan, $newforumlogo, $newsitename, $newsiteurl, $newforumadmin, $newforumadminemail, $newtopicsperpage, $newpostsperpage, $newmaxavatarsize, $newguestemail, $newfloodcontrol, $newfloodcontrol_search, $newmaxuploadsize, $newuploadextensions, $newlanguage, $newurl_rewriting, $newtimezone, $newencoding, $newdefaultstyle, $newexpire, $newdebug, $newhash, $newseveralaccountspermail, $newmaintainancemode
     34        global $commit, $newsqltype, $newsqlhost, $newsqluser, $newsqlpassword, $newdbname, $newdbtableprefix, $newforumname, $newslogan, $newforumlogo, $newsitename, $newsiteurl, $newforumadmin, $newforumadminemail, $newtopicsperpage, $newpostsperpage, $newmaxavatarsize, $newguestemail, $newfloodcontrol, $newfloodcontrol_search, $newmaxuploadsize, $newuploadextensions, $newlanguage, $newurl_rewriting, $newtimezone, $newencoding, $newdefaultstyle, $newexpire, $newdebug, $newhash, $newseveralaccountspermail, $newmaintainancemode, $newfspath, $newwebpath
    3535        // define location and title parameter 
    3636        $this->title = ''; 
     
    5656                    fwrite($file, "\$SETTINGS['dbname'] = '" . $newdbname . "'; // name of the SQL database\n"); 
    5757                    fwrite($file, "\$SETTINGS['dbtableprefix'] = '" . $newdbtableprefix . "'; // prefix of all the database tables\n"); 
     58                    fwrite($file, "\$SETTINGS['fspath'] = '" . $newfspath . "'; // full file system path to the forum root\n"); 
     59                    fwrite($file, "\$SETTINGS['webpath'] = '" . $newwebpath . "'; // path to the forum from domain's root\n"); 
    5860                    fwrite($file, "\$SETTINGS['forumname'] = '" . $newforumname . "'; // displayed in browser's title and used for outgoing e-mail\n"); 
    5961                    fwrite($file, "\$SETTINGS['slogan'] = '" . $newslogan . "'; // displayed in browser's title\n"); 
     
    8385                    // close file 
    8486                    @fclose($file); 
     87                    // write path to the .htaccess files (if present) 
     88                    if (is_file('../.htaccess')) { 
     89                        if ($newurl_rewriting == 1) { 
     90                            $_rewrite = 'On'; 
     91                        } else { 
     92                            $_rewrite = 'Off'; 
     93                        } 
     94                        if ($file = @fopen('../.htaccess', 'w')) { 
     95                            // write settings 
     96                            fwrite($file, "RewriteEngine " . $_rewrite . "\n\nRewriteBase " . $newwebpath . "\n\nRewriteRule ^index\.php$ index.php [L]\nRewriteRule ^([a-z]+)\.php$ index.php?show=$1&%{QUERY_STRING} [L]\n\nOptions -Indexes\n"); 
     97                            @fclose($file); 
     98                        } 
     99                        if ($file = @fopen('../admin/.htaccess', 'w')) { 
     100                            // write settings 
     101                            fwrite($file, "RewriteEngine " . $_rewrite . "\n\nRewriteBase " . $newwebpath . "admin/\n\nRewriteRule ^index\.php$ index.php [L]\nRewriteRule ^([a-z]+)\.php$ index.php?show=$1&%{QUERY_STRING} [L]\n\nOptions -Indexes\n"); 
     102                            @fclose($file); 
     103                        } 
     104                    } 
    85105                    $div = $this->html->body->addChild('div', $LANG['board_settings_updated']); 
    86106                    $div->addAttribute('id', 'admin_main'); 
     
    121141                $form->addTableRow($LANG['SQL_Database'], 'text', 'newdbname', $SETTINGS['dbname']); 
    122142                $form->addTableRow($LANG['SQL_Database_Table_Prefix'], 'text', 'newdbtableprefix', $SETTINGS['dbtableprefix']); 
     143                $form->addTableRow($LANG['Filesystem_Path'], 'text', 'newfspath', $SETTINGS['fspath']); 
     144                $form->addTableRow($LANG['Webserver_Path'], 'text', 'newwebpath', $SETTINGS['webpath']); 
    123145                $form->addTableRow($LANG['Board_Name'], 'text', 'newforumname', $SETTINGS['forumname']); 
    124146                $form->addTableRow($LANG['Board_Slogan'], 'text', 'newslogan', $SETTINGS['slogan']); 
  • trunk/includes/config/settings.tmpl

    r1 r3  
    1414$SETTINGS['dbname'] = ''; // name of the SQL database 
    1515$SETTINGS['dbtableprefix'] = 'sb_'; // prefix of all the database tables 
     16$SETTINGS['fspath'] = ''; // full file system path to the forum root 
     17$SETTINGS['webpath'] = ''; // path to the forum from domain's root 
    1618$SETTINGS['forumname'] = 'Spam Board'; // displayed in browser's title and used for outgoing e-mail 
    1719$SETTINGS['slogan'] = 'The Tastiest Forum on Earth!'; // displayed in browser's title 
  • trunk/includes/input.php

    r1 r3  
    539539} 
    540540 
     541$newfspath = $_POST['newfspath']; 
     542if (preg_match('/^[A-Za-z0-9_\-\/\\:\.]*$/', $newfspath) != 1) { 
     543    // die($LANG['error_input']); 
     544} 
     545 
     546$newwebpath = $_POST['newwebpath']; 
     547if (preg_match('/^[A-Za-z0-9_\-\/\.]*$/', $newwebpath) != 1) { 
     548    // die($LANG['error_input']); 
     549} 
     550 
    541551?> 
  • trunk/includes/lang/en.php

    r1 r3  
    297297$LANG['Maintainance_Mode'] = 'Maintainance Mode'; 
    298298$LANG['new_message_subject'] = 'New Private Message at ' . $SETTINGS['forumname']; 
     299$LANG['Filesystem_Path'] = 'Filesystem Path'; 
     300$LANG['Webserver_Path'] = 'Webserver Path'; 
    299301 
    300302/* actual sentences */ 
  • trunk/includes/login.php

    r1 r3  
    5959    // send cookie 
    6060    $exp = time() + $SETTINGS['expire'] * 24 * 60 * 60; 
    61     setcookie('sb_user', $encrypted_cookie . '*' . $row->offset, $exp, substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') - 11)); 
     61    setcookie('sb_user', $encrypted_cookie . '*' . $row->offset, $exp, $SETTINGS['webpath']); 
    6262} 
    6363// delete potential number of failed logins from cookie 
  • trunk/includes/session.php

    r1 r3  
    2525// ignore well-known bots 
    2626if (stristr($_SERVER['HTTP_USER_AGENT'], 'Googlebot') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'Slurp') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'ia_archiver') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'Harvest') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'crawl') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'bot') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'jeeves') === FALSE && stristr($_SERVER['HTTP_USER_AGENT'], 'spider') === FALSE) { 
    27     // if included from admin/redirectors subdirectory 
    28     if (strstr($_SERVER['PHP_SELF'], 'admin/redirectors')) { 
    29         // save session info in subdirectory instead of system-wide /tmp/ 
    30         ini_set('session.save_path', substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/') - 18) . '/sessions'); 
    31         // session valid for whole board 
    32         ini_set('session.cookie_path', substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') - 17)); 
    33     // if included from redirectors subdirectory 
    34     } elseif (strstr($_SERVER['PHP_SELF'], 'redirectors')) { 
    35         // save session info in subdirectory instead of system-wide /tmp/ 
    36         ini_set('session.save_path', substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/') - 12) . '/sessions'); 
    37         // session valid for whole board 
    38         ini_set('session.cookie_path', substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') - 11)); 
    39     // if included from admin subdirectory 
    40     } elseif (strstr($_SERVER['PHP_SELF'], 'admin')) { 
    41         // save session info in subdirectory instead of system-wide /tmp/ 
    42         ini_set('session.save_path', substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/') - 6) . '/sessions'); 
    43         // session valid for whole board 
    44         ini_set('session.cookie_path', substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') - 5)); 
    45     } else { 
    46         // save session info in subdirectory instead of system-wide /tmp/ 
    47         ini_set('session.save_path', substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')) . '/sessions'); 
    48         // session valid for whole board 
    49         ini_set('session.cookie_path', substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') + 1)); 
    50     } 
     27    // save session info in subdirectory instead of system-wide /tmp/ 
     28    ini_set('session.save_path', $SETTINGS['fspath'] . 'sessions'); 
     29    // session valid for whole board 
     30    ini_set('session.cookie_path', $SETTINGS['fspath']); 
    5131    // name of the session variable 
    5232    ini_set('session.name', 's'); 
  • trunk/redirectors/logout.php

    r1 r3  
    5757    if ($_SESSION['remember'] === 1) { 
    5858        // delete cookie 
    59         @setcookie('sb_user', '', -1, substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/') - 11)); 
     59        @setcookie('sb_user', '', -1, $SETTINGS['webpath']); 
    6060    } 
    6161    $_SESSION['remember'] = 0; 
     
    6464    session_start(); 
    6565    // update in database 
    66     $q = $C->prepare('UPDATE '.$SETTINGS['dbtableprefix'].'online SET onlinememberid=0 WHERE onlinesession=:session'); 
     66    $q = $C->prepare('UPDATE ' . $SETTINGS['dbtableprefix'] . 'online SET onlinememberid=0 WHERE onlinesession=:session'); 
    6767    $q->bindParam(':session', session_id(), PDO::PARAM_STR, 40); 
    6868    $q->execute();