37 $parts = explode(
'<?php', $str);
41 foreach ($parts as $part)
50 $partlings = explode(
'?>', $part);
51 if (!empty($partlings))
55 if (count($partlings) > 1) $partlings[0] =
'';
59 $newstr .=
'<span phptag>'.$replacewith.
'</span>'.implode(
'', $partlings);
79 $parts = explode(
'<?php', $str);
83 foreach ($parts as $part)
92 $partlings = explode(
'?>', $part, 2);
93 if (!empty($partlings))
95 $newstr .= $partlings[0].
'?>';
97 $newstr .= $part.
'?>';
120 dol_syslog(
'dolWebsiteReplacementOfLinks start (contenttype='.$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
')', LOG_DEBUG);
124 $replacewith =
'...php...';
125 if ($removephppart) $replacewith =
'';
126 $content = preg_replace(
'/value="<\?php((?!\?>).)*\?>\n*/ims',
'value="'.$replacewith.
'"', $content);
128 $replacewith =
'"callto=#';
129 if ($removephppart) $replacewith =
'';
130 $content = preg_replace(
'/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
132 $replacewith =
'"mailto=#';
133 if ($removephppart) $replacewith =
'';
134 $content = preg_replace(
'/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
136 $replacewith =
'src="php';
137 if ($removephppart) $replacewith =
'';
138 $content = preg_replace(
'/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
140 $replacewith =
'href="php';
141 if ($removephppart) $replacewith =
'';
142 $content = preg_replace(
'/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
145 $replacewith =
'...php...';
146 if ($removephppart) $replacewith =
'';
155 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
156 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
157 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
158 $content = str_replace(
'src="viewimage.php',
'src="!~!~!~/viewimage.php', $content);
159 $content = str_replace(
'src="/viewimage.php',
'src="!~!~!~/viewimage.php', $content);
160 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
161 $content = str_replace(
'href="document.php',
'href="!~!~!~/document.php', $content);
162 $content = str_replace(
'href="/document.php',
'href="!~!~!~/document.php', $content);
163 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
166 $content = preg_replace(
'/(href=")\/(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageid='.$website->fk_default_home.
'\2"', $content, -1, $nbrep);
168 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
170 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
173 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
174 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
178 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
180 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
182 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
185 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
188 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
189 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
192 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
195 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
196 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
198 $content = str_replace(
'!~!~!~',
'', $content);
200 dol_syslog(
'dolWebsiteReplacementOfLinks end', LOG_DEBUG);
218 global $db, $langs, $conf, $user;
219 global $dolibarr_main_url_root, $dolibarr_main_data_root;
221 global $includehtmlcontentopened;
225 dol_syslog(
"dolWebsiteOutput start - contenttype=".$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
' includehtmlcontentopened='.$includehtmlcontentopened);
230 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
231 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
234 if (defined(
'USEDOLIBARREDITOR'))
237 if ($contenttype ==
'html')
239 $content = preg_replace(
'/<head>.*<\/head>/ims',
'', $content);
240 $content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $content);
241 $content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $content);
243 } elseif (defined(
'USEDOLIBARRSERVER'))
245 $content = str_replace(
'<link rel="stylesheet" href="/styles.css',
'<link rel="stylesheet" href="styles.css', $content);
248 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
249 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
250 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
251 $content = str_replace(array(
'src="viewimage.php',
'src="/viewimage.php'),
'src="!~!~!~/viewimage.php', $content);
252 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
253 $content = str_replace(array(
'href="document.php',
'href="/document.php'),
'href="!~!~!~/document.php', $content);
254 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
257 $content = preg_replace(
'/(href=")\/\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'"', $content, -1, $nbrep);
259 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
263 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
265 $content = preg_replace(
'/(href=")\/?([a-zA-Z0-9\-_#]+)(\"|\?)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2\3', $content, -1, $nbrep);
268 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
269 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
272 $content = preg_replace(
'/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
273 $content = preg_replace(
'/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
274 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
277 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
278 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
282 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
284 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
286 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
289 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
292 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
293 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
296 if (empty($includehtmlcontentopened)) {
297 $content = str_replace(
'!~!~!~',
'', $content);
301 $symlinktomediaexists = 1;
302 if ($website->virtualhost) {
303 $content = preg_replace(
'/^(<link[^>]*rel="canonical" href=")\//m',
'\1'.$website->virtualhost.
'/', $content, -1, $nbrep);
312 if (!$symlinktomediaexists)
315 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
316 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
318 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
319 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
321 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
322 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
323 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
325 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
326 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
327 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
329 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
332 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
333 $content = preg_replace(
'/(<a[^>]*href=")\/?documents\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
336 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
337 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
339 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
340 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
342 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
343 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
344 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/medias/\4\5', $content, -1, $nbrep);
346 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
347 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
348 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
350 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
353 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
354 $content = preg_replace(
'/(<a[^>]*href=")\/?document\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
358 $content = str_replace(
' contenteditable="true"',
' contenteditable="false"', $content);
360 if (!empty($conf->global->WEBSITE_ADD_CSS_TO_BODY)) {
361 $content = str_replace(
'<body id="bodywebsite" class="bodywebsite',
'<body id="bodywebsite" class="bodywebsite '.$conf->global->WEBSITE_ADD_CSS_TO_BODY, $content);
408 global $db, $website;
414 if ($containeraliasalt)
416 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
418 $result = $tmpwebsitepage->fetch(0, $website->id,
'', $containeraliasalt);
421 $containerref = $tmpwebsitepage->pageurl;
423 print "Error, page contains a redirect to the alternative alias '".$containeraliasalt.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
428 if (defined(
'USEDOLIBARREDITOR'))
433 $text =
"This page contains dynamic code that make a redirect to '".$containerref.
"' in your current context. Redirect has been canceled as it is not supported in edition mode.";
434 setEventMessages($text, null,
'warnings',
'WEBSITEREDIRECTDISABLED'.$containerref);
438 if (defined(
'USEDOLIBARRSERVER'))
441 if (!$containeraliasalt)
443 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
445 $result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
446 unset($tmpwebsitepage);
450 $currenturi =
$_SERVER[
"REQUEST_URI"];
452 if (preg_match(
'/&pageref=([^&]+)/', $currenturi, $regtmp))
454 if ($regtmp[0] == $containerref)
456 print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref.
"' in web site '".$website->ref.
"'";
459 $newurl = preg_replace(
'/&pageref=([^&]+)/',
'&pageref='.$containerref, $currenturi);
462 $newurl = $currenturi.
'&pageref='.urlencode($containerref);
467 $newurl =
'/'.$containerref.
'.php';
473 header(
"Status: 301 Moved Permanently",
false, 301);
475 header(
"Location: ".$newurl);
478 print "Error, page contains a redirect to the alias page '".$containerref.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
493 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
494 global $includehtmlcontentopened;
495 global $websitekey, $websitepagefile;
499 if (!preg_match(
'/\.php$/i', $containerref)) $containerref .=
'.php';
501 $fullpathfile = DOL_DATA_ROOT.
'/website/'.$websitekey.
'/'.$containerref;
503 if (empty($includehtmlcontentopened)) $includehtmlcontentopened = 0;
504 $includehtmlcontentopened++;
505 if ($includehtmlcontentopened > $MAXLEVEL)
507 print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.
".\n";
518 $res = include $fullpathfile;
519 $tmpoutput = ob_get_contents();
522 print "\n".
'<!-- include '.$websitekey.
'/'.$containerref.(is_object($websitepage) ?
' parent id='.$websitepage->id :
'').
' level = '.$includehtmlcontentopened.
' -->'.
"\n";
523 print preg_replace(array(
'/^.*<body[^>]*>/ims',
'/<\/body>.*$/ims'), array(
'',
''), $tmpoutput);
527 print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.
".\n";
530 $includehtmlcontentopened--;
543 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs;
545 $type = strtolower($type);
547 if ($type ==
'software')
549 $ret =
'<!-- Add structured data for entry in a software annuary -->'.
"\n";
550 $ret .=
'<script type="application/ld+json">'.
"\n";
552 "@context": "https://schema.org",
553 "@type": "SoftwareApplication",
554 "name": "'.dol_escape_json($data[
'name']).
'",
556 "applicationCategory": "https://schema.org/'.$data[
'applicationCategory'].
'",';
557 if (!empty($data[
'ratingcount'])) {
560 "@type": "AggregateRating",
561 "ratingValue": "'.$data[
'ratingvalue'].
'",
562 "ratingCount": "'.$data[
'ratingcount'].
'"
568 "price": "'.$data[
'price'].
'",
569 "priceCurrency": "'.($data[
'currency'] ? $data[
'currency'] : $conf->currency).
'"
572 $ret .=
'</script>'.
"\n";
573 } elseif ($type ==
'organization')
575 $companyname = $mysoc->name;
578 $ret =
'<!-- Add structured data for organization -->'.
"\n";
579 $ret .=
'<script type="application/ld+json">'.
"\n";
581 "@context": "https://schema.org",
582 "@type": "Organization",
583 "name": "'.dol_escape_json($data[
'name'] ? $data[
'name'] : $companyname).
'",
585 "logo": "'.($data[
'logo'] ?
dol_escape_json($data[
'logo']) :
'/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo)).
'",
587 "@type": "ContactPoint",
588 "contactType": "Contact",
589 "email": "'.
dol_escape_json($data[
'email'] ? $data[
'email'] : $mysoc->email).
'"
591 if (is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
593 $ret .=
'"sameAs": [';
595 foreach ($mysoc->socialnetworks as $key => $value) {
596 if ($key ==
'linkedin') {
597 $ret .=
'"https://www.'.$key.
'.com/company/'.
dol_escape_json($value).
'"';
598 } elseif ($key ==
'youtube') {
604 if ($i < count($mysoc->socialnetworks)) $ret .=
', ';
609 $ret .=
'</script>'.
"\n";
610 } elseif ($type ==
'blogpost')
612 if (!empty($websitepage->author_alias))
618 $pageurl = $websitepage->pageurl;
619 $title = $websitepage->title;
620 $image = $websitepage->image;
621 $companyname = $mysoc->name;
622 $description = $websitepage->description;
624 $pageurl = str_replace(
'__WEBSITE_KEY__', $website->ref, $pageurl);
625 $title = str_replace(
'__WEBSITE_KEY__', $website->ref, $title);
626 $image =
'/medias/'.str_replace(
'__WEBSITE_KEY__', $website->ref, $image);
627 $companyname = str_replace(
'__WEBSITE_KEY__', $website->ref, $companyname);
628 $description = str_replace(
'__WEBSITE_KEY__', $website->ref, $description);
630 $ret =
'<!-- Add structured data for blog post -->'.
"\n";
631 $ret .=
'<script type="application/ld+json">'.
"\n";
633 "@context": "https://schema.org",
634 "@type": "NewsArticle",
635 "mainEntityOfPage": {
637 "@id": "'.dol_escape_json($pageurl).
'"
643 "dateCreated": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
644 "datePublished": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
645 "dateModified": "'.
dol_print_date($websitepage->date_modification,
'dayhourrfc').
'",
651 "@type": "Organization",
654 "@type": "ImageObject",
655 "url": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).
'"
658 if ($websitepage->keywords) {
659 $ret .=
'"keywords": [';
661 $arrayofkeywords = explode(
',', $websitepage->keywords);
662 foreach ($arrayofkeywords as $keyword) {
663 $ret .=
'"'.dol_escape_json($keyword).
'"';
665 if ($i < count($arrayofkeywords)) $ret .=
', ';
669 $ret .=
'"description": "'.dol_escape_json($description).
'"';
670 $ret .=
"\n".
'}'.
"\n";
671 $ret .=
'</script>'.
"\n";
673 } elseif ($type ==
'product')
675 $ret =
'<!-- Add structured data for product -->'.
"\n";
676 $ret .=
'<script type="application/ld+json">'.
"\n";
678 "@context": "https://schema.org/",
680 "name": "'.dol_escape_json($data[
'label']).
'",
697 "url": "https://example.com/anvil",
698 "priceCurrency": "'.($data[
'currency'] ? $data[
'currency'] : $conf->currency).
'",
699 "price": "'.$data[
'price'].
'",
700 "itemCondition": "https://schema.org/UsedCondition",
701 "availability": "https://schema.org/InStock",
703 "@type": "Organization",
708 $ret .=
'</script>'.
"\n";
709 } elseif ($type ==
'qa')
711 $ret =
'<!-- Add structured data for QA -->'.
"\n";
712 $ret .=
'<script type="application/ld+json">'.
"\n";
714 "@context": "https://schema.org/",
718 "name": "'.dol_escape_json($data[
'name']).
'",
735 $ret .=
'</script>'.
"\n";
747 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
749 $out =
'<!-- section for social network sharing of page -->'.
"\n";
751 if ($website->virtualhost) {
752 $fullurl = $website->virtualhost.
'/'.$websitepage->pageurl.
'.php';
753 $hashtags = trim(join(
' #', array_map(
'trim', explode(
',', $websitepage->keywords))));
755 $out .=
'<div class="dol-social-share">'.
"\n";
758 $out .=
'<div class="dol-social-share-tw">'.
"\n";
759 $out .=
'<a href="https://twitter.com/share" class="twitter-share-button" data-url="'.$fullurl.
'" data-text="'.
dol_escape_htmltag($websitepage->description).
'" data-lang="'.$websitepage->lang.
'" data-size="small" data-related="" data-hashtags="'.preg_replace(
'/^#/',
'', $hashtags).
'" data-count="horizontal">Tweet</a>';
760 $out .=
'<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>';
761 $out .=
'</div>'.
"\n";
764 $out .=
'<div class="dol-social-share-reddit">'.
"\n";
765 $out .=
'<a href="https://www.reddit.com/submit" target="_blank" onclick="window.location = \'https://www.reddit.com/submit?url='.$fullurl.
'\';
return false">';
766 $out .= '<span class="dol-social-share-reddit-span
">Reddit</span>';
768 $out .= '</div>'."\n";
771 $out .= '<div class="dol-social-share-fbl
">'."\n";
772 $out .= '<div id="fb-root
"></div>'."\n";
773 $out .= '<script>(function(d, s, id) {
774 var js, fjs = d.getElementsByTagName(s)[0];
775 if (d.getElementById(id)) return;
776 js = d.createElement(s); js.id = id;
778 fjs.parentNode.insertBefore(js, fjs);
779 }(document, \
'script\', \'facebook-jssdk\'));</script>
782 layout="button_count"
787 action="like" ></fb:like>'.
"\n";
788 $out .=
'</div>'.
"\n";
790 $out .=
"\n</div>\n";
793 $out .=
'<!-- virtual host not defined in CMS. No way to add sharing buttons -->'.
"\n";
795 $out .=
'<!-- section end for social network sharing of page -->'.
"\n";
815 function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield =
'date_creation', $sortorder =
'DESC', $langcode =
'', $otherfilters =
'null', $status = 1)
817 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
820 $arrayresult = array(
'code'=>
'',
'list'=>array());
822 if (!is_object($weblangs)) $weblangs = $langs;
824 if (empty($searchstring) && empty($type) && empty($langcode) && empty($otherfilters))
827 $arrayresult[
'code'] =
'KO';
828 $arrayresult[
'message'] = $weblangs->trans(
"EmptySearchString");
829 } elseif ($searchstring &&
dol_strlen($searchstring) < 2) {
830 $weblangs->load(
"errors");
832 $arrayresult[
'code'] =
'KO';
833 $arrayresult[
'message'] = $weblangs->trans(
"ErrorSearchCriteriaTooSmall");
835 $tmparrayoftype = explode(
',', $type);
849 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/meta/', $algo) || preg_match(
'/content/', $algo)))
851 $sql =
'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.
'website_page as wp';
852 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
853 $sql .=
', '.MAIN_DB_PREFIX.
'categorie_website_page as cwp';
855 $sql .=
" WHERE wp.fk_website = ".$website->id;
857 $sql .=
" AND wp.status = ".$status;
860 $sql .=
" AND wp.lang ='".$db->escape($langcode).
"'";
863 $tmparrayoftype = explode(
',', $type);
865 foreach ($tmparrayoftype as $tmptype) {
866 $typestring .= ($typestring ?
", " :
"").
"'".$db->escape(trim($tmptype)).
"'";
868 $sql .=
" AND wp.type_container IN (".$typestring.
")";
872 if (preg_match(
'/meta/', $algo))
874 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.title LIKE '%".$db->escape($searchstring).
"%' OR wp.description LIKE '%".$db->escape($searchstring).
"%'";
875 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.keywords LIKE '".$db->escape($searchstring).
",%' OR wp.keywords LIKE '% ".$db->escape($searchstring).
"%'";
877 if (preg_match(
'/content/', $algo))
879 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.content LIKE '%".$db->escape($searchstring).
"%'";
882 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
883 $sql .=
' AND cwp.fk_website_page = wp.rowid AND cwp.fk_categorie = '.((int) $otherfilters[
'category']);
886 $sql .= $db->order($sortfield, $sortorder);
887 $sql .= $db->plimit($max);
889 $resql = $db->query($sql);
893 while (($obj = $db->fetch_object(
$resql)) && ($i < $max || $max == 0))
898 $tmpwebsitepage->fetch($obj->rowid);
899 if ($tmpwebsitepage->id > 0) $arrayresult[
'list'][$obj->rowid] = $tmpwebsitepage;
906 $arrayresult[
'code'] = $db->lasterrno();
907 $arrayresult[
'message'] = $db->lasterror();
913 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/sitefiles/', $algo)))
915 global $dolibarr_main_data_root;
917 $pathofwebsite = $dolibarr_main_data_root.
'/website/'.$website->ref;
918 $filehtmlheader = $pathofwebsite.
'/htmlheader.html';
919 $filecss = $pathofwebsite.
'/styles.css.php';
920 $filejs = $pathofwebsite.
'/javascript.js.php';
921 $filerobot = $pathofwebsite.
'/robots.txt';
922 $filehtaccess = $pathofwebsite.
'/.htaccess';
923 $filemanifestjson = $pathofwebsite.
'/manifest.json.php';
924 $filereadme = $pathofwebsite.
'/README.md';
926 $filecontent = file_get_contents($filehtmlheader);
927 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent))
929 $arrayresult[
'list'][] = array(
'type'=>
'website_htmlheadercontent');
932 $filecontent = file_get_contents($filecss);
933 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent))
935 $arrayresult[
'list'][] = array(
'type'=>
'website_csscontent');
938 $filecontent = file_get_contents($filejs);
939 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent))
941 $arrayresult[
'list'][] = array(
'type'=>
'website_jscontent');
944 $filerobot = file_get_contents($filerobot);
945 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent))
947 $arrayresult[
'list'][] = array(
'type'=>
'website_robotcontent');
957 $arrayresult[
'code'] =
'OK';
958 if (empty($arrayresult[
'list']))
960 $arrayresult[
'code'] =
'KO';
961 $arrayresult[
'message'] = $weblangs->trans(
"NoRecordFound");
965 $arrayresult[
'code'] =
'KO';
966 $arrayresult[
'message'] =
'No supported algorithm found';
987 function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto =
'subpage')
993 dol_syslog(
"Call getAllImages with grabimagesinto=".$grabimagesinto);
995 $alreadygrabbed = array();
997 if (preg_match(
'/\/$/', $urltograb)) $urltograb .=
'.';
998 $urltograb = dirname($urltograb);
1002 preg_match_all(
'/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
1004 foreach ($regs[0] as $key => $val)
1006 if (preg_match(
'/^data:image/i', $regs[2][$key]))
continue;
1008 if (preg_match(
'/^\//', $regs[2][$key]))
1011 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1013 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1016 $linkwithoutdomain = $regs[2][$key];
1017 $dirforimages =
'/'.$objectpage->pageurl;
1018 if ($grabimagesinto ==
'root') $dirforimages =
'';
1021 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1022 if (preg_match(
'/^http/', $regs[2][$key]))
1024 $urltograbbis = $regs[2][$key];
1025 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1026 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1028 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1031 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1032 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1038 if (empty($alreadygrabbed[$urltograbbis]))
1043 if ($tmpgeturl[
'curl_error_no'])
1046 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'], null,
'errors');
1048 } elseif ($tmpgeturl[
'http_code'] !=
'200')
1051 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'], null,
'errors');
1054 $alreadygrabbed[$urltograbbis] = 1;
1058 $fp = fopen($filetosave,
"w");
1059 fputs($fp, $tmpgeturl[
'content']);
1061 if (!empty($conf->global->MAIN_UMASK))
1062 @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
1069 $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);
1074 preg_match_all(
'/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
1076 foreach ($regs[0] as $key => $val)
1078 if (preg_match(
'/^data:image/i', $regs[2][$key]))
continue;
1080 if (preg_match(
'/^\//', $regs[2][$key]))
1083 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1085 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1088 $linkwithoutdomain = $regs[2][$key];
1090 $dirforimages =
'/'.$objectpage->pageurl;
1091 if ($grabimagesinto ==
'root') $dirforimages =
'';
1093 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1095 if (preg_match(
'/^http/', $regs[2][$key]))
1097 $urltograbbis = $regs[2][$key];
1098 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1099 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1102 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1105 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1106 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1112 if (empty($alreadygrabbed[$urltograbbis]))
1117 if ($tmpgeturl[
'curl_error_no'])
1120 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'], null,
'errors');
1122 } elseif ($tmpgeturl[
'http_code'] !=
'200')
1125 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'], null,
'errors');
1128 $alreadygrabbed[$urltograbbis] = 1;
1132 $fp = fopen($filetosave,
"w");
1133 fputs($fp, $tmpgeturl[
'content']);
1135 if (!empty($conf->global->MAIN_UMASK))
1136 @chmod($filetosave, octdec($conf->global->MAIN_UMASK));
1143 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'background'.$regs[1][$key].
'url("'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file='.$filename.
'")', $tmp);
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
getStructuredData($type, $data=array())
Return HTML content to add structured data for an article, news or Blog Post.
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0, $contenttype= 'html', $containerid= '')
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content...
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
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'.
redirectToContainer($containerref, $containeraliasalt= '', $containerid=0, $permanent=0)
Format img tags to introduce viewimage on img src.
getURLContent($url, $postorget= 'GET', $param= '', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0)
Function to get a content from an URL (use proxy if proxy defined).
includeContainer($containerref)
Clean an HTML page to report only content, so we can include it into another page.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto= 'subpage')
Download all images found into page content $tmp.
dolWebsiteOutput($content, $contenttype= 'html', $containerid= '')
Render a string of an HTML content and output it.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
getSocialNetworkSharingLinks()
Return HTML content to add structured data for an article, news or Blog Post.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dolStripPhpCode($str, $replacewith= '')
Remove PHP code part from a string.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
print $_SERVER["PHP_SELF"] n
Edit parameters.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
getPagesFromSearchCriterias($type, $algo, $searchstring, $max=25, $sortfield= 'date_creation', $sortorder= 'DESC', $langcode= '', $otherfilters= 'null', $status=1)
Return list of containers object that match a criteria.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...