zeroneed.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. //----------------------------------------------------------------------------------------------------
  3. // ZERONEED PHP WEB FRAMEWORK
  4. //----------------------------------------------------------------------------------------------------
  5. //
  6. // Author : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  7. // Site : www.znframework.com
  8. // License : The MIT License
  9. // Copyright : Copyright (c) 2012-2016, ZN Framework
  10. //
  11. //----------------------------------------------------------------------------------------------------
  12. //----------------------------------------------------------------------------------------------------
  13. // REAL_BASE_DIR
  14. //----------------------------------------------------------------------------------------------------
  15. define('REAL_BASE_DIR', realpath(__DIR__).DIRECTORY_SEPARATOR);
  16. //----------------------------------------------------------------------------------------------------
  17. // INTERNAL_DIR
  18. //----------------------------------------------------------------------------------------------------
  19. //
  20. // @return Internal/
  21. //
  22. //----------------------------------------------------------------------------------------------------
  23. define('INTERNAL_DIR', 'Internal/');
  24. //----------------------------------------------------------------------------------------------------
  25. // CORE_DIR
  26. //----------------------------------------------------------------------------------------------------
  27. //
  28. // @return Internal/Core/
  29. //
  30. //----------------------------------------------------------------------------------------------------
  31. define('CORE_DIR', INTERNAL_DIR.'Core/');
  32. //----------------------------------------------------------------------------------------------------
  33. // EXTERNAL_DIR
  34. //----------------------------------------------------------------------------------------------------
  35. //
  36. // @return External/
  37. //
  38. //----------------------------------------------------------------------------------------------------
  39. define('EXTERNAL_DIR', 'External/');
  40. //----------------------------------------------------------------------------------------------------
  41. // EXTERNAL_CONFIG_DIR
  42. //----------------------------------------------------------------------------------------------------
  43. //
  44. // @return External/Config/
  45. //
  46. //----------------------------------------------------------------------------------------------------
  47. define('EXTERNAL_CONFIG_DIR', EXTERNAL_DIR.'Config/');
  48. //----------------------------------------------------------------------------------------------------
  49. // INTERNAL_CONFIG_DIR
  50. //----------------------------------------------------------------------------------------------------
  51. //
  52. // @return Internal/Config/
  53. //
  54. //----------------------------------------------------------------------------------------------------
  55. define('INTERNAL_CONFIG_DIR', INTERNAL_DIR.'Config/');
  56. //----------------------------------------------------------------------------------------------------
  57. // Dahili Uygulama Ayarları
  58. //----------------------------------------------------------------------------------------------------
  59. require_once INTERNAL_CONFIG_DIR . 'Application.php';
  60. //----------------------------------------------------------------------------------------------------
  61. //----------------------------------------------------------------------------------------------------
  62. // Global Application Variable
  63. //----------------------------------------------------------------------------------------------------
  64. global $config;
  65. $application = $config['Application'];
  66. //----------------------------------------------------------------------------------------------------
  67. //----------------------------------------------------------------------------------------------------
  68. // Directory Index
  69. //----------------------------------------------------------------------------------------------------
  70. define('DIRECTORY_INDEX', $application['directoryIndex']);
  71. //----------------------------------------------------------------------------------------------------
  72. //----------------------------------------------------------------------------------------------------
  73. // Uygulama Türü
  74. //----------------------------------------------------------------------------------------------------
  75. define('APPMODE', strtolower($application['mode']));
  76. //----------------------------------------------------------------------------------------------------
  77. //----------------------------------------------------------------------------------------------------
  78. // Kullanılabilir Uygulama Seçenekleri
  79. //----------------------------------------------------------------------------------------------------
  80. switch( APPMODE )
  81. {
  82. //------------------------------------------------------------------------------------------------
  83. // Publication Yayın Modu
  84. // Tüm hatalar kapalıdır.
  85. // Projenin tamamlanmasından sonra bu modun kullanılması önerilir.
  86. //------------------------------------------------------------------------------------------------
  87. case 'publication' :
  88. error_reporting(0);
  89. break;
  90. //------------------------------------------------------------------------------------------------
  91. //------------------------------------------------------------------------------------------------
  92. // Restoration Onarım Modu
  93. // Hataların görünümü görecelidir.
  94. //------------------------------------------------------------------------------------------------
  95. case 'restoration' :
  96. //------------------------------------------------------------------------------------------------
  97. // Development Geliştirme Modu
  98. // Tüm hatalar açıktır.
  99. //------------------------------------------------------------------------------------------------
  100. case 'development' :
  101. error_reporting(-1);
  102. break;
  103. //------------------------------------------------------------------------------------------------
  104. //------------------------------------------------------------------------------------------------
  105. // Farklı bir kullanım hatası
  106. //------------------------------------------------------------------------------------------------
  107. default: exit('Invalid Application Mode! Available Options: development, restoration or publication');
  108. //------------------------------------------------------------------------------------------------
  109. }
  110. //----------------------------------------------------------------------------------------------------
  111. //----------------------------------------------------------------------------------------------------
  112. // Ön Yüklenenler
  113. //----------------------------------------------------------------------------------------------------
  114. require_once CORE_DIR . 'Preloading.php';
  115. //----------------------------------------------------------------------------------------------------
  116. //----------------------------------------------------------------------------------------------------
  117. // Uygulama Dizini
  118. //----------------------------------------------------------------------------------------------------
  119. $appdir = $application['directory']['others'];
  120. if( is_array($appdir) && ! empty($appdir[host()]) )
  121. {
  122. $appdir = $appdir[host()];
  123. }
  124. elseif( defined('URIAPPDIR') )
  125. {
  126. $appdir = URIAPPDIR;
  127. }
  128. elseif( is_array($appdir) )
  129. {
  130. $appdir = $application['directory']['default'];
  131. }
  132. //----------------------------------------------------------------------------------------------------
  133. // Applications & Restorasyons Directories
  134. //----------------------------------------------------------------------------------------------------
  135. define('APPDIR', suffix(APPLICATIONS_DIR.$appdir));
  136. define('RESDIR', suffix(RESTORATIONS_DIR.$appdir));
  137. //----------------------------------------------------------------------------------------------------
  138. if( ! is_dir(APPDIR) )
  139. {
  140. exit('"'.$appdir.'" Application Directory Not Found!');
  141. }
  142. //----------------------------------------------------------------------------------------------------
  143. // Benchmarking Test
  144. //----------------------------------------------------------------------------------------------------
  145. $benchmark = $application['benchmark'];
  146. //----------------------------------------------------------------------------------------------------
  147. if( $benchmark === true )
  148. {
  149. //------------------------------------------------------------------------------------------------
  150. // Sisteminin Açılış Zamanını Hesaplamayı Başlat
  151. //------------------------------------------------------------------------------------------------
  152. $start = microtime();
  153. //------------------------------------------------------------------------------------------------
  154. }
  155. //----------------------------------------------------------------------------------------------------
  156. // Internal Hierarchy -- Internal/Core/Hierarchy.php
  157. //----------------------------------------------------------------------------------------------------
  158. require_once HIERARCHY_DIR;
  159. //----------------------------------------------------------------------------------------------------
  160. if( $benchmark === true )
  161. {
  162. //------------------------------------------------------------------------------------------------
  163. // Sistemin Açılış Zamanını Hesaplamayı Bitir
  164. //------------------------------------------------------------------------------------------------
  165. $finish = microtime();
  166. //------------------------------------------------------------------------------------------------
  167. //------------------------------------------------------------------------------------------------
  168. // System Elapsed Time Calculating
  169. //------------------------------------------------------------------------------------------------
  170. $elapsedTime = $finish - $start;
  171. //------------------------------------------------------------------------------------------------
  172. //------------------------------------------------------------------------------------------------
  173. // Sistemin Bellek Kullanımını Hesapla
  174. //------------------------------------------------------------------------------------------------
  175. $memoryUsage = memory_get_usage();
  176. //------------------------------------------------------------------------------------------------
  177. //------------------------------------------------------------------------------------------------
  178. // Sistemin Maksimum Bellek Kullanımını Hesapla
  179. //------------------------------------------------------------------------------------------------
  180. $maxMemoryUsage = memory_get_peak_usage();
  181. //------------------------------------------------------------------------------------------------
  182. //------------------------------------------------------------------------------------------------
  183. // Benchmark Performans Sonuç Tablosu
  184. //------------------------------------------------------------------------------------------------
  185. $benchmarkData =
  186. [
  187. 'elapsedTime' => $elapsedTime,
  188. 'memoryUsage' => $memoryUsage,
  189. 'maxMemoryUsage' => $maxMemoryUsage
  190. ];
  191. $benchResult = Import::template('BenchmarkTable', $benchmarkData, true);
  192. //------------------------------------------------------------------------------------------------
  193. //------------------------------------------------------------------------------------------------
  194. // Benchmark Performans Sonuç Tablosu Yazdırılıyor
  195. //------------------------------------------------------------------------------------------------
  196. echo $benchResult;
  197. //------------------------------------------------------------------------------------------------
  198. //------------------------------------------------------------------------------------------------
  199. // Sistem benchmark performans test sonuçlarını raporla.
  200. //------------------------------------------------------------------------------------------------
  201. report('Benchmarking Test Result', $benchResult, 'BenchmarkTestResults');
  202. //------------------------------------------------------------------------------------------------
  203. }