271 * @param string $title The title of the message |
271 * @param string $title The title of the message |
272 * @param string $message A short message to show to the user |
272 * @param string $message A short message to show to the user |
273 * @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. |
273 * @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. |
274 */ |
274 */ |
275 |
275 |
276 function redirect($url, $title = 'Redirecting...', $message = 'Please wait while you are redirected.', $timeout = 3) |
276 function redirect($url, $title = 'etc_redirect_title', $message = 'etc_redirect_body', $timeout = 3) |
277 { |
277 { |
278 global $db, $session, $paths, $template, $plugins; // Common objects |
278 global $db, $session, $paths, $template, $plugins; // Common objects |
|
279 global $lang; |
279 |
280 |
280 if ( $timeout == 0 ) |
281 if ( $timeout == 0 ) |
281 { |
282 { |
282 header('Location: ' . $url); |
283 header('Location: ' . $url); |
283 header('HTTP/1.1 307 Temporary Redirect'); |
284 header('HTTP/1.1 307 Temporary Redirect'); |
284 } |
285 } |
|
286 |
|
287 $title = $lang->get($title); |
|
288 $message = $lang->get($message); |
285 |
289 |
286 $template->add_header('<meta http-equiv="refresh" content="' . $timeout . '; url=' . str_replace('"', '\\"', $url) . '" />'); |
290 $template->add_header('<meta http-equiv="refresh" content="' . $timeout . '; url=' . str_replace('"', '\\"', $url) . '" />'); |
287 $template->add_header('<script type="text/javascript"> |
291 $template->add_header('<script type="text/javascript"> |
288 function __r() { |
292 function __r() { |
289 // FUNCTION AUTOMATICALLY GENERATED |
293 // FUNCTION AUTOMATICALLY GENERATED |
293 </script> |
297 </script> |
294 '); |
298 '); |
295 |
299 |
296 $template->tpl_strings['PAGE_NAME'] = $title; |
300 $template->tpl_strings['PAGE_NAME'] = $title; |
297 $template->header(true); |
301 $template->header(true); |
298 echo '<p>' . $message . '</p><p>If you are not redirected within ' . ( $timeout + 1 ) . ' seconds, <a href="' . str_replace('"', '\\"', $url) . '">please click here</a>.</p>'; |
302 echo '<p>' . $message . '</p>'; |
|
303 $subst = array( |
|
304 'timeout' => ( $timeout + 1 ), |
|
305 'redirect_url' => str_replace('"', '\\"', $url) |
|
306 ); |
|
307 echo '<p>' . $lang->get('etc_redirect_timeout', $subst) . '</p>'; |
299 $template->footer(true); |
308 $template->footer(true); |
300 |
309 |
301 $db->close(); |
310 $db->close(); |
302 exit(0); |
311 exit(0); |
303 |
312 |
628 */ |
639 */ |
629 |
640 |
630 function show_category_info() |
641 function show_category_info() |
631 { |
642 { |
632 global $db, $session, $paths, $template, $plugins; // Common objects |
643 global $db, $session, $paths, $template, $plugins; // Common objects |
|
644 global $lang; |
633 |
645 |
634 if ( $paths->namespace == 'Category' ) |
646 if ( $paths->namespace == 'Category' ) |
635 { |
647 { |
636 // Show member pages and subcategories |
648 // Show member pages and subcategories |
637 $q = $db->sql_query('SELECT p.urlname, p.namespace, p.name, p.namespace=\'Category\' AS is_category FROM '.table_prefix.'categories AS c |
649 $q = $db->sql_query('SELECT p.urlname, p.namespace, p.name, p.namespace=\'Category\' AS is_category FROM '.table_prefix.'categories AS c |
743 |
755 |
744 if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
756 if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
745 { |
757 { |
746 echo '<div class="mdg-comment" style="margin: 10px 0 0 0;" id="category_box_wrapper">'; |
758 echo '<div class="mdg-comment" style="margin: 10px 0 0 0;" id="category_box_wrapper">'; |
747 echo '<div style="float: right;">'; |
759 echo '<div style="float: right;">'; |
748 echo '(<a href="#" onclick="ajaxCatToTag(); return false;">show page tags</a>)'; |
760 echo '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)'; |
749 echo '</div>'; |
761 echo '</div>'; |
750 echo '<div id="mdgCatBox">Categories: '; |
762 echo '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' '; |
751 |
763 |
752 $where = '( c.page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND c.namespace=\'' . $db->escape($paths->namespace) . '\' )'; |
764 $where = '( c.page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND c.namespace=\'' . $db->escape($paths->namespace) . '\' )'; |
753 $prefix = table_prefix; |
765 $prefix = table_prefix; |
754 $sql = <<<EOF |
766 $sql = <<<EOF |
755 SELECT c.category_id FROM {$prefix}categories AS c |
767 SELECT c.category_id FROM {$prefix}categories AS c |
775 while ( $row = $db->fetchrow() ); |
787 while ( $row = $db->fetchrow() ); |
776 echo implode(', ', $list); |
788 echo implode(', ', $list); |
777 } |
789 } |
778 else |
790 else |
779 { |
791 { |
780 echo '(Uncategorized)'; |
792 echo $lang->get('catedit_catbox_lbl_uncategorized'); |
781 } |
793 } |
782 |
794 |
783 $can_edit = ( $session->get_permissions('edit_cat') && ( !$paths->page_protected || $session->get_permissions('even_when_protected') ) ); |
795 $can_edit = ( $session->get_permissions('edit_cat') && ( !$paths->page_protected || $session->get_permissions('even_when_protected') ) ); |
784 if ( $can_edit ) |
796 if ( $can_edit ) |
785 { |
797 { |
786 $edit_link = '<a href="' . makeUrl($paths->page, 'do=catedit', true) . '" onclick="ajaxCatEdit(); return false;">edit categorization</a>'; |
798 $edit_link = '<a href="' . makeUrl($paths->page, 'do=catedit', true) . '" onclick="ajaxCatEdit(); return false;">' . $lang->get('catedit_catbox_link_edit') . '</a>'; |
787 echo ' [ ' . $edit_link . ' ]'; |
799 echo ' [ ' . $edit_link . ' ]'; |
788 } |
800 } |
789 |
801 |
790 echo '</div></div>'; |
802 echo '</div></div>'; |
791 |
803 |
872 */ |
884 */ |
873 |
885 |
874 function display_page_headers() |
886 function display_page_headers() |
875 { |
887 { |
876 global $db, $session, $paths, $template, $plugins; // Common objects |
888 global $db, $session, $paths, $template, $plugins; // Common objects |
|
889 global $lang; |
877 if($session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
890 if($session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
878 { |
891 { |
879 $delvote_ips = unserialize($paths->cpage['delvote_ips']); |
892 $delvote_ips = unserialize($paths->cpage['delvote_ips']); |
880 $hr = htmlspecialchars(implode(', ', $delvote_ips['u'])); |
893 $hr = htmlspecialchars(implode(', ', $delvote_ips['u'])); |
881 $is = 'is'; |
894 |
882 $s = ''; |
895 $string_id = ( $paths->cpage['delvotes'] == 1 ) ? 'delvote_lbl_votes_one' : 'delvote_lbl_votes_plural'; |
883 $s2 = 's'; |
896 $string = $lang->get($string_id, array('num_users' => $paths->cpage['delvotes'])); |
884 if ( $paths->cpage['delvotes'] > 1) |
897 |
885 { |
|
886 $is = 'are'; |
|
887 $s = 's'; |
|
888 $s2 = ''; |
|
889 } |
|
890 echo '<div class="info-box" style="margin-left: 0; margin-top: 5px;" id="mdgDeleteVoteNoticeBox"> |
898 echo '<div class="info-box" style="margin-left: 0; margin-top: 5px;" id="mdgDeleteVoteNoticeBox"> |
891 <b>Notice:</b> There '.$is.' '.$paths->cpage['delvotes'].' user'.$s.' that think'.$s2.' this page should be deleted.<br /> |
899 <b>' . $lang->get('etc_lbl_notice') . '</b> ' . $string . '<br /> |
892 <b>Users that voted:</b> ' . $hr . '<br /> |
900 <b>' . $lang->get('delvote_lbl_users_that_voted') . '</b> ' . $hr . '<br /> |
893 <a href="'.makeUrl($paths->page, 'do=deletepage').'" onclick="ajaxDeletePage(); return false;">Delete page</a> | <a href="'.makeUrl($paths->page, 'do=resetvotes').'" onclick="ajaxResetDelVotes(); return false;">Reset votes</a> |
901 <a href="'.makeUrl($paths->page, 'do=deletepage').'" onclick="ajaxDeletePage(); return false;">' . $lang->get('delvote_btn_deletepage') . '</a> | <a href="'.makeUrl($paths->page, 'do=resetvotes').'" onclick="ajaxResetDelVotes(); return false;">' . $lang->get('delvote_btn_resetvotes') . '</a> |
894 </div>'; |
902 </div>'; |
895 } |
903 } |
896 } |
904 } |
897 |
905 |
898 /** |
906 /** |
3167 |
3175 |
3168 return $score; |
3176 return $score; |
3169 } |
3177 } |
3170 |
3178 |
3171 /** |
3179 /** |
3172 * Registers a task that will be run every X hours. Scheduled tasks should always be scheduled at runtime - they are not stored in the DB. |
3180 * Installs a language. |
3173 * @param string Function name to call, or array(object, string method) |
3181 * @param string The ISO-639-3 identifier for the language. Maximum of 6 characters, usually 3. |
3174 * @param int Interval between runs, in hours. Defaults to 24. |
3182 * @param string The name of the language in English (Spanish) |
3175 */ |
3183 * @param string The name of the language natively (EspaƱol) |
3176 |
3184 * @param string The path to the file containing the language's strings. Optional. |
3177 function register_cron_task($func, $hour_interval = 24) |
3185 */ |
3178 { |
3186 |
3179 global $cron_tasks; |
3187 function install_language($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false) |
3180 if ( !isset($cron_tasks[$hour_interval]) ) |
3188 { |
3181 $cron_tasks[$hour_interval] = array(); |
3189 global $db, $session, $paths, $template, $plugins; // Common objects |
3182 $cron_tasks[$hour_interval][] = $func; |
3190 |
|
3191 $q = $db->sql_query('SELECT 1 FROM '.table_prefix.'language WHERE lang_code = "' . $db->escape($lang_code) . '";'); |
|
3192 if ( !$q ) |
|
3193 $db->_die('functions.php - checking for language existence'); |
|
3194 |
|
3195 if ( $db->numrows() > 0 ) |
|
3196 // Language already exists |
|
3197 return false; |
|
3198 |
|
3199 $q = $db->sql_query('INSERT INTO ' . table_prefix . 'language(lang_code, lang_name_default, lang_name_native) |
|
3200 VALUES( |
|
3201 "' . $db->escape($lang_code) . '", |
|
3202 "' . $db->escape($lang_name_neutral) . '", |
|
3203 "' . $db->escape($lang_name_native) . '" |
|
3204 );'); |
|
3205 if ( !$q ) |
|
3206 $db->_die('functions.php - installing language'); |
|
3207 |
|
3208 $lang_id = $db->insert_id(); |
|
3209 if ( empty($lang_id) ) |
|
3210 return false; |
|
3211 |
|
3212 // Do we also need to install a language file? |
|
3213 if ( is_string($lang_file) && file_exists($lang_file) ) |
|
3214 { |
|
3215 $lang = new Language($lang_id); |
|
3216 $lang->import($lang_file); |
|
3217 } |
|
3218 else if ( is_string($lang_file) && !file_exists($lang_file) ) |
|
3219 { |
|
3220 echo '<b>Notice:</b> Can\'t load language file, so the specified language wasn\'t fully installed.<br />'; |
|
3221 return false; |
|
3222 } |
|
3223 return true; |
3183 } |
3224 } |
3184 |
3225 |
3185 //die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>'); |
3226 //die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>'); |
3186 |
3227 |
3187 ?> |
3228 ?> |