Dotclear

source: inc/admin/lib.dc.page.php @ 3872:39861f53bcc0

Revision 3872:39861f53bcc0, 45.5 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Use ... token for variable argument list rather than func_get_args() whenever is possible

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10if (!defined('DC_RC_PATH')) {return;}
11
12define('DC_AUTH_PAGE', 'auth.php');
13
14class dcPage
15{
16    private static $loaded_js     = array();
17    private static $loaded_css    = array();
18    private static $xframe_loaded = false;
19    private static $N_TYPES       = array(
20        "success" => "success",
21        "warning" => "warning-msg",
22        "error"   => "error",
23        "message" => "message",
24        "static"  => "static-msg");
25
26    # Auth check
27    public static function check($permissions)
28    {
29        global $core;
30
31        if ($core->blog && $core->auth->check($permissions, $core->blog->id)) {
32            return;
33        }
34
35        if (session_id()) {
36            $core->session->destroy();
37        }
38        http::redirect(DC_AUTH_PAGE);
39    }
40
41    # Check super admin
42    public static function checkSuper()
43    {
44        global $core;
45
46        if (!$core->auth->isSuperAdmin()) {
47            if (session_id()) {
48                $core->session->destroy();
49            }
50            http::redirect(DC_AUTH_PAGE);
51        }
52    }
53
54    # Top of admin page
55    public static function open($title = '', $head = '', $breadcrumb = '', $options = array())
56    {
57        global $core;
58
59        # List of user's blogs
60        if ($core->auth->getBlogCount() == 1 || $core->auth->getBlogCount() > 20) {
61            $blog_box =
62            '<p>' . __('Blog:') . ' <strong title="' . html::escapeHTML($core->blog->url) . '">' .
63            html::escapeHTML($core->blog->name) . '</strong>';
64
65            if ($core->auth->getBlogCount() > 20) {
66                $blog_box .= ' - <a href="' . $core->adminurl->get("admin.blogs") . '">' . __('Change blog') . '</a>';
67            }
68            $blog_box .= '</p>';
69        } else {
70            $rs_blogs = $core->getBlogs(array('order' => 'LOWER(blog_name)', 'limit' => 20));
71            $blogs    = array();
72            while ($rs_blogs->fetch()) {
73                $blogs[html::escapeHTML($rs_blogs->blog_name . ' - ' . $rs_blogs->blog_url)] = $rs_blogs->blog_id;
74            }
75            $blog_box =
76            '<p><label for="switchblog" class="classic">' .
77            __('Blogs:') . '</label> ' .
78            $core->formNonce() .
79            form::combo('switchblog', $blogs, $core->blog->id) .
80            '<input type="submit" value="' . __('ok') . '" class="hidden-if-js" /></p>';
81        }
82
83        $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'];
84
85        # Display
86        $headers = new ArrayObject(array());
87
88        # Content-Type
89        $headers['content-type'] = 'Content-Type: text/html; charset=UTF-8';
90
91        # Referrer Policy for admin pages
92        $headers['referrer'] = 'Referrer-Policy: strict-origin';
93
94        # Prevents Clickjacking as far as possible
95        if (isset($options['x-frame-allow'])) {
96            self::setXFrameOptions($headers, $options['x-frame-allow']);
97        } else {
98            self::setXFrameOptions($headers);
99        }
100
101        # Content-Security-Policy (only if safe mode if not active, it may help)
102        if (!$safe_mode && $core->blog->settings->system->csp_admin_on) {
103            // Get directives from settings if exist, else set defaults
104            $csp = new ArrayObject(array());
105
106                                                                                // SQlite Clearbricks driver does not allow using single quote at beginning or end of a field value
107                                                                                // so we have to use neutral values (localhost and 127.0.0.1) for some CSP directives
108            $csp_prefix = $core->con->driver() == 'sqlite' ? 'localhost ' : ''; // Hack for SQlite Clearbricks driver
109            $csp_suffix = $core->con->driver() == 'sqlite' ? ' 127.0.0.1' : ''; // Hack for SQlite Clearbricks driver
110
111            $csp['default-src'] = $core->blog->settings->system->csp_admin_default ?:
112            $csp_prefix . "'self'" . $csp_suffix;
113            $csp['script-src'] = $core->blog->settings->system->csp_admin_script ?:
114            $csp_prefix . "'self' 'unsafe-inline' 'unsafe-eval'" . $csp_suffix;
115            $csp['style-src'] = $core->blog->settings->system->csp_admin_style ?:
116            $csp_prefix . "'self' 'unsafe-inline'" . $csp_suffix;
117            $csp['img-src'] = $core->blog->settings->system->csp_admin_img ?:
118            $csp_prefix . "'self' data: http://media.dotaddict.org blob:";
119
120            # Cope with blog post preview (via public URL in iframe)
121            if (!is_null($core->blog->host)) {
122                $csp['default-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST);
123                $csp['script-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST);
124                $csp['style-src'] .= ' ' . parse_url($core->blog->host, PHP_URL_HOST);
125            }
126            # Cope with media display in media manager (via public URL)
127            if (!is_null($core->media)) {
128                $csp['img-src'] .= ' ' . parse_url($core->media->root_url, PHP_URL_HOST);
129            }
130            # Allow everything in iframe (used by editors to preview public content)
131            $csp['child-src'] = "*";
132
133            # --BEHAVIOR-- adminPageHTTPHeaderCSP
134            $core->callBehavior('adminPageHTTPHeaderCSP', $csp);
135
136            // Construct CSP header
137            $directives = array();
138            foreach ($csp as $key => $value) {
139                if ($value) {
140                    $directives[] = $key . ' ' . $value;
141                }
142            }
143            if (count($directives)) {
144                if (version_compare(phpversion(), '5.4', '>=')) {
145                    // csp_report.php needs PHP ≥ 5.4
146                    $directives[] = "report-uri " . DC_ADMIN_URL . "csp_report.php";
147                }
148                $report_only    = ($core->blog->settings->system->csp_admin_report_only) ? '-Report-Only' : '';
149                $headers['csp'] = "Content-Security-Policy" . $report_only . ": " . implode(" ; ", $directives);
150            }
151        }
152
153        # --BEHAVIOR-- adminPageHTTPHeaders
154        $core->callBehavior('adminPageHTTPHeaders', $headers);
155        foreach ($headers as $key => $value) {
156            header($value);
157        }
158
159        echo
160        '<!DOCTYPE html>' .
161        '<html lang="' . $core->auth->getInfo('user_lang') . '">' . "\n" .
162        "<head>\n" .
163        '  <meta charset="UTF-8" />' . "\n" .
164        '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />' . "\n" .
165        '  <meta name="GOOGLEBOT" content="NOSNIPPET" />' . "\n" .
166        '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />' . "\n" .
167        '  <title>' . $title . ' - ' . html::escapeHTML($core->blog->name) . ' - ' . html::escapeHTML(DC_VENDOR_NAME) . ' - ' . DC_VERSION . '</title>' . "\n";
168
169        if ($core->auth->user_prefs->interface->darkmode) {
170            echo self::jsVars(array('dotclear_darkMode' => 1));
171            echo self::cssLoad('style/default-dark.css');
172        } else {
173            echo self::jsVars(array('dotclear_darkMode' => 0));
174            echo self::cssLoad('style/default.css');
175        }
176        if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
177            echo self::cssLoad('style/default-rtl.css');
178        }
179
180        $core->auth->user_prefs->addWorkspace('interface');
181        if (!$core->auth->user_prefs->interface->hide_std_favicon) {
182            echo
183                '<link rel="icon" type="image/png" href="images/favicon96-login.png" />' . "\n" .
184                '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />' . "\n";
185        }
186
187        if ($core->auth->user_prefs->interface->htmlfontsize) {
188            echo
189            '<script type="text/javascript">' . "\n" .
190            self::jsVar('dotclear_htmlFontSize', $core->auth->user_prefs->interface->htmlfontsize) . "\n" .
191                "</script>\n";
192        }
193
194        echo
195        self::jsCommon() .
196        self::jsToggles() .
197            $head;
198
199        if ($core->auth->user_prefs->interface->hidemoreinfo) {
200            echo
201                '<script type="text/javascript">' . "\n" .
202                'dotclear.hideMoreInfo = true;' . "\n" .
203                "</script>\n";
204        }
205        if ($core->auth->user_prefs->interface->showajaxloader) {
206            echo
207                '<script type="text/javascript">' . "\n" .
208                'dotclear.showAjaxLoader = true;' . "\n" .
209                "</script>\n";
210        }
211
212        # --BEHAVIOR-- adminPageHTMLHead
213        $core->callBehavior('adminPageHTMLHead');
214
215        echo
216        "</head>\n" .
217        '<body id="dotclear-admin' .
218        ($safe_mode ? ' safe-mode' : '') . '" class="no-js' .
219        ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '') . '">' . "\n" .
220
221        '<ul id="prelude">' .
222        '<li><a href="#content">' . __('Go to the content') . '</a></li>' .
223        '<li><a href="#main-menu">' . __('Go to the menu') . '</a></li>' .
224        '<li><a href="#help">' . __('Go to help') . '</a></li>' .
225        '</ul>' . "\n" .
226        '<header id="header" role="banner">' .
227        '<h1><a href="' . $core->adminurl->get("admin.home") . '"><span class="hidden">' . DC_VENDOR_NAME . '</span></a></h1>' . "\n";
228
229        echo
230        '<form action="' . $core->adminurl->get("admin.home") . '" method="post" id="top-info-blog">' .
231        $blog_box .
232        '<p><a href="' . $core->blog->url . '" class="outgoing" title="' . __('Go to site') .
233        '">' . __('Go to site') . '<img src="images/outgoing-link.svg" alt="" /></a>' .
234        '</p></form>' .
235        '<ul id="top-info-user">' .
236        '<li><a class="' . (preg_match('/' . preg_quote($core->adminurl->get('admin.home')) . '$/', $_SERVER['REQUEST_URI']) ? ' active' : '') . '" href="' . $core->adminurl->get("admin.home") . '">' . __('My dashboard') . '</a></li>' .
237        '<li><a class="smallscreen' . (preg_match('/' . preg_quote($core->adminurl->get('admin.user.preferences')) . '(\?.*)?$/', $_SERVER['REQUEST_URI']) ? ' active' : '') .
238        '" href="' . $core->adminurl->get("admin.user.preferences") . '">' . __('My preferences') . '</a></li>' .
239        '<li><a href="' . $core->adminurl->get("admin.home", array('logout' => 1)) . '" class="logout"><span class="nomobile">' . sprintf(__('Logout %s'), $core->auth->userID()) .
240            '</span><img src="images/logout.png" alt="" /></a></li>' .
241            '</ul>' .
242            '</header>'; // end header
243
244        echo
245        '<div id="wrapper" class="clearfix">' . "\n" .
246        '<div class="hidden-if-no-js collapser-box"><button type="button" id="collapser" class="void-btn">' .
247        '<img class="collapse-mm visually-hidden" src="images/collapser-hide.png" alt="' . __('Hide main menu') . '" />' .
248        '<img class="expand-mm visually-hidden" src="images/collapser-show.png" alt="' . __('Show main menu') . '" />' .
249            '</button></div>' .
250            '<main id="main" role="main">' . "\n" .
251            '<div id="content" class="clearfix">' . "\n";
252
253        # Safe mode
254        if ($safe_mode) {
255            echo
256            '<div class="warning" role="alert"><h3>' . __('Safe mode') . '</h3>' .
257            '<p>' . __('You are in safe mode. All plugins have been temporarily disabled. Remind to log out then log in again normally to get back all functionalities') . '</p>' .
258                '</div>';
259        }
260
261        // Display breadcrumb (if given) before any error messages
262        echo $breadcrumb;
263
264        // Display notices and errors
265        echo self::notices();
266    }
267
268    public static function notices()
269    {
270        global $core;
271        static $error_displayed = false;
272
273        $res = '';
274
275        // return error messages if any
276        if ($core->error->flag() && !$error_displayed) {
277
278            # --BEHAVIOR-- adminPageNotificationError
279            $notice_error = $core->callBehavior('adminPageNotificationError', $core, $core->error);
280
281            if (isset($notice_error) && !empty($notice_error)) {
282                $res .= $notice_error;
283            } else {
284                $res .= '<div class="error"><p>' .
285                '<strong>' . (count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')) . '</strong>' .
286                '</p>' . $core->error->toHTML() . '</div>';
287            }
288            $error_displayed = true;
289        }
290
291        // return notices if any
292        if (isset($_SESSION['notifications'])) {
293            foreach ($_SESSION['notifications'] as $notification) {
294
295                # --BEHAVIOR-- adminPageNotification
296                $notice = $core->callBehavior('adminPageNotification', $core, $notification);
297
298                $res .= (isset($notice) && !empty($notice) ? $notice : self::getNotification($notification));
299            }
300            unset($_SESSION['notifications']);
301        }
302        return $res;
303    }
304
305    public static function addNotice($type, $message, $options = array())
306    {
307        if (isset(self::$N_TYPES[$type])) {
308            $class = self::$N_TYPES[$type];
309        } else {
310            $class = $type;
311        }
312        if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) {
313            $notifications = $_SESSION['notifications'];
314        } else {
315            $notifications = array();
316        }
317
318        $n = array_merge($options, array('class' => $class, 'ts' => time(), 'text' => $message));
319        if ($type != "static") {
320            $notifications[] = $n;
321        } else {
322            array_unshift($notifications, $n);
323        }
324        $_SESSION['notifications'] = $notifications;
325    }
326
327    public static function addSuccessNotice($message, $options = array())
328    {
329        self::addNotice("success", $message, $options);
330    }
331
332    public static function addWarningNotice($message, $options = array())
333    {
334        self::addNotice("warning", $message, $options);
335    }
336
337    public static function addErrorNotice($message, $options = array())
338    {
339        self::addNotice("error", $message, $options);
340    }
341
342    protected static function getNotification($n)
343    {
344        global $core;
345        $tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p';
346        $ts  = '';
347        if (!isset($n['with_ts']) || ($n['with_ts'] == true)) {
348            $ts = dt::str(__('[%H:%M:%S]'), $n['ts'], $core->auth->getInfo('user_tz')) . ' ';
349        }
350        $res = '<' . $tag . ' class="' . $n['class'] . '" role="alert">' . $ts . $n['text'] . '</' . $tag . '>';
351        return $res;
352    }
353
354    public static function close()
355    {
356        global $core;
357
358        if (!$GLOBALS['__resources']['ctxhelp']) {
359            if (!$core->auth->user_prefs->interface->hidehelpbutton) {
360                echo
361                '<p id="help-button"><a href="' . $core->adminurl->get("admin.help") . '" class="outgoing" title="' .
362                __('Global help') . '">' . __('Global help') . '</a></p>';
363            }
364        }
365
366        $menu = &$GLOBALS['_menu'];
367
368        echo
369        "</div>\n" . // End of #content
370        "</main>\n" . // End of #main
371
372        '<nav id="main-menu" role="navigation">' . "\n" .
373
374        '<form id="search-menu" action="' . $core->adminurl->get("admin.search") . '" method="get" role="search">' .
375        '<p><label for="qx" class="hidden">' . __('Search:') . ' </label>' . form::field('qx', 30, 255, '') .
376        '<input type="submit" value="' . __('OK') . '" /></p>' .
377            '</form>';
378
379        foreach ($menu as $k => $v) {
380            echo $menu[$k]->draw();
381        }
382
383        $text = sprintf(__('Thank you for using %s.'), 'Dotclear ' . DC_VERSION);
384
385        # --BEHAVIOR-- adminPageFooter
386        $textAlt = $core->callBehavior('adminPageFooter', $core, $text);
387        if ($textAlt != '') {
388            $text = $textAlt;
389        }
390        $text = html::escapeHTML($text);
391
392        echo
393        '</nav>' . "\n" . // End of #main-menu
394        "</div>\n";       // End of #wrapper
395
396        echo '<p id="gototop"><a href="#wrapper">' . __('Page top') . '</a></p>' . "\n";
397
398        $figure = "
399  ♥‿♥
400              |    |    |
401             )_)  )_)  )_)
402            )___))___))___)\
403           )____)____)_____)\\
404         _____|____|____|____\\\__
405---------\                   /---------
406  ^^^^^ ^^^^^^^^^^^^^^^^^^^^^
407    ^^^^      ^^^^     ^^^    ^^
408         ^^^^      ^^^
409  ";
410
411        echo
412            '<footer id="footer" role="contentinfo">' .
413            '<a href="http://dotclear.org/" title="' . $text . '">' .
414            '<img src="style/dc_logos/w-dotclear90.png" alt="' . $text . '" /></a></footer>' . "\n" .
415            "<!-- " . "\n" .
416            $figure .
417            " -->" . "\n";
418
419        if (defined('DC_DEV') && DC_DEV === true) {
420            echo self::debugInfo();
421        }
422
423        echo
424            '</body></html>';
425    }
426
427    public static function openPopup($title = '', $head = '', $breadcrumb = '')
428    {
429        global $core;
430
431        # Display
432        header('Content-Type: text/html; charset=UTF-8');
433
434        # Referrer Policy for admin pages
435        header('Referrer-Policy: strict-origin');
436
437        # Prevents Clickjacking as far as possible
438        header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
439
440        echo
441        '<!DOCTYPE html>' .
442        '<html lang="' . $core->auth->getInfo('user_lang') . '">' . "\n" .
443        "<head>\n" .
444        '  <meta charset="UTF-8" />' . "\n" .
445        '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />' . "\n" .
446        '  <title>' . $title . ' - ' . html::escapeHTML($core->blog->name) . ' - ' . html::escapeHTML(DC_VENDOR_NAME) . ' - ' . DC_VERSION . '</title>' . "\n" .
447        '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />' . "\n" .
448        '  <meta name="GOOGLEBOT" content="NOSNIPPET" />' . "\n";
449
450        if ($core->auth->user_prefs->interface->darkmode) {
451            echo self::jsVars(array('dotclear_darkMode' => 1));
452            echo self::cssLoad('style/default-dark.css');
453        } else {
454            echo self::jsVars(array('dotclear_darkMode' => 0));
455            echo self::cssLoad('style/default.css');
456        }
457        if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
458            echo self::cssLoad('style/default-rtl.css');
459        }
460
461        $core->auth->user_prefs->addWorkspace('interface');
462        if ($core->auth->user_prefs->interface->htmlfontsize) {
463            echo
464            '<script type="text/javascript">' . "\n" .
465            self::jsVar('dotclear_htmlFontSize', $core->auth->user_prefs->interface->htmlfontsize) . "\n" .
466                "</script>\n";
467        }
468
469        echo
470        self::jsCommon() .
471        self::jsToggles() .
472            $head;
473
474        if ($core->auth->user_prefs->interface->hidemoreinfo) {
475            echo
476                '<script type="text/javascript">' . "\n" .
477                'dotclear.hideMoreInfo = true;' . "\n" .
478                "</script>\n";
479        }
480        if ($core->auth->user_prefs->interface->showajaxloader) {
481            echo
482                '<script type="text/javascript">' . "\n" .
483                'dotclear.showAjaxLoader = true;' . "\n" .
484                "</script>\n";
485        }
486
487        # --BEHAVIOR-- adminPageHTMLHead
488        $core->callBehavior('adminPageHTMLHead');
489
490        echo
491            "</head>\n" .
492            '<body id="dotclear-admin" class="popup' .
493            ($core->auth->user_prefs->interface->dynfontsize ? ' responsive-font' : '') . '">' . "\n" .
494
495            '<h1>' . DC_VENDOR_NAME . '</h1>' . "\n";
496
497        echo
498            '<div id="wrapper">' . "\n" .
499            '<main id="main" role="main">' . "\n" .
500            '<div id="content">' . "\n";
501
502        // display breadcrumb if given
503        echo $breadcrumb;
504
505        // Display notices and errors
506        echo self::notices();
507    }
508
509    public static function closePopup()
510    {
511        echo
512        "</div>\n" . // End of #content
513        "</main>\n" . // End of #main
514        "</div>\n" . // End of #wrapper
515
516        '<p id="gototop"><a href="#wrapper">' . __('Page top') . '</a></p>' . "\n" .
517
518            '<footer id="footer" role="contentinfo"><p>&nbsp;</p></footer>' . "\n" .
519            '</body></html>';
520    }
521
522    public static function breadcrumb($elements = null, $options = array())
523    {
524        global $core;
525        $with_home_link = isset($options['home_link']) ? $options['home_link'] : true;
526        $hl             = isset($options['hl']) ? $options['hl'] : true;
527        $hl_pos         = isset($options['hl_pos']) ? $options['hl_pos'] : -1;
528        // First item of array elements should be blog's name, System or Plugins
529        $res = '<h2>' . ($with_home_link ?
530            '<a class="go_home" href="' . $core->adminurl->get("admin.home") . '"><img src="style/dashboard.png" alt="' . __('Go to dashboard') . '" /></a>' :
531            '<img src="style/dashboard-alt.png" alt="" />');
532        $index = 0;
533        if ($hl_pos < 0) {
534            $hl_pos = count($elements) + $hl_pos;
535        }
536        foreach ($elements as $element => $url) {
537            if ($hl && $index == $hl_pos) {
538                $element = sprintf('<span class="page-title">%s</span>', $element);
539            }
540            $res .= ($with_home_link ? ($index == 1 ? ' : ' : ' &rsaquo; ') : ($index == 0 ? ' ' : ' &rsaquo; ')) .
541                ($url ? '<a href="' . $url . '">' : '') . $element . ($url ? '</a>' : '');
542            $index++;
543        }
544        $res .= '</h2>';
545        return $res;
546    }
547
548    public static function message($msg, $timestamp = true, $div = false, $echo = true, $class = 'message')
549    {
550        global $core;
551
552        $res = '';
553        if ($msg != '') {
554            $res = ($div ? '<div class="' . $class . '">' : '') . '<p' . ($div ? '' : ' class="' . $class . '"') . '>' .
555                ($timestamp ? dt::str(__('[%H:%M:%S]'), null, $core->auth->getInfo('user_tz')) . ' ' : '') . $msg .
556                '</p>' . ($div ? '</div>' : '');
557            if ($echo) {
558                echo $res;
559            }
560        }
561        return $res;
562    }
563
564    public static function success($msg, $timestamp = true, $div = false, $echo = true)
565    {
566        return self::message($msg, $timestamp, $div, $echo, "success");
567    }
568
569    public static function warning($msg, $timestamp = true, $div = false, $echo = true)
570    {
571        return self::message($msg, $timestamp, $div, $echo, "warning-msg");
572    }
573
574    private static function debugInfo()
575    {
576        $global_vars = implode(', ', array_keys($GLOBALS));
577
578        $res =
579        '<div id="debug"><div>' .
580        '<p>memory usage: ' . memory_get_usage() . ' (' . files::size(memory_get_usage()) . ')</p>';
581
582        if (function_exists('xdebug_get_profiler_filename')) {
583            $res .= '<p>Elapsed time: ' . xdebug_time_index() . ' seconds</p>';
584
585            $prof_file = xdebug_get_profiler_filename();
586            if ($prof_file) {
587                $res .= '<p>Profiler file : ' . xdebug_get_profiler_filename() . '</p>';
588            } else {
589                $prof_url = http::getSelfURI();
590                $prof_url .= (strpos($prof_url, '?') === false) ? '?' : '&';
591                $prof_url .= 'XDEBUG_PROFILE';
592                $res .= '<p><a href="' . html::escapeURL($prof_url) . '">Trigger profiler</a></p>';
593            }
594
595            /* xdebug configuration:
596        zend_extension = /.../xdebug.so
597        xdebug.auto_trace = On
598        xdebug.trace_format = 0
599        xdebug.trace_options = 1
600        xdebug.show_mem_delta = On
601        xdebug.profiler_enable = 0
602        xdebug.profiler_enable_trigger = 1
603        xdebug.profiler_output_dir = /tmp
604        xdebug.profiler_append = 0
605        xdebug.profiler_output_name = timestamp
606         */
607        }
608
609        $res .=
610            '<p>Global vars: ' . $global_vars . '</p>' .
611            '</div></div>';
612
613        return $res;
614    }
615
616    public static function help($page, $index = '')
617    {
618        # Deprecated but we keep this for plugins.
619    }
620
621    public static function helpBlock(...$params)
622    {
623        global $core;
624
625        if ($core->auth->user_prefs->interface->hidehelpbutton) {
626            return;
627        }
628
629        $args = new ArrayObject($params);
630
631        # --BEHAVIOR-- adminPageHelpBlock
632        $GLOBALS['core']->callBehavior('adminPageHelpBlock', $args);
633
634        if (empty($args)) {
635            return;
636        };
637
638        global $__resources;
639        if (empty($__resources['help'])) {
640            return;
641        }
642
643        $content = '';
644        foreach ($args as $v) {
645            if (is_object($v) && isset($v->content)) {
646                $content .= $v->content;
647                continue;
648            }
649
650            if (!isset($__resources['help'][$v])) {
651                continue;
652            }
653            $f = $__resources['help'][$v];
654            if (!file_exists($f) || !is_readable($f)) {
655                continue;
656            }
657
658            $fc = file_get_contents($f);
659            if (preg_match('|<body[^>]*?>(.*?)</body>|ms', $fc, $matches)) {
660                $content .= $matches[1];
661            } else {
662                $content .= $fc;
663            }
664        }
665
666        if (trim($content) == '') {
667            return;
668        }
669
670        // Set contextual help global flag
671        $GLOBALS['__resources']['ctxhelp'] = true;
672
673        echo
674        '<div id="help"><hr /><div class="help-content clear"><h3>' . __('Help about this page') . '</h3>' .
675        $content .
676        '</div>' .
677        '<div id="helplink"><hr />' .
678        '<p>' .
679        sprintf(__('See also %s'), sprintf('<a href="' . $core->adminurl->get("admin.help") . '">%s</a>', __('the global help'))) .
680            '.</p>' .
681            '</div></div>';
682    }
683
684    public static function cssLoad($src, $media = 'screen', $v = '')
685    {
686        $escaped_src = html::escapeHTML($src);
687        if (!isset(self::$loaded_css[$escaped_src])) {
688            self::$loaded_css[$escaped_src] = true;
689            $escaped_src                    = self::appendVersion($escaped_src, $v);
690
691            return '<link rel="stylesheet" href="' . $escaped_src . '" type="text/css" media="' . $media . '" />' . "\n";
692        }
693    }
694
695    public static function jsLoad($src, $v = '')
696    {
697        $escaped_src = html::escapeHTML($src);
698        if (!isset(self::$loaded_js[$escaped_src])) {
699            self::$loaded_js[$escaped_src] = true;
700            $escaped_src                   = self::appendVersion($escaped_src, $v);
701            return '<script type="text/javascript" src="' . $escaped_src . '"></script>' . "\n";
702        }
703    }
704
705    private static function appendVersion($src, $v = '')
706    {
707        $src .= (strpos($src, '?') === false ? '?' : '&amp;') . 'v=';
708        if (defined('DC_DEV') && DC_DEV === true) {
709            $src .= md5(uniqid());
710        } else {
711            $src .= ($v === '' ? DC_VERSION : $v);
712        }
713        return $src;
714    }
715
716    public static function jsVar($n, $v)
717    {
718        return $n . " = '" . html::escapeJS($v) . "';\n";
719    }
720
721    public static function jsVars($vars)
722    {
723        $ret = '<script type="text/javascript">' . "\n";
724        foreach ($vars as $var => $value) {
725            $ret .= $var . ' = ' . (is_string($value) ? "'" . html::escapeJS($value) . "'" : $value) . ';' . "\n";
726        }
727        $ret .= "</script>\n";
728
729        return $ret;
730    }
731
732    public static function jsToggles()
733    {
734        if ($GLOBALS['core']->auth->user_prefs->toggles) {
735            $unfolded_sections = explode(',', $GLOBALS['core']->auth->user_prefs->toggles->unfolded_sections);
736            foreach ($unfolded_sections as $k => &$v) {
737                if ($v == '') {
738                    unset($unfolded_sections[$k]);
739                } else {
740                    $v = "'" . html::escapeJS($v) . "':true";
741                }
742            }
743        } else {
744            $unfolded_sections = array();
745        }
746        return '<script type="text/javascript">' . "\n" .
747        'dotclear.unfolded_sections = {' . join(",", $unfolded_sections) . "};\n" .
748            "</script>\n";
749    }
750
751    public static function jsCommon()
752    {
753        $mute_or_no = '';
754        if (empty($GLOBALS['core']->blog) || $GLOBALS['core']->blog->settings->system->jquery_migrate_mute) {
755            $mute_or_no .=
756                '<script type="text/javascript">' . "\n" .
757                'jQuery.migrateMute = true;' . "\n" .
758                "</script>\n";
759        }
760
761        return
762        self::jsLoad('js/jquery/jquery.js') .
763        $mute_or_no .
764        self::jsLoad('js/jquery/jquery-migrate.js') .
765        self::jsLoad('js/jquery/jquery.biscuit.js') .
766        self::jsLoad('js/common.js') .
767        self::jsLoad('js/prelude.js') .
768
769        '<script type="text/javascript">' . "\n" .
770        'jsToolBar = {}, jsToolBar.prototype = { elements : {} };' . "\n" .
771
772        self::jsVar('dotclear.nonce', $GLOBALS['core']->getNonce()) .
773
774        self::jsVar('dotclear.img_plus_src', 'images/expand.png') .
775        self::jsVar('dotclear.img_plus_txt', '►') .
776        self::jsVar('dotclear.img_plus_alt', __('uncover')) .
777        self::jsVar('dotclear.img_minus_src', 'images/hide.png') .
778        self::jsVar('dotclear.img_minus_txt', '▼') .
779        self::jsVar('dotclear.img_minus_alt', __('hide')) .
780        self::jsVar('dotclear.img_menu_on', 'images/menu_on.png') .
781        self::jsVar('dotclear.img_menu_off', 'images/menu_off.png') .
782
783        self::jsVar('dotclear.img_plus_theme_src', 'images/plus-theme.png') .
784        self::jsVar('dotclear.img_plus_theme_txt', '►') .
785        self::jsVar('dotclear.img_plus_theme_alt', __('uncover')) .
786        self::jsVar('dotclear.img_minus_theme_src', 'images/minus-theme.png') .
787        self::jsVar('dotclear.img_minus_theme_txt', '▼') .
788        self::jsVar('dotclear.img_minus_theme_alt', __('hide')) .
789
790        self::jsVar('dotclear.msg.help',
791            __('Need help?')) .
792        self::jsVar('dotclear.msg.new_window',
793            __('new window')) .
794        self::jsVar('dotclear.msg.help_hide',
795            __('Hide')) .
796        self::jsVar('dotclear.msg.to_select',
797            __('Select:')) .
798        self::jsVar('dotclear.msg.no_selection',
799            __('no selection')) .
800        self::jsVar('dotclear.msg.select_all',
801            __('select all')) .
802        self::jsVar('dotclear.msg.invert_sel',
803            __('Invert selection')) .
804        self::jsVar('dotclear.msg.website',
805            __('Web site:')) .
806        self::jsVar('dotclear.msg.email',
807            __('Email:')) .
808        self::jsVar('dotclear.msg.ip_address',
809            __('IP address:')) .
810        self::jsVar('dotclear.msg.error',
811            __('Error:')) .
812        self::jsVar('dotclear.msg.entry_created',
813            __('Entry has been successfully created.')) .
814        self::jsVar('dotclear.msg.edit_entry',
815            __('Edit entry')) .
816        self::jsVar('dotclear.msg.view_entry',
817            __('view entry')) .
818        self::jsVar('dotclear.msg.confirm_delete_posts',
819            __("Are you sure you want to delete selected entries (%s)?")) .
820        self::jsVar('dotclear.msg.confirm_delete_medias',
821            __("Are you sure you want to delete selected medias (%d)?")) .
822        self::jsVar('dotclear.msg.confirm_delete_categories',
823            __("Are you sure you want to delete selected categories (%s)?")) .
824        self::jsVar('dotclear.msg.confirm_delete_post',
825            __("Are you sure you want to delete this entry?")) .
826        self::jsVar('dotclear.msg.click_to_unlock',
827            __("Click here to unlock the field")) .
828        self::jsVar('dotclear.msg.confirm_spam_delete',
829            __('Are you sure you want to delete all spams?')) .
830        self::jsVar('dotclear.msg.confirm_delete_comments',
831            __('Are you sure you want to delete selected comments (%s)?')) .
832        self::jsVar('dotclear.msg.confirm_delete_comment',
833            __('Are you sure you want to delete this comment?')) .
834        self::jsVar('dotclear.msg.cannot_delete_users',
835            __('Users with posts cannot be deleted.')) .
836        self::jsVar('dotclear.msg.confirm_delete_user',
837            __('Are you sure you want to delete selected users (%s)?')) .
838        self::jsVar('dotclear.msg.confirm_delete_blog',
839            __('Are you sure you want to delete selected blogs (%s)?')) .
840        self::jsVar('dotclear.msg.confirm_delete_category',
841            __('Are you sure you want to delete category "%s"?')) .
842        self::jsVar('dotclear.msg.confirm_reorder_categories',
843            __('Are you sure you want to reorder all categories?')) .
844        self::jsVar('dotclear.msg.confirm_delete_media',
845            __('Are you sure you want to remove media "%s"?')) .
846        self::jsVar('dotclear.msg.confirm_delete_directory',
847            __('Are you sure you want to remove directory "%s"?')) .
848        self::jsVar('dotclear.msg.confirm_extract_current',
849            __('Are you sure you want to extract archive in current directory?')) .
850        self::jsVar('dotclear.msg.confirm_remove_attachment',
851            __('Are you sure you want to remove attachment "%s"?')) .
852        self::jsVar('dotclear.msg.confirm_delete_lang',
853            __('Are you sure you want to delete "%s" language?')) .
854        self::jsVar('dotclear.msg.confirm_delete_plugin',
855            __('Are you sure you want to delete "%s" plugin?')) .
856        self::jsVar('dotclear.msg.confirm_delete_plugins',
857            __('Are you sure you want to delete selected plugins?')) .
858        self::jsVar('dotclear.msg.use_this_theme',
859            __('Use this theme')) .
860        self::jsVar('dotclear.msg.remove_this_theme',
861            __('Remove this theme')) .
862        self::jsVar('dotclear.msg.confirm_delete_theme',
863            __('Are you sure you want to delete "%s" theme?')) .
864        self::jsVar('dotclear.msg.confirm_delete_themes',
865            __('Are you sure you want to delete selected themes?')) .
866        self::jsVar('dotclear.msg.confirm_delete_backup',
867            __('Are you sure you want to delete this backup?')) .
868        self::jsVar('dotclear.msg.confirm_revert_backup',
869            __('Are you sure you want to revert to this backup?')) .
870        self::jsVar('dotclear.msg.zip_file_content',
871            __('Zip file content')) .
872        self::jsVar('dotclear.msg.xhtml_validator',
873            __('XHTML markup validator')) .
874        self::jsVar('dotclear.msg.xhtml_valid',
875            __('XHTML content is valid.')) .
876        self::jsVar('dotclear.msg.xhtml_not_valid',
877            __('There are XHTML markup errors.')) .
878        self::jsVar('dotclear.msg.warning_validate_no_save_content',
879            __('Attention: an audit of a content not yet registered.')) .
880        self::jsVar('dotclear.msg.confirm_change_post_format',
881            __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')) .
882        self::jsVar('dotclear.msg.confirm_change_post_format_noconvert',
883            __("Warning: post format change will not convert existing content. You will need to apply new format by yourself. Proceed anyway?")) .
884        self::jsVar('dotclear.msg.load_enhanced_uploader',
885            __('Loading enhanced uploader, please wait.')) .
886
887        self::jsVar('dotclear.msg.module_author',
888            __('Author:')) .
889        self::jsVar('dotclear.msg.module_details',
890            __('Details')) .
891        self::jsVar('dotclear.msg.module_support',
892            __('Support')) .
893        self::jsVar('dotclear.msg.module_help',
894            __('Help:')) .
895        self::jsVar('dotclear.msg.module_section',
896            __('Section:')) .
897        self::jsVar('dotclear.msg.module_tags',
898            __('Tags:')) .
899
900        self::jsVar('dotclear.msg.close_notice',
901            __('Hide this notice')) .
902
903            "\n" .
904            "</script>\n";
905    }
906
907    /**
908    @deprecated since version 2.11
909     */
910    public static function jsLoadIE7()
911    {
912        return '';
913    }
914
915    public static function jsConfirmClose(...$args)
916    {
917        if (count($args) > 0) {
918            foreach ($args as $k => $v) {
919                $args[$k] = "'" . html::escapeJS($v) . "'";
920            }
921            $params = implode(',', $args);
922        } else {
923            $params = '';
924        }
925
926        return
927        self::jsLoad('js/confirm-close.js') .
928        '<script type="text/javascript">' . "\n" .
929        "confirmClosePage = new confirmClose(" . $params . "); " .
930        "confirmClose.prototype.prompt = '" . html::escapeJS(__('You have unsaved changes.')) . "'; " .
931            "</script>\n";
932    }
933
934    public static function jsPageTabs($default = null)
935    {
936        if ($default) {
937            $default = "'" . html::escapeJS($default) . "'";
938        }
939
940        return
941        self::jsLoad('js/jquery/jquery.pageTabs.js') .
942            '<script type="text/javascript">' . "\n" .
943            '$(function() {' . "\n" .
944            '   $.pageTabs(' . $default . ');' . "\n" .
945            '});' .
946            "</script>\n";
947    }
948
949    public static function jsModal()
950    {
951        return
952        self::jsLoad('js/jquery/jquery.magnific-popup.js');
953    }
954
955    public static function jsColorPicker()
956    {
957        return
958        self::cssLoad('style/farbtastic/farbtastic.css') .
959        self::jsLoad('js/jquery/jquery.farbtastic.js') .
960        self::jsLoad('js/color-picker.js');
961    }
962
963    public static function jsDatePicker()
964    {
965        return
966        self::cssLoad('style/date-picker.css') .
967        self::jsLoad('js/date-picker.js') .
968        '<script type="text/javascript">' . "\n" .
969
970        "datePicker.prototype.months[0] = '" . html::escapeJS(__('January')) . "'; " .
971        "datePicker.prototype.months[1] = '" . html::escapeJS(__('February')) . "'; " .
972        "datePicker.prototype.months[2] = '" . html::escapeJS(__('March')) . "'; " .
973        "datePicker.prototype.months[3] = '" . html::escapeJS(__('April')) . "'; " .
974        "datePicker.prototype.months[4] = '" . html::escapeJS(__('May')) . "'; " .
975        "datePicker.prototype.months[5] = '" . html::escapeJS(__('June')) . "'; " .
976        "datePicker.prototype.months[6] = '" . html::escapeJS(__('July')) . "'; " .
977        "datePicker.prototype.months[7] = '" . html::escapeJS(__('August')) . "'; " .
978        "datePicker.prototype.months[8] = '" . html::escapeJS(__('September')) . "'; " .
979        "datePicker.prototype.months[9] = '" . html::escapeJS(__('October')) . "'; " .
980        "datePicker.prototype.months[10] = '" . html::escapeJS(__('November')) . "'; " .
981        "datePicker.prototype.months[11] = '" . html::escapeJS(__('December')) . "'; " .
982
983        "datePicker.prototype.days[0] = '" . html::escapeJS(__('Monday')) . "'; " .
984        "datePicker.prototype.days[1] = '" . html::escapeJS(__('Tuesday')) . "'; " .
985        "datePicker.prototype.days[2] = '" . html::escapeJS(__('Wednesday')) . "'; " .
986        "datePicker.prototype.days[3] = '" . html::escapeJS(__('Thursday')) . "'; " .
987        "datePicker.prototype.days[4] = '" . html::escapeJS(__('Friday')) . "'; " .
988        "datePicker.prototype.days[5] = '" . html::escapeJS(__('Saturday')) . "'; " .
989        "datePicker.prototype.days[6] = '" . html::escapeJS(__('Sunday')) . "'; " .
990
991        "datePicker.prototype.img_src = 'images/date-picker.png'; " .
992        "datePicker.prototype.img_alt = '" . html::escapeJS(__('Choose date')) . "'; " .
993
994        "datePicker.prototype.close_msg = '" . html::escapeJS(__('close')) . "'; " .
995        "datePicker.prototype.now_msg = '" . html::escapeJS(__('now')) . "'; " .
996
997            "</script>\n";
998    }
999
1000    public static function jsToolBar()
1001    {
1002        # Deprecated but we keep this for plugins.
1003    }
1004
1005    public static function jsUpload($params = array(), $base_url = null)
1006    {
1007        if (!$base_url) {
1008            $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/', '', $_SERVER['REQUEST_URI']))) . '/';
1009        }
1010
1011        $params = array_merge($params, array(
1012            'sess_id=' . session_id(),
1013            'sess_uid=' . $_SESSION['sess_browser_uid'],
1014            'xd_check=' . $GLOBALS['core']->getNonce()
1015        ));
1016
1017        return
1018        '<script type="text/javascript">' . "\n" .
1019        "dotclear.jsUpload = {};\n" .
1020        "dotclear.jsUpload.msg = {};\n" .
1021        self::jsVar('dotclear.msg.enhanced_uploader_activate', __('Temporarily activate enhanced uploader')) .
1022        self::jsVar('dotclear.msg.enhanced_uploader_disable', __('Temporarily disable enhanced uploader')) .
1023        self::jsVar('dotclear.jsUpload.msg.limit_exceeded', __('Limit exceeded.')) .
1024        self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded', __('File size exceeds allowed limit.')) .
1025        self::jsVar('dotclear.jsUpload.msg.canceled', __('Canceled.')) .
1026        self::jsVar('dotclear.jsUpload.msg.http_error', __('HTTP Error:')) .
1027        self::jsVar('dotclear.jsUpload.msg.error', __('Error:')) .
1028        self::jsVar('dotclear.jsUpload.msg.choose_file', __('Choose file')) .
1029        self::jsVar('dotclear.jsUpload.msg.choose_files', __('Choose files')) .
1030        self::jsVar('dotclear.jsUpload.msg.cancel', __('Cancel')) .
1031        self::jsVar('dotclear.jsUpload.msg.clean', __('Clean')) .
1032        self::jsVar('dotclear.jsUpload.msg.upload', __('Upload')) .
1033        self::jsVar('dotclear.jsUpload.msg.send', __('Send')) .
1034        self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded', __('File successfully uploaded.')) .
1035        self::jsVar('dotclear.jsUpload.msg.no_file_in_queue', __('No file in queue.')) .
1036        self::jsVar('dotclear.jsUpload.msg.file_in_queue', __('1 file in queue.')) .
1037        self::jsVar('dotclear.jsUpload.msg.files_in_queue', __('%d files in queue.')) .
1038        self::jsVar('dotclear.jsUpload.msg.queue_error', __('Queue error:')) .
1039        self::jsVar('dotclear.jsUpload.base_url', $base_url) .
1040        "</script>\n" .
1041
1042        self::jsLoad('js/jquery/jquery-ui.custom.js') .
1043        self::jsLoad('js/jsUpload/tmpl.js') .
1044        self::jsLoad('js/jsUpload/template-upload.js') .
1045        self::jsLoad('js/jsUpload/template-download.js') .
1046        self::jsLoad('js/jsUpload/load-image.js') .
1047        self::jsLoad('js/jsUpload/jquery.iframe-transport.js') .
1048        self::jsLoad('js/jsUpload/jquery.fileupload.js') .
1049        self::jsLoad('js/jsUpload/jquery.fileupload-process.js') .
1050        self::jsLoad('js/jsUpload/jquery.fileupload-resize.js') .
1051        self::jsLoad('js/jsUpload/jquery.fileupload-ui.js');
1052    }
1053
1054    public static function jsMetaEditor()
1055    {
1056        return self::jsLoad('js/meta-editor.js');
1057    }
1058
1059    public static function jsFilterControl($show = true)
1060    {
1061        return
1062        self::jsLoad('js/filter-controls.js') .
1063        '<script type="text/javascript">' . "\n" .
1064        self::jsVar('dotclear.msg.show_filters', $show ? 'true' : 'false') . "\n" .
1065        self::jsVar('dotclear.msg.filter_posts_list', __('Show filters and display options')) . "\n" .
1066        self::jsVar('dotclear.msg.cancel_the_filter', __('Cancel filters and display options')) . "\n" .
1067            "</script>";
1068    }
1069
1070    public static function jsLoadCodeMirror($theme = '', $multi = true, $modes = array('css', 'htmlmixed', 'javascript', 'php', 'xml'))
1071    {
1072        $ret =
1073        self::cssLoad('js/codemirror/lib/codemirror.css') .
1074        self::jsLoad('js/codemirror/lib/codemirror.js');
1075        if ($multi) {
1076            $ret .= self::jsLoad('js/codemirror/addon/mode/multiplex.js');
1077        }
1078        foreach ($modes as $mode) {
1079            $ret .= self::jsLoad('js/codemirror/mode/' . $mode . '/' . $mode . '.js');
1080        }
1081        $ret .=
1082        self::jsLoad('js/codemirror/addon/edit/closebrackets.js') .
1083        self::jsLoad('js/codemirror/addon/edit/matchbrackets.js') .
1084        self::cssLoad('js/codemirror/addon/display/fullscreen.css') .
1085        self::jsLoad('js/codemirror/addon/display/fullscreen.js');
1086        if ($theme != '') {
1087            $ret .= self::cssLoad('js/codemirror/theme/' . $theme . '.css');
1088        }
1089        return $ret;
1090    }
1091
1092    public static function jsRunCodeMirror($name, $id, $mode, $theme = '')
1093    {
1094        $ret =
1095            '<script type="text/javascript">' . "\n" .
1096            'var ' . $name . ' = CodeMirror.fromTextArea(' . $id . ',{' . "\n" .
1097            '   mode: "' . $mode . '",' . "\n" .
1098            '   tabMode: "indent",' . "\n" .
1099            '   lineWrapping: 1,' . "\n" .
1100            '   lineNumbers: 1,' . "\n" .
1101            '   matchBrackets: 1,' . "\n" .
1102            '   autoCloseBrackets: 1,' . "\n" .
1103            '   extraKeys: {"F11": function(cm) {cm.setOption("fullScreen",!cm.getOption("fullScreen"));}}';
1104        if ($theme) {
1105            $ret .=
1106                ',' . "\n" .
1107                '   theme: "' . $theme . '"';
1108        }
1109        $ret .= "\n" .
1110            '});' . "\n" .
1111            '</script>';
1112        return $ret;
1113    }
1114
1115    public static function getCodeMirrorThemes()
1116    {
1117        $themes      = array();
1118        $themes_root = dirname(__FILE__) . '/../../admin' . '/js/codemirror/theme/';
1119        if (is_dir($themes_root) && is_readable($themes_root)) {
1120            if (($d = @dir($themes_root)) !== false) {
1121                while (($entry = $d->read()) !== false) {
1122                    if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_readable($themes_root . '/' . $entry)) {
1123                        $themes[] = substr($entry, 0, -4); // remove .css extension
1124                    }
1125                }
1126                sort($themes);
1127            }
1128        }
1129        return $themes;
1130    }
1131
1132    public static function getPF($file)
1133    {
1134        return $GLOBALS['core']->adminurl->get('load.plugin.file', array('pf' => $file));
1135    }
1136
1137    public static function getVF($file)
1138    {
1139        return $GLOBALS['core']->adminurl->get('load.var.file', array('vf' => $file));
1140    }
1141
1142    public static function setXFrameOptions($headers, $origin = null)
1143    {
1144        if (self::$xframe_loaded) {
1145            return;
1146        }
1147
1148        if ($origin !== null) {
1149            $url                        = parse_url($origin);
1150            $headers['x-frame-options'] = sprintf('X-Frame-Options: %s', is_array($url) && isset($url['host']) ?
1151                ("ALLOW-FROM " . (isset($url['scheme']) ? $url['scheme'] . ':' : '') . '//' . $url['host']) :
1152                'SAMEORIGIN');
1153        } else {
1154            $headers['x-frame-options'] = 'X-Frame-Options: SAMEORIGIN'; // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
1155        }
1156        self::$xframe_loaded = true;
1157    }
1158}
Note: See TracBrowser for help on using the repository browser.

Sites map