Changeset 1474
- Timestamp:
- 12/17/07 06:58:31 (10 months ago)
- Files:
-
- releases/0.9rc2/.htaccess (modified) (1 diff)
- releases/0.9rc2/config-dist.php (modified) (1 diff)
- releases/0.9rc2/config.php (modified) (1 diff)
- releases/0.9rc2/htaccess-dist (modified) (1 diff)
- releases/0.9rc2/install.php (modified) (1 diff)
- releases/0.9rc2/mod/elggadmin/lib.php (modified) (3 diffs)
- releases/0.9rc2/mod/elggadmin/lib/elggadmin.inc.php (modified) (5 diffs)
- releases/0.9rc2/mod/pages/index.php (modified) (3 diffs)
- releases/0.9rc2/mod/pages/lib.php (modified) (10 diffs)
- releases/0.9rc2/mod/pages/lib/function_frontpage_loggedin.php (deleted)
- releases/0.9rc2/mod/pages/lib/function_frontpage_loggedout.php (deleted)
- releases/0.9rc2/mod/pages/lib/pages.config.php (copied) (copied from releases/0.9/mod/pages/lib/pages.config.php)
- releases/0.9rc2/mod/pages/lib/pages.inc.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
releases/0.9rc2/.htaccess
r1465 r1474 82 82 ########### 83 83 RewriteRule ^content\/?(.*)?$ mod/pages/index.php?owner=-1&page=$1 [QSA,L] 84 RewriteRule ^([A-Za-z0-9]+)\/ pages\/?(.*)?$ mod/pages/index.php?profile_name=$1&page=$2 [QSA,L]84 RewriteRule ^([A-Za-z0-9]+)\/content\/(.*)?$ mod/pages/index.php?profile_name=$1&page=$2 [QSA,L] 85 85 86 86 RewriteRule ^_templates(\/)?$ mod/template/index.php?%{QUERY_STRING} releases/0.9rc2/config-dist.php
r1378 r1474 15 15 $CFG->dbhost = "localhost"; 16 16 17 $CFG->dbuser = " elgg";17 $CFG->dbuser = ""; 18 18 $CFG->dbpass = ""; 19 19 20 $CFG->dbname = " elgg";20 $CFG->dbname = ""; 21 21 $CFG->prefix = "elgg_"; 22 22 releases/0.9rc2/config.php
r1465 r1474 15 15 $CFG->dbhost = "localhost"; 16 16 17 $CFG->dbuser = " elgg";17 $CFG->dbuser = ""; 18 18 $CFG->dbpass = ""; 19 19 20 $CFG->dbname = " elgg";20 $CFG->dbname = ""; 21 21 $CFG->prefix = "elgg_"; 22 22 releases/0.9rc2/htaccess-dist
r1463 r1474 82 82 ########### 83 83 RewriteRule ^content\/?(.*)?$ mod/pages/index.php?owner=-1&page=$1 [QSA,L] 84 RewriteRule ^([A-Za-z0-9]+)\/ pages\/?(.*)?$ mod/pages/index.php?profile_name=$1&page=$2 [QSA,L]84 RewriteRule ^([A-Za-z0-9]+)\/content\/(.*)?$ mod/pages/index.php?profile_name=$1&page=$2 [QSA,L] 85 85 86 86 RewriteRule ^_templates(\/)?$ mod/template/index.php?%{QUERY_STRING} releases/0.9rc2/install.php
r1453 r1474 676 676 677 677 //$urlregex = '#https?://([\w\.-]+)+(:\d+)?(/([\w-_\./]*(\?\S+)?)?)?#'; //extended url regex 678 $urlregex = '#^https?://[\w\.-]+(:\d+)?([\w-_ \./]*)?/$#i';678 $urlregex = '#^https?://[\w\.-]+(:\d+)?([\w-_~\./()\#@%;$\+=\\\|&]*)?/$#i'; 679 679 $hostregex = '#^[\w\.-]+(:\d+)?$#'; 680 680 releases/0.9rc2/mod/elggadmin/lib.php
r1426 r1474 17 17 18 18 elggadmin_add_rule('mod/elggadmin/?$', 'elggadmin_page'); 19 elggadmin_add_rule('mod/elggadmin/(theme|frontpage )$', 'elggadmin_page');20 elggadmin_add_rule('mod/elggadmin/index.php/?(theme|frontpage )?$', 'elggadmin_page');19 elggadmin_add_rule('mod/elggadmin/(theme|frontpage|logs)$', 'elggadmin_page'); 20 elggadmin_add_rule('mod/elggadmin/index.php/?(theme|frontpage|logs)?$', 'elggadmin_page'); 21 21 22 22 elggadmin_add_function('elggadmin_page_before', 'elggadmin_actions'); … … 53 53 // submenu options 54 54 pages_submenu_add('elggadmin', __gettext('Configuration manager'), get_url(null, 'elggadmin::')); 55 pages_submenu_add('elggadmin', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme')); 56 pages_submenu_add('elggadmin', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage')); 55 pages_submenu_add('elggadmin:theme', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme')); 56 pages_submenu_add('elggadmin:frontpage', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage')); 57 pages_submenu_add('elggadmin:logs', __gettext('Error log'), get_url(null, 'elggadmin::logs')); 57 58 58 59 sidebar_add(50, 'sidebar-'.elggadmin_currentpage(), elggadmin_sidebar()); … … 84 85 $url = get_url(null, 'elggadmin::') . '/frontpage'; 85 86 break; 87 case 'elggadmin::logs': 88 $url = get_url(null, 'elggadmin::') . '/logs'; 89 break; 90 86 91 } 87 92 releases/0.9rc2/mod/elggadmin/lib/elggadmin.inc.php
r1453 r1474 30 30 $page = elggadmin_page_frontpage(); 31 31 elggadmin_currentpage('frontpage'); 32 } elseif ($page_name == 'logs') { 33 $page = elggadmin_page_logs(); 34 elggadmin_currentpage('logs'); 32 35 } else { 33 36 $page = elggadmin_page_config(); … … 212 215 } 213 216 217 function elggadmin_page_logs() { 218 global $CFG; 219 220 $action = optional_param('action'); 221 if ($action == 'elggadmin:logs:clear') { 222 elggadmin_writefile($CFG->dataroot.'errors.log',""); 223 header_redirect(get_url(null,'elggadmin::logs'), __gettext('Error log cleared')); 224 } 225 226 $logs = elggadmin_tailfile($CFG->dataroot.'errors.log', 50); 227 228 $clear = '» ' . pages_html_a(get_url_query(1, 'elggadmin::logs', 'action=elggadmin:logs:clear'), __gettext('Clear error log')); 229 230 $page = new StdClass; 231 $page->title = __gettext('Error log'); 232 $page->body = pages_html_wrap('p', $clear); 233 $page->body .= pages_html_wrap('textarea', $logs, array('wrap'=>'off', 'readonly'=>'readonly')); 234 235 return $page; 236 } 237 214 238 function elggadmin_page_theme() { 215 239 $page = new StdClass; … … 436 460 } 437 461 438 function elggadmin_tpltextarea($tplname, $title=null ) {462 function elggadmin_tpltextarea($tplname, $title=null, $attrs=null) { 439 463 $output = ''; 464 $_attrs = array('name' => $tplname, 'style' => 'width:95%;height:300px;margin:0px 10px 20px 10px;'); 465 440 466 if (is_string($title)) { 441 467 $output .= pages_html_wrap('h2', $title); … … 446 472 } 447 473 448 $output .= pages_html_wrap('textarea', empty($tpl) ? ' ' : $tpl, array('name' => $tplname, 'style' => 'width:95%;height:300px;margin:0px 10px 20px 10px;')); 474 if ($is_array($attrs)) { 475 $_attrs = array_merge($attrs, $_attrs); 476 } 477 478 $output .= pages_html_wrap('textarea', empty($tpl) ? ' ' : $tpl, $_attrs); 449 479 450 480 return $output; … … 498 528 } 499 529 530 function elggadmin_tailfile($file, $lines=20) { 531 if ($fp = @fopen($file, 'r')) { 532 $pos = -1; 533 $t = ' '; 534 $content = ''; 535 536 if ($lines < 0) { 537 $lines = 20; 538 } 539 540 while ($lines > 0) { 541 if (!fseek($fp, $pos, SEEK_END)) { 542 $t = fgetc($fp); 543 $pos--; 544 if ($t == "\n") { 545 $lines--; 546 } 547 $content = $t . $content; 548 } else { 549 rewind($fp); 550 $lines--; 551 } 552 } 553 554 @fclose($fp); 555 return $content; 556 } else { 557 return null; 558 } 559 } 560 500 561 ?> releases/0.9rc2/mod/pages/index.php
r1453 r1474 16 16 } else { 17 17 define('context', 'external'); 18 define('pages_external', true); 18 19 } 19 20 … … 25 26 if (page_owner() < 1) { 26 27 // remove all but pages block 27 sidebar_remove(array('pages_sidebar' , 'sidebar-profile'), true);28 sidebar_remove(array('pages_sidebar'), true); 28 29 } 29 30 … … 31 32 $do_action = optional_param('do'); 32 33 33 if ($do_action == 'edit') { 34 $page = pages_edit_page($page_id, page_owner()); 34 if (!pages_enabled()) { 35 $page = new StdClass; 36 $page->title = __gettext('Plugin disabled for users'); 37 $page->content = __gettext('This plugin is currently disabled by site administrator'); 35 38 } else { 36 $page = pages_get_page($page_id, page_owner()); 39 if ($do_action == 'edit') { 40 $page = pages_edit_page($page_id, page_owner()); 41 } else { 42 $page = pages_get_page($page_id, page_owner()); 43 } 37 44 } 45 38 46 39 47 if (!empty($page->ident)) { releases/0.9rc2/mod/pages/lib.php
r1463 r1474 11 11 12 12 function pages_init() { 13 global $CFG, $function, $PAGE; 14 15 define('pages_allow_php_admin', true); 16 define('pages_allow_php_user', false); 17 define('pages_parse_keywords', true); 18 define('pages_blog_textproc', false); // breaks content with br's 13 global $CFG; 14 15 require_once($CFG->dirroot . 'mod/pages/lib/pages.config.php'); 19 16 20 17 pages_dbsetup(); 21 22 //DEPRECATED: legacy pages23 /*24 $PAGE->pages->old_compat = array(25 'about.php' => array(26 'title' => sprintf(__gettext('About %s'), $CFG->sitename),27 'function' => 'content:about',28 ),29 'faq.php' => array(30 'title' => sprintf(__gettext('%s FAQ'), $CFG->sitename),31 'function' => 'content:faq',32 ),33 'privacy.php' => array(34 'title' => sprintf(__gettext('%s Privacy Police'), $CFG->sitename),35 'function' => 'content:privacy',36 ),37 'terms.php' => array(38 'title' => sprintf(__gettext('%s Terms & Conditions'), $CFG->sitename),39 'function' => 'content:terms',40 ),41 'run_your_own.php' => array(42 'title' => sprintf(__gettext('Running your own %s'), $CFG->sitename),43 'function' => 'content:run_your_own',44 ),45 );46 47 $function["pages:frontpage_loggedin"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedin.php";48 $function["pages:frontpage_loggedout"][] = dirname(__FILE__) . "/lib/function_frontpage_loggedout.php";49 50 $PAGE->pages->old_compat['frontpage_loggedin'] = array(51 'title' => sprintf(__gettext('Welcome {{username}}')),52 'function' => 'pages:frontpage_loggedin',53 );54 $PAGE->pages->old_compat['frontpage_loggedout'] = array(55 'title' => sprintf(__gettext('Welcome Guest')),56 'function' => 'pages:frontpage_loggedout',57 );58 */59 18 } 60 19 … … 68 27 $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail'; 69 28 70 if (defined('context') && context == 'pages' ) {71 if (p ermissions_check('pages::edit', page_owner())) {29 if (defined('context') && context == 'pages' || defined('pages_external')) { 30 if (pages_enabled() && permissions_check('pages::edit', page_owner())) { 72 31 $page_name = optional_param('page'); 73 32 $do_action = optional_param('do'); 74 33 75 34 if ($do_action != 'edit') { 76 pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 0); 77 } 78 } 79 } 80 81 if (isloggedin()) { 82 pages_menu_add('pages', __gettext('Your Pages'), get_url($_SESSION['userid'], 'pages::')); 83 } 84 85 // not show main site pages on sidebar 86 sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your pages')); 35 // new page link 36 pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0); 37 // edit this page link 38 pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1); 39 } 40 } 41 } 42 43 if (!PAGES_DISABLE_USERS && isloggedin()) { 44 pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::')); 45 } 46 47 if (pages_enabled()) { 48 // not show main site pages on sidebar 49 sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content')); 50 } 87 51 } 88 52 89 53 function pages_php_allowed() { 90 54 if (page_owner() == -1 91 || pages_allow_php_user92 || ( pages_allow_php_admin&& user_flag_get('admin', page_owner())))55 || PAGES_ALLOW_PHP_USER 56 || (PAGES_ALLOW_PHP_ADMIN && user_flag_get('admin', page_owner()))) 93 57 { 94 58 return true; … … 107 71 switch ($type) { 108 72 case 'pages::edit': 109 if ( $ident > 0) {73 if (pages_enabled() && $ident > 0) { 110 74 $result = run('permissions:check', 'profile'); 111 75 } else { … … 147 111 $_page = new StdClass; 148 112 $_page->uri = 'privacy.php'; //backward compatibility 113 $_page->name = 'privacy.php'; //backward compatibility 149 114 $_page->title = __gettext('Privacy Policy'); 150 115 $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_privacy.html'); … … 154 119 $_page = new StdClass; 155 120 $_page->uri = 'terms.php'; //backward compatibility 121 $_page->name = 'terms.php'; //backward compatibility 156 122 $_page->title = __gettext('Terms and Conditions'); 157 123 $_page->content = @file_get_contents(dirname(__FILE__).'/legacy/content_terms.html'); … … 202 168 if ($id > 0) { 203 169 $url = get_url($id, 'profile::'); 204 if (!empty($url)) $url .= ' pages/'; // url for user's pages170 if (!empty($url)) $url .= 'content/'; // url for user's pages 205 171 } else { 206 172 $url = $CFG->wwwroot . 'content/'; // url for site pages … … 321 287 if ($owner > 0) { 322 288 if ($_SESSION['userid'] == $owner) { 323 $title = __gettext('Your pages');289 $title = __gettext('Your Content'); 324 290 }else { 325 291 //$title = sprintf(__gettext("%s's pages"), htmlspecialchars(user_name($owner), ENT_COMPAT, 'utf-8')); 326 $title = __gettext(" Pages");292 $title = __gettext("Content"); 327 293 } 328 294 } else { … … 337 303 338 304 return $body; 305 } 306 307 function pages_enabled() { 308 if (page_owner() == -1 || 309 (page_owner() > 0 && !PAGES_DISABLE_USERS) ) { 310 return true; 311 } else { 312 return false; 313 } 339 314 } 340 315 … … 415 390 $main_link = pages_html_a(pages_url(__gettext('Main'), 'pages::page', $owner), __gettext('Main')); 416 391 $menu .= pages_html_wrap('li', $main_link, array('class' => 'menu-item')); 417 }418 419 // "add new" page link420 if (permissions_check('pages::edit',$owner)) {421 $new_page_link = pages_html_wrap('small', __gettext('New page'));422 $menu .= pages_html_wrap('li', pages_html_wrap('a', $new_page_link, array('href'=>pages_url('New_page', 'pages::edit', $owner), 'title'=>__gettext('New page')), array('class' => 'menu-item')));423 392 } 424 393 … … 721 690 } 722 691 } 692 693 if (!function_exists('html_entity_decode')) { 694 function html_entity_decode($string) { 695 // replace numeric entities 696 $string = preg_replace('/&#x([0-9a-f]+);/ei', 'chr(hexdec("\\1"))', $string); 697 $string = preg_replace('/&#([0-9]+);/e', 'char("\\1")', $string); 698 // replace literal entities 699 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 700 $trans_tbl = array_flip($trans_tbl); 701 return strtr($string, $trans_tbl); 702 703 } 704 } 723 705 ?> releases/0.9rc2/mod/pages/lib/pages.inc.php
r1463 r1474 30 30 $owner = ($owner > 0) ? $owner : -1; 31 31 32 if ( defined('context') && context == 'pages'&& $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) {32 if ((defined('context') && context == 'pages' || defined('pages_external')) && $action == 'pages:edit' && $do_action == 'edit' && permissions_check('pages::edit', $owner)) { 33 33 $submit = optional_param('submit'); 34 34 // get page id … … 157 157 $content = trim(optional_param('page-content')); 158 158 } 159 $content = html_entity_decode($content); 159 160 $name = trim(optional_param('page-name')); 160 161 $parent = optional_param('menu-parent', 0, PARAM_INT); … … 338 339 339 340 // parse elgg template keywords 340 if ( pages_parse_keywords) {341 if (PAGES_PARSE_KEYWORDS) { 341 342 // wrap into templates_draw 342 343 global $template; … … 352 353 353 354 // process with blog filters 354 if ( pages_blog_textproc) {355 if (PAGES_BLOG_TEXTPROC) { 355 356 $content = run('weblogs:text:process', $content); 356 357 } … … 378 379 $PAGE->pages->editing = true; 379 380 380 if ( !empty($page_name) && permissions_check('pages::edit', $owner)) {381 if (pages_enabled() && !empty($page_name) && permissions_check('pages::edit', $owner)) { 381 382 if ($owner == -1 && pages_is_frontpage($page_name)) { 382 383 $is_frontpage = true; … … 409 410 $title_enc = htmlspecialchars($page->title, ENT_QUOTES, 'utf-8'); 410 411 //$page->content = htmlspecialchars(stripslashes($page->content), ENT_COMPAT, 'utf-8'); 411 $page->content = $page->content;412 $page->content = trim($page->content); 412 413 $page->name = htmlspecialchars($page->name, ENT_QUOTES, 'utf-8'); 413 414 … … 426 427 $input_content = pages_html_wrap('label', __gettext('Content:'), array('for' => 'page-content')); 427 428 $input_content .= pages_html_wrap( 428 'textarea', $page->content,429 'textarea', htmlentities($page->content), 429 430 array( 430 431 'id' => 'page-content',
