dolibarr  7.0.0-beta
website.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 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 
35 function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
36 {
37  // Replace php code. Note $content may come from database and does not contains body tags.
38  $replacewith='...php...';
39  if ($removephppart) $replacewith='';
40  $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
41 
42  $replacewith='<span class="phptag">...php...</span>';
43  if ($removephppart) $replacewith='';
44  $content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
45 
46  // Replace relative link / with dolibarr URL
47  $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
48  // Replace relative link /xxx.php with dolibarr URL
49  $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
50 
51  $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
52 
53  // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
54  $content = preg_replace('/(<img[^>]*src=")(?!(http|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
55 
56  // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
57  $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
58 
59  return $content;
60 }
61 
62 
71 function dolWebsiteOutput($content)
72 {
73  global $db, $langs, $conf, $user;
74  global $dolibarr_main_url_root, $dolibarr_main_data_root;
75 
76  dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
77 
78  // Define $urlwithroot
79  $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
80  $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
81  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
82 
83  // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
84 
85  if (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server
86  {
87  global $website;
88 
89  // Replace relative link / with dolibarr URL: ...href="/"...
90  $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep);
91  // Replace relative link /xxx.php with dolibarr URL: ...href="....php"
92  $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
93  // Replace relative link /xxx with dolibarr URL: ...href="....php"
94  $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(["\?]+)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
95 
96  // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart="
97  $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
98  $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
99 
100  // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
101  $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
102 
103  // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
104  $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
105 
106  // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
107  $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
108  }
109  else // REPLACEMENT OF LINKS When page called from virtual host
110  {
111  $symlinktomediaexists=1;
112 
113  // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
114  // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
115  // become
116  // <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
117  $nbrep=0;
118  if (! $symlinktomediaexists)
119  {
120  $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
121  $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
122  $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
123  }
124  else
125  {
126  $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
127 
128  $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
129  $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep);
130  $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
131  }
132  }
133 
134  dol_syslog("dolWebsiteOutput end");
135 
136  print $content;
137 }
138 
139 
147 /*
148 function dolWebsiteSaveContent($content)
149 {
150  global $db, $langs, $conf, $user;
151  global $dolibarr_main_url_root, $dolibarr_main_data_root;
152 
153  //dol_syslog("dolWebsiteSaveContent start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
154 
155  // Define $urlwithroot
156  $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
157  $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
158  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
159 
160  //$content = preg_replace('/(<img.*src=")(?!(http|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
161 
162  return $content;
163 }
164 */
165 
166 
174 function includeContainer($containeralias)
175 {
176  global $conf, $db, $langs, $mysoc, $user, $website;
177  global $includehtmlcontentopened;
178  global $websitekey;
179 
180  $MAXLEVEL=20;
181 
182  if (! preg_match('/\.php$/i', $containeralias)) $containeralias.='.php';
183 
184  $fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containeralias;
185 
186  if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
187  $includehtmlcontentopened++;
188  if ($includehtmlcontentopened > $MAXLEVEL)
189  {
190  print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n";
191  return;
192  }
193  // file_get_contents is not possible. We must execute code with include
194  //$content = file_get_contents($fullpathfile);
195  //print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
196 
197  ob_start();
198  $res = include $fullpathfile; // Include because we want to execute code content
199  $tmpoutput = ob_get_contents();
200  ob_end_clean();
201 
202  print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n";
203  print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput);
204 
205  if (! $res)
206  {
207  print 'ERROR: FAILED TO INCLUDE PAGE '.$containeralias.".\n";
208  }
209 
210  $includehtmlcontentopened--;
211 }
212 
213 
214 
227 function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0)
228 {
229  global $conf;
230 
231  $error=0;
232 
233  $alreadygrabbed=array();
234 
235  if (preg_match('/\/$/', $urltograb)) $urltograb.='.';
236  $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1
237 
238  preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
239 
240  foreach ($regs[0] as $key => $val)
241  {
242  if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
243 
244  if (preg_match('/^\//', $regs[2][$key]))
245  {
246  $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
247  $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
248  }
249  else
250  {
251  $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file
252  }
253 
254  $linkwithoutdomain = $regs[2][$key];
255  $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
256  if (preg_match('/^http/', $regs[2][$key]))
257  {
258  $urltograbbis = $regs[2][$key];
259  $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
260  $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
261  }
262 
263  $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
264 
265  // Clean the aa/bb/../cc into aa/cc
266  $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
267  $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
268 
269  //var_dump($filetosave);
270  //var_dump($filename);
271  //exit;
272 
273  if (empty($alreadygrabbed[$urltograbbis]))
274  {
275  $tmpgeturl = getURLContent($urltograbbis);
276  if ($tmpgeturl['curl_error_no'])
277  {
278  $error++;
279  setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
280  $action='create';
281  }
282  elseif ($tmpgeturl['http_code'] != '200')
283  {
284  $error++;
285  setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
286  $action='create';
287  }
288  else
289  {
290  $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed.
291 
292  dol_mkdir(dirname($filetosave));
293 
294  $fp = fopen($filetosave, "w");
295  fputs($fp, $tmpgeturl['content']);
296  fclose($fp);
297  if (! empty($conf->global->MAIN_UMASK))
298  @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
299  }
300  }
301 
302  if ($modifylinks)
303  {
304  $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
305  }
306  }
307 
308  // Search X in "background...url(X)"
309  preg_match_all('/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
310 
311  foreach ($regs[0] as $key => $val)
312  {
313  if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images
314 
315  if (preg_match('/^\//', $regs[2][$key]))
316  {
317  $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb);
318  $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot
319  }
320  else
321  {
322  $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file
323  }
324 
325  $linkwithoutdomain = $regs[2][$key];
326  $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
327 
328  if (preg_match('/^http/', $regs[2][$key]))
329  {
330  $urltograbbis = $regs[2][$key];
331  $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
332  $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
333  }
334 
335  $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
336 
337  // Clean the aa/bb/../cc into aa/cc
338  $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave);
339  $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename);
340 
341  //var_dump($filetosave);
342  //var_dump($filename);
343  //exit;
344 
345  if (empty($alreadygrabbed[$urltograbbis]))
346  {
347  $tmpgeturl = getURLContent($urltograbbis);
348  if ($tmpgeturl['curl_error_no'])
349  {
350  $error++;
351  setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
352  $action='create';
353  }
354  elseif ($tmpgeturl['http_code'] != '200')
355  {
356  $error++;
357  setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
358  $action='create';
359  }
360  else
361  {
362  $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed.
363 
364  dol_mkdir(dirname($filetosave));
365 
366  $fp = fopen($filetosave, "w");
367  fputs($fp, $tmpgeturl['content']);
368  fclose($fp);
369  if (! empty($conf->global->MAIN_UMASK))
370  @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
371  }
372  }
373 
374  if ($modifylinks)
375  {
376  $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
377  }
378  }
379 }
380 
381 
382 
391 function dolSavePageAlias($filealias, $object, $objectpage)
392 {
393  global $conf;
394 
395  // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
396  dol_syslog("We regenerate the alias page filealias=".$filealias);
397 
398  $aliascontent = '<?php'."\n";
399  $aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
400  $aliascontent.= 'global $dolibarr_main_data_root;'."\n";
401  $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
402  $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
403  $aliascontent.= '?>'."\n";
404  $result = file_put_contents($filealias, $aliascontent);
405  if (! empty($conf->global->MAIN_UMASK))
406  @chmod($filealias, octdec($conf->global->MAIN_UMASK));
407 
408  return ($result?true:false);
409 }
410 
411 
420 function dolSavePageContent($filetpl, $object, $objectpage)
421 {
422  global $conf;
423 
424  // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
425  dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
426 
427  dol_delete_file($filetpl);
428 
429  $shortlangcode = '';
430  if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
431 
432  $tplcontent ='';
433  $tplcontent.= "<?php // BEGIN PHP\n";
434  $tplcontent.= '$websitekey=basename(dirname(__FILE__));'."\n";
435  $tplcontent.= "if (! defined('USEDOLIBARRSERVER')) { require_once './master.inc.php'; } // Not already loaded"."\n";
436  $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
437  $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
438  $tplcontent.= "ob_start();\n";
439  $tplcontent.= "// END PHP ?>\n";
440  $tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
441  $tplcontent.= '<head>'."\n";
442  $tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
443  $tplcontent.= '<meta charset="UTF-8">'."\n";
444  $tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
445  $tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
446  $tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
447  $tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
448  $tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
449  $tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
450  $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.'" />'."\n";
451  $tplcontent.= '<!-- Include link to CSS file -->'."\n";
452  $tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
453  $tplcontent.= '<!-- Include HTML header from common file -->'."\n";
454  $tplcontent.= '<?php print file_get_contents(DOL_DATA_ROOT."/website/'.$object->ref.'/htmlheader.html"); ?>'."\n";
455  $tplcontent.= '<!-- Include HTML header from page inline block -->'."\n";
456  $tplcontent.= $objectpage->htmlheader."\n";
457  $tplcontent.= '</head>'."\n";
458 
459  $tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
460  $tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n";
461  $tplcontent.= $objectpage->content."\n";
462  $tplcontent.= '</body>'."\n";
463  $tplcontent.= '</html>'."\n";
464 
465  $tplcontent.= '<?php // BEGIN PHP'."\n";
466  $tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
467  $tplcontent.= "// END PHP ?>"."\n";
468 
469  //var_dump($filetpl);exit;
470  $result = file_put_contents($filetpl, $tplcontent);
471  if (! empty($conf->global->MAIN_UMASK))
472  @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
473 
474  return $result;
475 }
476 
477 
485 function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
486 {
487  global $conf, $pathofwebsite;
488 
489  dol_syslog("Save html header into ".$filehtmlheader);
490 
491  dol_mkdir($pathofwebsite);
492  $result = file_put_contents($filehtmlheader, $htmlheadercontent);
493  if (! empty($conf->global->MAIN_UMASK))
494  @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
495 
496  if (! $result)
497  {
498  setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
499  return false;
500  }
501 
502  return true;
503 }
504 
512 function dolSaveCssFile($filecss, $csscontent)
513 {
514  global $conf, $pathofwebsite;
515 
516  dol_syslog("Save css file into ".$filecss);
517 
518  dol_mkdir($pathofwebsite);
519  $result = file_put_contents($filecss, $csscontent);
520  if (! empty($conf->global->MAIN_UMASK))
521  @chmod($filecss, octdec($conf->global->MAIN_UMASK));
522 
523  if (! $result)
524  {
525  setEventMessages('Failed to write file '.$filecss, null, 'errors');
526  return false;
527  }
528 
529  return true;
530 }
531 
539 function dolSaveJsFile($filejs, $jscontent)
540 {
541  global $conf, $pathofwebsite;
542 
543  dol_syslog("Save js file into ".$filejs);
544 
545  dol_mkdir($pathofwebsite);
546  $result = file_put_contents($filejs, $jscontent);
547  if (! empty($conf->global->MAIN_UMASK))
548  @chmod($filejs, octdec($conf->global->MAIN_UMASK));
549 
550  if (! $result)
551  {
552  setEventMessages('Failed to write file '.$filejs, null, 'errors');
553  return false;
554  }
555 
556  return true;
557 }
558 
566 function dolSaveRobotFile($filerobot, $robotcontent)
567 {
568  global $conf, $pathofwebsite;
569 
570  dol_syslog("Save robot file into ".$filerobot);
571 
572  dol_mkdir($pathofwebsite);
573  $result = file_put_contents($filerobot, $robotcontent);
574  if (! empty($conf->global->MAIN_UMASK))
575  @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
576 
577  if (! $result)
578  {
579  setEventMessages('Failed to write file '.$filerobot, null, 'errors');
580  return false;
581  }
582 
583  return true;
584 }
585 
593 function dolSaveHtaccessFile($filehtaccess, $htaccess)
594 {
595  global $conf, $pathofwebsite;
596 
597  dol_syslog("Save htaccess file into ".$filehtaccess);
598 
599  dol_mkdir($pathofwebsite);
600  $result = file_put_contents($filehtaccess, $htaccess);
601  if (! empty($conf->global->MAIN_UMASK))
602  @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
603 
604  if (! $result)
605  {
606  setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
607  return false;
608  }
609 
610  return true;
611 }
612 
613 
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dolWebsiteOutput($content)
Render a string of an HTML content and output it.
Definition: website.lib.php:71
dolSavePageAlias($filealias, $object, $objectpage)
Save content of a page on disk.
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page.html return 'https://www.abc.mydomain.com' For example: http://www.abc.mydomain.com/ return 'https://www.abc.mydomain.com'.
Definition: geturl.lib.php:189
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content...
Definition: website.lib.php:35
dolSavePageContent($filetpl, $object, $objectpage)
Save content of a page on disk.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
includeContainer($containeralias)
Format img tags to introduce viewimage on img src.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array())
Function get content from an URL (use proxy if proxy defined)
Definition: geturl.lib.php:34
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0)
Download all images found into page content $tmp.
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
print
Draft customers invoices.
Definition: index.php:91
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null)
Remove a file or several files with a mask.
Definition: files.lib.php:1103