34 $str = str_replace(
'<?=',
'<?php', $str);
40 $parts = preg_split(
'/'.preg_quote(
'<?php',
'/').
'/i', $str);
44 foreach ($parts as $part) {
51 $partlings = explode(
'?>', $part);
52 if (!empty($partlings)) {
55 if (count($partlings) > 1) {
61 $newstr .=
'<span phptag>'.$replacewith.
'</span>'.implode(
'', $partlings);
78 $str = str_replace(
'<?=',
'<?php', $str);
79 $str = str_replace(
'<?php',
'__LTINTPHP__', $str);
80 $str = str_replace(
'<?',
'<?php', $str);
81 $str = str_replace(
'__LTINTPHP__',
'<?php', $str);
87 $parts = preg_split(
'/'.preg_quote(
'<?php',
'/').
'/i', $str);
91 foreach ($parts as $part) {
98 $partlings = explode(
'?>', $part, 2);
99 if (!empty($partlings)) {
100 $newstr .= $partlings[0].
'?>';
102 $newstr .= $part.
'?>';
125 dol_syslog(
'dolWebsiteReplacementOfLinks start (contenttype='.$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
')', LOG_DEBUG);
129 $replacewith =
'...php...';
130 if ($removephppart) {
133 $content = preg_replace(
'/value="<\?php((?!\?>).)*\?>\n*/ims',
'value="'.$replacewith.
'"', $content);
135 $replacewith =
'"callto=#';
136 if ($removephppart) {
139 $content = preg_replace(
'/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
141 $replacewith =
'"mailto=#';
142 if ($removephppart) {
145 $content = preg_replace(
'/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
147 $replacewith =
'src="php';
148 if ($removephppart) {
151 $content = preg_replace(
'/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
153 $replacewith =
'href="php';
154 if ($removephppart) {
157 $content = preg_replace(
'/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
160 $replacewith =
'...php...';
161 if ($removephppart) {
171 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
172 $content = str_replace(
'src="javascript.js.php',
'src="!~!~!~javascript.js.php', $content);
173 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
174 $content = str_replace(
'xlink:href="',
'xlink:href="!~!~!~', $content);
175 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
176 $content = str_replace(
'src="//',
'src="!~!~!~//', $content);
177 $content = str_replace(
'src="viewimage.php',
'src="!~!~!~/viewimage.php', $content);
178 $content = str_replace(
'src="/viewimage.php',
'src="!~!~!~/viewimage.php', $content);
179 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
180 $content = str_replace(
'href="document.php',
'href="!~!~!~/document.php', $content);
181 $content = str_replace(
'href="/document.php',
'href="!~!~!~/document.php', $content);
182 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
185 $content = preg_replace(
'/(href=")\/(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageid='.$website->fk_default_home.
'\2"', $content, -1, $nbrep);
187 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
189 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
192 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
193 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
197 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
199 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
201 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
204 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
207 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
208 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
211 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
214 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
215 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
217 $content = str_replace(
'!~!~!~',
'', $content);
219 dol_syslog(
'dolWebsiteReplacementOfLinks end', LOG_DEBUG);
234 ":face_with_tears_of_joy:" =>
"\xF0\x9F\x98\x82",
235 ":grinning_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x81",
236 ":smiling_face_with_open_mouth:" =>
"\xF0\x9F\x98\x83",
237 ":smiling_face_with_open_mouth_and_cold_sweat:" =>
"\xF0\x9F\x98\x85",
238 ":smiling_face_with_open_mouth_and_tightly_closed_eyes:" =>
"\xF0\x9F\x98\x86",
239 ":winking_face:" =>
"\xF0\x9F\x98\x89",
240 ":smiling_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x8A",
241 ":face_savouring_delicious_food:" =>
"\xF0\x9F\x98\x8B",
242 ":relieved_face:" =>
"\xF0\x9F\x98\x8C",
243 ":smiling_face_with_heart_shaped_eyes:" =>
"\xF0\x9F\x98\x8D",
244 ":smiling_face_with_sunglasses:" =>
"\xF0\x9F\x98\x8E",
245 ":smirking_face:" =>
"\xF0\x9F\x98\x8F",
246 ":neutral_face:" =>
"\xF0\x9F\x98\x90",
247 ":expressionless_face:" =>
"\xF0\x9F\x98\x91",
248 ":unamused_face:" =>
"\xF0\x9F\x98\x92",
249 ":face_with_cold_sweat:" =>
"\xF0\x9F\x98\x93",
250 ":pensive_face:" =>
"\xF0\x9F\x98\x94",
251 ":confused_face:" =>
"\xF0\x9F\x98\x95",
252 ":confounded_face:" =>
"\xF0\x9F\x98\x96",
253 ":kissing_face:" =>
"\xF0\x9F\x98\x97",
254 ":face_throwing_a_kiss:" =>
"\xF0\x9F\x98\x98",
255 ":kissing_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x99",
256 ":kissing_face_with_closed_eyes:" =>
"\xF0\x9F\x98\x9A",
257 ":face_with_stuck_out_tongue:" =>
"\xF0\x9F\x98\x9B",
258 ":face_with_stuck_out_tongue_and_winking_eye:" =>
"\xF0\x9F\x98\x9C",
259 ":face_with_stuck_out_tongue_and_tightly_closed_eyes:" =>
"\xF0\x9F\x98\x9D",
260 ":disappointed_face:" =>
"\xF0\x9F\x98\x9E",
261 ":worried_face:" =>
"\xF0\x9F\x98\x9F",
262 ":angry_face:" =>
"\xF0\x9F\x98\xA0",
263 ":face_with_symbols_on_mouth:" =>
"\xF0\x9F\x98\xA1",
265 foreach ($map as $key => $value) {
266 $content = str_replace($key, $value, $content);
284 global $db, $langs, $conf, $user;
285 global $dolibarr_main_url_root, $dolibarr_main_data_root;
287 global $includehtmlcontentopened;
291 dol_syslog(
"dolWebsiteOutput start - contenttype=".$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
' includehtmlcontentopened='.$includehtmlcontentopened);
296 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
297 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
300 if (defined(
'USEDOLIBARREDITOR')) {
302 if ($contenttype ==
'html') {
303 $content = preg_replace(
'/<head>.*<\/head>/ims',
'', $content);
304 $content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $content);
305 $content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $content);
307 } elseif (defined(
'USEDOLIBARRSERVER')) {
308 $content = str_replace(
'<link rel="stylesheet" href="/styles.css',
'<link rel="stylesheet" href="styles.css', $content);
309 $content = str_replace(
' async src="/javascript.js',
' async src="javascript.js', $content);
312 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
313 $content = str_replace(
'src="javascript.css.php',
'src="!~!~!~javascript.css.php', $content);
314 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
315 $content = str_replace(
'xlink:href="',
'xlink:href="!~!~!~', $content);
316 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
317 $content = str_replace(
'src="//',
'src="!~!~!~//', $content);
318 $content = str_replace(array(
'src="viewimage.php',
'src="/viewimage.php'),
'src="!~!~!~/viewimage.php', $content);
319 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
320 $content = str_replace(array(
'href="document.php',
'href="/document.php'),
'href="!~!~!~/document.php', $content);
321 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
324 $content = preg_replace(
'/(href=")\/\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'"', $content, -1, $nbrep);
326 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
330 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
332 $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);
335 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
336 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
339 $content = preg_replace(
'/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
340 $content = preg_replace(
'/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
341 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
344 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
345 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
349 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
351 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
353 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
356 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
359 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
360 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
363 if (empty($includehtmlcontentopened)) {
364 $content = str_replace(
'!~!~!~',
'', $content);
367 $symlinktomediaexists = 1;
368 if ($website->virtualhost) {
369 $content = preg_replace(
'/^(<link[^>]*rel="canonical" href=")\//m',
'\1'.$website->virtualhost.
'/', $content, -1, $nbrep);
378 if (!$symlinktomediaexists) {
380 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
381 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
383 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
384 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
386 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
387 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
388 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
390 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
391 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
392 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
394 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
397 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
398 $content = preg_replace(
'/(<a[^>]*href=")\/?documents\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
401 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
402 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
404 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
405 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
407 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
408 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
409 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/medias/\4\5', $content, -1, $nbrep);
411 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
412 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
413 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
415 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
418 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
419 $content = preg_replace(
'/(<a[^>]*href=")\/?document\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
423 if (!defined(
'USEDOLIBARREDITOR')) {
424 $content = str_replace(
' contenteditable="true"',
' contenteditable="false"', $content);
428 $content = str_replace(
'<body id="bodywebsite" class="bodywebsite',
'<body id="bodywebsite" class="bodywebsite ' .
getDolGlobalString(
'WEBSITE_ADD_CSS_TO_BODY'), $content);
450 if (in_array($websitepagetype, array(
'blogpost',
'page'))) {
455 $sql =
"UPDATE ".$db->prefix().
"website SET ";
456 $sql .=
" pageviews_total = pageviews_total + 1,";
457 $sql .=
" pageviews_month = pageviews_month + 1,";
459 $sql .=
" pageviews_previous_month = ".$db->ifsql(
"lastaccess < '".$db->idate(
dol_mktime(0, 0, 0, $tmpnow[
'mon'], 1, $tmpnow[
'year'],
'gmt', 0),
'gmt').
"'",
'pageviews_month',
'pageviews_previous_month').
",";
460 $sql .=
" lastaccess = '".$db->idate(
dol_now(
'gmt'),
'gmt').
"'";
461 $sql .=
" WHERE rowid = ".((int) $websiteid);
462 $resql = $db->query($sql);
511 global $db, $website;
517 if ($containeraliasalt) {
518 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
520 $result = $tmpwebsitepage->fetch(0, $website->id,
'', $containeraliasalt);
522 $containerref = $tmpwebsitepage->pageurl;
524 print
"Error, page contains a redirect to the alternative alias '".$containeraliasalt.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
529 if (defined(
'USEDOLIBARREDITOR')) {
533 $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.";
534 setEventMessages($text,
null,
'warnings',
'WEBSITEREDIRECTDISABLED'.$containerref);
538 if (defined(
'USEDOLIBARRSERVER')) {
540 if (!$containeraliasalt) {
541 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
543 $result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
544 unset($tmpwebsitepage);
547 $currenturi = $_SERVER[
"REQUEST_URI"];
549 if (preg_match(
'/&pageref=([^&]+)/', $currenturi, $regtmp)) {
550 if ($regtmp[0] == $containerref) {
551 print
"Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref.
"' in web site '".$website->ref.
"'";
554 $newurl = preg_replace(
'/&pageref=([^&]+)/',
'&pageref='.$containerref, $currenturi);
557 $newurl = $currenturi.
'&pageref='.urlencode($containerref);
561 $newurl =
'/'.$containerref.
'.php';
562 $newurl = $newurl.(empty($_SERVER[
"QUERY_STRING"]) ?
'' :
'?'.$_SERVER[
"QUERY_STRING"]);
567 header(
"Status: 301 Moved Permanently",
false, 301);
569 header(
"Location: ".$newurl);
572 print
"Error, page contains a redirect to the alias page '".$containerref.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
587 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
588 global $includehtmlcontentopened;
589 global $websitekey, $websitepagefile;
593 if (!preg_match(
'/\.php$/i', $containerref)) {
594 $containerref .=
'.php';
597 $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey.
'/'.$containerref;
599 if (empty($includehtmlcontentopened)) {
600 $includehtmlcontentopened = 0;
602 $includehtmlcontentopened++;
603 if ($includehtmlcontentopened > $MAXLEVEL) {
604 print
'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.((int) $MAXLEVEL).
".\n";
615 $res = include $fullpathfile;
616 $tmpoutput = ob_get_contents();
619 print
"\n".
'<!-- include '.$websitekey.
'/'.$containerref.(is_object($websitepage) ?
' parent id='.$websitepage->id :
'').
' level = '.$includehtmlcontentopened.
' -->'.
"\n";
620 print preg_replace(array(
'/^.*<body[^>]*>/ims',
'/<\/body>.*$/ims'), array(
'',
''), $tmpoutput);
623 print
'ERROR: FAILED TO INCLUDE PAGE '.$containerref.
".\n";
626 $includehtmlcontentopened--;
641 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs;
643 $type = strtolower($type);
645 if ($type ==
'software') {
646 $ret =
'<!-- Add structured data for entry in a software annuary -->'.
"\n";
647 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
649 "@context": "https://schema.org",
650 "@type": "SoftwareApplication",
651 "name": "'.dol_escape_json($data[
'name']).
'",
653 "applicationCategory": "https://schema.org/'.
dol_escape_json($data[
'applicationCategory']).
'",';
654 if (!empty($data[
'ratingcount'])) {
657 "@type": "AggregateRating",
658 "ratingValue": "'.dol_escape_json($data[
'ratingvalue']).
'",
665 "price": "'.dol_escape_json($data[
'price']).
'",
666 "priceCurrency": "'.
dol_escape_json($data[
'currency'] ? $data[
'currency'] : $conf->currency).
'"
669 $ret .=
'</script>'.
"\n";
670 } elseif ($type ==
'organization') {
671 $companyname = $mysoc->name;
674 $ret =
'<!-- Add structured data for organization -->'.
"\n";
675 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
677 "@context": "https://schema.org",
678 "@type": "Organization",
679 "name": "'.dol_escape_json(!empty($data[
'name']) ? $data[
'name'] : $companyname).
'",
680 "url": "'.
dol_escape_json(!empty($data[
'url']) ? $data[
'url'] : $url).
'",
681 "logo": "'.($data[
'logo'] ?
dol_escape_json($data[
'logo']) :
'/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo)).
'",
683 "@type": "ContactPoint",
684 "contactType": "Contact",
685 "email": "'.
dol_escape_json(!empty($data[
'email']) ? $data[
'email'] : $mysoc->email).
'"
687 if (is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
689 $ret .=
'"sameAs": [';
691 foreach ($mysoc->socialnetworks as $key => $value) {
692 if ($key ==
'linkedin') {
693 $ret .=
'"https://www.'.$key.
'.com/company/'.
dol_escape_json($value).
'"';
694 } elseif ($key ==
'youtube') {
700 if ($i < count($mysoc->socialnetworks)) {
707 $ret .=
'</script>'.
"\n";
708 } elseif ($type ==
'blogpost') {
709 if (!empty($websitepage->author_alias)) {
714 $pageurl = $websitepage->pageurl;
715 $title = $websitepage->title;
716 $image = $websitepage->image;
717 $companyname = $mysoc->name;
718 $description = $websitepage->description;
720 $pageurl = str_replace(
'__WEBSITE_KEY__', $website->ref, $pageurl);
721 $title = str_replace(
'__WEBSITE_KEY__', $website->ref, $title);
722 $image =
'/medias'.(preg_match(
'/^\//', $image) ?
'' :
'/').str_replace(
'__WEBSITE_KEY__', $website->ref, $image);
723 $companyname = str_replace(
'__WEBSITE_KEY__', $website->ref, $companyname);
724 $description = str_replace(
'__WEBSITE_KEY__', $website->ref, $description);
726 $ret =
'<!-- Add structured data for blog post -->'.
"\n";
727 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
729 "@context": "https://schema.org",
730 "@type": "NewsArticle",
731 "mainEntityOfPage": {
733 "@id": "'.dol_escape_json($pageurl).
'"
739 "dateCreated": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
740 "datePublished": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
741 "dateModified": "'.
dol_print_date($websitepage->date_modification,
'dayhourrfc').
'",
747 "@type": "Organization",
750 "@type": "ImageObject",
751 "url": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).
'"
754 if ($websitepage->keywords) {
755 $ret .=
'"keywords": [';
757 $arrayofkeywords = explode(
',', $websitepage->keywords);
758 foreach ($arrayofkeywords as $keyword) {
759 $ret .=
'"'.dol_escape_json($keyword).
'"';
761 if ($i < count($arrayofkeywords)) {
767 $ret .=
'"description": "'.dol_escape_json($description).
'"';
768 $ret .=
"\n".
'}'.
"\n";
769 $ret .=
'</script>'.
"\n";
771 $ret =
'<!-- no structured data inserted inline inside blogpost because no author_alias defined -->'.
"\n";
773 } elseif ($type ==
'product') {
774 $ret =
'<!-- Add structured data for product -->'.
"\n";
775 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
777 "@context": "https://schema.org/",
779 "name": "'.dol_escape_json($data[
'label']).
'",
796 "url": "https://example.com/anvil",
797 "priceCurrency": "'.
dol_escape_json($data[
'currency'] ? $data[
'currency'] : $conf->currency).
'",
799 "itemCondition": "https://schema.org/UsedCondition",
800 "availability": "https://schema.org/InStock",
802 "@type": "Organization",
807 $ret .=
'</script>'.
"\n";
808 } elseif ($type ==
'qa') {
809 $ret =
'<!-- Add structured data for QA -->'.
"\n";
810 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
812 "@context": "https://schema.org/",
816 "name": "'.dol_escape_json($data[
'name']).
'",
833 $ret .=
'</script>'.
"\n";
846 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
850 if ($website->virtualhost) {
851 $pageurl = $websitepage->pageurl;
852 $title = $websitepage->title;
853 $image = $websitepage->image;
854 $companyname = $mysoc->name;
855 $description = $websitepage->description;
857 $pageurl = str_replace(
'__WEBSITE_KEY__', $website->ref, $pageurl);
858 $title = str_replace(
'__WEBSITE_KEY__', $website->ref, $title);
859 $image =
'/medias'.(preg_match(
'/^\//', $image) ?
'' :
'/').str_replace(
'__WEBSITE_KEY__', $website->ref, $image);
860 $companyname = str_replace(
'__WEBSITE_KEY__', $website->ref, $companyname);
861 $description = str_replace(
'__WEBSITE_KEY__', $website->ref, $description);
864 if ($websitepage->lang) {
865 $shortlangcode = substr($websitepage->lang, 0, 2);
867 if (empty($shortlangcode)) {
868 $shortlangcode = substr($website->lang, 0, 2);
871 $fullurl = $website->virtualhost.
'/'.$websitepage->pageurl.
'.php';
872 $canonicalurl = $website->virtualhost.(($websitepage->id == $website->fk_default_home) ?
'/' : (($shortlangcode != substr($website->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$websitepage->pageurl.
'.php'));
873 $hashtags = trim(join(
' #', array_map(
'trim', explode(
',', $websitepage->keywords))));
876 $out .=
'<meta name="og:type" content="website">'.
"\n";
877 $out .=
'<meta name="og:title" content="'.$websitepage->title.
'">'.
"\n";
878 if ($websitepage->image) {
879 $out .=
'<meta name="og:image" content="'.$website->virtualhost.$image.
'">'.
"\n";
881 $out .=
'<meta name="og:url" content="'.$canonicalurl.
'">'.
"\n";
884 $out .=
'<meta name="twitter:card" content="summary">'.
"\n";
885 if (!empty($params) && !empty($params[
'twitter_account'])) {
886 $out .=
'<meta name="twitter:site" content="@'.$params[
'twitter_account'].
'">'.
"\n";
887 $out .=
'<meta name="twitter:creator" content="@'.$params[
'twitter_account'].
'">'.
"\n";
889 $out .=
'<meta name="twitter:title" content="'.$websitepage->title.
'">'.
"\n";
890 if ($websitepage->description) {
891 $out .=
'<meta name="twitter:description" content="'.$websitepage->description.
'">'.
"\n";
893 if ($websitepage->image) {
894 $out .=
'<meta name="twitter:image" content="'.$website->virtualhost.$image.
'">'.
"\n";
920 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
922 $out =
'<!-- section for social network sharing of page -->'.
"\n";
924 if ($website->virtualhost) {
925 $fullurl = $website->virtualhost.
'/'.$websitepage->pageurl.
'.php';
926 $hashtags = trim(join(
' #', array_map(
'trim', explode(
',', $websitepage->keywords))));
928 $out .=
'<div class="dol-social-share">'.
"\n";
931 $out .=
'<div class="dol-social-share-tw">'.
"\n";
932 $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>';
933 $out .=
'<script nonce="'.getNonce().
'">!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>';
934 $out .=
'</div>'.
"\n";
937 $out .=
'<div class="dol-social-share-reddit">'.
"\n";
938 $out .=
'<a href="https://www.reddit.com/submit" target="_blank" rel="noopener noreferrer external" onclick="window.location = \'https://www.reddit.com/submit?url='.$fullurl.
'\';
return false">';
939 $out .= '<span class="dol-social-share-reddit-span
">Reddit</span>';
941 $out .= '</div>'."\n
";
944 $out .= '<div class="dol-social-share-fbl
">'."\n
";
945 $out .= '<div id="fb-root
"></div>'."\n
";
946 $out .= '<script nonce="'.getNonce().'">(function(d, s, id) {
947 var js, fjs = d.getElementsByTagName(s)[0];
948 if (d.getElementById(id)) return;
949 js = d.createElement(s); js.id = id;
951 fjs.parentNode.insertBefore(js, fjs);
952 }(document, \
'script\', \'facebook-jssdk\'));</script>
955 layout="button_count"
960 action="like" ></fb:like>'.
"\n";
961 $out .=
'</div>'.
"\n";
963 $out .=
"\n</div>\n";
965 $out .=
'<!-- virtual host not defined in CMS. No way to add sharing buttons -->'.
"\n";
967 $out .=
'<!-- section end for social network sharing of page -->'.
"\n";
987function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield =
'date_creation', $sortorder =
'DESC', $langcode =
'', $otherfilters =
'null', $status = 1)
989 global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
992 $arrayresult = array(
'code'=>
'',
'list'=>array());
994 if (!is_object($weblangs)) {
998 if (empty($searchstring) && empty($type) && empty($langcode) && empty($otherfilters)) {
1000 $arrayresult[
'code'] =
'KO';
1001 $arrayresult[
'message'] = $weblangs->trans(
"EmptySearchString");
1002 } elseif ($searchstring &&
dol_strlen($searchstring) < 2) {
1003 $weblangs->load(
"errors");
1005 $arrayresult[
'code'] =
'KO';
1006 $arrayresult[
'message'] = $weblangs->trans(
"ErrorSearchCriteriaTooSmall");
1008 $tmparrayoftype = explode(
',', $type);
1022 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/meta/', $algo) || preg_match(
'/content/', $algo))) {
1023 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
1025 $sql =
'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.
'website_page as wp';
1026 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
1027 $sql .=
', '.MAIN_DB_PREFIX.
'categorie_website_page as cwp';
1029 $sql .=
" WHERE wp.fk_website = ".((int) $website->id);
1031 $sql .=
" AND wp.status = ".((int) $status);
1034 $sql .=
" AND wp.lang = '".$db->escape($langcode).
"'";
1037 $tmparrayoftype = explode(
',', $type);
1039 foreach ($tmparrayoftype as $tmptype) {
1040 $typestring .= ($typestring ?
", " :
"").
"'".$db->escape(trim($tmptype)).
"'";
1042 $sql .=
" AND wp.type_container IN (".$db->sanitize($typestring, 1).
")";
1046 if (preg_match(
'/meta/', $algo)) {
1047 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%'";
1048 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).
",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring)).
"%'";
1050 if (preg_match(
'/content/', $algo)) {
1051 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%'";
1053 $sql .= $searchalgo;
1054 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
1055 $sql .=
' AND cwp.fk_website_page = wp.rowid AND cwp.fk_categorie = '.((int) $otherfilters[
'category']);
1058 $sql .= $db->order($sortfield, $sortorder);
1059 $sql .= $db->plimit($max);
1062 $resql = $db->query($sql);
1066 while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0)) {
1067 if ($obj->rowid > 0) {
1069 $tmpwebsitepage->fetch($obj->rowid);
1070 if ($tmpwebsitepage->id > 0) {
1071 $arrayresult[
'list'][$obj->rowid] = $tmpwebsitepage;
1079 $arrayresult[
'code'] = $db->lasterrno();
1080 $arrayresult[
'message'] = $db->lasterror();
1086 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/sitefiles/', $algo))) {
1087 global $dolibarr_main_data_root;
1089 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$website->ref;
1090 $filehtmlheader = $pathofwebsite.
'/htmlheader.html';
1091 $filecss = $pathofwebsite.
'/styles.css.php';
1092 $filejs = $pathofwebsite.
'/javascript.js.php';
1093 $filerobot = $pathofwebsite.
'/robots.txt';
1094 $filehtaccess = $pathofwebsite.
'/.htaccess';
1095 $filemanifestjson = $pathofwebsite.
'/manifest.json.php';
1096 $filereadme = $pathofwebsite.
'/README.md';
1098 $filecontent = file_get_contents($filehtmlheader);
1099 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1100 $arrayresult[
'list'][] = array(
'type'=>
'website_htmlheadercontent');
1103 $filecontent = file_get_contents($filecss);
1104 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1105 $arrayresult[
'list'][] = array(
'type'=>
'website_csscontent');
1108 $filecontent = file_get_contents($filejs);
1109 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1110 $arrayresult[
'list'][] = array(
'type'=>
'website_jscontent');
1113 $filerobot = file_get_contents($filerobot);
1114 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1115 $arrayresult[
'list'][] = array(
'type'=>
'website_robotcontent');
1123 $arrayresult[
'code'] =
'OK';
1124 if (empty($arrayresult[
'list'])) {
1125 $arrayresult[
'code'] =
'KO';
1126 $arrayresult[
'message'] = $weblangs->trans(
"NoRecordFound");
1130 $arrayresult[
'code'] =
'KO';
1131 $arrayresult[
'message'] =
'No supported algorithm found';
1135 return $arrayresult;
1152function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto =
'subpage')
1158 dol_syslog(
"Call getAllImages with grabimagesinto=".$grabimagesinto);
1160 $alreadygrabbed = array();
1162 if (preg_match(
'/\/$/', $urltograb)) {
1165 $urltograb = dirname($urltograb);
1169 preg_match_all(
'/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
1171 foreach ($regs[0] as $key => $val) {
1172 if (preg_match(
'/^data:image/i', $regs[2][$key])) {
1176 if (preg_match(
'/^\//', $regs[2][$key])) {
1178 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1180 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1183 $linkwithoutdomain = $regs[2][$key];
1184 $dirforimages =
'/'.$objectpage->pageurl;
1185 if ($grabimagesinto ==
'root') {
1190 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1191 if (preg_match(
'/^http/', $regs[2][$key])) {
1192 $urltograbbis = $regs[2][$key];
1193 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1194 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1196 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1199 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1200 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1206 if (empty($alreadygrabbed[$urltograbbis])) {
1208 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1209 if ($tmpgeturl[
'curl_error_no']) {
1211 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1213 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1215 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1218 $alreadygrabbed[$urltograbbis] = 1;
1222 $fp = fopen($filetosave,
"w");
1223 fputs($fp, $tmpgeturl[
'content']);
1231 $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);
1236 preg_match_all(
'/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
1238 foreach ($regs[0] as $key => $val) {
1239 if (preg_match(
'/^data:image/i', $regs[2][$key])) {
1243 if (preg_match(
'/^\//', $regs[2][$key])) {
1245 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1247 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1250 $linkwithoutdomain = $regs[2][$key];
1252 $dirforimages =
'/'.$objectpage->pageurl;
1253 if ($grabimagesinto ==
'root') {
1257 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1259 if (preg_match(
'/^http/', $regs[2][$key])) {
1260 $urltograbbis = $regs[2][$key];
1261 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1262 $filetosave = $conf->medias->multidir_output[$conf->entity].
'/image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1265 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1268 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1269 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1275 if (empty($alreadygrabbed[$urltograbbis])) {
1277 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1278 if ($tmpgeturl[
'curl_error_no']) {
1280 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1282 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1284 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1287 $alreadygrabbed[$urltograbbis] = 1;
1291 $fp = fopen($filetosave,
"w");
1292 fputs($fp, $tmpgeturl[
'content']);
1300 $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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
Download all images found into page content $tmp.
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.
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.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
getStructuredData($type, $data=array())
Return HTML content to add structured data for an article, news or Blog Post.
dolWebsiteIncrementCounter($websiteid, $websitepagetype, $websitepageid)
Increase the website counter of page access.
dolReplaceSmileyCodeWithUTF8($content)
Converts smiley string into the utf8 sequence.
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.
getSocialNetworkSharingLinks()
Return HTML content to add structured data for an article, news or Blog Post.
redirectToContainer($containerref, $containeraliasalt='', $containerid=0, $permanent=0)
Format img tags to introduce viewimage on img src.
dolWebsiteOutput($content, $contenttype='html', $containerid='')
Render a string of an HTML content and output it.
getSocialNetworkHeaderCards($params=null)
Return HTML content to add as header card for an article, news or Blog Post or home page.