Changeset 2911:5434e75ad738 for inc
- Timestamp:
- 01/07/15 12:55:08 (11 years ago)
- Branch:
- twig
- Parents:
- 2715:a87ddf7dbfb5 (diff), 2910:69efb1571e90 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- inc
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.dc.page.php
r2650 r2911 17 17 { 18 18 private static $loaded_js = array(); 19 private static $xframe_loaded = false; 19 20 private static $N_TYPES = array( 20 21 "success" => "success", … … 54 55 55 56 # Top of admin page 56 public static function open($title='',$head='',$breadcrumb='' )57 public static function open($title='',$head='',$breadcrumb='',$options=array()) 57 58 { 58 59 global $core; … … 66 67 67 68 if ($core->auth->getBlogCount() > 20) { 68 $blog_box .= ' - <a href=" blogs.php">'.__('Change blog').'</a>';69 $blog_box .= ' - <a href="'.$core->adminurl->get("admin.blogs").'">'.__('Change blog').'</a>'; 69 70 } 70 71 $blog_box .= '</p>'; … … 89 90 # Display 90 91 header('Content-Type: text/html; charset=UTF-8'); 91 echo 92 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 93 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 94 '<html xmlns="http://www.w3.org/1999/xhtml" '. 95 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 96 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 92 93 // Prevents Clickjacking as far as possible 94 if (isset($options['x-frame-allow'])) { 95 self::setXFrameOptions($options['x-frame-allow']); 96 } else { 97 self::setXFrameOptions(); 98 } 99 echo 100 '<!DOCTYPE html>'. 101 '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". 97 102 "<head>\n". 98 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".103 ' <meta charset="UTF-8" />'."\n". 99 104 ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". 100 105 ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". … … 137 142 '<li><a href="#help">'.__('Go to help').'</a></li>'. 138 143 '</ul>'."\n". 139 '<div id="header" >'.140 '<h1><a href=" index.php"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n";141 142 echo 143 '<form action=" index.php" method="post" id="top-info-blog">'.144 '<div id="header" role="banner">'. 145 '<h1><a href="'.$core->adminurl->get("admin.home").'"><span class="hidden">'.DC_VENDOR_NAME.'</span></a></h1>'."\n"; 146 147 echo 148 '<form action="'.$core->adminurl->get("admin.home").'" method="post" id="top-info-blog">'. 144 149 $blog_box. 145 150 '<p><a href="'.$core->blog->url.'" class="outgoing" title="'.__('Go to site'). … … 147 152 '</p></form>'. 148 153 '<ul id="top-info-user">'. 149 '<li><a class="'.(preg_match('/ index.php$/',$_SERVER['REQUEST_URI']) ? ' active' : '').'" href="index.php">'.__('My dashboard').'</a></li>'.150 '<li><a class="smallscreen'.(preg_match('/ preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : '').151 '" href=" preferences.php">'.__('My preferences').'</a></li>'.152 '<li><a href=" index.php?logout=1" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()).154 '<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>'. 155 '<li><a class="smallscreen'.(preg_match('/'.preg_quote($core->adminurl->get('admin.user.preferences')).'(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' active' : ''). 156 '" href="'.$core->adminurl->get("admin.user.preferences").'">'.__('My preferences').'</a></li>'. 157 '<li><a href="'.$core->adminurl->get("admin.home",array('logout' => 1)).'" class="logout"><span class="nomobile">'.sprintf(__('Logout %s'),$core->auth->userID()). 153 158 '</span><img src="images/logout.png" alt="" /></a></li>'. 154 159 '</ul>'. … … 161 166 '<img class="expand-mm" src="images/collapser-show.png" alt="'.__('Show main menu').'" />'. 162 167 '</a></div>'. 163 '<div id="main" >'."\n".168 '<div id="main" role="main">'."\n". 164 169 '<div id="content" class="clearfix">'."\n"; 165 170 … … 168 173 { 169 174 echo 170 '<div class="warning" ><h3>'.__('Safe mode').'</h3>'.175 '<div class="warning" role="alert"><h3>'.__('Safe mode').'</h3>'. 171 176 '<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>'. 172 177 '</div>'; … … 246 251 $ts = dt::str(__('[%H:%M:%S]'),$n['ts'],$core->auth->getInfo('user_tz')).' '; 247 252 } 248 $res = '<'.$tag.' class="'.$n['class'].'" >'.$ts.$n['text'].'</'.$tag.'>';253 $res = '<'.$tag.' class="'.$n['class'].'" role="alert">'.$ts.$n['text'].'</'.$tag.'>'; 249 254 return $res; 250 255 } … … 256 261 if (!$GLOBALS['__resources']['ctxhelp']) { 257 262 echo 258 '<p id="help-button"><a href=" help.php" class="outgoing" title="'.263 '<p id="help-button"><a href="'.$core->adminurl->get("admin.help").'" class="outgoing" title="'. 259 264 __('Global help').'">'.__('Global help').'</a></p>'; 260 265 } … … 266 271 "</div>\n". // End of #main 267 272 268 '<div id="main-menu" >'."\n".269 270 '<form id="search-menu" action=" search.php" method="get">'.273 '<div id="main-menu" role="navigation">'."\n". 274 275 '<form id="search-menu" action="'.$core->adminurl->get("admin.search").'" method="get" role="search">'. 271 276 '<p><label for="qx" class="hidden">'.__('Search:').' </label>'.form::field('qx',30,255,''). 272 277 '<input type="submit" value="'.__('OK').'" /></p>'. … … 291 296 292 297 echo 293 '<div id="footer" >'.298 '<div id="footer" role="contentinfo">'. 294 299 '<a href="http://dotclear.org/" title="'.$text.'">'. 295 300 '<img src="style/dc_logos/w-dotclear90.png" alt="'.$text.'" /></a></div>'."\n". 296 "<!-- \n \n ,;:'`'::\n". 297 " __||\n _____/LLLL\_\n \__________\"|\n". 298 " ~^~^~^~^~^~^~^~^~^~\n -->\n"; 301 "<!-- "."\n". 302 "( \\"."\n". 303 " ) )"."\n". 304 "( ( .-\"\"-. A.-.A"."\n". 305 " \ \/ \/ , , \\"."\n". 306 " \ \ =; t /="."\n". 307 " \ |\"\". ',--'"."\n". 308 " / // | ||"."\n". 309 " /_,)) |_,))"."\n". 310 " -->"."\n"; 299 311 300 312 if (defined('DC_DEV') && DC_DEV === true) { … … 312 324 # Display 313 325 header('Content-Type: text/html; charset=UTF-8'); 314 echo 315 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. 316 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". 317 '<html xmlns="http://www.w3.org/1999/xhtml" '. 318 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. 319 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". 326 327 // Prevents Clickjacking as far as possible 328 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 329 330 echo 331 '<!DOCTYPE html>'. 332 '<html lang="'.$core->auth->getInfo('user_lang').'">'."\n". 320 333 "<head>\n". 334 ' <meta charset="UTF-8" />'."\n". 321 335 ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". 322 ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".323 336 ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". 324 337 … … 349 362 echo 350 363 '<div id="wrapper">'."\n". 351 '<div id="main" >'."\n".364 '<div id="main" role="main">'."\n". 352 365 '<div id="content">'."\n"; 353 366 … … 357 370 if ($core->error->flag()) { 358 371 echo 359 '<div class="error" ><strong>'.__('Errors:').'</strong>'.372 '<div class="error" role="alert"><strong>'.__('Errors:').'</strong>'. 360 373 $core->error->toHTML(). 361 374 '</div>'; … … 369 382 "</div>\n". // End of #main 370 383 "</div>\n". // End of #wrapper 371 '<div id="footer" ><p> </p></div>'."\n".384 '<div id="footer" role="contentinfo"><p> </p></div>'."\n". 372 385 '</body></html>'; 373 386 } … … 375 388 public static function breadcrumb($elements=null,$options=array()) 376 389 { 390 global $core; 377 391 $with_home_link = isset($options['home_link'])?$options['home_link']:true; 378 392 $hl = isset($options['hl'])?$options['hl']:true; … … 380 394 // First item of array elements should be blog's name, System or Plugins 381 395 $res = '<h2>'.($with_home_link ? 382 '<a class="go_home" href=" index.php"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' :396 '<a class="go_home" href="'.$core->adminurl->get("admin.home").'"><img src="style/dashboard.png" alt="'.__('Go to dashboard').'" /></a>' : 383 397 '<img src="style/dashboard-alt.png" alt="" />'); 384 398 $index = 0; … … 474 488 public static function helpBlock() 475 489 { 490 global $core; 476 491 $args = func_get_args(); 477 492 … … 527 542 '<div id="helplink"><hr />'. 528 543 '<p>'. 529 sprintf(__('See also %s'),sprintf('<a href=" help.php">%s</a>',__('the global help'))).544 sprintf(__('See also %s'),sprintf('<a href="'.$core->adminurl->get("admin.help").'">%s</a>',__('the global help'))). 530 545 '.</p>'. 531 546 '</div></div>'; … … 823 838 824 839 "datePicker.prototype.img_src = 'images/date-picker.png'; ". 840 "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". 825 841 826 842 "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". … … 905 921 '<script type="text/javascript" src="js/meta-editor.js"></script>'; 906 922 } 923 924 public static function getPF($file) { 925 return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); 926 } 927 928 public static function setXFrameOptions($origin=null) { 929 if (self::$xframe_loaded) { 930 return; 931 } 932 if ($origin !== null) { 933 $url = parse_url($origin); 934 header(sprintf('X-Frame-Options: %s', is_array($url)?($url['scheme'].'://'.$url['host']):'SAMEORIGIN')); 935 } else { 936 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 937 } 938 self::$xframe_loaded = true; 939 940 } 907 941 } -
inc/admin/lib.dc.page.php
r2909 r2911 19 19 private static $xframe_loaded = false; 20 20 private static $N_TYPES = array( 21 "success" => "success", 22 "warning" => "warning-msg", 23 "error" => "error", 24 "message" => "message", 21 "success" => "success", 22 "warning" => "warning-msg", 23 "error" => "error", 24 "message" => "message", 25 25 "static" => "static-msg"); 26 26 … … 109 109 110 110 self::jsLoadIE7(). 111 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";111 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 112 112 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 113 113 echo 114 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";114 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 115 115 } 116 116 … … 118 118 $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; 119 119 if (!$user_ui_hide_std_favicon) { 120 echo 120 echo 121 121 '<link rel="icon" type="image/png" href="images/favicon96-login.png" />'. 122 122 '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; 123 123 } 124 124 125 echo 125 126 self::jsCommon(). … … 217 218 $notifications = array(); 218 219 } 219 220 220 221 $n = array_merge($options,array('class' => $class,'ts' => time(), 'text' => $message)); 221 222 if ($type != "static") { … … 339 340 340 341 self::jsLoadIE7(). 341 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n";342 ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; 342 343 if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { 343 344 echo 344 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n";345 ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; 345 346 } 346 347 … … 580 581 "</script>\n"; 581 582 } 582 583 583 584 public static function jsCommon() 584 585 { … … 606 607 'jsToolBar = {}, jsToolBar.prototype = { elements : {} };'."\n". 607 608 self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). 609 608 610 self::jsVar('dotclear.img_plus_src','images/expand.png'). 609 611 self::jsVar('dotclear.img_plus_alt',__('uncover')). … … 725 727 self::jsVar('dotclear.msg.module_tags', 726 728 __('Tags:')). 727 729 "\n//]]>\n". 728 730 "</script>\n"; 729 731 } … … 787 789 public static function jsModal() 788 790 { 789 790 791 792 793 794 795 796 797 791 return 792 '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". 793 self::jsLoad('js/jquery/jquery.modal.js'). 794 '<script type="text/javascript">'."\n". 795 "//<![CDATA[\n". 796 self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). 797 self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). 798 "\n//]]>\n". 799 "</script>\n"; 798 800 } 799 801 800 802 public static function jsColorPicker() 801 803 { 802 803 804 805 804 return 805 '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". 806 self::jsLoad('js/jquery/jquery.farbtastic.js'). 807 self::jsLoad('js/color-picker.js'); 806 808 } 807 809 808 810 public static function jsDatePicker() 809 811 { 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 812 return 813 '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". 814 self::jsLoad('js/date-picker.js'). 815 '<script type="text/javascript">'."\n". 816 "//<![CDATA[\n". 817 818 "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". 819 "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". 820 "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". 821 "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". 822 "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". 823 "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". 824 "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". 825 "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". 826 "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". 827 "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". 828 "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". 829 "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". 830 831 "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". 832 "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". 833 "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". 834 "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". 835 "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". 836 "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". 837 "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". 838 839 "datePicker.prototype.img_src = 'images/date-picker.png'; ". 838 840 "datePicker.prototype.img_alt = '".html::escapeJS(__('Choose date'))."'; ". 839 841 840 841 842 843 844 845 } 846 847 842 "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". 843 "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". 844 845 "\n//]]>\n". 846 "</script>\n"; 847 } 848 849 848 850 public static function jsToolBar() 849 851 { … … 853 855 public static function jsUpload($params=array(),$base_url=null) 854 856 { 855 856 857 858 859 860 861 862 857 if (!$base_url) { 858 $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; 859 } 860 861 $params = array_merge($params,array( 862 'sess_id='.session_id(), 863 'sess_uid='.$_SESSION['sess_browser_uid'], 864 'xd_check='.$GLOBALS['core']->getNonce() 863 865 )); 864 866 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 867 return 868 '<script type="text/javascript">'."\n". 869 "//<![CDATA[\n". 870 "dotclear.jsUpload = {};\n". 871 "dotclear.jsUpload.msg = {};\n". 872 self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). 873 self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). 874 self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). 875 self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). 876 self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). 877 self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). 878 self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). 879 self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). 880 self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). 881 self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). 882 self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). 883 self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). 882 884 self::jsVar('dotclear.jsUpload.msg.send',__('Send')). 883 885 self::jsVar('dotclear.jsUpload.msg.file_successfully_uploaded',__('File successfully uploaded.')). 884 885 886 887 888 889 886 self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). 887 self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). 888 self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). 889 self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). 890 self::jsVar('dotclear.jsUpload.base_url',$base_url). 891 "\n//]]>\n". 890 892 "</script>\n". 891 893 … … 904 906 public static function jsToolMan() 905 907 { 906 907 908 909 910 911 912 913 908 return 909 '<script type="text/javascript" src="js/tool-man/core.js"></script>'. 910 '<script type="text/javascript" src="js/tool-man/events.js"></script>'. 911 '<script type="text/javascript" src="js/tool-man/css.js"></script>'. 912 '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. 913 '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. 914 '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. 915 '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; 914 916 } 915 917 916 918 public static function jsMetaEditor() 917 919 { 918 919 920 return 921 '<script type="text/javascript" src="js/meta-editor.js"></script>'; 920 922 } 921 923 -
inc/admin/prepend.php
r2715 r2911 61 61 } 62 62 63 function addMenuItem($section,$desc,$adminurl,$icon,$perm) 64 { 65 global $core,$_menu; 66 67 $url = $core->adminurl->get($adminurl); 68 $_menu[$section]->prependItem($desc,$url,$icon,preg_match('/'.preg_quote($url).'(\?.*)?$/',$_SERVER['REQUEST_URI']),$perm); 69 } 70 63 71 if (defined('DC_AUTH_SESS_ID') && defined('DC_AUTH_SESS_UID')) 64 72 { … … 120 128 } 121 129 122 123 130 if (!empty($_REQUEST['switchblog']) 124 131 && $core->auth->getPermissions($_REQUEST['switchblog']) !== false) … … 164 171 http::redirect('auth.php'); 165 172 } 166 167 /*168 # Check add to my fav fired169 if (!empty($_REQUEST['add-favorite'])) {170 $redir = $_SERVER['REQUEST_URI'];171 # Extract admin page from URI172 # TO BE COMPLETED173 }174 */175 173 } 176 174 … … 179 177 $core->adminurl->register('admin.posts','posts.php'); 180 178 $core->adminurl->register('admin.post','post.php'); 179 $core->adminurl->register('admin.post.media','post_media.php'); 181 180 $core->adminurl->register('admin.blog.theme','blog_theme.php'); 182 181 $core->adminurl->register('admin.blog.pref','blog_pref.php'); 182 $core->adminurl->register('admin.blog.del','blog_del.php'); 183 $core->adminurl->register('admin.blog','blog.php'); 183 184 $core->adminurl->register('admin.blogs','blogs.php'); 184 185 $core->adminurl->register('admin.categories','categories.php'); 185 186 $core->adminurl->register('admin.category','category.php'); 186 187 $core->adminurl->register('admin.comments','comments.php'); 187 $core->adminurl->register('admin.comment s','comment.php');188 $core->adminurl->register('admin.comment','comment.php'); 188 189 $core->adminurl->register('admin.help','help.php'); 189 190 $core->adminurl->register('admin.home','index.php'); 190 191 $core->adminurl->register('admin.langs','langs.php'); 191 192 $core->adminurl->register('admin.media','media.php'); 192 $core->adminurl->register('admin.media _item','media_item.php');193 $core->adminurl->register('admin.media.item','media_item.php'); 193 194 $core->adminurl->register('admin.plugins','plugins.php'); 194 195 $core->adminurl->register('admin.plugin','plugin.php'); 196 $core->adminurl->register('admin.search','search.php'); 195 197 $core->adminurl->register('admin.user.preferences','preferences.php'); 196 198 $core->adminurl->register('admin.user','user.php'); 199 $core->adminurl->register('admin.user.actions','users_actions.php'); 197 200 $core->adminurl->register('admin.users','users.php'); 201 $core->adminurl->register('admin.auth','auth.php'); 202 $core->adminurl->register('admin.help','help.php'); 203 $core->adminurl->register('admin.update','update.php'); 204 205 $core->adminurl->registercopy('load.plugin.file','admin.home',array('pf' => 'dummy.css')); 198 206 199 207 if ($core->auth->userID() && $core->blog !== null) … … 227 235 # [] : Title, URL, small icon, large icon, permissions, id, class 228 236 # NB : '*' in permissions means any, null means super admin only 229 230 237 231 238 # Menus creation … … 246 253 } 247 254 248 249 255 # Set menu titles 250 256 … … 253 259 $_menu['Plugins']->title = __('Plugins'); 254 260 255 256 $_menu['Blog']->prependItem(__('Blog appearance'),'blog_theme.php','images/menu/themes.png', 257 preg_match('/blog_theme.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 261 addMenuItem('Blog',__('Blog appearance'),'admin.blog.theme','images/menu/themes.png', 258 262 $core->auth->check('admin',$core->blog->id)); 259 $_menu['Blog']->prependItem(__('Blog settings'),'blog_pref.php','images/menu/blog-pref.png', 260 preg_match('/blog_pref.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 263 addMenuItem('Blog',__('Blog settings'),'admin.blog.pref','images/menu/blog-pref.png', 261 264 $core->auth->check('admin',$core->blog->id)); 262 $_menu['Blog']->prependItem(__('Media manager'),'media.php','images/menu/media.png', 263 preg_match('/media(_item)?.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 265 addMenuItem('Blog',__('Media manager'),'admin.media','images/menu/media.png', 264 266 $core->auth->check('media,media_admin',$core->blog->id)); 265 $_menu['Blog']->prependItem(__('Categories'),'categories.php','images/menu/categories.png', 266 preg_match('/categories.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 267 addMenuItem('Blog',__('Categories'),'admin.categories','images/menu/categories.png', 267 268 $core->auth->check('categories',$core->blog->id)); 268 $_menu['Blog']->prependItem(__('Search'),'search.php','images/menu/search.png', 269 preg_match('/search.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 269 addMenuItem('Blog',__('Search'),'admin.search','images/menu/search.png', 270 270 $core->auth->check('usage,contentadmin',$core->blog->id)); 271 $_menu['Blog']->prependItem(__('Comments'),'comments.php','images/menu/comments.png', 272 preg_match('/comments.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 271 addMenuItem('Blog',__('Comments'),'admin.comments','images/menu/comments.png', 273 272 $core->auth->check('usage,contentadmin',$core->blog->id)); 274 $_menu['Blog']->prependItem(__('Entries'),'posts.php','images/menu/entries.png', 275 preg_match('/posts.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 273 addMenuItem('Blog',__('Entries'),'admin.posts','images/menu/entries.png', 276 274 $core->auth->check('usage,contentadmin',$core->blog->id)); 277 $_menu['Blog']->prependItem(__('New entry'),'post.php','images/menu/edit.png', 278 preg_match('/post.php$/',$_SERVER['REQUEST_URI']), 275 addMenuItem('Blog',__('New entry'),'admin.post','images/menu/edit.png', 279 276 $core->auth->check('usage,contentadmin',$core->blog->id)); 280 277 281 $_menu['System']->prependItem(__('Update'),'update.php','images/menu/update.png', 282 preg_match('/update.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 278 addMenuItem('System',__('Update'),'admin.update','images/menu/update.png', 283 279 $core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)); 284 $_menu['System']->prependItem(__('Languages'),'langs.php','images/menu/langs.png', 285 preg_match('/langs.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 280 addMenuItem('System',__('Languages'),'admin.langs','images/menu/langs.png', 286 281 $core->auth->isSuperAdmin()); 287 $_menu['System']->prependItem(__('Plugins management'),'plugins.php','images/menu/plugins.png', 288 preg_match('/plugins.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 282 addMenuItem('System',__('Plugins management'),'admin.plugins','images/menu/plugins.png', 289 283 $core->auth->isSuperAdmin()); 290 $_menu['System']->prependItem(__('Users'),'users.php','images/menu/users.png', 291 preg_match('/users.php$/',$_SERVER['REQUEST_URI']), 284 addMenuItem('System',__('Users'),'admin.users','images/menu/users.png', 292 285 $core->auth->isSuperAdmin()); 293 $_menu['System']->prependItem(__('Blogs'),'blogs.php','images/menu/blogs.png', 294 preg_match('/blogs.php$/',$_SERVER['REQUEST_URI']), 286 addMenuItem('System',__('Blogs'),'admin.blogs','images/menu/blogs.png', 295 287 $core->auth->isSuperAdmin() || 296 288 $core->auth->check('usage,contentadmin',$core->blog->id) && $core->auth->getBlogCount() > 1); -
inc/admin/prepend.php
r2815 r2911 24 24 function dc_load_locales() { 25 25 global $_lang, $core; 26 26 27 27 $_lang = $core->auth->getInfo('user_lang'); 28 28 $_lang = preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_lang) ? $_lang : 'en'; 29 29 30 30 l10n::lang($_lang); 31 31 if (l10n::set(dirname(__FILE__).'/../../locales/'.$_lang.'/date') === false && $_lang != 'en') { … … 40 40 { 41 41 global $core; 42 42 43 43 $core->auth->user_prefs->addWorkspace('interface'); 44 44 $user_ui_iconset = @$core->auth->user_prefs->interface->iconset; 45 45 if (($user_ui_iconset) && ($img)) { 46 46 $icon = false; 47 if ((preg_match('/^images\/menu\/(.+)$/',$img,$m)) || 47 if ((preg_match('/^images\/menu\/(.+)$/',$img,$m)) || 48 48 (preg_match('/^index\.php\?pf=(.+)$/',$img,$m))) { 49 49 if ($m[1]) { … … 73 73 # We have session information in constants 74 74 $_COOKIE[DC_SESSION_NAME] = DC_AUTH_SESS_ID; 75 75 76 76 if (!$core->auth->checkSession(DC_AUTH_SESS_UID)) { 77 77 throw new Exception('Invalid session data.'); 78 78 } 79 79 80 80 # Check nonce from POST requests 81 81 if (!empty($_POST)) … … 85 85 } 86 86 } 87 87 88 88 if (empty($_SESSION['sess_blog_id'])) { 89 89 throw new Exception('Permission denied.'); 90 90 } 91 91 92 92 # Loading locales 93 93 dc_load_locales(); 94 94 95 95 $core->setBlog($_SESSION['sess_blog_id']); 96 96 if (!$core->blog->id) { … … 108 108 $p[3] = '/'; 109 109 call_user_func_array('setcookie',$p); 110 110 111 111 http::redirect('auth.php'); 112 112 } … … 116 116 ,20); 117 117 } 118 118 119 119 # Check nonce from POST requests 120 120 if (!empty($_POST)) … … 127 127 } 128 128 } 129 129 130 130 if (!empty($_REQUEST['switchblog']) 131 131 && $core->auth->getPermissions($_REQUEST['switchblog']) !== false) … … 138 138 unset($_SESSION['media_manager_page']); 139 139 } 140 140 141 141 # Removing switchblog from URL 142 142 $redir = $_SERVER['REQUEST_URI']; … … 146 146 exit; 147 147 } 148 148 149 149 # Check blog to use and log out if no result 150 150 if (isset($_SESSION['sess_blog_id'])) … … 161 161 } 162 162 } 163 163 164 164 # Loading locales 165 165 dc_load_locales(); 166 166 167 167 if (isset($_SESSION['sess_blog_id'])) { 168 168 $core->setBlog($_SESSION['sess_blog_id']); … … 214 214 } 215 215 unset($f); 216 216 217 217 if (($hfiles = @scandir($locales_root.$_lang.'/help')) !== false) 218 218 { … … 232 232 $core->favs = new dcFavorites($core); 233 233 234 234 235 # [] : Title, URL, small icon, large icon, permissions, id, class 235 236 # NB : '*' in permissions means any, null means super admin only 236 237 237 238 # Menus creation 238 239 $_menu = new ArrayObject(); … … 253 254 254 255 # Set menu titles 255 256 256 257 $_menu['System']->title = __('System settings'); 257 258 $_menu['Blog']->title = __('Blog'); … … 274 275 addMenuItem('Blog',__('New entry'),'admin.post','images/menu/edit.png', 275 276 $core->auth->check('usage,contentadmin',$core->blog->id)); 276 277 277 278 addMenuItem('System',__('Update'),'admin.update','images/menu/update.png', 278 279 $core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)); … … 292 293 } 293 294 295 # Add admin default templates path 296 $core->tpl->getLoader()->addPath(dirname(__FILE__).'/default-templates'); 297 # Set admin context 298 $_ctx = new dcAdminContext($core); 299 $core->tpl->addExtension($_ctx); 300 301 # --BEHAVIOR-- adminPrepend 302 $core->callBehavior('adminPrepend',$core,$_ctx); 303 ?> -
inc/core/class.dc.blog.php
r2655 r2911 118 118 119 119 return $this->url; 120 } 121 122 /** 123 Reruens jQuery version selected for the blog. 124 */ 125 public function getJsJQuery() 126 { 127 $version = $this->settings->system->jquery_version; 128 if ($version == '') { 129 $version = DC_DEFAULT_JQUERY; // defined in inc/prepend.php 130 } 131 return 'jquery/'.$version; 120 132 } 121 133 -
inc/core/class.dc.blog.php
r2800 r2911 877 877 878 878 if (!empty($params['user_id'])) { 879 $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 879 $not=""; 880 if (!empty($params['user_id_not'])) { 881 $not=" not"; 882 } 883 $strReq .= "AND U.user_id ".$not.$this->con->in($params['user_id'])." "; 880 884 } 881 885 … … 978 982 979 983 if (!$count_only && !empty($params['limit'])) { 980 $strReq .= $this->con->limit($params['limit']);981 }984 $strReq .= $this->con->limit($params['limit']); 985 } 982 986 983 987 if (!empty($params['sql_only'])) { … … 2218 2222 'UPDATE '.$this->prefix.'comment '. 2219 2223 'SET comment_status = '.$status.' '; 2220 $strReq .=2224 $strReq .= 2221 2225 'WHERE comment_id'.$this->con->in($co_ids). 2222 2226 'AND post_id in (SELECT tp.post_id '. … … 2275 2279 } 2276 2280 2277 $strReq =2281 $strReq = 2278 2282 'DELETE FROM '.$this->prefix.'comment '. 2279 2283 'WHERE comment_id'.$this->con->in($co_ids).' '. … … 2299 2303 } 2300 2304 2301 $strReq =2305 $strReq = 2302 2306 'DELETE FROM '.$this->prefix.'comment '. 2303 2307 'WHERE comment_status = -2 '. -
inc/core/class.dc.core.php
r2715 r2911 299 299 @return <b>array</b> An array of formaters names in values. 300 300 301 302 303 304 305 306 307 return empty() array if editor is not active. 308 301 /** 302 if @param editor_id is empty: 303 return all formaters sorted by actives editors 304 305 if @param editor_id is not empty 306 return formaters for an editor if editor is active 307 return empty() array if editor is not active. 308 It can happens when a user choose an editor and admin deactivate that editor later 309 309 */ 310 310 public function getFormaters($editor_id='') … … 330 330 331 331 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 332 @param name <b>string</b> 333 @param str <b>string</b>String to transform332 @param name <b>string</b> Formater name 333 @param str <b>string</b> String to transform 334 334 @return <b>string</b> String transformed 335 335 */ … … 349 349 350 350 @param name <b>string</b> Formater name 351 @param str <b>string</b> String to transform351 @param str <b>string</b> String to transform 352 352 @return <b>string</b> String transformed 353 353 */ … … 901 901 'edit_size' => 24, 902 902 'enable_wysiwyg' => true, 903 'editor' => 'dcLegacyEditor',903 'editor' => array('xhtml' => 'dcCKEditor', 'wiki' => 'dcLegacyEditor'), 904 904 'post_format' => 'wiki' 905 905 ); -
inc/core/class.dc.core.php
r2753 r2911 39 39 public $rest; ///< <b>dcRestServer</b> dcRestServer object 40 40 public $log; ///< <b>dcLog</b> dcLog object 41 public $tpl; ///< <b>Twig_Environment</b> Twig_Environment object 41 42 public $stime; ///< <b>float</b> starting time 42 43 43 44 private $versions = null; 44 45 private $formaters = array(); 45 46 private $behaviors = array(); 46 47 private $post_types = array(); 47 48 48 49 /** 49 50 dcCore constructor inits everything related to Dotclear. It takes arguments 50 51 to init database connection. 51 52 52 53 @param driver <b>string</b> Database driver name 53 54 @param host <b>string</b> Database hostname … … 67 68 68 69 $this->con = dbLayer::init($driver,$host,$db,$user,$password,$persist); 69 70 70 71 # define weak_locks for mysql 71 72 if ($this->con instanceof mysqlConnection) { … … 74 75 mysqliConnection::$weak_locks = true; 75 76 } 76 77 77 78 # define searchpath for postgresql 78 79 if ($this->con instanceof pgsqlConnection) … … 86 87 } 87 88 } 88 89 89 90 $this->prefix = $prefix; 90 91 91 92 $this->error = new dcError(); 92 93 $this->auth = $this->authInstance(); 93 94 $this->session = new sessionDB($this->con,$this->prefix.'session',DC_SESSION_NAME,'',null,DC_ADMIN_SSL); 94 95 $this->url = new dcUrlHandlers(); 95 96 96 97 $this->plugins = new dcPlugins($this); 97 98 98 99 $this->rest = new dcRestServer($this); 99 100 100 101 $this->meta = new dcMeta($this); 101 102 102 103 $this->log = new dcLog($this); 103 104 } 104 105 105 106 private function authInstance() 106 107 { … … 112 113 $c = DC_AUTH_CLASS; 113 114 } 114 115 115 116 if (!class_exists($c)) { 116 117 throw new Exception('Authentication class '.$c.' does not exist.'); 117 118 } 118 119 119 120 if ($c != 'dcAuth' && !is_subclass_of($c,'dcAuth')) { 120 121 throw new Exception('Authentication class '.$c.' does not inherit dcAuth.'); 121 122 } 122 123 123 124 return new $c($this); 124 125 } 125 126 126 127 /** 128 Create template environment (Twig_Environment instance) 129 130 default-templates path must be added from admin|public/prepend.php with: 131 $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 132 Selected theme path must be added with: 133 $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 134 */ 135 public function loadTemplateEnvironment() 136 { 137 $cache_dir = path::real(DC_TPL_CACHE.'/twtpl',false); 138 if (!is_dir($cache_dir)) { 139 try { 140 files::makeDir($cache_dir); 141 } catch (Exception $e) { 142 $cache_dir = false; 143 } 144 } 145 146 $this->tpl = new Twig_Environment( 147 new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 148 array( 149 'auto_reload' => true, 150 'autoescape' => false, 151 'base_template_class' => 'Twig_Template', 152 'cache' => $cache_dir, 153 'charset' => 'UTF-8', 154 'debug' => DC_DEBUG, 155 'optimizations' => -1, 156 'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 157 ) 158 ); 159 $this->tpl->addExtension(new dcFormExtension($this)); 160 $this->tpl->addExtension(new dcTabExtension($this)); 161 } 162 127 163 /// @name Blog init methods 128 164 //@{ 129 165 /** 130 166 Sets a blog to use in <var>blog</var> property. 131 167 132 168 @param id <b>string</b> Blog ID 133 169 */ … … 136 172 $this->blog = new dcBlog($this, $id); 137 173 } 138 174 139 175 /** 140 176 Unsets <var>blog</var> property. … … 145 181 } 146 182 //@} 147 148 183 184 149 185 /// @name Blog status methods 150 186 //@{ 151 187 /** 152 188 Returns an array of available blog status codes and names. 153 189 154 190 @return <b>array</b> Simple array with codes in keys and names in value 155 191 */ … … 162 198 ); 163 199 } 164 200 165 201 /** 166 202 Returns a blog status name given to a code. This is intended to be 167 203 human-readable and will be translated, so never use it for tests. 168 204 If status code does not exist, returns <i>offline</i>. 169 205 170 206 @param s <b>integer</b> Status code 171 207 @return <b>string</b> Blog status name … … 180 216 } 181 217 //@} 182 218 183 219 /// @name Admin nonce secret methods 184 220 //@{ 185 221 186 222 public function getNonce() 187 223 { 188 224 return crypt::hmac(DC_MASTER_KEY,session_id()); 189 225 } 190 226 191 227 public function checkNonce($secret) 192 228 { … … 194 230 return false; 195 231 } 196 232 197 233 return $secret == crypt::hmac(DC_MASTER_KEY,session_id()); 198 234 } 199 235 200 236 public function formNonce() 201 237 { … … 203 239 return; 204 240 } 205 241 206 242 return form::hidden(array('xd_check'),$this->getNonce()); 207 243 } 208 244 //@} 209 245 210 246 /// @name Text Formatters methods 211 247 //@{ … … 225 261 } 226 262 } 227 263 228 264 /// @name Text Formatters methods 229 265 //@{ … … 232 268 transform text. The function must be a valid callback and takes one 233 269 argument: the string to transform. It returns the transformed string. 234 270 235 271 @param name <b>string</b> Formater name 236 272 @param func <b>callback</b> Function to use, must be a valid and callable callback … … 256 292 return $editors; 257 293 } 258 294 259 295 /** 260 296 Returns formaters list by editor 261 297 262 298 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 263 299 @return <b>array</b> An array of formaters names in values. … … 288 324 return $formaters_list; 289 325 } 290 326 291 327 /** 292 328 If <var>$name</var> is a valid formater, it returns <var>$str</var> 293 329 transformed using that formater. 294 330 295 331 @param editor_id <b>string</b> Editor id (dcLegacyEditor, dcCKEditor, ...) 296 332 @param name <b>string</b> Formater name … … 303 339 return call_user_func($this->formaters[$editor_id][$name],$str); 304 340 } 305 341 306 342 return $str; 307 343 } 308 344 //@} 309 345 310 346 /** 311 347 If <var>$name</var> is a valid formater, it returns <var>$str</var> … … 322 358 //@} 323 359 324 360 325 361 /// @name Behaviors methods 326 362 //@{ … … 328 364 Adds a new behavior to behaviors stack. <var>$func</var> must be a valid 329 365 and callable callback. 330 366 331 367 @param behavior <b>string</b> Behavior name 332 368 @param func <b>callback</b> Function to call … … 338 374 } 339 375 } 340 376 341 377 /** 342 378 Tests if a particular behavior exists in behaviors stack. 343 379 344 380 @param behavior <b>string</b> Behavior name 345 381 @return <b>boolean</b> … … 349 385 return isset($this->behaviors[$behavior]); 350 386 } 351 387 352 388 /** 353 389 Get behaviors stack (or part of). 354 390 355 391 @param behavior <b>string</b> Behavior name 356 392 @return <b>array</b> … … 359 395 { 360 396 if (empty($this->behaviors)) return null; 361 397 362 398 if ($behavior == '') { 363 399 return $this->behaviors; … … 365 401 return $this->behaviors[$behavior]; 366 402 } 367 403 368 404 return array(); 369 405 } 370 406 371 407 /** 372 408 Calls every function in behaviors stack for a given behavior and returns 373 409 concatened result of each function. 374 410 375 411 Every parameters added after <var>$behavior</var> will be pass to 376 412 behavior calls. 377 413 378 414 @param behavior <b>string</b> Behavior name 379 415 @return <b>string</b> Behavior concatened result … … 385 421 $args = func_get_args(); 386 422 array_shift($args); 387 423 388 424 $res = ''; 389 425 390 426 foreach ($this->behaviors[$behavior] as $f) { 391 427 $res .= call_user_func_array($f,$args); 392 428 } 393 429 394 430 return $res; 395 431 } 396 432 } 397 433 //@} 398 434 399 435 /// @name Post types URLs management 400 436 //@{ … … 404 440 $type = 'post'; 405 441 } 406 442 407 443 $url = sprintf($this->post_types[$type]['admin_url'],$post_id); 408 444 return $escaped ? html::escapeURL($url) : $url; 409 445 } 410 446 411 447 public function getPostPublicURL($type,$post_url,$escaped=true) 412 448 { … … 414 450 $type = 'post'; 415 451 } 416 452 417 453 $url = sprintf($this->post_types[$type]['public_url'],$post_url); 418 454 return $escaped ? html::escapeURL($url) : $url; 419 455 } 420 456 421 457 public function setPostType($type,$admin_url,$public_url,$label='') 422 458 { … … 427 463 ); 428 464 } 429 465 430 466 public function getPostTypes() 431 467 { … … 433 469 } 434 470 //@} 435 471 436 472 /// @name Versions management methods 437 473 //@{ 438 474 /** 439 475 Returns a given $module version. 440 476 441 477 @param module <b>string</b> Module name 442 478 @return <b>string</b> Module version … … 449 485 $strReq = 'SELECT module, version FROM '.$this->prefix.'version'; 450 486 $rs = $this->con->select($strReq); 451 487 452 488 while ($rs->fetch()) { 453 489 $this->versions[$rs->module] = $rs->version; 454 490 } 455 491 } 456 492 457 493 if (isset($this->versions[$module])) { 458 494 return $this->versions[$module]; … … 461 497 } 462 498 } 463 499 464 500 /** 465 501 Sets $version to given $module. 466 502 467 503 @param module <b>string</b> Module name 468 504 @param version <b>string</b> Module version … … 471 507 { 472 508 $cur_version = $this->getVersion($module); 473 509 474 510 $cur = $this->con->openCursor($this->prefix.'version'); 475 511 $cur->module = (string) $module; 476 512 $cur->version = (string) $version; 477 513 478 514 if ($cur_version === null) { 479 515 $cur->insert(); … … 481 517 $cur->update("WHERE module='".$this->con->escape($module)."'"); 482 518 } 483 519 484 520 $this->versions[$module] = $version; 485 521 } 486 522 487 523 /** 488 524 Removes given $module version entry. 489 525 490 526 @param module <b>string</b> Module name 491 527 */ … … 495 531 'DELETE FROM '.$this->prefix.'version '. 496 532 "WHERE module = '".$this->con->escape($module)."' "; 497 533 498 534 $this->con->execute($strReq); 499 535 500 536 if (is_array($this->versions)) { 501 537 unset($this->versions[$module]); 502 538 } 503 539 } 504 540 505 541 //@} 506 542 507 543 /// @name Users management methods 508 544 //@{ 509 545 /** 510 546 Returns a user by its ID. 511 547 512 548 @param id <b>string</b> User ID 513 549 @return <b>record</b> … … 516 552 { 517 553 $params['user_id'] = $id; 518 554 519 555 return $this->getUsers($params); 520 556 } 521 557 522 558 /** 523 559 Returns a users list. <b>$params</b> is an array with the following 524 560 optionnal parameters: 525 561 526 562 - <var>q</var>: search string (on user_id, user_name, user_firstname) 527 563 - <var>user_id</var>: user ID 528 564 - <var>order</var>: ORDER BY clause (default: user_id ASC) 529 565 - <var>limit</var>: LIMIT clause (should be an array ![limit,offset]) 530 566 531 567 @param params <b>array</b> Parameters 532 568 @param count_only <b>boolean</b> Only counts results … … 553 589 'WHERE NULL IS NULL '; 554 590 } 555 591 556 592 if (!empty($params['q'])) { 557 593 $q = $this->con->escape(str_replace('*','%',strtolower($params['q']))); … … 562 598 ') '; 563 599 } 564 600 565 601 if (!empty($params['user_id'])) { 566 602 $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 567 603 } 568 604 569 605 if (!$count_only) { 570 606 $strReq .= 'GROUP BY U.user_id,user_super,user_status,user_pwd,user_change_pwd,'. 571 607 'user_name,user_firstname,user_displayname,user_email,user_url,'. 572 608 'user_desc, user_lang,user_tz,user_post_status,user_options '; 573 609 574 610 if (!empty($params['order']) && !$count_only) { 575 611 $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; … … 578 614 } 579 615 } 580 616 581 617 if (!$count_only && !empty($params['limit'])) { 582 618 $strReq .= $this->con->limit($params['limit']); 583 619 } 584 620 585 621 $rs = $this->con->select($strReq); 586 622 $rs->extend('rsExtUser'); 587 623 return $rs; 588 624 } 589 625 590 626 /** 591 627 Create a new user. Takes a cursor as input and returns the new user ID. 592 628 593 629 @param cur <b>cursor</b> User cursor 594 630 @return <b>string</b> … … 599 635 throw new Exception(__('You are not an administrator')); 600 636 } 601 637 602 638 if ($cur->user_id == '') { 603 639 throw new Exception(__('No user ID given')); 604 640 } 605 641 606 642 if ($cur->user_pwd == '') { 607 643 throw new Exception(__('No password given')); 608 644 } 609 645 610 646 $this->getUserCursor($cur); 611 647 612 648 if ($cur->user_creadt === null) { 613 649 $cur->user_creadt = date('Y-m-d H:i:s'); 614 650 } 615 651 616 652 $cur->insert(); 617 653 618 654 $this->auth->afterAddUser($cur); 619 655 620 656 return $cur->user_id; 621 657 } 622 658 623 659 /** 624 660 Updates an existing user. Returns the user ID. 625 661 626 662 @param id <b>string</b> User ID 627 663 @param cur <b>cursor</b> User cursor … … 631 667 { 632 668 $this->getUserCursor($cur); 633 669 634 670 if (($cur->user_id !== null || $id != $this->auth->userID()) && 635 671 !$this->auth->isSuperAdmin()) { 636 672 throw new Exception(__('You are not an administrator')); 637 673 } 638 674 639 675 $cur->update("WHERE user_id = '".$this->con->escape($id)."' "); 640 676 641 677 $this->auth->afterUpdUser($id,$cur); 642 678 643 679 if ($cur->user_id !== null) { 644 680 $id = $cur->user_id; 645 681 } 646 682 647 683 # Updating all user's blogs 648 684 $rs = $this->con->select( … … 650 686 "WHERE user_id = '".$this->con->escape($id)."' " 651 687 ); 652 688 653 689 while ($rs->fetch()) { 654 690 $b = new dcBlog($this,$rs->blog_id); … … 656 692 unset($b); 657 693 } 658 694 659 695 return $id; 660 696 } 661 697 662 698 /** 663 699 Deletes a user. 664 700 665 701 @param id <b>string</b> User ID 666 702 */ … … 670 706 throw new Exception(__('You are not an administrator')); 671 707 } 672 708 673 709 if ($id == $this->auth->userID()) { 674 710 return; 675 711 } 676 712 677 713 $rs = $this->getUser($id); 678 714 679 715 if ($rs->nb_post > 0) { 680 716 return; 681 717 } 682 718 683 719 $strReq = 'DELETE FROM '.$this->prefix.'user '. 684 720 "WHERE user_id = '".$this->con->escape($id)."' "; 685 721 686 722 $this->con->execute($strReq); 687 723 688 724 $this->auth->afterDelUser($id); 689 725 } 690 726 691 727 /** 692 728 Checks whether a user exists. 693 729 694 730 @param id <b>string</b> User ID 695 731 @return <b>boolean</b> … … 700 736 'FROM '.$this->prefix.'user '. 701 737 "WHERE user_id = '".$this->con->escape($id)."' "; 702 738 703 739 $rs = $this->con->select($strReq); 704 740 705 741 return !$rs->isEmpty(); 706 742 } 707 743 708 744 /** 709 745 Returns all user permissions as an array which looks like: 710 746 711 747 - [blog_id] 712 748 - [name] => Blog name 713 749 - [url] => Blog URL 714 750 - [p] 715 - [permission] => true751 - [permission] => true 716 752 - ... 717 753 718 754 @param id <b>string</b> User ID 719 755 @return <b>array</b> … … 725 761 'INNER JOIN '.$this->prefix.'blog B ON P.blog_id = B.blog_id '. 726 762 "WHERE user_id = '".$this->con->escape($id)."' "; 727 763 728 764 $rs = $this->con->select($strReq); 729 765 730 766 $res = array(); 731 767 732 768 while ($rs->fetch()) 733 769 { … … 738 774 ); 739 775 } 740 776 741 777 return $res; 742 778 } 743 779 744 780 /** 745 781 Sets user permissions. The <var>$perms</var> array looks like: 746 782 747 783 - [blog_id] => '|perm1|perm2|' 748 784 - ... 749 785 750 786 @param id <b>string</b> User ID 751 787 @param perms <b>array</b> Permissions array … … 756 792 throw new Exception(__('You are not an administrator')); 757 793 } 758 794 759 795 $strReq = 'DELETE FROM '.$this->prefix.'permissions '. 760 796 "WHERE user_id = '".$this->con->escape($id)."' "; 761 797 762 798 $this->con->execute($strReq); 763 799 764 800 foreach ($perms as $blog_id => $p) { 765 801 $this->setUserBlogPermissions($id, $blog_id, $p, false); 766 802 } 767 803 } 768 804 769 805 /** 770 806 Sets user permissions for a given blog. <var>$perms</var> is an array with 771 807 permissions in values 772 808 773 809 @param id <b>string</b> User ID 774 810 @param blog_id <b>string</b> Blog ID … … 781 817 throw new Exception(__('You are not an administrator')); 782 818 } 783 819 784 820 $no_perm = empty($perms); 785 821 786 822 $perms = '|'.implode('|',array_keys($perms)).'|'; 787 823 788 824 $cur = $this->con->openCursor($this->prefix.'permissions'); 789 825 790 826 $cur->user_id = (string) $id; 791 827 $cur->blog_id = (string) $blog_id; 792 828 $cur->permissions = $perms; 793 829 794 830 if ($delete_first || $no_perm) 795 831 { … … 797 833 "WHERE blog_id = '".$this->con->escape($blog_id)."' ". 798 834 "AND user_id = '".$this->con->escape($id)."' "; 799 835 800 836 $this->con->execute($strReq); 801 837 } 802 838 803 839 if (!$no_perm) { 804 840 $cur->insert(); 805 841 } 806 842 } 807 843 808 844 /** 809 845 Sets a user default blog. This blog will be selected when user log in. 810 846 811 847 @param id <b>string</b> User ID 812 848 @param blog_id <b>string</b> Blog ID … … 815 851 { 816 852 $cur = $this->con->openCursor($this->prefix.'user'); 817 853 818 854 $cur->user_default_blog = (string) $blog_id; 819 855 820 856 $cur->update("WHERE user_id = '".$this->con->escape($id)."'"); 821 857 } 822 858 823 859 private function getUserCursor($cur) 824 860 { … … 827 863 throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); 828 864 } 829 865 830 866 if ($cur->user_url !== null && $cur->user_url != '') { 831 867 if (!preg_match('|^http(s?)://|',$cur->user_url)) { … … 833 869 } 834 870 } 835 871 836 872 if ($cur->isField('user_pwd')) { 837 873 if (strlen($cur->user_pwd) < 6) { … … 840 876 $cur->user_pwd = crypt::hmac(DC_MASTER_KEY,$cur->user_pwd); 841 877 } 842 878 843 879 if ($cur->user_lang !== null && !preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$cur->user_lang)) { 844 880 throw new Exception(__('Invalid user language code')); 845 881 } 846 882 847 883 if ($cur->user_upddt === null) { 848 884 $cur->user_upddt = date('Y-m-d H:i:s'); 849 885 } 850 886 851 887 if ($cur->user_options !== null) { 852 888 $cur->user_options = serialize((array) $cur->user_options); 853 889 } 854 890 } 855 891 856 892 /** 857 893 Returns user default settings in an associative array with setting names in 858 894 keys. 859 895 860 896 @return <b>array</b> 861 897 */ … … 870 906 } 871 907 //@} 872 908 873 909 /// @name Blog management methods 874 910 //@{ 875 911 /** 876 912 Returns all blog permissions (users) as an array which looks like: 877 913 878 914 - [user_id] 879 915 - [name] => User name … … 882 918 - [super] => (true|false) super admin 883 919 - [p] 884 - [permission] => true920 - [permission] => true 885 921 - ... 886 922 887 923 @param id <b>string</b> Blog ID 888 924 @param with_super <b>boolean</b> Includes super admins in result … … 897 933 'JOIN '.$this->prefix.'permissions P ON U.user_id = P.user_id '. 898 934 "WHERE blog_id = '".$this->con->escape($id)."' "; 899 935 900 936 if ($with_super) { 901 937 $strReq .= … … 906 942 'WHERE user_super = 1 '; 907 943 } 908 944 909 945 $rs = $this->con->select($strReq); 910 946 911 947 $res = array(); 912 948 913 949 while ($rs->fetch()) 914 950 { … … 922 958 ); 923 959 } 924 960 925 961 return $res; 926 962 } 927 963 928 964 /** 929 965 Returns a blog of given ID. 930 966 931 967 @param id <b>string</b> Blog ID 932 968 @return <b>record</b> … … 935 971 { 936 972 $blog = $this->getBlogs(array('blog_id'=>$id)); 937 973 938 974 if ($blog->isEmpty()) { 939 975 return false; 940 976 } 941 977 942 978 return $blog; 943 979 } 944 980 945 981 /** 946 982 Returns a record of blogs. <b>$params</b> is an array with the following 947 983 optionnal parameters: 948 984 949 985 - <var>blog_id</var>: Blog ID 950 986 - <var>q</var>: Search string on blog_id, blog_name and blog_url 951 987 - <var>limit</var>: limit results 952 988 953 989 @param params <b>array</b> Parameters 954 990 @param count_only <b>boolean</b> Count only results … … 959 995 $join = ''; // %1$s 960 996 $where = ''; // %2$s 961 997 962 998 if ($count_only) 963 999 { … … 977 1013 'WHERE NULL IS NULL '. 978 1014 '%2$s '; 979 1015 980 1016 if (!empty($params['order'])) { 981 1017 $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; … … 983 1019 $strReq .= 'ORDER BY B.blog_id ASC '; 984 1020 } 985 1021 986 1022 if (!empty($params['limit'])) { 987 1023 $strReq .= $this->con->limit($params['limit']); 988 1024 } 989 1025 } 990 1026 991 1027 if ($this->auth->userID() && !$this->auth->isSuperAdmin()) 992 1028 { … … 999 1035 $where = 'AND blog_status IN (1,0) '; 1000 1036 } 1001 1037 1002 1038 if (!empty($params['blog_id'])) { 1003 1039 $where .= "AND B.blog_id = '".$this->con->escape($params['blog_id'])."' "; 1004 1040 } 1005 1041 1006 1042 if (!empty($params['q'])) { 1007 1043 $params['q'] = strtolower(str_replace('*','%',$params['q'])); … … 1013 1049 ') '; 1014 1050 } 1015 1051 1016 1052 $strReq = sprintf($strReq,$join,$where); 1017 1053 return $this->con->select($strReq); 1018 1054 } 1019 1055 1020 1056 /** 1021 1057 Creates a new blog. 1022 1058 1023 1059 @param cur <b>cursor</b> Blog cursor 1024 1060 */ … … 1028 1064 throw new Exception(__('You are not an administrator')); 1029 1065 } 1030 1066 1031 1067 $this->getBlogCursor($cur); 1032 1068 1033 1069 $cur->blog_creadt = date('Y-m-d H:i:s'); 1034 1070 $cur->blog_upddt = date('Y-m-d H:i:s'); 1035 1071 $cur->blog_uid = md5(uniqid()); 1036 1072 1037 1073 $cur->insert(); 1038 1074 } 1039 1075 1040 1076 /** 1041 1077 Updates a given blog. 1042 1078 1043 1079 @param id <b>string</b> Blog ID 1044 1080 @param cur <b>cursor</b> Blog cursor … … 1047 1083 { 1048 1084 $this->getBlogCursor($cur); 1049 1085 1050 1086 $cur->blog_upddt = date('Y-m-d H:i:s'); 1051 1087 1052 1088 $cur->update("WHERE blog_id = '".$this->con->escape($id)."'"); 1053 1089 } 1054 1090 1055 1091 private function getBlogCursor($cur) 1056 1092 { … … 1058 1094 && !preg_match('/^[A-Za-z0-9._-]{2,}$/',$cur->blog_id)) || 1059 1095 (!$cur->blog_id)) { 1060 throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.')); 1061 } 1062 1096 throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.')); 1097 } 1098 1063 1099 if (($cur->blog_name !== null && $cur->blog_name == '') || 1064 1100 (!$cur->blog_name)) { 1065 1101 throw new Exception(__('No blog name')); 1066 1102 } 1067 1103 1068 1104 if (($cur->blog_url !== null && $cur->blog_url == '') || 1069 1105 (!$cur->blog_url)) { 1070 1106 throw new Exception(__('No blog URL')); 1071 1107 } 1072 1108 1073 1109 if ($cur->blog_desc !== null) { 1074 1110 $cur->blog_desc = html::clean($cur->blog_desc); 1075 1111 } 1076 1112 } 1077 1113 1078 1114 /** 1079 1115 Removes a given blog. 1080 1116 @warning This will remove everything related to the blog (posts, 1081 1117 categories, comments, links...) 1082 1118 1083 1119 @param id <b>string</b> Blog ID 1084 1120 */ … … 1088 1124 throw new Exception(__('You are not an administrator')); 1089 1125 } 1090 1126 1091 1127 $strReq = 'DELETE FROM '.$this->prefix.'blog '. 1092 1128 "WHERE blog_id = '".$this->con->escape($id)."' "; 1093 1129 1094 1130 $this->con->execute($strReq); 1095 1131 } 1096 1132 1097 1133 /** 1098 1134 Checks if a blog exist. 1099 1135 1100 1136 @param id <b>string</b> Blog ID 1101 1137 @return <b>boolean</b> … … 1106 1142 'FROM '.$this->prefix.'blog '. 1107 1143 "WHERE blog_id = '".$this->con->escape($id)."' "; 1108 1144 1109 1145 $rs = $this->con->select($strReq); 1110 1146 1111 1147 return !$rs->isEmpty(); 1112 1148 } 1113 1149 1114 1150 /** 1115 1151 Count posts on a blog 1116 1152 1117 1153 @param id <b>string</b> Blog ID 1118 1154 @param type <b>string</b> Post type … … 1124 1160 'FROM '.$this->prefix.'post '. 1125 1161 "WHERE blog_id = '".$this->con->escape($id)."' "; 1126 1162 1127 1163 if ($type) { 1128 1164 $strReq .= "AND post_type = '".$this->con->escape($type)."' "; 1129 1165 } 1130 1166 1131 1167 return $this->con->select($strReq)->f(0); 1132 1168 } 1133 1169 //@} 1134 1170 1135 1171 /// @name HTML Filter methods 1136 1172 //@{ … … 1139 1175 tidy extension is present). If <b>enable_html_filter</b> blog setting is 1140 1176 false, returns not filtered string. 1141 1177 1142 1178 @param str <b>string</b> String to filter 1143 1179 @return <b>string</b> Filtered string. … … 1148 1184 return $str; 1149 1185 } 1150 1186 1151 1187 $filter = new htmlFilter; 1152 1188 $str = trim($filter->apply($str)); … … 1154 1190 } 1155 1191 //@} 1156 1192 1157 1193 /// @name wiki2xhtml methods 1158 1194 //@{ … … 1161 1197 $this->wiki2xhtml = new wiki2xhtml; 1162 1198 } 1163 1199 1164 1200 /** 1165 1201 Returns a transformed string with wiki2xhtml. 1166 1202 1167 1203 @param str <b>string</b> String to transform 1168 1204 @return <b>string</b> Transformed string … … 1175 1211 return $this->wiki2xhtml->transform($str); 1176 1212 } 1177 1213 1178 1214 /** 1179 1215 Inits <var>wiki2xhtml</var> property for blog post. … … 1182 1218 { 1183 1219 $this->initWiki(); 1184 1220 1185 1221 $this->wiki2xhtml->setOpts(array( 1186 1222 'active_title' => 1, … … 1214 1250 'note_str' => '<div class="footnotes"><h4>Notes</h4>%s</div>' 1215 1251 )); 1216 1252 1217 1253 $this->wiki2xhtml->registerFunction('url:post',array($this,'wikiPostLink')); 1218 1254 1219 1255 # --BEHAVIOR-- coreWikiPostInit 1220 1256 $this->callBehavior('coreInitWikiPost',$this->wiki2xhtml); 1221 1257 } 1222 1258 1223 1259 /** 1224 1260 Inits <var>wiki2xhtml</var> property for simple blog comment (basic syntax). … … 1227 1263 { 1228 1264 $this->initWiki(); 1229 1265 1230 1266 $this->wiki2xhtml->setOpts(array( 1231 1267 'active_title' => 0, … … 1256 1292 'active_fr_syntax' => 0 1257 1293 )); 1258 1294 1259 1295 # --BEHAVIOR-- coreInitWikiSimpleComment 1260 1296 $this->callBehavior('coreInitWikiSimpleComment',$this->wiki2xhtml); 1261 1297 } 1262 1298 1263 1299 /** 1264 1300 Inits <var>wiki2xhtml</var> property for blog comment. … … 1267 1303 { 1268 1304 $this->initWiki(); 1269 1305 1270 1306 $this->wiki2xhtml->setOpts(array( 1271 1307 'active_title' => 0, … … 1296 1332 'active_fr_syntax' => 0 1297 1333 )); 1298 1334 1299 1335 # --BEHAVIOR-- coreInitWikiComment 1300 1336 $this->callBehavior('coreInitWikiComment',$this->wiki2xhtml); 1301 1337 } 1302 1338 1303 1339 public function wikiPostLink($url,$content) 1304 1340 { 1305 if (!($this->blog instanceof dcBlog)) { 1341 if (!($this->blog instanceof dcBlog)) { 1306 1342 return array(); 1307 1343 } 1308 1344 1309 1345 $post_id = abs((integer) substr($url,5)); 1310 1346 if (!$post_id) { 1311 1347 return array(); 1312 1348 } 1313 1349 1314 1350 $post = $this->blog->getPosts(array('post_id'=>$post_id)); 1315 1351 if ($post->isEmpty()) { 1316 1352 return array(); 1317 1353 } 1318 1354 1319 1355 $res = array('url' => $post->getURL()); 1320 1356 $post_title = $post->post_title; 1321 1357 1322 1358 if ($content != $url) { 1323 1359 $res['title'] = html::escapeHTML($post->post_title); 1324 1360 } 1325 1361 1326 1362 if ($content == '' || $content == $url) { 1327 1363 $res['content'] = html::escapeHTML($post->post_title); 1328 1364 } 1329 1365 1330 1366 if ($post->post_lang) { 1331 1367 $res['lang'] = $post->post_lang; 1332 1368 } 1333 1369 1334 1370 return $res; 1335 1371 } 1336 1372 //@} 1337 1373 1338 1374 /// @name Maintenance methods 1339 1375 //@{ … … 1341 1377 Creates default settings for active blog. Optionnal parameter 1342 1378 <var>defaults</var> replaces default params while needed. 1343 1379 1344 1380 @param defaults <b>array</b> Default parameters 1345 1381 */ … … 1426 1462 ); 1427 1463 } 1428 1464 1429 1465 $settings = new dcSettings($this,null); 1430 1466 $settings->addNamespace('system'); 1431 1467 1432 1468 foreach ($defaults as $v) { 1433 1469 $settings->system->put($v[0],$v[2],$v[1],$v[3],false,true); 1434 1470 } 1435 1471 } 1436 1472 1437 1473 /** 1438 1474 Recreates entries search engine index. 1439 1475 1440 1476 @param start <b>integer</b> Start entry index 1441 1477 @param limit <b>integer</b> Number of entry to index 1442 1478 1443 1479 @return <b>integer</b> <var>$start</var> and <var>$limit</var> sum 1444 1480 */ … … 1449 1485 $rs = $this->con->select($strReq); 1450 1486 $count = $rs->f(0); 1451 1487 1452 1488 $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml '. 1453 1489 'FROM '.$this->prefix.'post '; 1454 1490 1455 1491 if ($start !== null && $limit !== null) { 1456 1492 $strReq .= $this->con->limit($start,$limit); 1457 1493 } 1458 1494 1459 1495 $rs = $this->con->select($strReq,true); 1460 1496 1461 1497 $cur = $this->con->openCursor($this->prefix.'post'); 1462 1498 1463 1499 while ($rs->fetch()) 1464 1500 { 1465 1501 $words = $rs->post_title.' '. $rs->post_excerpt_xhtml.' '. 1466 1502 $rs->post_content_xhtml; 1467 1503 1468 1504 $cur->post_words = implode(' ',text::splitWords($words)); 1469 1505 $cur->update('WHERE post_id = '.(integer) $rs->post_id); 1470 1506 $cur->clean(); 1471 1507 } 1472 1508 1473 1509 if ($start+$limit > $count) { 1474 1510 return null; … … 1476 1512 return $start+$limit; 1477 1513 } 1478 1514 1479 1515 /** 1480 1516 Recreates comments search engine index. 1481 1517 1482 1518 @param start <b>integer</b> Start comment index 1483 1519 @param limit <b>integer</b> Number of comments to index 1484 1520 1485 1521 @return <b>integer</b> <var>$start</var> and <var>$limit</var> sum 1486 1522 */ … … 1491 1527 $rs = $this->con->select($strReq); 1492 1528 $count = $rs->f(0); 1493 1529 1494 1530 $strReq = 'SELECT comment_id, comment_content '. 1495 1531 'FROM '.$this->prefix.'comment '; 1496 1532 1497 1533 if ($start !== null && $limit !== null) { 1498 1534 $strReq .= $this->con->limit($start,$limit); 1499 1535 } 1500 1536 1501 1537 $rs = $this->con->select($strReq); 1502 1538 1503 1539 $cur = $this->con->openCursor($this->prefix.'comment'); 1504 1540 1505 1541 while ($rs->fetch()) 1506 1542 { … … 1509 1545 $cur->clean(); 1510 1546 } 1511 1547 1512 1548 if ($start+$limit > $count) { 1513 1549 return null; … … 1515 1551 return $start+$limit; 1516 1552 } 1517 1553 1518 1554 /** 1519 1555 Reinits nb_comment and nb_trackback in post table. … … 1521 1557 public function countAllComments() 1522 1558 { 1523 1559 1524 1560 $updCommentReq = 'UPDATE '.$this->prefix.'post P '. 1525 1561 'SET nb_comment = ('. … … 1537 1573 $this->con->execute($updTrackbackReq); 1538 1574 } 1539 1575 1540 1576 /** 1541 1577 Empty templates cache directory … … 1550 1586 /** 1551 1587 Return elapsed time since script has been started 1552 @param 1553 1554 @return <b>float</b> 1588 @param $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 1589 current time is taken if null 1590 @return <b>float</b> elapsed time 1555 1591 */ 1556 1592 public function getElapsedTime ($mtime=null) { -
inc/load_plugin_file.php
r2655 r2911 61 61 $paths = array_reverse(explode(PATH_SEPARATOR,DC_PLUGINS_ROOT)); 62 62 63 # Adding admin/res folderhere to load some stuff63 # Adding some folders here to load some stuff 64 64 $paths[] = dirname(__FILE__).'/swf'; 65 $paths[] = dirname(__FILE__).'/js'; 66 $paths[] = dirname(__FILE__).'/css'; 65 67 66 68 foreach ($paths as $m) -
inc/load_plugin_file.php
r2804 r2911 14 14 if (@is_dir('/usr/lib/clearbricks')) { 15 15 define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 16 } elseif (is_dir(dirname(__FILE__).'/ libs/clearbricks')) {17 define('CLEARBRICKS_PATH',dirname(__FILE__).'/ libs/clearbricks');16 } elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 17 define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 18 18 } elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 19 19 define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); -
inc/prepend.php
r2715 r2911 170 170 define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); 171 171 define('DC_L10N_UPDATE_URL','http://services.dotclear.net/dc2.l10n/?version=%s'); 172 define('DC_DISTRIB_PLUGINS','aboutConfig,akismet,antispam,attachments,blogroll,blowupConfig,dclegacy,fairTrackbacks,importExport,maintenance,pages,pings,simpleMenu,tags,themeEditor,userPref,widgets,dcLegacyEditor ');172 define('DC_DISTRIB_PLUGINS','aboutConfig,akismet,antispam,attachments,blogroll,blowupConfig,dclegacy,fairTrackbacks,importExport,maintenance,pages,pings,simpleMenu,tags,themeEditor,userPref,widgets,dcLegacyEditor,dcCKEditor'); 173 173 define('DC_DISTRIB_THEMES','berlin,blueSilence,blowupConfig,customCSS,default,ductile'); 174 174 define('DC_DEFAULT_TPLSET','mustek'); 175 define('DC_DEFAULT_JQUERY','1.4.2'); 175 176 176 177 if (!defined('DC_VENDOR_NAME')) { … … 270 271 $core->url->register('xmlrpc','xmlrpc','^xmlrpc/(.+)$',array('dcUrlHandlers','xmlrpc')); 271 272 273 // Should use dcAdminURL class, but only in admin -> to be moved to public/prepend.php and admin/prepend.php ? 272 274 $core->setPostType('post','post.php?id=%d',$core->url->getURLFor('post','%s'),'Posts'); 273 275 … … 280 282 define('DC_MAX_UPLOAD_SIZE',$u_max_size); 281 283 unset($u_max_size); unset($p_max_size); 284 285 # Register supplemental mime types 286 files::registerMimeTypes(array( 287 // Audio 288 'aac' => 'audio/aac', 289 'ogg' => 'audio/ogg', 290 'weba' => 'audio/webm', 291 'm4a' => 'audio/mp4', 292 // Video 293 'mp4' => 'video/mp4', 294 'm4p' => 'video/mp4', 295 'webm' => 'video/webm' 296 )); 282 297 283 298 # Shutdown -
inc/prepend.php
r2903 r2911 15 15 16 16 /* ------------------------------------------------------------------------------------------- */ 17 # ClearBricks, DotClear classes auto-loader17 # ClearBricks, Twig, DotClear classes auto-loader 18 18 if (@is_dir('/usr/lib/clearbricks')) { 19 19 define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 20 } elseif (is_dir(dirname(__FILE__).'/ libs/clearbricks')) {21 define('CLEARBRICKS_PATH',dirname(__FILE__).'/ libs/clearbricks');20 } elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 21 define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 22 22 } elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 23 23 define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); … … 29 29 30 30 require CLEARBRICKS_PATH.'/_common.php'; 31 $__autoload['dcCore'] = dirname(__FILE__).'/core/class.dc.core.php'; 32 $__autoload['dcAuth'] = dirname(__FILE__).'/core/class.dc.auth.php'; 33 $__autoload['dcBlog'] = dirname(__FILE__).'/core/class.dc.blog.php'; 34 $__autoload['dcCategories'] = dirname(__FILE__).'/core/class.dc.categories.php'; 35 $__autoload['dcError'] = dirname(__FILE__).'/core/class.dc.error.php'; 36 $__autoload['dcMeta'] = dirname(__FILE__).'/core/class.dc.meta.php'; 37 $__autoload['dcMedia'] = dirname(__FILE__).'/core/class.dc.media.php'; 38 $__autoload['dcPostMedia'] = dirname(__FILE__).'/core/class.dc.postmedia.php'; 39 $__autoload['dcModules'] = dirname(__FILE__).'/core/class.dc.modules.php'; 40 $__autoload['dcPlugins'] = dirname(__FILE__).'/core/class.dc.plugins.php'; 41 $__autoload['dcThemes'] = dirname(__FILE__).'/core/class.dc.themes.php'; 42 $__autoload['dcRestServer'] = dirname(__FILE__).'/core/class.dc.rest.php'; 43 $__autoload['dcNamespace'] = dirname(__FILE__).'/core/class.dc.namespace.php'; 44 $__autoload['dcSettings'] = dirname(__FILE__).'/core/class.dc.settings.php'; 45 $__autoload['dcTrackback'] = dirname(__FILE__).'/core/class.dc.trackback.php'; 46 $__autoload['dcUpdate'] = dirname(__FILE__).'/core/class.dc.update.php'; 47 $__autoload['dcUtils'] = dirname(__FILE__).'/core/class.dc.utils.php'; 48 $__autoload['dcXmlRpc'] = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 49 $__autoload['dcLog'] = dirname(__FILE__).'/core/class.dc.log.php'; 50 $__autoload['dcWorkspace'] = dirname(__FILE__).'/core/class.dc.workspace.php'; 51 $__autoload['dcPrefs'] = dirname(__FILE__).'/core/class.dc.prefs.php'; 52 $__autoload['dcStore'] = dirname(__FILE__).'/core/class.dc.store.php'; 53 $__autoload['dcStoreReader'] = dirname(__FILE__).'/core/class.dc.store.reader.php'; 54 $__autoload['dcStoreParser'] = dirname(__FILE__).'/core/class.dc.store.parser.php'; 55 $__autoload['dcFavorites'] = dirname(__FILE__).'/admin/class.dc.favorites.php'; 56 57 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 58 $__autoload['rsExtComment'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 59 $__autoload['rsExtDates'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 60 $__autoload['rsExtUser'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 61 62 $__autoload['dcMenu'] = dirname(__FILE__).'/admin/class.dc.menu.php'; 63 $__autoload['dcPage'] = dirname(__FILE__).'/admin/lib.dc.page.php'; 64 $__autoload['adminGenericList'] = dirname(__FILE__).'/admin/lib.pager.php'; 65 $__autoload['adminPostList'] = dirname(__FILE__).'/admin/lib.pager.php'; 66 $__autoload['adminPostMiniList'] = dirname(__FILE__).'/admin/lib.pager.php'; 67 $__autoload['adminCommentList'] = dirname(__FILE__).'/admin/lib.pager.php'; 68 $__autoload['adminUserList'] = dirname(__FILE__).'/admin/lib.pager.php'; 69 $__autoload['dcPager'] = dirname(__FILE__).'/admin/lib.pager.php'; 70 $__autoload['dcAdminCombos'] = dirname(__FILE__).'/admin/lib.admincombos.php'; 71 $__autoload['adminModulesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 72 $__autoload['adminThemesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 31 $__autoload['dcCore'] = dirname(__FILE__).'/core/class.dc.core.php'; 32 $__autoload['dcAuth'] = dirname(__FILE__).'/core/class.dc.auth.php'; 33 $__autoload['dcBlog'] = dirname(__FILE__).'/core/class.dc.blog.php'; 34 $__autoload['dcCategories'] = dirname(__FILE__).'/core/class.dc.categories.php'; 35 $__autoload['dcError'] = dirname(__FILE__).'/core/class.dc.error.php'; 36 $__autoload['dcMeta'] = dirname(__FILE__).'/core/class.dc.meta.php'; 37 $__autoload['dcMedia'] = dirname(__FILE__).'/core/class.dc.media.php'; 38 $__autoload['dcPostMedia'] = dirname(__FILE__).'/core/class.dc.postmedia.php'; 39 $__autoload['dcModules'] = dirname(__FILE__).'/core/class.dc.modules.php'; 40 $__autoload['dcPlugins'] = dirname(__FILE__).'/core/class.dc.plugins.php'; 41 $__autoload['dcThemes'] = dirname(__FILE__).'/core/class.dc.themes.php'; 42 $__autoload['dcRestServer'] = dirname(__FILE__).'/core/class.dc.rest.php'; 43 $__autoload['dcNamespace'] = dirname(__FILE__).'/core/class.dc.namespace.php'; 44 $__autoload['dcSettings'] = dirname(__FILE__).'/core/class.dc.settings.php'; 45 $__autoload['dcTrackback'] = dirname(__FILE__).'/core/class.dc.trackback.php'; 46 $__autoload['dcUpdate'] = dirname(__FILE__).'/core/class.dc.update.php'; 47 $__autoload['dcUtils'] = dirname(__FILE__).'/core/class.dc.utils.php'; 48 $__autoload['dcXmlRpc'] = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 49 $__autoload['dcLog'] = dirname(__FILE__).'/core/class.dc.log.php'; 50 $__autoload['dcWorkspace'] = dirname(__FILE__).'/core/class.dc.workspace.php'; 51 $__autoload['dcPrefs'] = dirname(__FILE__).'/core/class.dc.prefs.php'; 52 $__autoload['dcTwigPage'] = dirname(__FILE__).'/core/class.dc.twig.page.php'; 53 $__autoload['dcStore'] = dirname(__FILE__).'/core/class.dc.store.php'; 54 $__autoload['dcStoreReader'] = dirname(__FILE__).'/core/class.dc.store.reader.php'; 55 $__autoload['dcStoreParser'] = dirname(__FILE__).'/core/class.dc.store.parser.php'; 56 $__autoload['dcFavorites'] = dirname(__FILE__).'/admin/class.dc.favorites.php'; 57 58 $__autoload['rsExtPost'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 59 $__autoload['rsExtComment'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 60 $__autoload['rsExtDates'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 61 $__autoload['rsExtUser'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 62 63 $__autoload['dcAdminContext'] = dirname(__FILE__).'/admin/class.dc.admincontext.php'; 64 $__autoload['dcMenu'] = dirname(__FILE__).'/admin/class.dc.menu.php'; 65 $__autoload['dcPage'] = dirname(__FILE__).'/admin/lib.dc.page.php'; 66 $__autoload['adminGenericList'] = dirname(__FILE__).'/admin/lib.pager.php'; 67 $__autoload['adminPostList'] = dirname(__FILE__).'/admin/lib.pager.php'; 68 $__autoload['adminPostMiniList'] = dirname(__FILE__).'/admin/lib.pager.php'; 69 $__autoload['adminCommentList'] = dirname(__FILE__).'/admin/lib.pager.php'; 70 $__autoload['adminUserList'] = dirname(__FILE__).'/admin/lib.pager.php'; 71 $__autoload['dcPager'] = dirname(__FILE__).'/admin/lib.pager.php'; 72 $__autoload['dcAdminCombos'] = dirname(__FILE__).'/admin/lib.admincombos.php'; 73 $__autoload['adminModulesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 74 $__autoload['adminThemesList'] = dirname(__FILE__).'/admin/lib.moduleslist.php'; 73 75 $__autoload['dcThemeConfig'] = dirname(__FILE__).'/admin/lib.themeconfig.php'; 74 76 75 $__autoload['dcTemplate'] 76 $__autoload['context'] 77 $__autoload['dcUrlHandlers'] 77 $__autoload['dcTemplate'] = dirname(__FILE__).'/public/class.dc.template.php'; 78 $__autoload['context'] = dirname(__FILE__).'/public/lib.tpl.context.php'; 79 $__autoload['dcUrlHandlers'] = dirname(__FILE__).'/public/lib.urlhandlers.php'; 78 80 $__autoload['dcAdminURL'] = dirname(__FILE__).'/admin/lib.dc.adminurl.php'; 79 $__autoload['dcPostsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 80 $__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 81 $__autoload['dcActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 81 $__autoload['dcPostsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 82 $__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 83 $__autoload['dcActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 84 $__autoload['dcForm'] = dirname(__FILE__).'/admin/class.dc.form.php'; 85 $__autoload['dcFormExtension'] = dirname(__FILE__).'/admin/class.dc.form.php'; 86 $__autoload['dcTabExtension'] = dirname(__FILE__).'/admin/class.dc.tab.php'; 87 $__autoload['dcItemList'] = dirname(__FILE__).'/admin/class.dc.list.php'; 88 $__autoload['dcListFetcher'] = dirname(__FILE__).'/admin/class.dc.list.php'; 89 90 foreach (array('dcFilterSet', 'dcFilter','dcFilterCombo','dcFilterText','dcFilterBoolean') as $c) { 91 $__autoload[$c] = dirname(__FILE__).'/admin/class.dc.filter.php'; 92 } 82 93 83 94 # Clearbricks extensions 84 95 html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu'; 85 96 html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu'; 97 98 if (@is_dir('/usr/lib/twig')) { 99 define('TWIG_PATH','/usr/lib/Twig'); 100 } elseif (is_dir(dirname(__FILE__).'/../vendor/twig/twig/lib/Twig')) { 101 define('TWIG_PATH',dirname(__FILE__).'/../vendor/twig/twig/lib/Twig'); 102 } elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 103 define('TWIG_PATH',$_SERVER['TWIG_PATH']); 104 } 105 106 if (!defined('TWIG_PATH') || !is_dir(TWIG_PATH)) { 107 exit('No Twig path defined'); 108 } 109 require TWIG_PATH.'/Autoloader.php'; 110 Twig_Autoloader::register(); 111 86 112 /* ------------------------------------------------------------------------------------------- */ 87 113 … … 140 166 # Constants 141 167 define('DC_ROOT',path::real(dirname(__FILE__).'/..')); 142 define('DC_VERSION','2. 8-dev');168 define('DC_VERSION','2.99-dev'); 143 169 define('DC_DIGESTS',dirname(__FILE__).'/digests'); 144 170 define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); -
inc/public/lib.urlhandlers.php
r2650 r2911 110 110 111 111 header('Content-Type: '.$_ctx->content_type.'; charset=UTF-8'); 112 113 if ($core->blog->settings->system->prevents_clickjacking) { 114 // Prevents Clickjacking as far as possible 115 header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+ 116 } 117 112 118 $result['content'] = $core->tpl->getData($_ctx->current_tpl); 113 119 $result['content_type'] = $_ctx->content_type; … … 385 391 386 392 # Check for match 393 # Note: We must prefix post_id key with '#'' in pwd_cookie array in order to avoid integer conversion 394 # because MyArray["12345"] is treated as MyArray[12345] 387 395 if ((!empty($_POST['password']) && $_POST['password'] == $post_password) 388 || (isset($pwd_cookie[ $post_id]) && $pwd_cookie[$post_id] == $post_password))396 || (isset($pwd_cookie['#'.$post_id]) && $pwd_cookie['#'.$post_id] == $post_password)) 389 397 { 390 $pwd_cookie[ $post_id] = $post_password;398 $pwd_cookie['#'.$post_id] = $post_password; 391 399 setcookie('dc_passwd',json_encode($pwd_cookie),0,'/'); 392 400 }
Note: See TracChangeset
for help on using the changeset viewer.