36 $str = str_replace(
'<?=',
'<?php', $str);
42 $parts = preg_split(
'/'.preg_quote(
'<?php',
'/').
'/i', $str);
46 foreach ($parts as $part) {
53 $partlings = explode(
'?>', $part);
54 if (!empty($partlings)) {
57 if (count($partlings) > 1) {
63 $newstr .=
'<span phptag>'.$replacewith.
'</span>'.implode(
'', $partlings);
80 $str = str_replace(
'<?=',
'<?php', $str);
81 $str = str_replace(
'<?php',
'__LTINTPHP__', $str);
82 $str = str_replace(
'<?',
'<?php', $str);
83 $str = str_replace(
'__LTINTPHP__',
'<?php', $str);
89 $parts = preg_split(
'/'.preg_quote(
'<?php',
'/').
'/i', $str);
93 foreach ($parts as $part) {
100 $partlings = explode(
'?>', $part, 2);
101 if (!empty($partlings)) {
102 $newstr .= $partlings[0].
'?>';
104 $newstr .= $part.
'?>';
127 dol_syslog(
'dolWebsiteReplacementOfLinks start (contenttype='.$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
')', LOG_DEBUG);
131 $replacewith =
'...php...';
132 if ($removephppart) {
135 $content = preg_replace(
'/value="<\?php((?!\?>).)*\?>\n*/ims',
'value="'.$replacewith.
'"', $content);
137 $replacewith =
'"callto=#';
138 if ($removephppart) {
141 $content = preg_replace(
'/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
143 $replacewith =
'"mailto=#';
144 if ($removephppart) {
147 $content = preg_replace(
'/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
149 $replacewith =
'src="php';
150 if ($removephppart) {
153 $content = preg_replace(
'/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
155 $replacewith =
'href="php';
156 if ($removephppart) {
159 $content = preg_replace(
'/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
162 $replacewith =
'...php...';
163 if ($removephppart) {
173 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
174 $content = str_replace(
'src="javascript.js.php',
'src="!~!~!~javascript.js.php', $content);
175 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
176 $content = str_replace(
'xlink:href="',
'xlink:href="!~!~!~', $content);
177 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
178 $content = str_replace(
'src="//',
'src="!~!~!~//', $content);
179 $content = str_replace(
'src="viewimage.php',
'src="!~!~!~/viewimage.php', $content);
180 $content = str_replace(
'src="/viewimage.php',
'src="!~!~!~/viewimage.php', $content);
181 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
182 $content = str_replace(
'href="document.php',
'href="!~!~!~/document.php', $content);
183 $content = str_replace(
'href="/document.php',
'href="!~!~!~/document.php', $content);
184 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
187 $content = preg_replace(
'/(href=")\/(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageid='.$website->fk_default_home.
'\2"', $content, -1, $nbrep);
189 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
191 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
194 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
195 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
199 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
201 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
203 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
206 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
209 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
210 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
213 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
216 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
217 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
219 $content = str_replace(
'!~!~!~',
'', $content);
221 dol_syslog(
'dolWebsiteReplacementOfLinks end', LOG_DEBUG);
236 ":face_with_tears_of_joy:" =>
"\xF0\x9F\x98\x82",
237 ":grinning_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x81",
238 ":smiling_face_with_open_mouth:" =>
"\xF0\x9F\x98\x83",
239 ":smiling_face_with_open_mouth_and_cold_sweat:" =>
"\xF0\x9F\x98\x85",
240 ":smiling_face_with_open_mouth_and_tightly_closed_eyes:" =>
"\xF0\x9F\x98\x86",
241 ":winking_face:" =>
"\xF0\x9F\x98\x89",
242 ":smiling_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x8A",
243 ":face_savouring_delicious_food:" =>
"\xF0\x9F\x98\x8B",
244 ":relieved_face:" =>
"\xF0\x9F\x98\x8C",
245 ":smiling_face_with_heart_shaped_eyes:" =>
"\xF0\x9F\x98\x8D",
246 ":smiling_face_with_sunglasses:" =>
"\xF0\x9F\x98\x8E",
247 ":smirking_face:" =>
"\xF0\x9F\x98\x8F",
248 ":neutral_face:" =>
"\xF0\x9F\x98\x90",
249 ":expressionless_face:" =>
"\xF0\x9F\x98\x91",
250 ":unamused_face:" =>
"\xF0\x9F\x98\x92",
251 ":face_with_cold_sweat:" =>
"\xF0\x9F\x98\x93",
252 ":pensive_face:" =>
"\xF0\x9F\x98\x94",
253 ":confused_face:" =>
"\xF0\x9F\x98\x95",
254 ":confounded_face:" =>
"\xF0\x9F\x98\x96",
255 ":kissing_face:" =>
"\xF0\x9F\x98\x97",
256 ":face_throwing_a_kiss:" =>
"\xF0\x9F\x98\x98",
257 ":kissing_face_with_smiling_eyes:" =>
"\xF0\x9F\x98\x99",
258 ":kissing_face_with_closed_eyes:" =>
"\xF0\x9F\x98\x9A",
259 ":face_with_stuck_out_tongue:" =>
"\xF0\x9F\x98\x9B",
260 ":face_with_stuck_out_tongue_and_winking_eye:" =>
"\xF0\x9F\x98\x9C",
261 ":face_with_stuck_out_tongue_and_tightly_closed_eyes:" =>
"\xF0\x9F\x98\x9D",
262 ":disappointed_face:" =>
"\xF0\x9F\x98\x9E",
263 ":worried_face:" =>
"\xF0\x9F\x98\x9F",
264 ":angry_face:" =>
"\xF0\x9F\x98\xA0",
265 ":face_with_symbols_on_mouth:" =>
"\xF0\x9F\x98\xA1",
267 foreach ($map as $key => $value) {
268 $content = str_replace($key, $value, $content);
286 global $db, $langs,
$conf, $user;
287 global $dolibarr_main_url_root, $dolibarr_main_data_root;
289 global $includehtmlcontentopened;
290 '@phan-var-force Website $website';
294 dol_syslog(
"dolWebsiteOutput start - contenttype=".$contenttype.
" containerid=".$containerid.
" USEDOLIBARREDITOR=".(defined(
'USEDOLIBARREDITOR') ?
'1' :
'').
" USEDOLIBARRSERVER=".(defined(
'USEDOLIBARRSERVER') ?
'1' :
'').
' includehtmlcontentopened='.$includehtmlcontentopened);
299 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
300 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
303 if (defined(
'USEDOLIBARREDITOR')) {
305 if ($contenttype ==
'html') {
306 $content = preg_replace(
'/<head>.*<\/head>/ims',
'', $content);
307 $content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $content);
308 $content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $content);
310 } elseif (defined(
'USEDOLIBARRSERVER')) {
311 $content = str_replace(
'<link rel="stylesheet" href="/styles.css',
'<link rel="stylesheet" href="styles.css', $content);
312 $content = str_replace(
' async src="/javascript.js',
' async src="javascript.js', $content);
315 $content = str_replace(
'href="styles.css.php',
'href="!~!~!~styles.css.php', $content);
316 $content = str_replace(
'src="javascript.css.php',
'src="!~!~!~javascript.css.php', $content);
317 $content = str_replace(
'href="http',
'href="!~!~!~http', $content);
318 $content = str_replace(
'xlink:href="',
'xlink:href="!~!~!~', $content);
319 $content = str_replace(
'href="//',
'href="!~!~!~//', $content);
320 $content = str_replace(
'src="//',
'src="!~!~!~//', $content);
321 $content = str_replace(array(
'src="viewimage.php',
'src="/viewimage.php'),
'src="!~!~!~/viewimage.php', $content);
322 $content = str_replace(
'src="'.DOL_URL_ROOT.
'/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
323 $content = str_replace(array(
'href="document.php',
'href="/document.php'),
'href="!~!~!~/document.php', $content);
324 $content = str_replace(
'href="'.DOL_URL_ROOT.
'/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
327 $content = preg_replace(
'/(href=")\/\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'"', $content, -1, $nbrep);
329 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2\3"', $content, -1, $nbrep);
333 $content = preg_replace(
'/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2&\3\4"', $content, -1, $nbrep);
335 $content = preg_replace(
'/([\'"])_service_([^\'"]+)\.php\1/',
'\1!~!~!~' . DOL_URL_ROOT .
'/public/website/index.php?website=' . $website->ref .
'&pageref=_service_\2\1', $content, -1, $nbrep);
337 $content = preg_replace(
'/([\'"])_library_([^\'"]+)\.php\1/',
'\1!~!~!~' . DOL_URL_ROOT .
'/public/website/index.php?website=' . $website->ref .
'&pageref=_library_\2\1', $content, -1, $nbrep);
339 $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);
342 $content = preg_replace(
'/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
343 $content = preg_replace(
'/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
346 $content = preg_replace(
'/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
347 $content = preg_replace(
'/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
348 $content = preg_replace(
'/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'\2\3', $content, -1, $nbrep);
351 $content = preg_replace(
'/url\((["\']?)\/?medias\//',
'url(\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
352 $content = preg_replace(
'/data-slide-bg=(["\']?)\/?medias\//',
'data-slide-bg=\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
356 $content = preg_replace(
'/(<img[^>]*src=")\/?medias\//',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
358 $content = preg_replace(
'/(<img[^>]*src=")\/?([^:\"\!]+)\"/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=\2"', $content, -1, $nbrep);
360 $content = preg_replace(
'/(<img[^>]*src=")(\/?viewimage\.php)/',
'\1!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content, -1, $nbrep);
363 $content = preg_replace(
'/(action=")\/?([^:\"]*)(\.php\")/',
'\1!~!~!~'.DOL_URL_ROOT.
'/public/website/index.php?website='.$website->ref.
'&pageref=\2"', $content, -1, $nbrep);
366 $content = str_replace(
'src="!~!~!~/viewimage.php',
'src="!~!~!~'.DOL_URL_ROOT.
'/viewimage.php', $content);
367 $content = str_replace(
'href="!~!~!~/document.php',
'href="!~!~!~'.DOL_URL_ROOT.
'/document.php', $content);
370 if (empty($includehtmlcontentopened)) {
371 $content = str_replace(
'!~!~!~',
'', $content);
374 $symlinktomediaexists = 1;
375 if ($website->virtualhost) {
376 $content = preg_replace(
'/^(<link[^>]*rel="canonical" href=")\//m',
'\1'.$website->virtualhost.
'/', $content, -1, $nbrep);
385 if (!$symlinktomediaexists) {
387 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
388 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/wrapper.php?modulepart=medias&file=medias/image/', $content, -1, $nbrep);
390 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
391 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
393 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
394 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
395 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
397 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
398 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
399 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep);
401 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
404 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
405 $content = preg_replace(
'/(<a[^>]*href=")\/?documents\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
408 $content = preg_replace(
'/(<img[^>]*src=")\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
409 $content = preg_replace(
'/(url\(["\']?)\/?image\//',
'\1/medias/image/', $content, -1, $nbrep);
411 $content = preg_replace(
'/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
412 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
414 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
415 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/medias/\4\5', $content, -1, $nbrep);
416 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/',
'\1/medias/\4\5', $content, -1, $nbrep);
418 $content = preg_replace(
'/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
419 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
420 $content = preg_replace(
'/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/',
'\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep);
422 $content = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/',
'\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep);
425 $content = preg_replace(
'/(<img[^>]*src=")\/?viewimage\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
426 $content = preg_replace(
'/(<a[^>]*href=")\/?document\.php/',
'\1/wrapper.php', $content, -1, $nbrep);
430 if (!defined(
'USEDOLIBARREDITOR')) {
431 $content = str_replace(
' contenteditable="true"',
' contenteditable="false"', $content);
435 $content = str_replace(
'<body id="bodywebsite" class="bodywebsite',
'<body id="bodywebsite" class="bodywebsite ' .
getDolGlobalString(
'WEBSITE_ADD_CSS_TO_BODY'), $content);
457 if (in_array($websitepagetype, array(
'blogpost',
'page'))) {
462 $sql =
"UPDATE ".$db->prefix().
"website SET ";
463 $sql .=
" pageviews_total = pageviews_total + 1,";
464 $sql .=
" pageviews_month = pageviews_month + 1,";
466 $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').
",";
467 $sql .=
" lastaccess = '".$db->idate(
dol_now(
'gmt'),
'gmt').
"',";
468 $sql .=
" lastpageid = ".((int) $websitepageid);
469 $sql .=
" WHERE rowid = ".((int) $websiteid);
471 $resql = $db->query($sql);
519function redirectToContainer($containerref, $containeraliasalt =
'', $containerid = 0, $permanent = 0, $parameters = array())
521 global $db, $website;
522 '@phan-var-force Website $website';
528 if ($containeraliasalt) {
529 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
532 $result = $tmpwebsitepage->fetch(0, $website->id,
'', $containeraliasalt);
534 $containerref = $tmpwebsitepage->pageurl;
536 print
"Error, page contains a redirect to the alternative alias '".$containeraliasalt.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
541 if (defined(
'USEDOLIBARREDITOR')) {
545 $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.";
546 setEventMessages($text,
null,
'warnings',
'WEBSITEREDIRECTDISABLED'.$containerref);
550 if (defined(
'USEDOLIBARRSERVER')) {
552 if (!$containeraliasalt) {
553 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
556 $result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
557 unset($tmpwebsitepage);
560 $currenturi = $_SERVER[
"REQUEST_URI"];
562 if (preg_match(
'/&pageref=([^&]+)/', $currenturi, $regtmp)) {
563 if ($regtmp[0] == $containerref) {
564 print
"Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref.
"' in web site '".$website->ref.
"'";
567 $newurl = preg_replace(
'/&pageref=([^&]+)/',
'&pageref='.$containerref, $currenturi);
570 $newurl = $currenturi.
'&pageref='.urlencode($containerref);
574 $newurl =
'/'.$containerref.
'.php';
575 $newurl .= (empty($_SERVER[
"QUERY_STRING"]) ?
'' :
'?'.$_SERVER[
"QUERY_STRING"]);
579 if (!empty($parameters)) {
580 $separator = (parse_url($newurl, PHP_URL_QUERY) ==
null) ?
'?' :
'&';
581 $newurl = $newurl . $separator . http_build_query($parameters);
584 header(
"Status: 301 Moved Permanently",
false, 301);
586 header(
"Location: ".$newurl);
589 print
"Error, page contains a redirect to the alias page '".$containerref.
"' that does not exists in web site (".$website->id.
" / ".$website->ref.
")";
605 global
$conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
606 global $includehtmlcontentopened;
607 global $websitekey, $websitepagefile;
608 '@phan-var-force Website $website';
612 if (!preg_match(
'/\.php$/i', $containerref)) {
613 $containerref .=
'.php';
616 $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey.
'/'.$containerref;
618 if (empty($includehtmlcontentopened)) {
619 $includehtmlcontentopened = 0;
621 $includehtmlcontentopened++;
622 if ($includehtmlcontentopened > $MAXLEVEL) {
623 print
'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.((int) $MAXLEVEL).
".\n";
635 $res = @include_once $fullpathfile;
637 $res = @include $fullpathfile;
639 $tmpoutput = ob_get_contents();
643 if (!empty($websitepage->type_container) && !in_array($websitepage->type_container, array(
'library',
'service'))) {
644 print
"\n".
'<!-- include '.$websitekey.
'/'.$containerref.(is_object($websitepage) ?
' parent id='.$websitepage->id :
'').
' level = '.$includehtmlcontentopened.
' -->'.
"\n";
646 print preg_replace(array(
'/^.*<body[^>]*>/ims',
'/<\/body>.*$/ims'), array(
'',
''), $tmpoutput);
649 print
'ERROR: FAILED TO INCLUDE PAGE '.$containerref.
".\n";
652 $includehtmlcontentopened--;
667 global
$conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs;
668 '@phan-var-force Website $website';
670 $type = strtolower($type);
672 if ($type ==
'software') {
673 $ret =
'<!-- Add structured data for entry in a software annuary -->'.
"\n";
674 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
676 "@context": "https://schema.org",
677 "@type": "SoftwareApplication",
678 "name": "'.dol_escape_json($data[
'name']).
'",
680 "applicationCategory": "https://schema.org/'.
dol_escape_json($data[
'applicationCategory']).
'",';
681 if (!empty($data[
'ratingcount'])) {
684 "@type": "AggregateRating",
685 "ratingValue": "'.dol_escape_json($data[
'ratingvalue']).
'",
692 "price": "'.dol_escape_json($data[
'price']).
'",
696 $ret .=
'</script>'.
"\n";
697 } elseif ($type ==
'organization') {
698 $companyname = $mysoc->name;
701 $ret =
'<!-- Add structured data for organization -->'.
"\n";
702 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
704 "@context": "https://schema.org",
705 "@type": "Organization",
706 "name": "'.dol_escape_json(!empty($data[
'name']) ? $data[
'name'] : $companyname).
'",
707 "url": "'.
dol_escape_json(!empty($data[
'url']) ? $data[
'url'] : $url).
'",
708 "logo": "'.($data[
'logo'] ?
dol_escape_json($data[
'logo']) :
'/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo)).
'",
710 "@type": "ContactPoint",
711 "contactType": "Contact",
712 "email": "'.
dol_escape_json(!empty($data[
'email']) ? $data[
'email'] : $mysoc->email).
'"
714 if (is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
716 $ret .=
'"sameAs": [';
718 foreach ($mysoc->socialnetworks as $key => $value) {
719 if ($key ==
'linkedin') {
720 $ret .=
'"https://www.'.$key.
'.com/company/'.
dol_escape_json($value).
'"';
721 } elseif ($key ==
'youtube') {
727 if ($i < count($mysoc->socialnetworks)) {
734 $ret .=
'</script>'.
"\n";
735 } elseif ($type ==
'blogpost') {
736 if (!empty($websitepage->author_alias)) {
741 $pageurl = $websitepage->pageurl;
742 $title = $websitepage->title;
743 $image = $websitepage->image;
744 $companyname = $mysoc->name;
745 $description = $websitepage->description;
747 $pageurl = str_replace(
'__WEBSITE_KEY__', $website->ref, $pageurl);
748 $title = str_replace(
'__WEBSITE_KEY__', $website->ref, $title);
749 $image =
'/medias'.(preg_match(
'/^\//', $image) ?
'' :
'/').str_replace(
'__WEBSITE_KEY__', $website->ref, $image);
750 $companyname = str_replace(
'__WEBSITE_KEY__', $website->ref, $companyname);
751 $description = str_replace(
'__WEBSITE_KEY__', $website->ref, $description);
753 $ret =
'<!-- Add structured data for blog post -->'.
"\n";
754 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
756 "@context": "https://schema.org",
757 "@type": "NewsArticle",
758 "mainEntityOfPage": {
760 "@id": "'.dol_escape_json($pageurl).
'"
766 "dateCreated": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
767 "datePublished": "'.
dol_print_date($websitepage->date_creation,
'dayhourrfc').
'",
768 "dateModified": "'.
dol_print_date($websitepage->date_modification,
'dayhourrfc').
'",
774 "@type": "Organization",
777 "@type": "ImageObject",
778 "url": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).
'"
781 if ($websitepage->keywords) {
782 $ret .=
'"keywords": [';
784 $arrayofkeywords = explode(
',', $websitepage->keywords);
785 foreach ($arrayofkeywords as $keyword) {
786 $ret .=
'"'.dol_escape_json($keyword).
'"';
788 if ($i < count($arrayofkeywords)) {
794 $ret .=
'"description": "'.dol_escape_json($description).
'"';
795 $ret .=
"\n".
'}'.
"\n";
796 $ret .=
'</script>'.
"\n";
798 $ret =
'<!-- no structured data inserted inline inside blogpost because no author_alias defined -->'.
"\n";
800 } elseif ($type ==
'product') {
801 $ret =
'<!-- Add structured data for product -->'.
"\n";
802 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
804 "@context": "https://schema.org/",
806 "name": "'.dol_escape_json($data[
'label']).
'",
823 "url": "https://example.com/anvil",
824 "priceCurrency": "'.
dol_escape_json($data[
'currency'] ? $data[
'currency'] :
$conf->currency).
'",
826 "itemCondition": "https://schema.org/UsedCondition",
827 "availability": "https://schema.org/InStock",
829 "@type": "Organization",
834 $ret .=
'</script>'.
"\n";
835 } elseif ($type ==
'qa') {
836 $ret =
'<!-- Add structured data for QA -->'.
"\n";
837 $ret .=
'<script nonce="'.getNonce().
'" type="application/ld+json">'.
"\n";
839 "@context": "https://schema.org/",
843 "name": "'.dol_escape_json($data[
'name']).
'",
860 $ret .=
'</script>'.
"\n";
875 global
$conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
876 '@phan-var-force Website $website';
880 if ($website->virtualhost) {
881 $pageurl = $websitepage->pageurl;
882 $title = $websitepage->title;
883 $image = $websitepage->image;
884 $companyname = $mysoc->name;
885 $description = $websitepage->description;
887 $pageurl = str_replace(
'__WEBSITE_KEY__', $website->ref, $pageurl);
888 $title = str_replace(
'__WEBSITE_KEY__', $website->ref, $title);
889 $image =
'/medias'.(preg_match(
'/^\//', $image) ?
'' :
'/').str_replace(
'__WEBSITE_KEY__', $website->ref, $image);
890 $companyname = str_replace(
'__WEBSITE_KEY__', $website->ref, $companyname);
891 $description = str_replace(
'__WEBSITE_KEY__', $website->ref, $description);
894 if ($websitepage->lang) {
895 $shortlangcode = substr($websitepage->lang, 0, 2);
897 if (empty($shortlangcode)) {
898 $shortlangcode = substr($website->lang, 0, 2);
901 $fullurl = $website->virtualhost.
'/'.$websitepage->pageurl.
'.php';
902 $canonicalurl = $website->virtualhost.(($websitepage->id == $website->fk_default_home) ?
'/' : (($shortlangcode != substr($website->lang, 0, 2) ?
'/'.$shortlangcode :
'').
'/'.$websitepage->pageurl.
'.php'));
903 $hashtags = trim(implode(
' #', array_map(
'trim', explode(
',', $websitepage->keywords))));
906 $out .=
'<meta name="og:type" content="website">'.
"\n";
907 $out .=
'<meta name="og:title" content="'.$websitepage->title.
'">'.
"\n";
908 if ($websitepage->image) {
909 $out .=
'<meta name="og:image" content="'.$website->virtualhost.$image.
'">'.
"\n";
911 $out .=
'<meta name="og:url" content="'.$canonicalurl.
'">'.
"\n";
914 $out .=
'<meta name="twitter:card" content="summary">'.
"\n";
915 if (!empty($params) && !empty($params[
'twitter_account'])) {
916 $out .=
'<meta name="twitter:site" content="@'.$params[
'twitter_account'].
'">'.
"\n";
917 $out .=
'<meta name="twitter:creator" content="@'.$params[
'twitter_account'].
'">'.
"\n";
919 $out .=
'<meta name="twitter:title" content="'.$websitepage->title.
'">'.
"\n";
920 if ($websitepage->description) {
921 $out .=
'<meta name="twitter:description" content="'.$websitepage->description.
'">'.
"\n";
923 if ($websitepage->image) {
924 $out .=
'<meta name="twitter:image" content="'.$website->virtualhost.$image.
'">'.
"\n";
951 global $website, $websitepage;
952 '@phan-var-force Website $website';
954 $out =
'<!-- section for social network sharing of page -->'.
"\n";
956 if ($website->virtualhost) {
957 $fullurl = $website->virtualhost.
'/'.$websitepage->pageurl.
'.php';
958 $hashtags = trim(implode(
' #', array_map(
'trim', explode(
',', $websitepage->keywords))));
960 $out .=
'<div class="dol-social-share">'.
"\n";
963 if (empty($socialnetworks) || preg_match(
'/twitter/', $socialnetworks)) {
964 $out .=
'<div class="dol-social-share-tw">'.
"\n";
965 $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>';
966 $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>';
967 $out .=
'</div>'.
"\n";
971 if (empty($socialnetworks) || preg_match(
'/reddit/', $socialnetworks)) {
972 $out .=
'<div class="dol-social-share-reddit">'.
"\n";
973 $out .=
'<a href="https://www.reddit.com/submit" target="_blank" rel="noopener noreferrer external" onclick="window.location = \'https://www.reddit.com/submit?url='.urlencode($fullurl).
'\';
return false">';
974 $out .= '<span class="dol-social-share-reddit-span
">Reddit</span>';
976 $out .= '</div>'."\n
";
980 if (empty($socialnetworks) || preg_match('/facebook/', $socialnetworks)) {
981 $out .= '<div class="dol-social-share-fbl
">'."\n
";
982 $out .= '<a href="https:
983 $out .=
'<span class="dol-social-share-fbl-span">Facebook</span>';
988 $out .=
"\n</div>\n";
990 $out .=
'<!-- virtual host not defined in CMS. No way to add sharing buttons -->'.
"\n";
992 $out .=
'<!-- section end for social network sharing of page -->'.
"\n";
1011 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1013 $regexforimg =
'('.$regexforimg.
')$';
1015 $sql =
"SELECT COUNT(rowid) as nb";
1016 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ecm_files";
1017 $sql .=
" WHERE entity IN (".getEntity(
$object->element).
")";
1018 $sql .=
" AND src_object_type = '".$db->escape(
$object->element).
"' AND src_object_id = ".((int)
$object->id);
1019 $sql .=
" AND ".$db->regexpsql(
'filename', $regexforimg, 1);
1020 $sql .=
" AND share IS NOT NULL";
1022 $resql = $db->query($sql);
1024 $obj = $db->fetch_object($resql);
1049 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1051 $regexforimg =
'('.$regexforimg.
')$';
1053 $sql =
"SELECT rowid, ref, share, filename, cover, position";
1054 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ecm_files";
1055 $sql .=
" WHERE entity IN (".getEntity(
$object->element).
")";
1056 $sql .=
" AND src_object_type = '".$db->escape(
$object->element).
"' AND src_object_id = ".((int)
$object->id);
1057 $sql .=
" AND ".$db->regexpsql(
'filename', $regexforimg, 1);
1058 $sql .= $db->order(
"cover,position,rowid",
"ASC,ASC,ASC");
1060 $resql = $db->query($sql);
1062 $num = $db->num_rows($resql);
1065 $foundnotshared = 0;
1067 $obj = $db->fetch_object($resql);
1069 if (empty($obj->share)) {
1074 if (defined(
'USEDOLIBARRSERVER') || defined(
'USEDOLIBARREDITOR')) {
1075 $image_path = DOL_URL_ROOT.
'/viewimage.php?hashp='.urlencode($obj->share);
1077 $image_path =
'/wrapper.php?hashp='.urlencode($obj->share);
1081 $image_path .=
'&extname='.urlencode($extName);
1085 if ($found >= $no) {
1090 if (!$found && $foundnotshared) {
1091 if (defined(
'USEDOLIBARRSERVER') || defined(
'USEDOLIBARREDITOR')) {
1092 $image_path = DOL_URL_ROOT.
'/viewimage.php?modulepart=common&file=nophotopublic.png';
1094 $image_path =
'/wrapper.php?modulepart=common&file=nophotopublic.png';
1099 if (empty($image_path)) {
1100 if (defined(
'USEDOLIBARRSERVER') || defined(
'USEDOLIBARREDITOR')) {
1101 $image_path = DOL_URL_ROOT.
'/viewimage.php?modulepart=common&file=nophoto.png';
1103 $image_path =
'/wrapper.php?modulepart=common&file=nophoto.png';
1123 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1125 $regexforimg =
'/('.$regexforimg.
')$/i';
1127 $sql =
"SELECT rowid, ref, share, filename, cover, position";
1128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ecm_files";
1129 $sql .=
" WHERE entity IN (".getEntity(
$object->element).
")";
1130 $sql .=
" AND src_object_type = '".$db->escape(
$object->element).
"' AND src_object_id = ".((int)
$object->id);
1131 $sql .= $db->order(
"cover,position,rowid",
"ASC,ASC,ASC");
1133 $resql = $db->query($sql);
1135 $num = $db->num_rows($resql);
1138 $obj = $db->fetch_object($resql);
1140 if (!empty($obj->share)) {
1141 $files[$obj->rowid][
'filename'] = $obj->filename;
1142 $files[$obj->rowid][
'position'] = $obj->position;
1143 if (defined(
'USEDOLIBARRSERVER') || defined(
'USEDOLIBARREDITOR')) {
1144 if (preg_match($regexforimg, $obj->filename)) {
1145 $files[$obj->rowid][
'url'] = DOL_URL_ROOT.
'/viewimage.php?hashp='.urlencode($obj->share);
1147 $files[$obj->rowid][
'url'] = DOL_URL_ROOT.
'/document.php?hashp='.urlencode($obj->share);
1150 $files[$obj->rowid][
'url'] =
'/wrapper.php?hashp='.urlencode($obj->share);
1177function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield =
'date_creation', $sortorder =
'DESC', $langcode =
'', $otherfilters = [], $status = 1)
1179 global
$conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs;
1180 '@phan-var-force Website $website';
1183 $arrayresult = array(
'code' =>
'',
'list' => array());
1186 if (!is_object($weblangs)) {
1205 $tmparrayoftype = explode(
',', $type);
1219 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/meta/', $algo) || preg_match(
'/content/', $algo))) {
1220 include_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
1222 $sql =
'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.
'website_page as wp';
1223 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
1224 $sql .=
', '.MAIN_DB_PREFIX.
'categorie_website_page as cwp';
1226 $sql .=
" WHERE wp.fk_website = ".((int) $website->id);
1228 $sql .=
" AND wp.status = ".((int) $status);
1231 $sql .=
" AND wp.lang = '".$db->escape($langcode).
"'";
1234 $tmparrayoftype = explode(
',', $type);
1236 foreach ($tmparrayoftype as $tmptype) {
1237 $typestring .= ($typestring ?
", " :
"").
"'".$db->escape(trim($tmptype)).
"'";
1239 $sql .=
" AND wp.type_container IN (".$db->sanitize($typestring, 1).
")";
1243 if (preg_match(
'/meta/', $algo)) {
1244 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%'";
1245 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).
",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring)).
"%'";
1247 if (preg_match(
'/content/', $algo)) {
1248 $searchalgo .= ($searchalgo ?
' OR ' :
'').
"wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring)).
"%'";
1250 $sql .= $searchalgo;
1251 if (is_array($otherfilters) && !empty($otherfilters[
'category'])) {
1252 $sql .=
' AND cwp.fk_website_page = wp.rowid AND cwp.fk_categorie = '.((int) $otherfilters[
'category']);
1255 $sql .= $db->order($sortfield, $sortorder);
1256 $sql .= $db->plimit($max);
1259 $resql = $db->query($sql);
1263 while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0)) {
1264 if ($obj->rowid > 0) {
1266 $tmpwebsitepage->fetch($obj->rowid);
1267 if ($tmpwebsitepage->id > 0) {
1268 $arrayresult[
'list'][$obj->rowid] = $tmpwebsitepage;
1276 $arrayresult[
'code'] = $db->lasterrno();
1277 $arrayresult[
'message'] = $db->lasterror();
1283 if (!$error && (empty($max) || ($found < $max)) && (preg_match(
'/sitefiles/', $algo))) {
1284 global $dolibarr_main_data_root;
1286 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$website->ref;
1287 $filehtmlheader = $pathofwebsite.
'/htmlheader.html';
1288 $filecss = $pathofwebsite.
'/styles.css.php';
1289 $filejs = $pathofwebsite.
'/javascript.js.php';
1290 $filerobot = $pathofwebsite.
'/robots.txt';
1291 $filehtaccess = $pathofwebsite.
'/.htaccess';
1292 $filemanifestjson = $pathofwebsite.
'/manifest.json.php';
1293 $filereadme = $pathofwebsite.
'/README.md';
1295 $filecontent = file_get_contents($filehtmlheader);
1296 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1297 $arrayresult[
'list'][] = array(
'type' =>
'website_htmlheadercontent');
1300 $filecontent = file_get_contents($filecss);
1301 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1302 $arrayresult[
'list'][] = array(
'type' =>
'website_csscontent');
1305 $filecontent = file_get_contents($filejs);
1306 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1307 $arrayresult[
'list'][] = array(
'type' =>
'website_jscontent');
1310 $filerobot = file_get_contents($filerobot);
1311 if ((empty($max) || ($found < $max)) && preg_match(
'/'.preg_quote($searchstring,
'/').
'/', $filecontent)) {
1312 $arrayresult[
'list'][] = array(
'type' =>
'website_robotcontent');
1320 $arrayresult[
'code'] =
'OK';
1321 if (empty($arrayresult[
'list'])) {
1322 $arrayresult[
'code'] =
'KO';
1323 $arrayresult[
'message'] = $weblangs->trans(
"NoRecordFound");
1327 $arrayresult[
'code'] =
'KO';
1328 $arrayresult[
'message'] =
'No supported algorithm found';
1332 return $arrayresult;
1346 $dom =
new DOMDocument();
1348 libxml_use_internal_errors(
false);
1349 if (LIBXML_VERSION < 20900) {
1353 libxml_disable_entity_loader(
true);
1357 $dom->loadHTML($htmlContent);
1360 libxml_clear_errors();
1363 $images = $dom->getElementsByTagName(
'img');
1366 if ($imageNumber > 0 && $imageNumber <= $images->length) {
1368 $img = $images->item($imageNumber - 1);
1369 if ($img instanceof DOMElement) {
1370 return $img->getAttribute(
'src');
1393function getAllImages(
$object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto =
'subpage')
1399 dol_syslog(
"Call getAllImages with grabimagesinto=".$grabimagesinto);
1401 $alreadygrabbed = array();
1403 if (preg_match(
'/\/$/', $urltograb)) {
1406 $urltograb = dirname($urltograb);
1410 preg_match_all(
'/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs);
1412 foreach ($regs[0] as $key => $val) {
1413 if (preg_match(
'/^data:image/i', $regs[2][$key])) {
1417 if (preg_match(
'/^\//', $regs[2][$key])) {
1419 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1421 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1424 $linkwithoutdomain = $regs[2][$key];
1425 $dirforimages =
'/'.$objectpage->pageurl;
1426 if ($grabimagesinto ==
'root') {
1431 $filetosave =
$conf->medias->multidir_output[
$conf->entity].
'/image/'.
$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1432 if (preg_match(
'/^http/', $regs[2][$key])) {
1433 $urltograbbis = $regs[2][$key];
1434 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1435 $filetosave =
$conf->medias->multidir_output[
$conf->entity].
'/image/'.
$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1437 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1440 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1441 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1443 if (empty($alreadygrabbed[$urltograbbis])) {
1445 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1446 if ($tmpgeturl[
'curl_error_no']) {
1448 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1450 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1452 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1455 $alreadygrabbed[$urltograbbis] = 1;
1459 $fp = fopen($filetosave,
"w");
1460 fwrite($fp, $tmpgeturl[
'content']);
1468 $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);
1473 preg_match_all(
'/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs);
1475 foreach ($regs[0] as $key => $val) {
1476 if (preg_match(
'/^data:image/i', $regs[2][$key])) {
1480 if (preg_match(
'/^\//', $regs[2][$key])) {
1482 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1484 $urltograbbis = $urltograb.
'/'.$regs[2][$key];
1487 $linkwithoutdomain = $regs[2][$key];
1489 $dirforimages =
'/'.$objectpage->pageurl;
1490 if ($grabimagesinto ==
'root') {
1494 $filetosave =
$conf->medias->multidir_output[
$conf->entity].
'/image/'.
$object->ref.$dirforimages.(preg_match(
'/^\//', $regs[2][$key]) ?
'' :
'/').$regs[2][$key];
1496 if (preg_match(
'/^http/', $regs[2][$key])) {
1497 $urltograbbis = $regs[2][$key];
1498 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1499 $filetosave =
$conf->medias->multidir_output[
$conf->entity].
'/image/'.
$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1502 $filename =
'image/'.$object->ref.$dirforimages.(preg_match(
'/^\//', $linkwithoutdomain) ?
'' :
'/').$linkwithoutdomain;
1505 $filetosave = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filetosave);
1506 $filename = preg_replace(
'/\/[^\/]+\/\.\./',
'', $filename);
1508 if (empty($alreadygrabbed[$urltograbbis])) {
1510 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1511 if ($tmpgeturl[
'curl_error_no']) {
1513 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1515 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1517 setEventMessages(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1520 $alreadygrabbed[$urltograbbis] = 1;
1524 $fp = fopen($filetosave,
"w");
1525 fwrite($fp, $tmpgeturl[
'content']);
1533 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'background'.$regs[1][$key].
'url("'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file='.$filename.
'")', $tmp);
1548 if (empty($postId)) {
1552 $sql =
"SELECT p.title, p.description, p.date_creation, p.image
1553 FROM ".MAIN_DB_PREFIX.
"website_page as p
1554 WHERE p.rowid = ".(intval($postId));
1556 $resql = $db->query($sql);
1558 return $db->fetch_array($resql);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
getDolGlobalString($key, $default='')
Return a 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).
getListOfPossibleImageExt($acceptsvg=0)
Return if a filename is file name of a supported image format.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
Download all images found into an external URL.
getImagePublicURLOfObject($object, $no=1, $extName='')
Return the public image URL of an object.
redirectToContainer($containerref, $containeraliasalt='', $containerid=0, $permanent=0, $parameters=array())
Format img tags to introduce viewimage on img src.
includeContainer($containerref, $once=0)
Clean an HTML page to report only content, so we can include it into another page.
getPublicFilesOfObject($object)
Return array with list of all public files of a given object.
getImageFromHtmlContent($htmlContent, $imageNumber=1)
Return the URL of an image found into a HTML content.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
getNbOfImagePublicURLOfObject($object)
Return nb of images known into inde files for an object;.
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=0)
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
getPagesFromSearchCriterias($type, $algo, $searchstring, $max=25, $sortfield='date_creation', $sortorder='DESC', $langcode='', $otherfilters=[], $status=1)
Return list of containers object that match a criteria.
dolWebsiteIncrementCounter($websiteid, $websitepagetype, $websitepageid)
Increase the website counter of page access.
getNewsDetailsById($postId)
Retrieves the details of a news post by its ID.
dolReplaceSmileyCodeWithUTF8($content)
Converts smiley string into the utf8 sequence.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolWebsiteOutput($content, $contenttype='html', $containerid=0)
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.
getSocialNetworkSharingLinks($socialnetworks='')
Return HTML content to add structured data for an article, news or Blog Post.