perf.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <?php
  2. /* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/system/perf.php
  19. * \brief Page to show Performance information
  20. */
  21. require '../../main.inc.php';
  22. require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  26. $langs->load("admin");
  27. $langs->load("install");
  28. $langs->load("other");
  29. if (! $user->admin)
  30. accessforbidden();
  31. if (GETPOST('action') == 'donothing')
  32. {
  33. exit;
  34. }
  35. /*
  36. * View
  37. */
  38. $form=new Form($db);
  39. $nowstring=dol_print_date(dol_now(),'dayhourlog');
  40. llxHeader();
  41. print_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup');
  42. print $langs->trans("YouMayFindPerfAdviceHere",'http://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' (<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Reload").'</a>)<br>';
  43. // Recupere la version de PHP
  44. $phpversion=version_php();
  45. print "<br>PHP - ".$langs->trans("Version").": ".$phpversion."<br>\n";
  46. // Recupere la version du serveur web
  47. print "<br>Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
  48. // XDebug
  49. print '<br>';
  50. print '<strong>'.$langs->trans("XDebug").'</strong>: ';
  51. $test=!function_exists('xdebug_is_enabled');
  52. if ($test) print img_picto('','tick.png').' '.$langs->trans("NotInstalled");
  53. else
  54. {
  55. print img_picto('','warning').' '.$langs->trans("XDebugInstalled");
  56. print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
  57. }
  58. print '<br>';
  59. // Applicative cache
  60. print '<br>';
  61. print '<strong>'.$langs->trans("ApplicativeCache").'</strong>: ';
  62. $test=!empty($conf->memcached->enabled);
  63. if ($test)
  64. {
  65. if (!empty($conf->global->MEMCACHED_SERVER))
  66. {
  67. print img_picto('','tick.png').' '.$langs->trans("MemcachedAvailableAndSetup");
  68. print ' '.$langs->trans("MoreInformation").' <a href="'.dol_buildpath('/memcached/admin/memcached.php',1).'">Memcached module admin page</a>';
  69. }
  70. else
  71. {
  72. print img_picto('','warning').' '.$langs->trans("MemcachedModuleAvailableButNotSetup");
  73. print ' <a href="'.dol_buildpath('/memcached/admin/memcached.php',1).'">Memcached module admin page</a>';
  74. }
  75. }
  76. else print img_picto('','warning').' '.$langs->trans("MemcachedNotAvailable");
  77. print '</br>';
  78. // OPCode cache
  79. print '<br>';
  80. print '<strong>'.$langs->trans("OPCodeCache").'</strong>: ';
  81. $foundcache=0;
  82. $test=function_exists('xcache_info');
  83. if (! $foundcache && $test)
  84. {
  85. $foundcache++;
  86. print img_picto('','tick.png').' '.$langs->trans("XCacheInstalled");
  87. print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xcache.php'.'">Xcache admin page</a>';
  88. }
  89. $test=function_exists('eaccelerator_info');
  90. if (! $foundcache && $test)
  91. {
  92. $foundcache++;
  93. print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled");
  94. }
  95. $test=function_exists('apc_cache_info');
  96. if (! $foundcache && $test)
  97. {
  98. //var_dump(apc_cache_info());
  99. if (ini_get('apc.enabled'))
  100. {
  101. $foundcache++;
  102. print img_picto('','tick.png').' '.$langs->trans("APCInstalled");
  103. }
  104. else
  105. {
  106. print img_picto('','warning').' '.$langs->trans("APCCacheInstalledButDisabled");
  107. }
  108. }
  109. if (! $foundcache) print $langs->trans("NoOPCodeCacheFound");
  110. print '<br>';
  111. // HTTPCacheStaticResources
  112. print '<script type="text/javascript" language="javascript">
  113. jQuery(document).ready(function() {
  114. var getphpurl;
  115. var cachephpstring;
  116. var compphpstring;
  117. getphpurl = $.ajax({
  118. type: "GET",
  119. url: \''.DOL_URL_ROOT.'/index.php\',
  120. cache: false,
  121. /* async: false, */
  122. /* crossDomain: true,*/
  123. success: function () {
  124. cachephpstring=getphpurl.getResponseHeader(\'Cache-Control\');
  125. /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */
  126. /*alert(\'php:\'+cachephpstring);*/
  127. if (cachephpstring == null || cachephpstring.indexOf("no-cache") !== -1)
  128. {
  129. jQuery("#httpcachephpok").hide();
  130. jQuery("#httpcachephpko").show();
  131. }
  132. else
  133. {
  134. jQuery("#httpcachephpok").show();
  135. jQuery("#httpcachephpko").hide();
  136. }
  137. compphpstring=getphpurl.getResponseHeader(\'Content-Encoding\');
  138. /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */
  139. /*alert(\'php:\'+compphpstring);*/
  140. if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1))
  141. {
  142. jQuery("#httpcompphpok").hide();
  143. jQuery("#httpcompphpko").show();
  144. }
  145. else
  146. {
  147. jQuery("#httpcompphpok").show();
  148. jQuery("#httpcompphpko").hide();
  149. }
  150. }
  151. })
  152. var getcssurl;
  153. var cachecssstring;
  154. var compcssstring;
  155. getcssurl = $.ajax({
  156. type: "GET",
  157. url: \''.DOL_URL_ROOT.'/includes/jquery/css/smoothness/jquery-ui-latest.custom.css\',
  158. cache: false,
  159. /* async: false, */
  160. /*crossDomain: true, */
  161. success: function () {
  162. cachecssstring=getcssurl.getResponseHeader(\'Cache-Control\');
  163. /* alert(\'css:\'+getcssurl.getAllResponseHeaders()); */
  164. /*alert(\'css:\'+cachecssstring);*/
  165. if (cachecssstring != null && cachecssstring.indexOf("no-cache") !== -1)
  166. {
  167. jQuery("#httpcachecssok").hide();
  168. jQuery("#httpcachecssko").show();
  169. }
  170. else
  171. {
  172. jQuery("#httpcachecssok").show();
  173. jQuery("#httpcachecssko").hide();
  174. }
  175. compcssstring=getcssurl.getResponseHeader(\'Content-Encoding\');
  176. /* alert(\'php:\'+getcssurl.getAllResponseHeaders()); */
  177. /*alert(\'php:\'+compcssstring);*/
  178. if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1))
  179. {
  180. jQuery("#httpcompcssok").hide();
  181. jQuery("#httpcompcssko").show();
  182. }
  183. else
  184. {
  185. jQuery("#httpcompcssok").show();
  186. jQuery("#httpcompcssko").hide();
  187. }
  188. }
  189. })
  190. var getcssphpurl;
  191. var cachecssphpstring;
  192. var compcssphpstring;
  193. getcssphpurl = $.ajax({
  194. type: "GET",
  195. url: \''.DOL_URL_ROOT.'/theme/eldy/style.css.php\',
  196. cache: false,
  197. /* async: false, */
  198. /*crossDomain: true,*/
  199. success: function () {
  200. cachecssphpstring=getcssphpurl.getResponseHeader(\'Cache-Control\');
  201. /* alert(\'cssphp:\'+getcssphpurl.getAllResponseHeaders()); */
  202. /*alert(\'cssphp:\'+cachecssphpstring);*/
  203. if (cachecssphpstring != null && cachecssphpstring.indexOf("no-cache") !== -1)
  204. {
  205. jQuery("#httpcachecssphpok").hide();
  206. jQuery("#httpcachecssphpko").show();
  207. }
  208. else
  209. {
  210. jQuery("#httpcachecssphpok").show();
  211. jQuery("#httpcachecssphpko").hide();
  212. }
  213. compcssphpstring=getcssphpurl.getResponseHeader(\'Content-Encoding\');
  214. /* alert(\'php:\'+getcssphpurl.getAllResponseHeaders()); */
  215. /*alert(\'php:\'+compcssphpstring);*/
  216. if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1))
  217. {
  218. jQuery("#httpcompcssphpok").hide();
  219. jQuery("#httpcompcssphpko").show();
  220. }
  221. else
  222. {
  223. jQuery("#httpcompcssphpok").show();
  224. jQuery("#httpcompcssphpko").hide();
  225. }
  226. }
  227. })
  228. var getimgurl;
  229. var cacheimgstring;
  230. var compimgstring;
  231. getimgurl = $.ajax({
  232. type: "GET",
  233. url: \''.DOL_URL_ROOT.'/theme/eldy/img/help.png\',
  234. cache: false,
  235. /* async: false, */
  236. /*crossDomain: true,*/
  237. success: function () {
  238. cacheimgstring=getimgurl.getResponseHeader(\'Cache-Control\');
  239. /* alert(\'img:\'+getimgurl.getAllResponseHeaders()); */
  240. /*alert(\'img:\'+cacheimgstring);*/
  241. if (cacheimgstring != null && cacheimgstring.indexOf("no-cache") !== -1)
  242. {
  243. jQuery("#httpcacheimgok").hide();
  244. jQuery("#httpcacheimgko").show();
  245. }
  246. else
  247. {
  248. jQuery("#httpcacheimgok").show();
  249. jQuery("#httpcacheimgko").hide();
  250. }
  251. compimgstring=getimgurl.getResponseHeader(\'Content-Encoding\');
  252. /* alert(\'php:\'+getimgurl.getAllResponseHeaders()); */
  253. /*alert(\'php:\'+compimgstring);*/
  254. if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1))
  255. {
  256. jQuery("#httpcompimgok").hide();
  257. jQuery("#httpcompimgko").show();
  258. }
  259. else
  260. {
  261. jQuery("#httpcompimgok").show();
  262. jQuery("#httpcompimgko").hide();
  263. }
  264. }
  265. })
  266. var getjsurl;
  267. var cachejsstring;
  268. var compjsstring;
  269. getjsurl = $.ajax({
  270. type: "GET",
  271. url: \''.DOL_URL_ROOT.'/core/js/lib_head.js\',
  272. cache: false,
  273. /* async: false, */
  274. /* crossDomain: true,*/
  275. success: function () {
  276. cachejsstring=getjsurl.getResponseHeader(\'Cache-Control\');
  277. /*alert(\'js:\'+getjsurl.getAllResponseHeaders());*/
  278. /*alert(\'js:\'+cachejsstring);*/
  279. if (cachejsstring != null && cachejsstring.indexOf("no-cache") !== -1)
  280. {
  281. jQuery("#httpcachejsok").hide();
  282. jQuery("#httpcachejsko").show();
  283. }
  284. else
  285. {
  286. jQuery("#httpcachejsok").show();
  287. jQuery("#httpcachejsko").hide();
  288. }
  289. compjsstring=getjsurl.getResponseHeader(\'Content-Encoding\');
  290. /* alert(\'js:\'+getjsurl.getAllResponseHeaders()); */
  291. /*alert(\'js:\'+compjsstring);*/
  292. if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1))
  293. {
  294. jQuery("#httpcompjsok").hide();
  295. jQuery("#httpcompjsko").show();
  296. }
  297. else
  298. {
  299. jQuery("#httpcompjsok").show();
  300. jQuery("#httpcompjsko").hide();
  301. }
  302. }
  303. })
  304. var getjsphpurl;
  305. var cachejsphpstring;
  306. var compjsphpstring;
  307. getjsphpurl = $.ajax({
  308. type: "GET",
  309. url: \''.DOL_URL_ROOT.'/core/js/datepicker.js.php\',
  310. cache: false,
  311. /* async: false, */
  312. /* crossDomain: true,*/
  313. success: function () {
  314. cachejsphpstring=getjsphpurl.getResponseHeader(\'Cache-Control\');
  315. /* alert(\'jsphp:\'+getjsphpurl.getAllResponseHeaders()); */
  316. /*alert(\'jsphp:\'+cachejsphpstring);*/
  317. if (cachejsphpstring != null && cachejsphpstring.indexOf("no-cache") !== -1)
  318. {
  319. jQuery("#httpcachejsphpok").hide();
  320. jQuery("#httpcachejsphpko").show();
  321. }
  322. else
  323. {
  324. jQuery("#httpcachejsphpok").show();
  325. jQuery("#httpcachejsphpko").hide();
  326. }
  327. compjsphpstring=getjsphpurl.getResponseHeader(\'Content-Encoding\');
  328. /* alert(\'php:\'+getjsphpurl.getAllResponseHeaders()); */
  329. /*alert(\'php:\'+compjsphpstring);*/
  330. if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1))
  331. {
  332. jQuery("#httpcompjsphpok").hide();
  333. jQuery("#httpcompjsphpko").show();
  334. }
  335. else
  336. {
  337. jQuery("#httpcompjsphpok").show();
  338. jQuery("#httpcompjsphpko").hide();
  339. }
  340. }
  341. })
  342. });
  343. </script>';
  344. print '<br>';
  345. print '<strong>'.$langs->trans("HTTPCacheStaticResources").' - ';
  346. print $langs->trans("CacheByServer").':</strong><br>';
  347. // No cahce on PHP
  348. //print '<div id="httpcachephpok">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'php (.php)').'</div>';
  349. //print '<div id="httpcachephpko">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeNotCached",'php (.php)').'</div>';
  350. // Cache on rest
  351. print '<div id="httpcachecssok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'css (.css)').'</div>';
  352. print '<div id="httpcachecssko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'css (.css)').'</div>';
  353. print '<div id="httpcachecssphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'css (.css.php)').'</div>';
  354. print '<div id="httpcachecssphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'css (.css.php)').'</div>';
  355. print '<div id="httpcacheimgok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'img (.png)').'</div>';
  356. print '<div id="httpcacheimgko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'img (.png)').'</div>';
  357. print '<div id="httpcachejsok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'javascript (.js)').'</div>';
  358. print '<div id="httpcachejsko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'javascript (.js)').'</div>';
  359. print '<div id="httpcachejsphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'javascript (.js.php)').'</div>';
  360. print '<div id="httpcachejsphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'javascript (.js.php)').'</div>';
  361. print '<br>';
  362. print '<strong>'.$langs->trans("HTTPCacheStaticResources").' - ';
  363. print $langs->trans("CacheByClient").':</strong><br>';
  364. print $langs->trans("TestNotPossibleWithCurrentBrowsers").'<br>';
  365. // Compressions
  366. print '<br>';
  367. print '<strong>'.$langs->trans("CompressionOfResources").'</strong>: ';
  368. //$tmp=getURLContent(DOL_URL_ROOT.'/index.php','GET');var_dump($tmp);
  369. print '<br>';
  370. // on PHP
  371. print '<div id="httpcompphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'php (.php)').'</div>';
  372. print '<div id="httpcompphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'php (.php)').'</div>';
  373. // on rest
  374. print '<div id="httpcompcssok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'css (.css)').'</div>';
  375. print '<div id="httpcompcssko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'css (.css)').'</div>';
  376. print '<div id="httpcompcssphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'css (.css.php)').'</div>';
  377. print '<div id="httpcompcssphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'css (.css.php)').'</div>';
  378. //print '<div id="httpcompimgok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'img (.png)').'</div>';
  379. //print '<div id="httpcompimgko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'img (.png)').'</div>';
  380. print '<div id="httpcompjsok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'javascript (.js)').'</div>';
  381. print '<div id="httpcompjsko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'javascript (.js)').'</div>';
  382. print '<div id="httpcompjsphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'javascript (.js.php)').'</div>';
  383. print '<div id="httpcompjsphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'javascript (.js.php)').'</div>';
  384. // Database driver
  385. print '<br>';
  386. print '<strong>'.$langs->trans("DriverType").'</strong>: ';
  387. print '<br>';
  388. if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
  389. {
  390. $test=($conf->db->type == 'mysqli');
  391. if ($test)
  392. {
  393. print img_picto('','tick.png').' '.$langs->trans("YouUseBestDriver",$conf->db->type);
  394. }
  395. else
  396. {
  397. print img_picto('','warning.png').' '.$langs->trans("YouDoNotUseBestDriver",$conf->db->type,'mysqli');
  398. }
  399. print '<br>';
  400. }
  401. // Product search
  402. print '<br>';
  403. print '<strong>'.$langs->trans("SearchOptim").'</strong>: ';
  404. print '<br>';
  405. $tab = array();
  406. $sql = "SELECT COUNT(*) as nb";
  407. $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
  408. $resql=$db->query($sql);
  409. if ($resql)
  410. {
  411. $limitforoptim=10000;
  412. $num=$db->num_rows($resql);
  413. $obj=$db->fetch_object($resql);
  414. $nb=$obj->nb;
  415. if ($nb > $limitforoptim)
  416. {
  417. if (empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
  418. {
  419. print img_picto('','warning.png').' '.$langs->trans("YouHaveXProductUseSearchOptim",$nb);
  420. }
  421. else
  422. {
  423. print img_picto('','tick.png').' '.$langs->trans("YouHaveXProductAndSearchOptimOn",$nb);
  424. }
  425. }
  426. else
  427. {
  428. print img_picto('','tick.png').' '.$langs->trans("NbOfProductIsLowerThanNoPb",$nb);
  429. }
  430. print '<br>';
  431. $db->free($resql);
  432. }
  433. // Browser
  434. print '<br>';
  435. print '<strong>'.$langs->trans("Browser").'</strong>:<br>';
  436. if (! in_array($conf->browser->name, array('chrome','opera','safari','firefox')))
  437. {
  438. print img_picto('','warning.png').' '.$langs->trans("BrowserIsKO",$conf->browser->name);
  439. }
  440. else
  441. {
  442. print img_picto('','tick.png').' '.$langs->trans("BrowserIsOK",$conf->browser->name);
  443. }
  444. print '<br>';
  445. // Database statistics update
  446. /*
  447. print '<br>';
  448. print '<strong>'.$langs->trans("DatabaseStatistics").'</strong>: ';
  449. print '<br>';
  450. */
  451. llxFooter();
  452. $db->close();