dolibarr  9.0.0
perf.php
Go to the documentation of this file.
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 
23 require '../../main.inc.php';
24 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
28 
29 // Load translation files required by the page
30 $langs->loadLangs(array("install","other","admin"));
31 
32 if (! $user->admin)
34 
35 if (GETPOST('action','aZ09') == 'donothing')
36 {
37  exit;
38 }
39 
40 
41 /*
42  * View
43  */
44 
45 $form=new Form($db);
46 $nowstring=dol_print_date(dol_now(),'dayhourlog');
47 
48 llxHeader();
49 
50 print load_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup');
51 
52 print $langs->trans("YouMayFindPerfAdviceHere",'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' (<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Reload").'</a>)<br>';
53 
54 // Recupere la version de PHP
55 $phpversion=version_php();
56 print "<br>PHP - ".$langs->trans("Version").": ".$phpversion."<br>\n";
57 
58 // Recupere la version du serveur web
59 print "<br>Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
60 
61 // XDebug
62 print '<br>';
63 print '<strong>'.$langs->trans("XDebug").'</strong>: ';
64 $test=!function_exists('xdebug_is_enabled');
65 if ($test) print img_picto('','tick.png').' '.$langs->trans("NotInstalled");
66 else
67 {
68  print img_picto('','warning').' '.$langs->trans("XDebugInstalled");
69  print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
70 }
71 print '<br>';
72 
73 // Applicative cache
74 print '<br>';
75 print '<strong>'.$langs->trans("ApplicativeCache").'</strong>: ';
76 $test=!empty($conf->memcached->enabled);
77 if ($test)
78 {
79  if (!empty($conf->global->MEMCACHED_SERVER))
80  {
81  print img_picto('','tick.png').' '.$langs->trans("MemcachedAvailableAndSetup");
82  print ' '.$langs->trans("MoreInformation").' <a href="'.dol_buildpath('/memcached/admin/memcached.php',1).'">Memcached module admin page</a>';
83  }
84  else
85  {
86  print img_picto('','warning').' '.$langs->trans("MemcachedModuleAvailableButNotSetup");
87  print ' <a href="'.dol_buildpath('/memcached/admin/memcached.php',1).'">Memcached module admin page</a>';
88  }
89 }
90 else print img_picto('','warning').' '.$langs->trans("MemcachedNotAvailable");
91 print '</br>';
92 
93 // OPCode cache
94 print '<br>';
95 print '<strong>'.$langs->trans("OPCodeCache").'</strong>: ';
96 $foundcache=0;
97 $test=function_exists('xcache_info');
98 if (! $foundcache && $test)
99 {
100  $foundcache++;
101  print img_picto('','tick.png').' '.$langs->trans("XCacheInstalled");
102  print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xcache.php'.'">Xcache admin page</a>';
103 }
104 $test=function_exists('eaccelerator_info');
105 if (! $foundcache && $test)
106 {
107  $foundcache++;
108  print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled");
109 }
110 $test=function_exists('opcache_get_status');
111 if (! $foundcache && $test)
112 {
113  $foundcache++;
114  print img_picto('','tick.png').' '.$langs->trans("ZendOPCacheInstalled"); // Should be by default starting with PHP 5.5
115  //$tmp=opcache_get_status();
116  //var_dump($tmp);
117 }
118 $test=function_exists('apc_cache_info');
119 if (! $foundcache && $test)
120 {
121  //var_dump(apc_cache_info());
122  if (ini_get('apc.enabled'))
123  {
124  $foundcache++;
125  print img_picto('','tick.png').' '.$langs->trans("APCInstalled");
126  }
127  else
128  {
129  print img_picto('','warning').' '.$langs->trans("APCCacheInstalledButDisabled");
130  }
131 }
132 if (! $foundcache) print $langs->trans("NoOPCodeCacheFound");
133 print '<br>';
134 
135 // HTTPCacheStaticResources
136 print '<script type="text/javascript" language="javascript">
137 jQuery(document).ready(function() {
138  var getphpurl;
139  var cachephpstring;
140  var compphpstring;
141  getphpurl = $.ajax({
142  type: "GET",
143  url: \''.DOL_URL_ROOT.'/index.php\',
144  cache: false,
145  /* async: false, */
146  /* crossDomain: true,*/
147  success: function () {
148  cachephpstring=getphpurl.getResponseHeader(\'Cache-Control\');
149  /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */
150  /*alert(\'php:\'+cachephpstring);*/
151  if (cachephpstring == null || cachephpstring.indexOf("no-cache") !== -1)
152  {
153  jQuery("#httpcachephpok").hide();
154  jQuery("#httpcachephpko").show();
155  }
156  else
157  {
158  jQuery("#httpcachephpok").show();
159  jQuery("#httpcachephpko").hide();
160  }
161  compphpstring=getphpurl.getResponseHeader(\'Content-Encoding\');
162  /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */
163  /*alert(\'php:\'+compphpstring);*/
164  if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1))
165  {
166  jQuery("#httpcompphpok").hide();
167  jQuery("#httpcompphpko").show();
168  }
169  else
170  {
171  jQuery("#httpcompphpok").show();
172  jQuery("#httpcompphpko").hide();
173  }
174  }
175  })
176 
177  var getcssurl;
178  var cachecssstring;
179  var compcssstring;
180  getcssurl = $.ajax({
181  type: "GET",
182  url: \''.DOL_URL_ROOT.'/includes/jquery/css/base/jquery-ui.css\',
183  cache: false,
184  /* async: false, */
185  /*crossDomain: true, */
186  success: function () {
187  cachecssstring=getcssurl.getResponseHeader(\'Cache-Control\');
188  /* alert(\'css:\'+getcssurl.getAllResponseHeaders()); */
189  /*alert(\'css:\'+cachecssstring);*/
190  if (cachecssstring != null && cachecssstring.indexOf("no-cache") !== -1)
191  {
192  jQuery("#httpcachecssok").hide();
193  jQuery("#httpcachecssko").show();
194  }
195  else
196  {
197  jQuery("#httpcachecssok").show();
198  jQuery("#httpcachecssko").hide();
199  }
200  compcssstring=getcssurl.getResponseHeader(\'Content-Encoding\');
201  /* alert(\'php:\'+getcssurl.getAllResponseHeaders()); */
202  /*alert(\'php:\'+compcssstring);*/
203  if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1))
204  {
205  jQuery("#httpcompcssok").hide();
206  jQuery("#httpcompcssko").show();
207  }
208  else
209  {
210  jQuery("#httpcompcssok").show();
211  jQuery("#httpcompcssko").hide();
212  }
213  }
214  })
215 
216  var getcssphpurl;
217  var cachecssphpstring;
218  var compcssphpstring;
219  getcssphpurl = $.ajax({
220  type: "GET",
221  url: \''.DOL_URL_ROOT.'/theme/eldy/style.css.php\',
222  cache: false,
223  /* async: false, */
224  /*crossDomain: true,*/
225  success: function () {
226  cachecssphpstring=getcssphpurl.getResponseHeader(\'Cache-Control\');
227  /* alert(\'cssphp:\'+getcssphpurl.getAllResponseHeaders()); */
228  /*alert(\'cssphp:\'+cachecssphpstring);*/
229  if (cachecssphpstring != null && cachecssphpstring.indexOf("no-cache") !== -1)
230  {
231  jQuery("#httpcachecssphpok").hide();
232  jQuery("#httpcachecssphpko").show();
233  }
234  else
235  {
236  jQuery("#httpcachecssphpok").show();
237  jQuery("#httpcachecssphpko").hide();
238  }
239  compcssphpstring=getcssphpurl.getResponseHeader(\'Content-Encoding\');
240  /* alert(\'php:\'+getcssphpurl.getAllResponseHeaders()); */
241  /*alert(\'php:\'+compcssphpstring);*/
242  if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1))
243  {
244  jQuery("#httpcompcssphpok").hide();
245  jQuery("#httpcompcssphpko").show();
246  }
247  else
248  {
249  jQuery("#httpcompcssphpok").show();
250  jQuery("#httpcompcssphpko").hide();
251  }
252  }
253  })
254 
255  var getimgurl;
256  var cacheimgstring;
257  var compimgstring;
258  getimgurl = $.ajax({
259  type: "GET",
260  url: \''.DOL_URL_ROOT.'/theme/eldy/img/help.png\',
261  cache: false,
262  /* async: false, */
263  /*crossDomain: true,*/
264  success: function () {
265  cacheimgstring=getimgurl.getResponseHeader(\'Cache-Control\');
266  /* alert(\'img:\'+getimgurl.getAllResponseHeaders()); */
267  /*alert(\'img:\'+cacheimgstring);*/
268  if (cacheimgstring != null && cacheimgstring.indexOf("no-cache") !== -1)
269  {
270  jQuery("#httpcacheimgok").hide();
271  jQuery("#httpcacheimgko").show();
272  }
273  else
274  {
275  jQuery("#httpcacheimgok").show();
276  jQuery("#httpcacheimgko").hide();
277  }
278  compimgstring=getimgurl.getResponseHeader(\'Content-Encoding\');
279  /* alert(\'php:\'+getimgurl.getAllResponseHeaders()); */
280  /*alert(\'php:\'+compimgstring);*/
281  if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1))
282  {
283  jQuery("#httpcompimgok").hide();
284  jQuery("#httpcompimgko").show();
285  }
286  else
287  {
288  jQuery("#httpcompimgok").show();
289  jQuery("#httpcompimgko").hide();
290  }
291  }
292  })
293 
294  var getjsurl;
295  var cachejsstring;
296  var compjsstring;
297  getjsurl = $.ajax({
298  type: "GET",
299  url: \''.DOL_URL_ROOT.'/core/js/lib_rare.js\',
300  cache: false,
301  /* async: false, */
302  /* crossDomain: true,*/
303  success: function () {
304  cachejsstring=getjsurl.getResponseHeader(\'Cache-Control\');
305  /*alert(\'js:\'+getjsurl.getAllResponseHeaders());*/
306  /*alert(\'js:\'+cachejsstring);*/
307  if (cachejsstring != null && cachejsstring.indexOf("no-cache") !== -1)
308  {
309  jQuery("#httpcachejsok").hide();
310  jQuery("#httpcachejsko").show();
311  }
312  else
313  {
314  jQuery("#httpcachejsok").show();
315  jQuery("#httpcachejsko").hide();
316  }
317  compjsstring=getjsurl.getResponseHeader(\'Content-Encoding\');
318  /* alert(\'js:\'+getjsurl.getAllResponseHeaders()); */
319  /*alert(\'js:\'+compjsstring);*/
320  if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1))
321  {
322  jQuery("#httpcompjsok").hide();
323  jQuery("#httpcompjsko").show();
324  }
325  else
326  {
327  jQuery("#httpcompjsok").show();
328  jQuery("#httpcompjsko").hide();
329  }
330  }
331  })
332 
333  var getjsphpurl;
334  var cachejsphpstring;
335  var compjsphpstring;
336  getjsphpurl = $.ajax({
337  type: "GET",
338  url: \''.DOL_URL_ROOT.'/core/js/lib_head.js.php\',
339  cache: false,
340  /* async: false, */
341  /* crossDomain: true,*/
342  success: function () {
343  cachejsphpstring=getjsphpurl.getResponseHeader(\'Cache-Control\');
344  /* alert(\'jsphp:\'+getjsphpurl.getAllResponseHeaders()); */
345  /*alert(\'jsphp:\'+cachejsphpstring);*/
346  if (cachejsphpstring != null && cachejsphpstring.indexOf("no-cache") !== -1)
347  {
348  jQuery("#httpcachejsphpok").hide();
349  jQuery("#httpcachejsphpko").show();
350  }
351  else
352  {
353  jQuery("#httpcachejsphpok").show();
354  jQuery("#httpcachejsphpko").hide();
355  }
356  compjsphpstring=getjsphpurl.getResponseHeader(\'Content-Encoding\');
357  /* alert(\'php:\'+getjsphpurl.getAllResponseHeaders()); */
358  /*alert(\'php:\'+compjsphpstring);*/
359  if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1))
360  {
361  jQuery("#httpcompjsphpok").hide();
362  jQuery("#httpcompjsphpko").show();
363  }
364  else
365  {
366  jQuery("#httpcompjsphpok").show();
367  jQuery("#httpcompjsphpko").hide();
368  }
369  }
370  })
371 
372 });
373 </script>';
374 
375 
376 print '<br>';
377 print '<strong>'.$langs->trans("HTTPCacheStaticResources").' - ';
378 print $form->textwithpicto($langs->trans("CacheByServer"), $langs->trans("CacheByServerDesc"));
379 print ':</strong><br>';
380 // No cahce on PHP
381 //print '<div id="httpcachephpok">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'php (.php)').'</div>';
382 //print '<div id="httpcachephpko">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeNotCached",'php (.php)').'</div>';
383 // Cache on rest
384 print '<div id="httpcachecssok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'css (.css)').'</div>';
385 print '<div id="httpcachecssko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'css (.css)').'</div>';
386 print '<div id="httpcachecssphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'css (.css.php)').'</div>';
387 print '<div id="httpcachecssphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'css (.css.php)').'</div>';
388 print '<div id="httpcacheimgok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'img (.png)').'</div>';
389 print '<div id="httpcacheimgko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'img (.png)').'</div>';
390 print '<div id="httpcachejsok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'javascript (.js)').'</div>';
391 print '<div id="httpcachejsko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'javascript (.js)').'</div>';
392 print '<div id="httpcachejsphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCached",'javascript (.js.php)').'</div>';
393 print '<div id="httpcachejsphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCached",'javascript (.js.php)').'</div>';
394 print '<br>';
395 print '<strong>'.$langs->trans("HTTPCacheStaticResources").' - ';
396 print $langs->trans("CacheByClient").':</strong><br>';
397 print $langs->trans("TestNotPossibleWithCurrentBrowsers").'<br>';
398 
399 
400 // Compressions
401 print '<br>';
402 print '<strong>';
403 print $form->textwithpicto($langs->trans("CompressionOfResources"), $langs->trans("CompressionOfResourcesDesc"));
404 print '</strong>: ';
405 //$tmp=getURLContent(DOL_URL_ROOT.'/index.php','GET');var_dump($tmp);
406 print '<br>';
407 // on PHP
408 print '<div id="httpcompphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'php (.php)').'</div>';
409 print '<div id="httpcompphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'php (.php)').'</div>';
410 // on rest
411 print '<div id="httpcompcssok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'css (.css)').'</div>';
412 print '<div id="httpcompcssko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'css (.css)').'</div>';
413 print '<div id="httpcompcssphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'css (.css.php)').'</div>';
414 print '<div id="httpcompcssphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'css (.css.php)').'</div>';
415 //print '<div id="httpcompimgok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'img (.png)').'</div>';
416 //print '<div id="httpcompimgko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'img (.png)').'</div>';
417 print '<div id="httpcompjsok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'javascript (.js)').'</div>';
418 print '<div id="httpcompjsko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'javascript (.js)').'</div>';
419 print '<div id="httpcompjsphpok">'.img_picto('','tick.png').' '.$langs->trans("FilesOfTypeCompressed",'javascript (.js.php)').'</div>';
420 print '<div id="httpcompjsphpko">'.img_picto('','warning.png').' '.$langs->trans("FilesOfTypeNotCompressed",'javascript (.js.php)').'</div>';
421 
422 // Database driver
423 print '<br>';
424 print '<strong>'.$langs->trans("DriverType").'</strong>: ';
425 print '<br>';
426 if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
427 {
428  $test=($conf->db->type == 'mysqli');
429  if ($test)
430  {
431  print img_picto('','tick.png').' '.$langs->trans("YouUseBestDriver",$conf->db->type);
432  }
433  else
434  {
435  print img_picto('','warning.png').' '.$langs->trans("YouDoNotUseBestDriver",$conf->db->type,'mysqli');
436  }
437  print '<br>';
438 }
439 
440 // Product search
441 print '<br>';
442 print '<strong>'.$langs->trans("SearchOptim").'</strong>: ';
443 print '<br>';
444 $tab = array();
445 $sql = "SELECT COUNT(*) as nb";
446 $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
447 $resql=$db->query($sql);
448 if ($resql)
449 {
450  $limitforoptim=10000;
451  $num=$db->num_rows($resql);
452  $obj=$db->fetch_object($resql);
453  $nb=$obj->nb;
454  if ($nb > $limitforoptim)
455  {
456  if (empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE))
457  {
458  print img_picto('','warning.png').' '.$langs->trans("YouHaveXProductUseSearchOptim",$nb);
459  }
460  else
461  {
462  print img_picto('','tick.png').' '.$langs->trans("YouHaveXProductAndSearchOptimOn",$nb);
463  }
464  }
465  else
466  {
467  print img_picto('','tick.png').' '.$langs->trans("NbOfProductIsLowerThanNoPb",$nb);
468  }
469  print '<br>';
470  $db->free($resql);
471 }
472 
473 // Browser
474 print '<br>';
475 print '<strong>'.$langs->trans("Browser").'</strong>:<br>';
476 if (! in_array($conf->browser->name, array('chrome','opera','safari','firefox')))
477 {
478  print img_picto('','warning.png').' '.$langs->trans("BrowserIsKO",$conf->browser->name);
479 }
480 else
481 {
482  print img_picto('','tick.png').' '.$langs->trans("BrowserIsOK",$conf->browser->name);
483 }
484 print '<br>';
485 
486 // Database statistics update
487 /*
488 print '<br>';
489 print '<strong>'.$langs->trans("DatabaseStatistics").'</strong>: ';
490 print '<br>';
491 */
492 
493 // End of page
494 llxFooter();
495 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
llxHeader()
Empty header.
Definition: wrapper.php:44
dol_now($mode='gmt')
Return date for now.
version_php()
Return PHP version.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)