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