Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Forum] Początek pisania własnego forum
MaestroS
post
Post #1





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 8.11.2006
Skąd: Kanagawa-ken, Japonia

Ostrzeżenie: (10%)
X----


Przeglądałem niedawno strukturę myBB i tak myślę, czy moja koncepcja jest dobra.

Nie jestem profesjonalistą, aczkolwiek w PHP siedzę już od 5 lat. Myślę nad napisaniem kilku projektów do mojego portfolio (forum, CMS, galeria, dziennik szkolny).

Sam początek wygląda tak:

  1. <?
  2. /* Index file */
  3. //Enable buffor
  4. @ob_start() or die("Buffor initialization has failed.");
  5.  
  6. //Enable sessions
  7. @session_start() or die("Session initialization has failed.");
  8.  
  9. //Define constants
  10. define("_nBB_RootDir", dirname(__FILE__));
  11. define("_nBB_CurrentFile", __FILE__);
  12. define("_nBB_Version", 011);
  13.  
  14. //Load pre-core
  15. require_once "inc/classes/init.php";
  16.  
  17.        //Load constant modules
  18.        if (@!file_exists("inc/const_modules.php")) {
  19.            die("Unable to open pre-definition file of constant modules.");
  20.        } else {
  21.            require_once "inc/const_modules.php";
  22.        }
  23.  
  24.        //Check for required directories
  25.        for ($i=0; $i<count($sys_const_dirs); $i++) {
  26.            if (@is_dir($sys_const_dirs[$i]) == FALSE) {
  27.                die("Directory [".$sys_const_dirs[$i]."] could not be found.");
  28.            }
  29.        }
  30.  
  31.        //Check availability of constant modules and attach them
  32.        for ($i=0; $i<count($sys_const_modules); $i++) {
  33.            if (@!file_exists($sys_const_modules[$i])) {
  34.                die("Unable to open ".$sys_const_modules[$i]);
  35.            } else {
  36.                require_once $sys_const_modules[$i];
  37.            }
  38.        }
  39.  
  40.        //Check for availability of constant classes and attach them
  41.        for ($i=0; $i<count($sys_class_list); $i++) {
  42.            if (@!file_exists("inc/classes/".$sys_class_prefix.$sys_class_list[$i].".php")) {
  43.                die("Class ".$sys_class_list[$i]." could not be found.");
  44.            } else {
  45.                require_once "inc/classes/".$sys_class_prefix.$sys_class_list[$i].".php";
  46.            }
  47.        }
  48.        
  49. $nBB = new nBB;
  50. $nBB->initialize;
  51.  
  52. $nDB = new mySQL;
  53.  
  54. ?>


Chcę, aby index.php był tym głównym plikiem, moduł takie jak showthread i inne wywoływane będą przez index.php?module=. Tutaj pojawia się moje pytanie: Za każdym wywołaniem index.php będzie ustanawiane połączenie MySQL ($nDB->connect()) - czy to dobre wyjście? Chodzi mi najbardziej o aspekty wydajnościowe. Przy takim rozwiązaniu (index.php?module=) potrzebowałbym pewnych wskazówek. Wykonanie nie jest dla mnie żadną trudnością, ale nigdy wcześniej nie pisałem for internetowych, myBB, phpBB już nie mówiąc o IPB czy vBulletin to tony kodu, którego nie chcę przeglądać, bo jak coś zobaczę, to skopiuję, a chcę, aby kod był moją indywidualną pracą. Was proszę o jakieś rady dotyczące wydajności czy jakiś innych kosmetycznych aspektów.

Pozdrawiam.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 14:27