[ Index ]
 

Code source de Phorum 5.1.25

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/include/admin/ -> install.php (source)

   1  <?php
   2  
   3  ////////////////////////////////////////////////////////////////////////////////
   4  //                                                                            //
   5  //   Copyright (C) 2006  Phorum Development Team                              //
   6  //   http://www.phorum.org                                                    //
   7  //                                                                            //
   8  //   This program is free software. You can redistribute it and/or modify     //
   9  //   it under the terms of either the current Phorum License (viewable at     //
  10  //   phorum.org) or the Phorum License that was distributed with this file    //
  11  //                                                                            //
  12  //   This program is distributed in the hope that it will be useful,          //
  13  //   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
  14  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
  15  //                                                                            //
  16  //   You should have received a copy of the Phorum License                    //
  17  //   along with this program.                                                 //
  18  ////////////////////////////////////////////////////////////////////////////////
  19  
  20      if(!defined("PHORUM_ADMIN")) return;
  21  
  22      if(!phorum_db_check_connection()){
  23          echo "A database connection could not be established.  Please edit include/db/config.php.";
  24          return;
  25      }
  26  
  27  
  28      if(!file_exists("./include/admin/PhorumInputForm.php")) {
  29  
  30          echo "./include/admin/PhorumInputForm.php doesn't exist but its required for the Phorum-Admin.<br />Please check that this file <strong>with this name</strong> exists.<br />E.g. some ftp-clients change the names to be all lower-case.";
  31  
  32          return;
  33      }
  34  
  35      if(!file_exists("./include/admin/PhorumAdminMenu.php")) {
  36          echo "<br /><br />./include/admin/PhorumAdminMenu.php doesn't exist but its required for the Phorum-Admin.<br />Please check that this file <strong>with this name</strong> exists.<br />E.g. some ftp-clients change the names to be all lower-case.";
  37  
  38          return;
  39      }
  40  
  41  
  42  
  43      include_once  "./include/admin/PhorumInputForm.php";
  44  
  45      if(empty($_POST["step"])){
  46          $step = 0;
  47      } else {
  48          $step = $_POST["step"];
  49      }
  50  
  51      if(count($_POST)){
  52  
  53          // THIS IS THE WORK STEP
  54  
  55          switch ($step){
  56  
  57              case 5:
  58  
  59                  if(!empty($_POST["admin_user"]) && !empty($_POST["admin_pass"]) && !empty($_POST["admin_pass2"]) && !empty($_POST["admin_email"])){
  60                      if($_POST["admin_pass"]!=$_POST["admin_pass2"]){
  61                          echo "The password fields do not match<br />";
  62                          $step=4;
  63                      } elseif(phorum_user_check_login($_POST["admin_user"], $_POST["admin_pass"])){
  64                          if($PHORUM["user"]["admin"]){
  65                              echo "Admin user already exists and has permissions<br />";
  66                          } else {
  67                              echo "That user already exists but does not have admin permissions<br />";
  68                              $step=4;
  69                          }
  70                      } else {
  71  
  72                          // add the user
  73                          $user = array( "username"=>$_POST["admin_user"], "password"=>$_POST["admin_pass"], "email"=>$_POST["admin_email"], "active"=>1, "admin"=>1 );
  74  
  75                          if(!phorum_user_add($user)){
  76  
  77                              echo "There was an error adding the user.<br />";
  78                              $step=4;
  79                          }
  80  
  81                          // set the default http_path so we can continue.
  82                          if(!empty($_SERVER["HTTP_REFERER"])) {
  83                              $http_path=$_SERVER["HTTP_REFERER"];
  84                          } elseif(!empty($_SERVER['HTTP_HOST'])) {
  85                              $http_path="http://".$_SERVER['HTTP_HOST'];
  86                              $http_path.=$_SERVER['PHP_SELF'];
  87                          } else {
  88                              $http_path="http://".$_SERVER['SERVER_NAME'];
  89                              $http_path.=$_SERVER['PHP_SELF'];
  90                          }
  91                          phorum_db_update_settings(array("http_path"=>dirname($http_path)));
  92                          phorum_db_update_settings(array("system_email_from_address"=>$_POST["admin_email"]));
  93  
  94  
  95                      }
  96                  } else {
  97                      echo "Please fill in all fields.<br />";
  98                      $step=4;
  99                  }
 100  
 101                  break;
 102          }
 103  
 104      }
 105  
 106      // THIS IS THE OUTPUT STEP
 107  
 108      if($PHORUM["installed"]) $step=5;
 109  
 110      switch ($step){
 111  
 112          case 0:
 113  
 114              $frm =& new PhorumInputForm ("", "post", "Continue ->");
 115              $frm->addbreak("Welcome to Phorum");
 116              $frm->addmessage("This wizard will setup Phorum on your server.  The first step is to prepare the database.  Phorum has already confirmed that it can connect to your database.  Press continue when you are ready.");
 117              $frm->hidden("module", "install");
 118              $frm->hidden("step", "2");
 119              $frm->show();
 120  
 121              break;
 122  
 123          case 2:
 124              // ok, fresh install
 125  
 126              $err=phorum_db_create_tables();
 127  
 128              if($err){
 129                  $message="Could not create tables, database said:<blockquote>$err</blockquote>";
 130                  $message.="Your database user will need to have create table permissions.  If you know what the error is (tables already exist, etc.) and want to continue, click the button below.";
 131              } else {
 132                  $message="Tables created.  Next we will check your cache settings. Press continue when ready.";
 133  
 134                  // setup vars for initial settings
 135                  $tmp_dir = (substr(__FILE__, 0, 1)=="/") ? "/tmp" : "C:\\Windows\\Temp";
 136  
 137                  $default_forum_options=array(
 138                  'forum_id'=>0,
 139                  'moderation'=>0,
 140                  'email_moderators'=>0,
 141                  'pub_perms'=>1,
 142                  'reg_perms'=>15,
 143                  'display_fixed'=>0,
 144                  'template'=>'default',
 145                  'language'=>'english',
 146                  'threaded_list'=>0,
 147                  'threaded_read'=>0,
 148                  'reverse_threading'=>0,
 149                  'float_to_top'=>1,
 150                  'list_length_flat'=>30,
 151                  'list_length_threaded'=>15,
 152                  'read_length'=>30,
 153                  'display_ip_address'=>0,
 154                  'allow_email_notify'=>0,
 155                  'check_duplicate'=>1,
 156                  'count_views'=>2,
 157                  'max_attachments'=>0,
 158                  'allow_attachment_types'=>'',
 159                  'max_attachment_size'=>0,
 160                  'max_totalattachment_size'=>0,
 161                  'vroot'=>0,
 162                  );
 163  
 164                  // insert the default module settings
 165                  // hooks
 166  
 167                  $hooks_initial=array(
 168                  'format'=>array(
 169                          'mods'=>array('smileys','bbcode'),
 170                          'funcs'=>array('phorum_mod_smileys','phorum_bb_code')
 171                          )
 172                  );
 173  
 174                  $mods_initial=array(
 175                      'html'   =>0,
 176                      'replace'=>0,
 177                      'smileys'=>1,
 178                      'bbcode' =>1
 179                  );
 180  
 181                  // set initial settings
 182                  $settings=array(
 183                  "title" => "Phorum 5",
 184                  "cache" => "$tmp_dir",
 185                  "session_timeout" => "30",
 186                  "short_session_timeout" => "60",
 187                  "tight_security" => "0",
 188                  "session_path" => "/",
 189                  "session_domain" => "",
 190                  "admin_session_salt" => microtime(),
 191                  "cache_users" => "0",
 192                  "cache_rss" => "0",
 193                  "default_template" => "default",
 194                  "default_language" => "english",
 195                  "use_cookies" => "1",
 196                  "use_bcc" => "1",
 197                  "use_rss" => "1",
 198                  "internal_version" => "" . PHORUMINTERNAL . "",
 199                  "PROFILE_FIELDS" => array('num_fields'=>1,0=>array('name'=>'real_name','length'=>'255','html_disabled'=>'1')),
 200                  "enable_pm" => "1",
 201                  "user_edit_timelimit" => "0",
 202                  "enable_new_pm_count" => "1",
 203                  "enable_dropdown_userlist" => "1",
 204                  "enable_moderator_notifications" => "1",
 205                  "show_new_on_index" => "1",
 206                  "dns_lookup" => "1",
 207                  "tz_offset" => "0",
 208                  "user_time_zone" => "1",
 209                  "user_template" => "0",
 210                  "registration_control" => "1",
 211                  "file_uploads" => "0",
 212                  "file_types" => "",
 213                  "max_file_size" => "",
 214                  "file_space_quota" => "",
 215                  "file_offsite" => "0",
 216                  "system_email_from_name" => "",
 217                  "hide_forums" => "1",
 218                  "enable_new_pm_count" => "1",
 219                  "track_user_activity" => "86400",
 220                  "html_title" => "Phorum",
 221                  "head_tags" => "",
 222                  "cache_users" => 0,
 223                  "redirect_after_post" => "list",
 224                  "reply_on_read_page" => 1,
 225                  "status" => "normal",
 226                  "use_new_folder_style" => 1,
 227                  "default_forum_options" => $default_forum_options,
 228                  "hooks"=> $hooks_initial,
 229                  "mods" => $mods_initial
 230  
 231                  );
 232  
 233                  phorum_db_update_settings($settings);
 234  
 235                  // posting forum and test-message
 236  
 237                  // create a test forum
 238                  $forum=array(
 239                  "name"=>'Test Forum',
 240                  "active"=>1,
 241                  "description"=>'This is a test forum.  Feel free to delete it or edit after installation.',
 242                  "template"=>'default',
 243                  "folder_flag"=>0,
 244                  "parent_id"=>0,
 245                  "list_length_flat"=>30,
 246                  "list_length_threaded"=>15,
 247                  "read_length"=>20,
 248                  "moderation"=>0,
 249                  "threaded_list"=>0,
 250                  "threaded_read"=>0,
 251                  "float_to_top"=>1,
 252                  "display_ip_address"=>0,
 253                  "allow_email_notify"=>1,
 254                  "language"=>'english',
 255                  "email_moderators"=>0,
 256                  "display_order"=>0,
 257                  "edit_post"=>1,
 258                  "pub_perms" =>  1,
 259                  "reg_perms" =>  15
 260                  );
 261  
 262                  $GLOBALS["PHORUM"]['forum_id']=phorum_db_add_forum($forum);
 263                  $GLOBALS["PHORUM"]['vroot']=0;
 264  
 265                  // create a test post
 266                  $test_message=array(
 267                  "forum_id" => $GLOBALS['PHORUM']["forum_id"],
 268                  "thread" => 0,
 269                  "parent_id" => 0,
 270                  "author" => 'Phorum Installer',
 271                  "subject" => 'Test Message',
 272                  "email" => '',
 273                  "ip" => '127.0.0.1',
 274                  "user_id" => 0,
 275                  "moderator_post" => 0,
 276                  "closed" => 0,
 277                  "status" => PHORUM_STATUS_APPROVED,
 278                  "sort" => PHORUM_SORT_DEFAULT,
 279                  "msgid" => '',
 280                  "body" => "This is a test message.  You can delete it after install using the admin.\n\nPhorum 5 Team"
 281                  );
 282  
 283                  phorum_db_post_message($test_message);
 284  
 285                  include_once  ("./include/thread_info.php");
 286  
 287                  phorum_update_thread_info($test_message["thread"]);
 288  
 289                  phorum_db_update_forum_stats(true);
 290  
 291              }
 292  
 293              $frm =& new PhorumInputForm ("", "post", "Continue ->");
 294              $frm->addbreak("Creating tables....");
 295              $frm->addmessage($message);
 296              $frm->hidden("step", "6");
 297              $frm->hidden("module", "install");
 298              $frm->show();
 299  
 300              break;
 301  
 302          case 4:
 303  
 304              $frm =& new PhorumInputForm ("", "post");
 305              $frm->hidden("step", "5");
 306              $frm->hidden("module", "install");
 307              $frm->addbreak("Creating An Administrator");
 308              $frm->addmessage("Please enter the following information.  This can be your user information or you can create an administrator that is separate from yourself.<br /><br />Note: If you are using a pre-existing authentication database, please enter the username and password of the admin user that already exists.");
 309              $admin_user = isset($_POST["admin_user"]) ? $_POST["admin_user"] : "";
 310              $admin_email = isset($_POST["admin_email"]) ? $_POST["admin_email"] : "";
 311              $frm->addrow("Admin User Name", $frm->text_box("admin_user", $admin_user, 30));
 312              $frm->addrow("Admin Email Address", $frm->text_box("admin_email", $admin_email, 30));
 313              $frm->addrow("Admin Password", $frm->text_box("admin_pass", "", 30, 0, true));
 314              $frm->addrow("(again)", $frm->text_box("admin_pass2", "", 30, 0, true));
 315              $frm->show();
 316  
 317              break;
 318  
 319          case 5:
 320  
 321              phorum_db_update_settings( array("installed"=>1) );
 322              echo "The setup is complete.  You can now go to <a href=\"$_SERVER[PHP_SELF]\">the admin</a> and start making Phorum all your own.<br /><br /><strong>Here are some things you will want to look at:</strong><br /><br /><a href=\"$_SERVER[PHP_SELF]?module=settings\">The General Settings page</a><br /><br /><a href=\"$_SERVER[PHP_SELF]?module=mods\">Pre-installed modules</a><br /><br /><a href=\"docs/faq.txt\">The FAQ</a><br /><br /><a href=\"docs/performance.txt\">How to get peak performance from Phorum</a><br /><br /><strong>For developers:</strong><br /><br /><a href=\"docs/creating_mods.txt\">Module Creation</a><br /><br /><a href=\"docs/permissions.txt\">How Phorum permisssions work</a><br /><br /><a href=\"docs/CODING-STANDARDS\">The Phorum Team's codings standards</a>";
 323  
 324              break;
 325  
 326          case 6:
 327              // try to figure out if we can write to the cache directory
 328              $message = "";
 329              error_reporting(0);
 330              $err = false;
 331              if ($fp = fopen($PHORUM["cache"] . "/phorum-install-test", "w+")) {
 332                  unlink($PHORUM["cache"] . "/phorum-install-test");
 333              }
 334              else {
 335                  // in this case the normal setting is wrong, so try ./cache
 336                  $PHORUM["cache"] = "./cache";
 337                  $settings = array("cache" => $PHORUM["cache"]);
 338                  if (!phorum_db_update_settings($settings)) {
 339                      $message .= "Database error updating settings.<br />";
 340                      $err = true;
 341                  }
 342                  elseif ($fp = fopen($PHORUM["cache"] . "/phorum-install-test", "w+")) {
 343                      unlink($PHORUM["cache"] . "/phorum-install-test");
 344                  }
 345                  else {
 346                      $err = true;
 347                  }
 348  
 349              }
 350              error_reporting(E_WARN);
 351              if ($message == "") {
 352                  if($err){
 353                      $message.="Your cache directory is not writable. Please change the permissions on '/cache' inside the Phorum directory to allow writing. In Unix, you may have to use this command: chmod 777 cache<br /><br />If you want to continue anyway and set a cache directory manually, press continue. Note that you must do this, Phorum will not work without a valid cache.";
 354                  } else {
 355                      $message.="Cache directory set.  Next we will create a user with administrator privileges.  Press continue when ready.";
 356                  }
 357              }
 358  
 359              $frm =& new PhorumInputForm ("", "post", "Continue ->");
 360              $frm->hidden("module", "install");
 361              $frm->addbreak("Checking cache....");
 362              $frm->addmessage($message);
 363              $frm->hidden("step", "4");
 364              $frm->show();
 365  
 366              break;
 367      }
 368  
 369  ?>


Généré le : Thu Nov 29 12:22:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics