/**
 * Validate an IP address, indirectly by passing through a confirmation code.
 */
function validate_ip_script()
{
    @ob_end_clean();
    global $EXTRA_HEAD;
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $keep = keep_symbol(array('1'));
    $code = either_param('code', '');
    if ($code == '') {
        $title = get_page_title('CONFIRM');
        require_code('form_templates');
        $fields = new ocp_tempcode();
        $fields->attach(form_input_codename(do_lang_tempcode('CODE'), '', 'code', '', true));
        $submit_name = do_lang_tempcode('PROCEED');
        $url = find_script('validateip') . $keep;
        $middle = do_template('FORM_SCREEN', array('_GUID' => 'd92ce4ec82dc709f920a4ce6760778de', 'TITLE' => $title, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => $url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name));
        $echo = globalise($middle, NULL, '', true);
        $echo->evaluate_echo();
        exit;
    }
    // If we're still here, we're ok to go
    require_lang('ocf');
    $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_member_known_login_ips', 'i_val_code', array('i_val_code' => $code));
    if (is_null($test)) {
        warn_exit(do_lang_tempcode('ALREADY_VALIDATED'));
    }
    $GLOBALS['FORUM_DB']->query_update('f_member_known_login_ips', array('i_val_code' => ''), array('i_val_code' => $code), '', 1);
    $title = get_page_title('CONFIRM');
    $middle = redirect_screen($title, get_base_url() . $keep, do_lang_tempcode('SUCCESS'));
    $echo = globalise($middle, NULL, '', true);
    $echo->evaluate_echo();
    exit;
}
Example #2
0
/**
 * Show the current user a message. Function does not return.
 *
 * @param  tempcode	The message to show
 * @param  ID_TEXT	Code of message type to show
 * @set    warn inform fatal
 */
function ocw_refresh_with_message($message, $msg_type = 'inform')
{
    $url = build_url(array('page' => 'ocworld'), '_SELF');
    @ob_end_clean();
    $title = get_page_title('MESSAGE');
    $tpl = redirect_screen($title, $url, $message, false, $msg_type);
    $echo = globalise($tpl, NULL, '', true);
    $echo->evaluate_echo();
    exit;
}
Example #3
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function ___text()
 {
     if (get_option('is_on_flagrant_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWTEXT');
     // Define variables
     $member_id = get_member();
     $message = post_param('message');
     $days = post_param_integer('days');
     $points_left = available_points($member_id);
     // First we need to know the price of the number of days we ordered. After that, compare that price with our users current number of points.
     $dayprice = intval(get_option('text'));
     $total = $dayprice * $days;
     if ($points_left < $total && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('FLAGRANT_LACK_POINTS', integer_format($days), integer_format($total), integer_format($points_left)));
     }
     // Add this to the database
     $GLOBALS['SITE_DB']->query_insert('text', array('notes' => '', 'activation_time' => NULL, 'active_now' => 0, 'user_id' => $member_id, 'the_message' => insert_lang_comcode($message, 2), 'days' => $days, 'order_time' => time()));
     // Mail off the notice
     require_code('notifications');
     $_url = build_url(array('page' => 'admin_flagrant'), 'adminzone', NULL, false, false, true);
     $manage_url = $_url->evaluate();
     dispatch_notification('pointstore_request_flagrant', NULL, do_lang('TITLE_NEWTEXT', NULL, NULL, NULL, get_site_default_lang()), do_lang('MAIL_FLAGRANT_TEXT', $message, comcode_escape($manage_url), NULL, get_site_default_lang()));
     // Now, deduct the points from our user's account
     require_code('points2');
     charge_member($member_id, $total, do_lang('PURCHASED_FLAGRANT'));
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_FLAGRANT_DONE'));
 }
Example #4
0
 /**
  * Actualiser to deliver an invoice.
  *
  * @return tempcode	The result.
  */
 function deliver()
 {
     $title = get_page_title('MARK_AS_DELIVERED');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES')), array('_SELF:_SELF:undelivered', do_lang_tempcode('UNDELIVERED_INVOICES'))));
     $GLOBALS['SITE_DB']->query_update('invoices', array('i_state' => 'delivered'), array('id' => get_param_integer('id')), '', 1);
     $url = build_url(array('page' => '_SELF', 'type' => 'undelivered'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #5
0
 /**
  * Actualiser to edit a test section.
  *
  * @return tempcode	The result of execution.
  */
 function __ed()
 {
     check_specific_permission('edit_own_tests');
     $id = get_param_integer('id');
     $rows = $GLOBALS['SITE_DB']->query_select('test_sections', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit('MISSING_RESOURCE');
     }
     $section = $rows[0];
     if (!(has_specific_permission(get_member(), 'edit_own_tests') && ($section['s_assigned_to'] == get_member() || $GLOBALS['FORUM_DRIVER']->is_staff(get_member())))) {
         access_denied('ACCESS_DENIED');
     }
     if (post_param_integer('delete', 0) == 1) {
         $title = get_page_title('DELETE_TEST_SECTION');
         $GLOBALS['SITE_DB']->query_delete('test_sections', array('id' => $id), '', 1);
         $GLOBALS['SITE_DB']->query_delete('tests', array('t_section' => $id));
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     } else {
         $title = get_page_title('EDIT_TEST_SECTION');
         // New tests
         $this->_add_new_tests($id);
         $assigned_to = post_param_integer('assigned_to');
         if ($assigned_to == -1) {
             $assigned_to = NULL;
         }
         $GLOBALS['SITE_DB']->query_update('test_sections', array('s_section' => post_param('section'), 's_notes' => post_param('notes'), 's_inheritable' => post_param_integer('inheritable', 0), 's_assigned_to' => $assigned_to), array('id' => get_param_integer('id')), '', 1);
         // Tests that are edited/deleted (or possibly unchanged, but we count that as edited)
         foreach (array_keys($_POST) as $key) {
             $matches = array();
             if (preg_match('#edit_(\\d+)_test#', $key, $matches) != 0) {
                 $tid = $matches[1];
                 $delete = post_param_integer('edit_' . $tid . '_delete', 0);
                 if ($delete == 1) {
                     $GLOBALS['SITE_DB']->query_delete('tests', array('id' => $tid), '', 1);
                 } else {
                     $assigned_to = post_param_integer('edit_' . $tid . '_assigned_to');
                     if ($assigned_to == -1) {
                         $assigned_to = NULL;
                     }
                     $inherit_section = post_param_integer('edit_' . $tid . '_inherit_section');
                     if ($inherit_section == -1) {
                         $inherit_section = NULL;
                     }
                     $GLOBALS['SITE_DB']->query_update('tests', array('t_test' => post_param('edit_' . $tid . '_test'), 't_assigned_to' => $assigned_to, 't_enabled' => post_param_integer('edit_' . $tid . '_enabled', 0), 't_inherit_section' => $inherit_section), array('id' => $tid), '', 1);
                 }
             }
         }
         // Show it worked / Refresh
         $url = build_url(array('page' => '_SELF', 'type' => 'go'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
 }
Example #6
0
 /**
  * The actualiser to translate code (called externally, and may operate on many lang files).
  *
  * @return tempcode		The UI
  */
 function set_lang_code_2()
 {
     $lang = post_param('lang');
     $lang_files = get_lang_files(fallback_lang());
     foreach (array_keys($lang_files) as $lang_file) {
         $for_base_lang = get_lang_file_map(fallback_lang(), $lang_file, true);
         $for_base_lang_2 = get_lang_file_map($lang, $lang_file, false);
         $descriptions = get_lang_file_descriptions(fallback_lang(), $lang_file);
         $out = '';
         foreach ($for_base_lang_2 + $for_base_lang as $key => $now_val) {
             $val = post_param('l_' . $key, array_key_exists($key, $for_base_lang_2) ? $for_base_lang_2[$key] : $now_val);
             if (str_replace(chr(10), '\\n', $val) != $now_val || !array_key_exists($key, $for_base_lang) || $for_base_lang[$key] != $val || !file_exists(get_file_base() . '/lang/' . fallback_lang() . '/' . $lang_file . '.ini')) {
                 // if it's changed from default ocPortal, or not in default ocPortal, or was already changed in language file, or whole file is not in default ocPortal
                 $out .= $key . '=' . str_replace(chr(10), '\\n', $val) . "\n";
             }
         }
         if ($out != '') {
             $path = get_custom_file_base() . '/lang_custom/' . filter_naughty($lang) . '/' . filter_naughty($lang_file) . '.ini';
             $path_backup = $path . '.' . strval(time());
             if (file_exists($path)) {
                 @copy($path, $path_backup) or intelligent_write_error($path_backup);
                 sync_file($path_backup);
             }
             $myfile = @fopen($path, 'wt');
             if ($myfile === false) {
                 intelligent_write_error($path);
             }
             fwrite($myfile, "[descriptions]\n");
             foreach ($descriptions as $key => $description) {
                 if (fwrite($myfile, $key . '=' . $description . "\n") == 0) {
                     warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                 }
             }
             fwrite($myfile, "\n[strings]\n");
             fwrite($myfile, $out);
             fclose($myfile);
             fix_permissions($path);
             sync_file($path);
             $path_backup2 = $path . '.latest_in_ocp_edit';
             @copy($path, $path_backup2) or intelligent_write_error($path_backup2);
             sync_file($path_backup2);
         }
     }
     $title = get_page_title('TRANSLATE_CODE');
     log_it('TRANSLATE_CODE');
     require_code('view_modes');
     erase_cached_language();
     erase_cached_templates();
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url == '') {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #7
0
 /**
  * The actualiser for uploading a file.
  *
  * @return tempcode	The UI.
  */
 function module_do_upload()
 {
     if (!has_specific_permission(get_member(), 'upload_filedump')) {
         access_denied('I_ERROR');
     }
     $title = get_page_title('FILEDUMP_UPLOAD');
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     // Slowly uploading a file can trigger time limit, on some servers
     $place = filter_naughty(post_param('place'));
     require_code('uploads');
     if (!is_swf_upload(true) && (!array_key_exists('file', $_FILES) || !is_uploaded_file($_FILES['file']['tmp_name']))) {
         $attach_name = 'file';
         $max_size = get_max_file_size();
         if (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 1 || $_FILES[$attach_name]['error'] == 2)) {
             warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format($max_size)));
         } elseif (isset($_FILES[$attach_name]) && ($_FILES[$attach_name]['error'] == 3 || $_FILES[$attach_name]['error'] == 6 || $_FILES[$attach_name]['error'] == 7)) {
             warn_exit(do_lang_tempcode('ERROR_UPLOADING_' . strval($_FILES[$attach_name]['error'])));
         } else {
             warn_exit(do_lang_tempcode('ERROR_UPLOADING'));
         }
     }
     $file = $_FILES['file']['name'];
     if (get_magic_quotes_gpc()) {
         $file = stripslashes($file);
     }
     if (!has_specific_permission(get_member(), 'upload_anything_filedump') || get_file_base() != get_custom_file_base()) {
         check_extension($file);
     }
     $file = str_replace('.', '-', basename($file, '.' . get_file_extension($file))) . '.' . get_file_extension($file);
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place . $file)) {
         $max_size = get_max_file_size();
         if ($_FILES['file']['size'] > $max_size) {
             warn_exit(do_lang_tempcode('FILE_TOO_BIG', integer_format(intval($max_size))));
         }
         $full = get_custom_file_base() . '/uploads/filedump' . $place . $file;
         if (is_swf_upload(true)) {
             @rename($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place)));
         } else {
             @move_uploaded_file($_FILES['file']['tmp_name'], $full) or warn_exit(do_lang_tempcode('FILE_MOVE_ERROR', escape_html($file), escape_html('uploads/filedump' . $place)));
         }
         fix_permissions($full);
         sync_file($full);
         $return_url = build_url(array('page' => '_SELF', 'place' => $place), '_SELF');
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => $file, 'path' => $place));
         if (!is_null($test)) {
             delete_lang($test);
         }
         $GLOBALS['SITE_DB']->query_delete('filedump', array('name' => $file, 'path' => $place), '', 1);
         $description = post_param('description');
         $GLOBALS['SITE_DB']->query_insert('filedump', array('name' => $file, 'path' => $place, 'the_member' => get_member(), 'description' => insert_lang_comcode($description, 3)));
         require_code('notifications');
         $subject = do_lang('FILEDUMP_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $file, $place);
         $mail = do_lang('FILEDUMP_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($file), array(comcode_escape($place), comcode_escape($description)));
         dispatch_notification('filedump', $place, $subject, $mail);
         log_it('FILEDUMP_UPLOAD', $file, $place);
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), get_page_name(), get_zone_name())) {
             syndicate_described_activity('filedump:ACTIVITY_FILEDUMP_UPLOAD', $place . '/' . $file, '', '', '', '', '', 'filedump');
         }
         return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS'));
     } else {
         warn_exit(do_lang_tempcode('OVERWRITE_ERROR'));
     }
     return new ocp_tempcode();
 }
Example #8
0
 /**
  * The actualiser for toggling invisible mode.
  *
  * @return tempcode	The UI.
  */
 function invisible()
 {
     if (get_option('is_on_invisibility') == '1') {
         $visible = array_key_exists(get_session_id(), $GLOBALS['SESSION_CACHE']) && $GLOBALS['SESSION_CACHE'][get_session_id()]['session_invisible'] == 0;
     } else {
         $visible = false;
         // Small fudge: always say thay are not visible now, so this will make them visible -- because they don't have permission to be invisible
     }
     $title = get_page_title($visible ? 'INVISIBLE' : 'BE_VISIBLE');
     $GLOBALS['SITE_DB']->query_update('sessions', array('session_invisible' => $visible ? 1 : 0), array('the_user' => get_member(), 'the_session' => get_session_id()), '', 1);
     global $SESSION_CACHE;
     if ($SESSION_CACHE[get_session_id()]['the_user'] == get_member()) {
         $SESSION_CACHE[get_session_id()]['session_invisible'] = $visible ? 1 : 0;
         if (get_value('session_prudence') !== '1') {
             persistant_cache_set('SESSION_CACHE', $SESSION_CACHE);
         }
     }
     decache('side_users_online');
     // Store in cookie, if we have login cookies around
     if (array_key_exists(get_member_cookie(), $_COOKIE)) {
         require_code('users_active_actions');
         ocp_setcookie(get_member_cookie() . '_invisible', strval($visible ? 1 : 0));
         $_COOKIE[get_member_cookie() . '_invisible'] = strval($visible ? 1 : 0);
     }
     $url = get_param('redirect', NULL);
     if (is_null($url)) {
         $_url = build_url(array('page' => ''), '');
         $url = $_url->evaluate();
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #9
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0' || get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if ($GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_highlighted_name') == 1) {
         warn_exit(do_lang_tempcode('_ALREADY_HAVE'));
     }
     $title = get_page_title('NAME_HIGHLIGHTING');
     post_param_integer('confirm');
     // To make sure we're not being passed by a GET
     // Check points
     $cost = intval(get_option($class));
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     // Actuate
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_highlighted_name' => 1), array('id' => get_member()), '', 1);
     require_code('points2');
     charge_member(get_member(), $cost, do_lang('NAME_HIGHLIGHTING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'NAME_HIGHLIGHTING', 'details' => '', 'details2' => ''));
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
Example #10
0
 /**
  * The actualiser to validate a post.
  *
  * @return tempcode		The UI
  */
 function validate_post()
 {
     $post_id = get_param_integer('id');
     require_code('ocf_posts_action');
     require_code('ocf_posts_action2');
     require_code('ocf_posts_action3');
     $topic_id = ocf_validate_post($post_id);
     $redirect = get_param('redirect', '');
     if ($redirect != '') {
         return redirect_screen(get_page_title('VALIDATE_POST'), $redirect, do_lang_tempcode('SUCCESS'));
     }
     return $this->redirect_to('VALIDATE_POST', $topic_id);
 }
Example #11
0
 /**
  * The actualiser for super debranding.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     require_code('config2');
     if (get_file_base() == get_custom_file_base()) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     set_value('rebrand_name', post_param('rebrand_name'));
     set_value('rebrand_base_url', post_param('rebrand_base_url'));
     set_value('company_name', post_param('company_name'));
     set_option('show_docs', post_param('show_docs', '0'));
     require_code('database_action');
     //set_option('allow_member_integration','off');
     foreach (array(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang(), get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang()) as $dir) {
         if (!file_exists($dir)) {
             require_code('files');
             if (@mkdir($dir, 0777) === false) {
                 warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR', escape_html($dir)));
             }
             fix_permissions($dir, 0777);
             sync_file($dir);
         }
     }
     $keyboard_map_path = get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt';
     $myfile = @fopen($keyboard_map_path, 'wb');
     if ($myfile === false) {
         intelligent_write_error($keyboard_map_path);
     }
     $km = post_param('keyboard_map');
     if (fwrite($myfile, $km) < strlen($km)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions($keyboard_map_path);
     sync_file($keyboard_map_path);
     $adminguide_path = get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt';
     $adminguide = post_param('adminguide');
     $adminguide = str_replace('__company__', post_param('company_name'), $adminguide);
     $myfile = @fopen($adminguide_path, 'wb');
     if ($myfile === false) {
         intelligent_write_error($adminguide_path);
     }
     if (fwrite($myfile, $adminguide) < strlen($adminguide)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions($adminguide_path);
     sync_file($adminguide_path);
     $start_path = get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt';
     if (!file_exists($start_path)) {
         $start = post_param('start_page');
         $myfile = @fopen($start_path, 'wb');
         if ($myfile === false) {
             intelligent_write_error($start_path);
         }
         if (fwrite($myfile, $start) < strlen($start)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         fix_permissions($start_path);
         sync_file($start_path);
     }
     if (get_file_base() == get_custom_file_base()) {
         $critical_errors = file_get_contents(get_file_base() . '/sources/critical_errors.php');
         $critical_errors = str_replace('ocPortal', post_param('rebrand_name'), $critical_errors);
         $critical_errors = str_replace('http://ocportal.com', post_param('rebrand_base_url'), $critical_errors);
         $critical_errors = str_replace('ocProducts', 'ocProducts/' . post_param('company_name'), $critical_errors);
         $critical_errors_path = 'sources_custom/critical_errors.php';
         afm_make_file($critical_errors_path, $critical_errors, false);
     }
     $save_header_path = get_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_custom/HEADER.tpl';
     $header_path = $save_header_path;
     if (!file_exists($header_path)) {
         $header_path = get_file_base() . '/themes/default/templates/HEADER.tpl';
     }
     $header_tpl = file_get_contents($header_path);
     $header_tpl = str_replace('Copyright ocProducts Limited', '', $header_tpl);
     $myfile = @fopen($save_header_path, 'wb');
     if ($myfile === false) {
         intelligent_write_error($save_header_path);
     }
     if (fwrite($myfile, $header_tpl) < strlen($header_tpl)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions($save_header_path);
     sync_file($save_header_path);
     if (post_param_integer('churchy', 0) == 1) {
         if (is_object($GLOBALS['FORUM_DB'])) {
             $GLOBALS['FORUM_DB']->query_delete('f_emoticons', array('e_code' => ':devil:'), '', 1);
         } else {
             $GLOBALS['SITE_DB']->query_delete('f_emoticons', array('e_code' => ':devil:'), '', 1);
         }
     }
     // Make sure some stuff is disabled for non-admin staff
     $staff_groups = $GLOBALS['FORUM_DRIVER']->get_moderator_groups();
     $disallowed_pages = array('admin_setupwizard', 'admin_addons', 'admin_backup', 'admin_errorlog', 'admin_import', 'admin_occle', 'admin_phpinfo', 'admin_debrand');
     foreach (array_keys($staff_groups) as $id) {
         foreach ($disallowed_pages as $page) {
             $GLOBALS['SITE_DB']->query_delete('group_page_access', array('page_name' => $page, 'zone_name' => 'adminzone', 'group_id' => $id), '', 1);
             // in case already exists
             $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => $page, 'zone_name' => 'adminzone', 'group_id' => $id));
         }
     }
     // Clean up the theme images
     //  background-image
     $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
     find_theme_image('background_image');
     //$GLOBALS['SITE_DB']->query_update('theme_images',array('path'=>'themes/default/images/blank.gif'),array('id'=>'background-image','theme'=>$theme),'',1); No longer ocp-specific
     //  logo/*
     if (addon_installed('zone_logos')) {
         find_theme_image('logo/adminzone-logo');
         find_theme_image('logo/cms-logo');
         find_theme_image('logo/collaboration-logo');
         $main_logo_url = find_theme_image('logo/-logo', false, true);
         $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $main_logo_url), array('id' => 'logo/adminzone-logo', 'theme' => $theme), '', 1);
         $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $main_logo_url), array('id' => 'logo/cms-logo', 'theme' => $theme), '', 1);
         $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $main_logo_url), array('id' => 'logo/collaboration-logo', 'theme' => $theme), '', 1);
     }
     // Various other icons
     require_code('uploads');
     $path = get_url('', 'favicon', 'themes/default/images_custom');
     if ($path[0] != '') {
         $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $path[0]), array('id' => 'favicon'));
     }
     $path = get_url('', 'appleicon', 'themes/default/images_custom');
     if ($path[0] != '') {
         $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $path[0]), array('id' => 'appleicon'));
     }
     if (addon_installed('ocf_avatars')) {
         $path = get_url('', 'system_avatar', 'themes/default/images_custom');
         if ($path[0] != '') {
             $GLOBALS['SITE_DB']->query_update('theme_images', array('path' => $path[0]), array('id' => 'ocf_default_avatars/default_set/ocp_fanatic'));
         }
     }
     $title = get_page_title('SUPER_DEBRAND');
     // Redirect them back to editing screen
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #12
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done2()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $title = get_page_title('OCGIFTS_TITLE');
     $gift_id = get_param_integer('gift');
     $member_id = get_member();
     $to_member = post_param('username', '');
     $gift_message = post_param('gift_message', '');
     $member_row = $GLOBALS['FORUM_DB']->query_select('f_members', array('*'), array('m_username' => $to_member), '', 1);
     if (isset($member_row[0]['id']) && $member_row[0]['id'] > 0) {
         $to_member_id = $member_row[0]['id'];
         $anonymous = post_param_integer('anonymous', 0);
         $gift_row = $GLOBALS['SITE_DB']->query_select('ocgifts', array('*'), array('id' => $gift_id));
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             //check available points and charge
             $available_points = available_points($member_id);
             if ($gift_row[0]['price'] > $available_points) {
                 warn_exit(do_lang_tempcode('CANT_AFFORD'));
             }
             require_code('points2');
             //get gift points
             charge_member($member_id, $gift_row[0]['price'], do_lang('GIFT_PURCHASING') . ' - ' . strval($gift_row[0]['price']) . ' point(-s).');
             $gift_row_id = $GLOBALS['SITE_DB']->query_insert('members_gifts', array('to_user_id' => $to_member_id, 'from_user_id' => $member_id, 'gift_id' => $gift_id, 'add_time' => time(), 'is_anonymous' => $anonymous, 'topic_id' => NULL, 'gift_message' => $gift_message), true);
         }
         if (isset($gift_row[0]['id']) && $gift_row[0]['id'] > 0) {
             require_code('notifications');
             if ($anonymous == 0) {
                 $subject = do_lang('GOT_GIFT');
                 $message = '[html]' . do_lang('GIFT_EXPLANATION1', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $gift_row[0]['name']) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id));
             } else {
                 $subject = do_lang('GOT_GIFT', NULL, NULL, NULL, get_lang($to_member_id));
                 $message = '[html]' . do_lang('GIFT_EXPLANATION2', $gift_row[0]['name'], NULL, NULL, get_lang($to_member_id)) . '[/html].' . "\n\n" . '[img]' . get_custom_base_url() . '/' . $gift_row[0]['image'] . '[/img]' . "\n\n" . $gift_message;
                 dispatch_notification('gift', NULL, $subject, $message, array($to_member_id), A_FROM_SYSTEM_UNPRIVILEGED);
             }
         }
     } else {
         warn_exit(do_lang_tempcode('NO_MEMBER_SELECTED'));
     }
     // Show message
     $result = do_lang_tempcode('GIFT_CONGRATULATIONS');
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, $result);
 }
Example #13
0
 /**
  * The actualiser to toggle an IP ban.
  *
  * @return tempcode		The UI
  */
 function toggle_ip_ban()
 {
     $ip = get_param('id');
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip', 'ip', array('ip' => $ip));
     if (is_null($test)) {
         $title = get_page_title('IP_BANNED');
         if ($ip == get_ip_address()) {
             warn_exit(do_lang_tempcode('AVOIDING_BANNING_SELF'));
         }
         if (post_param_integer('confirm', 0) == 0) {
             $preview = do_lang_tempcode('BAN_IP_DESCRIPTION', escape_html($ip));
             $url = get_self_url(false, false);
             return do_template('CONFIRM_SCREEN', array('TITLE' => $title, 'PREVIEW' => $preview, 'FIELDS' => form_input_hidden('confirm', '1'), 'URL' => $url));
         }
         require_code('failure');
         add_ip_ban($ip);
         log_it('IP_BANNED', $ip);
     } else {
         $title = get_page_title('IP_UNBANNED');
         if (post_param_integer('confirm', 0) == 0) {
             $preview = do_lang_tempcode('UNBAN_IP_DESCRIPTION', escape_html($ip));
             $url = get_self_url(false, false);
             return do_template('CONFIRM_SCREEN', array('TITLE' => $title, 'PREVIEW' => $preview, 'FIELDS' => form_input_hidden('confirm', '1'), 'URL' => $url));
         }
         require_code('failure');
         remove_ip_ban($ip);
         log_it('IP_UNBANNED', $ip);
     }
     persistant_cache_delete('IP_BANS');
     // Show it worked / Refresh
     $_url = get_param('redirect', NULL);
     if (!is_null($_url)) {
         $url = make_string_tempcode($_url);
     } else {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #14
0
 /**
  * Actualise ticket creation/reply, then show the ticket again.
  *
  * @return tempcode		The UI
  */
 function do_update_ticket()
 {
     $title = get_page_title('SUPPORT_TICKETS');
     $id = get_param('id');
     $_title = post_param('title');
     $post = post_param('post');
     if ($post == '') {
         warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post'));
     }
     $ticket_type = post_param_integer('ticket_type', -1);
     $this->check_id($id);
     $staff_only = post_param_integer('staff_only', 0) == 1;
     // Update
     $_home_url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id, 'redirect' => NULL), '_SELF', NULL, false, true, true);
     $home_url = $_home_url->evaluate();
     $email = '';
     if ($ticket_type != -1) {
         $type_string = get_translated_text($ticket_type);
         $ticket_type_details = get_ticket_type($ticket_type);
         //$_title=$type_string.' ('.$_title.')';
         if (!has_category_access(get_member(), 'tickets', $type_string)) {
             access_denied('I_ERROR');
         }
         // Check FAQ search results first
         if ($ticket_type_details['search_faq'] && post_param_integer('faq_searched', 0) == 0) {
             $results = $this->do_search($title, $id, $post);
             if (!is_null($results)) {
                 return $results;
             }
         }
         $new_post = new ocp_tempcode();
         $new_post->attach(do_lang('THIS_WITH_COMCODE', do_lang('TICKET_TYPE'), $type_string) . "\n\n");
         $email = trim(post_param('email', ''));
         if ($email != '') {
             $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post);
             if (substr($body, -2) == '> ') {
                 $body = substr($body, 0, strlen($body) - 2);
             }
             $new_post->attach('[email subject="Re: ' . comcode_escape(post_param('title')) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n");
         } elseif (is_guest() && $ticket_type_details['guest_emails_mandatory']) {
             // Error if the e-mail address is required for this ticket type
             warn_exit(do_lang_tempcode('ERROR_GUEST_EMAILS_MANDATORY'));
         }
         $new_post->attach($post);
         $post = $new_post->evaluate();
     }
     if (addon_installed('captcha')) {
         if (get_option('captcha_on_feedback') == '1') {
             require_code('captcha');
             enforce_captcha();
         }
     }
     ticket_add_post(get_member(), $id, $ticket_type, $_title, $post, $home_url, $staff_only);
     // Find true ticket title
     $_forum = 1;
     $_topic_id = 1;
     $_ticket_type = 1;
     // These will be returned by reference
     $posts = get_ticket_posts($id, $_forum, $_topic_id, $_ticket_type);
     if (!is_array($posts)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $__title = $_title;
     foreach ($posts as $ticket_post) {
         $__title = $ticket_post['title'];
         if ($__title != '') {
             break;
         }
     }
     // Send email
     if (!$staff_only) {
         if ($email == '') {
             $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
         }
         send_ticket_email($id, $__title, $post, $home_url, $email, $ticket_type);
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id), '_SELF');
     if (is_guest()) {
         $url = build_url(array('page' => '_SELF'), '_SELF');
     }
     if (get_param('redirect', '') != '') {
         $url = make_string_tempcode(get_param('redirect'));
     }
     return redirect_screen($title, $url, do_lang_tempcode('TICKET_STARTED'));
 }
Example #15
0
/**
 * Render the OCF forumview.
 *
 * @param  ?integer	Forum ID (NULL: personal topics).
 * @param  string		The filter category (blank if no filter)
 * @param  integer	Maximum results to show
 * @param  integer	Offset for result showing
 * @param  AUTO_LINK	Virtual root
 * @param  ?MEMBER	The member to show personal topics of (NULL: not showing personal topics)
 * @return mixed		Either Tempcode (an interface that must be shown) or a Tuple: The main Tempcode, a title to use (also Tempcode), breadcrumbs (also Tempcode), the forum name (string). For a PT view, it is always a tuple, never raw Tempcode (as it can go inside a tabset).
 */
function ocf_render_forumview($id, $current_filter_cat, $max, $start, $root, $of_member_id)
{
    require_css('ocf');
    $type = is_null($id) ? 'pt' : 'misc';
    if ($type == 'pt') {
        if (is_guest()) {
            access_denied('NOT_AS_GUEST');
        }
        require_code('ocf_forumview_pt');
        $details = ocf_get_personal_topics($start, $max, $of_member_id);
        $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => $root));
        $tree = hyperlink(build_url(array('page' => '_SELF', 'id' => $root == db_get_first_id() ? NULL : $root), '_SELF'), escape_html($root_forum_name), false, false, do_lang_tempcode('GO_BACKWARDS_TO', $root_forum_name), NULL, NULL, 'up');
        $tree->attach(' &gt; ');
        $pt_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member_id);
        if (is_null($pt_username)) {
            $pt_username = do_lang('UNKNOWN');
        }
        $tree->attach(do_lang_tempcode('PERSONAL_TOPICS_OF', escape_html($pt_username)));
        $details['name'] = do_lang_tempcode('PERSONAL_TOPICS_OF', escape_html($pt_username));
    } else {
        $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_forumview&filter=' . strval($id);
        $details = ocf_get_forum_view($start, $max, $id);
        $tree = ocf_forum_breadcrumbs($id, $details['name'], $details['parent_forum']);
        if (array_key_exists('question', $details) && is_null(get_bot_type())) {
            // Was there a question answering attempt?
            $answer = post_param('answer', '-1#');
            if ($answer != '-1#') {
                if (strtolower(trim($answer)) == strtolower(trim($details['answer']))) {
                    if (!is_guest()) {
                        $GLOBALS['FORUM_DB']->query_insert('f_forum_intro_member', array('i_forum_id' => $id, 'i_member_id' => get_member()));
                    } else {
                        $GLOBALS['FORUM_DB']->query_insert('f_forum_intro_ip', array('i_forum_id' => $id, 'i_ip' => get_ip_address(3)));
                    }
                } else {
                    $url = get_self_url();
                    $title = get_page_title('INTRO_QUESTION');
                    return redirect_screen($title, $url, do_lang_tempcode('INTRO_ANSWER_INCORRECT'), false, 'warn');
                }
            } else {
                // Ask the question
                $title = get_page_title($details['answer'] == '' ? 'INTRO_NOTICE' : 'INTRO_QUESTION');
                $url = get_self_url();
                return do_template('OCF_FORUM_INTRO_QUESTION_SCREEN', array('ANSWER' => $details['answer'], 'TITLE' => $title, 'URL' => $url, 'QUESTION' => $details['question']));
            }
        }
    }
    if ($type == 'pt') {
        $forum_name = do_lang('PERSONAL_TOPICS');
    } else {
        $forum_name = $details['name'];
    }
    $may_mass_moderate = array_key_exists('may_move_topics', $details) || array_key_exists('may_delete_topics', $details);
    // Find categories
    $categories = new ocp_tempcode();
    if ($type != 'pt') {
        foreach ($details['categories'] as $best => $category) {
            if (array_key_exists('subforums', $category)) {
                // Subforums
                $forums = new ocp_tempcode();
                foreach ($category['subforums'] as $subforum) {
                    if (array_key_exists('last_topic_id', $subforum) && !is_null($subforum['last_topic_id'])) {
                        if (!is_null($subforum['last_member_id'])) {
                            if (!is_guest($subforum['last_member_id'])) {
                                //$colour=get_group_colour(ocf_get_member_primary_group($subforum['last_member_id']));
                                $poster = do_template('OCF_USER_MEMBER', array('_GUID' => '39r932rwefldjfldjlf', 'USERNAME' => $subforum['last_username'], 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($subforum['last_member_id'], false, true)));
                            } else {
                                $poster = protect_from_escaping(escape_html($subforum['last_username']));
                            }
                        } else {
                            $poster = do_lang_tempcode('NA_EM');
                        }
                        $topic_url = build_url(array('page' => 'topicview', 'id' => $subforum['last_topic_id'], 'type' => 'first_unread'), get_module_zone('topicview'));
                        $topic_url->attach('#first_unread');
                        $latest = do_template('OCF_FORUM_LATEST', array('_GUID' => 'dlfsdfkoewfdlfsldfk', 'DATE' => is_null($subforum['last_time']) ? do_lang_tempcode('NA_EM') : protect_from_escaping(escape_html(get_timezoned_date($subforum['last_time']))), 'DATE_RAW' => is_null($subforum['last_time']) ? '' : strval($subforum['last_time']), 'TOPIC_URL' => $topic_url, 'TOPIC_TITLE' => $subforum['last_title'] == '' ? do_lang_tempcode('NA') : $subforum['last_title'], 'POSTER' => $poster, 'MEMBER_ID' => is_null($subforum['last_member_id']) ? '' : strval($subforum['last_member_id']), 'ID' => strval($subforum['last_topic_id'])));
                    } elseif (array_key_exists('protected_last_post', $subforum)) {
                        $latest = do_lang_tempcode('PROTECTED_LAST_POST');
                    } else {
                        $latest = do_lang_tempcode('NO_POSTS_YET');
                    }
                    // Work out where the subforum URL is
                    if ($subforum['redirection'] != '' && !is_numeric($subforum['redirection'])) {
                        $subforum_url = $subforum['redirection'];
                        $subforum_num_posts = do_lang_tempcode('NA_EM');
                        $subforum_num_topics = do_lang_tempcode('NA_EM');
                        $latest = do_lang_tempcode('NA_EM');
                        $subforum['has_new'] = false;
                        $subforums = new ocp_tempcode();
                        $new_post_or_not = 'redirect';
                    } else {
                        if ($subforum['redirection'] != '') {
                            $subforum_url = build_url(array('page' => '_SELF', 'id' => $subforum['redirection']), '_SELF');
                            $new_post_or_not = $subforum['has_new'] ? 'new_posts_redirect' : 'no_new_posts_redirect';
                        } else {
                            $subforum_url = build_url(array('page' => '_SELF', 'id' => $subforum['id']), '_SELF');
                            $new_post_or_not = $subforum['has_new'] ? 'new_posts' : 'no_new_posts';
                        }
                        $subforum_num_posts = protect_from_escaping(escape_html(integer_format($subforum['num_posts'])));
                        $subforum_num_topics = protect_from_escaping(escape_html(integer_format($subforum['num_topics'])));
                        // Subsubforums
                        $subforums = new ocp_tempcode();
                        ksort($subforum['children']);
                        foreach ($subforum['children'] as $child) {
                            // Work out where the subsubforum url is
                            if (is_numeric($child['redirection'])) {
                                $link = hyperlink(build_url(array('page' => '_SELF', 'id' => $child['redirection']), '_SELF'), $child['name'], false, true);
                            } elseif ($child['redirection'] != '') {
                                $link = hyperlink($child['redirection'], $child['name'], false, true);
                            } else {
                                $link = hyperlink(build_url(array('page' => '_SELF', 'id' => $child['id']), '_SELF'), $child['name'], false, true);
                            }
                            if (!$subforums->is_empty()) {
                                $subforums->attach(do_lang_tempcode('LIST_SEP'));
                            }
                            $subforums->attach($link);
                        }
                    }
                    $edit_url = has_actual_page_access(get_member(), 'admin_ocf_forums') ? build_url(array('page' => 'admin_ocf_forums', 'type' => '_ed', 'id' => $subforum['id']), 'adminzone') : new ocp_tempcode();
                    $forum_rules_url = '';
                    $intro_question_url = '';
                    if (!$subforum['intro_question']->is_empty()) {
                        if ($subforum['intro_answer'] == '') {
                            $keep = keep_symbol(array());
                            $intro_rules_url = find_script('rules') . '?id=' . rawurlencode(strval($subforum['id'])) . $keep;
                        } else {
                            $keep = keep_symbol(array());
                            $intro_question_url = find_script('rules') . '?id=' . rawurlencode(strval($subforum['id'])) . $keep;
                        }
                    }
                    $forums->attach(do_template('OCF_FORUM_IN_CATEGORY', array('_GUID' => 'slkfjof9jlsdjcsd', 'ID' => strval($subforum['id']), 'NEW_POST_OR_NOT' => $new_post_or_not, 'LANG_NEW_POST_OR_NOT' => do_lang('POST_INDICATOR_' . $new_post_or_not), 'FORUM_NAME' => $subforum['name'], 'FORUM_URL' => $subforum_url, 'DESCRIPTION' => $subforum['description'], 'NUM_POSTS' => $subforum_num_posts, 'NUM_TOPICS' => $subforum_num_topics, 'LATEST' => $latest, 'SUBFORUMS' => $subforums, 'EDIT_URL' => $edit_url, 'FORUM_RULES_URL' => $forum_rules_url, 'INTRO_QUESTION_URL' => $intro_question_url)));
                }
                // Category itself
                if (!array_key_exists('expanded_by_default', $category) || $category['expanded_by_default'] == 1) {
                    $display = 'table';
                    $expand_type = 'contract';
                } else {
                    $display = 'none';
                    $expand_type = 'expand';
                }
                $category_description = $category['description'];
                $categories->attach(do_template('OCF_FORUM_CATEGORY', array('_GUID' => 'fc9bae42c680ea0162287e2ed3917bbe', 'CATEGORY_ID' => strval($best), 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'CATEGORY_TITLE' => $category['title'], 'CATEGORY_DESCRIPTION' => $category_description, 'FORUMS' => $forums)));
            }
        }
    }
    // Work out what moderator actions can be performed (also includes marking read/unread)
    $moderator_actions = '';
    if ($type == 'pt' && $of_member_id == get_member() && get_value('disable_pt_filtering') !== '1') {
        $moderator_actions .= '<option value="categorise_pts">' . do_lang('CATEGORISE_PTS') . '</option>';
    }
    if (get_value('disable_mark_forum_read') !== '1') {
        $moderator_actions .= '<option value="mark_topics_read">' . do_lang('MARK_READ') . '</option>';
        $moderator_actions .= '<option value="mark_topics_unread">' . do_lang('MARK_UNREAD') . '</option>';
    }
    // Mass moderation
    if ($may_mass_moderate) {
        $moderator_actions .= '<option value="move_topics">' . do_lang('MOVE_TOPICS') . '</option>';
        if (has_specific_permission(get_member(), 'delete_midrange_content', 'topics', array('forums', $id))) {
            $moderator_actions .= '<option value="delete_topics">' . do_lang('DELETE_TOPICS') . '</option>';
        }
        $moderator_actions .= '<option value="pin_topics">' . do_lang('PIN_TOPIC') . '</option>';
        $moderator_actions .= '<option value="unpin_topics">' . do_lang('UNPIN_TOPIC') . '</option>';
        $moderator_actions .= '<option value="sink_topics">' . do_lang('SINK_TOPIC') . '</option>';
        $moderator_actions .= '<option value="unsink_topics">' . do_lang('UNSINK_TOPIC') . '</option>';
        $moderator_actions .= '<option value="cascade_topics">' . do_lang('CASCADE_TOPIC') . '</option>';
        $moderator_actions .= '<option value="uncascade_topics">' . do_lang('UNCASCADE_TOPIC') . '</option>';
        $moderator_actions .= '<option value="open_topics">' . do_lang('OPEN_TOPIC') . '</option>';
        $moderator_actions .= '<option value="close_topics">' . do_lang('CLOSE_TOPIC') . '</option>';
        if (!is_null($id)) {
            $multi_moderations = ocf_list_multi_moderations($id);
            if (count($multi_moderations) != 0) {
                $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">';
                foreach ($multi_moderations as $mm_id => $mm_name) {
                    $moderator_actions .= '<option value="mmt_' . strval($mm_id) . '">' . $mm_name . '</option>';
                }
                $moderator_actions .= '</optgroup>';
            }
        }
    }
    // Find topics
    $topics = new ocp_tempcode();
    $pinned = false;
    $num_unread = 0;
    foreach ($details['topics'] as $topic) {
        if ($pinned && !in_array('pinned', $topic['modifiers'])) {
            $topics->attach(do_template('OCF_PINNED_DIVIDER'));
        }
        $pinned = in_array('pinned', $topic['modifiers']);
        $topics->attach(ocf_render_topic($topic, $moderator_actions != '', $type == 'pt', NULL));
        if (in_array('unread', $topic['modifiers'])) {
            $num_unread++;
        }
    }
    // Buttons
    $button_array = array();
    if (!is_guest() && $type != 'pt') {
        if (get_value('disable_mark_forum_read') !== '1') {
            $read_url = build_url(array('page' => 'topics', 'type' => 'mark_read', 'id' => $id), get_module_zone('topics'));
            $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_READ'), 'url' => $read_url, 'img' => 'mark_read');
        }
    }
    if ($type != 'pt') {
        if (addon_installed('search')) {
            $search_url = build_url(array('page' => 'search', 'type' => 'misc', 'id' => 'ocf_posts', 'search_under' => $id), get_module_zone('search'));
            $button_array[] = array('immediate' => false, 'rel' => 'search', 'title' => do_lang_tempcode('SEARCH'), 'url' => $search_url, 'img' => 'search');
        }
        $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $id), get_module_zone('topics'));
    } else {
        if (addon_installed('search')) {
            $search_url = build_url(array('page' => 'search', 'type' => 'misc', 'id' => 'ocf_own_pt'), get_module_zone('search'));
            $button_array[] = array('immediate' => false, 'rel' => 'search', 'title' => do_lang_tempcode('SEARCH'), 'url' => $search_url, 'img' => 'search');
        }
        $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => get_member()), get_module_zone('topics'));
    }
    if ($type == 'pt') {
        //$archive_url=$GLOBALS['FORUM_DRIVER']->forum_url(db_get_first_id());
        //$button_array[]=array('immediate'=>false,'title'=>do_lang_tempcode('ROOT_FORUM'),'url'=>$archive_url,'img'=>'forum');
    }
    if (array_key_exists('may_post_topic', $details)) {
        if ($type == 'pt') {
            $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_PERSONAL_TOPIC'), 'url' => $new_topic_url, 'img' => 'send_message');
        } else {
            $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic');
        }
    }
    $buttons = ocf_screen_button_wrap($button_array);
    $starter_title = $type == 'pt' ? do_lang_tempcode('WITH_TITLING') : new ocp_tempcode();
    // Wrap it all up
    $action_url = build_url(array('page' => 'topics'), get_module_zone('topics'), NULL, false, true);
    if (!$topics->is_empty()) {
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($moderator_actions);
        }
        require_code('templates_results_browser');
        $results_browser = results_browser(do_lang_tempcode('FORUM_TOPICS'), $type == 'pt' ? $of_member_id : $id, $start, 'start', $max, 'max', $details['max_rows'], NULL, $type == 'pt' && get_page_name() != 'forumview' ? 'view' : $type, true, false, 7, NULL, $type == 'pt' && get_page_name() != 'forumview' ? 'tab__pts' : '');
        $order = array_key_exists('order', $details) ? $details['order'] : 'last_post';
        $topic_wrapper = do_template('OCF_FORUM_TOPIC_WRAPPER', array('_GUID' => 'e452b81001e5c6b7adb4d82e627bf983', 'TYPE' => $type, 'ID' => is_null($id) ? NULL : strval($id), 'MAX' => strval($max), 'ORDER' => $order, 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $details), 'ACTION_URL' => $action_url, 'BUTTONS' => $buttons, 'STARTER_TITLE' => $starter_title, 'TREE' => $tree, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'TOPICS' => $topics, 'FORUM_NAME' => $forum_name));
    } else {
        $topic_wrapper = new ocp_tempcode();
        $moderator_actions = '';
    }
    // Filters
    $filters = new ocp_tempcode();
    if (get_value('disable_pt_filtering') !== '1') {
        if ($type == 'pt') {
            $filter_cats = ocf_get_filter_cats(true);
            $filters_arr = array();
            foreach ($filter_cats as $fi => $filter_cat) {
                if ($filter_cat != '') {
                    $filtered_url = build_url(array('page' => '_SELF', 'category' => $filter_cat), '_SELF', NULL, true, false, false, 'tab__pts');
                    $filter_active = $filter_cat == $current_filter_cat;
                    $filters_arr[] = array('URL' => $filter_active ? new ocp_tempcode() : $filtered_url, 'CAPTION' => $filter_cat, 'HAS_NEXT' => isset($filter_cats[$fi + 1]));
                }
            }
            $filters = do_template('OCF_PT_FILTERS', array('FILTERS' => $filters_arr, 'RESET_URL' => build_url(array('page' => '_SELF', 'category' => NULL), '_SELF', NULL, true)));
        }
    }
    $map = array('_GUID' => '1c14afd9265b1bf69375169dd6faf83c', 'STARTER_TITLE' => $starter_title, 'ID' => is_null($id) ? NULL : strval($id), 'DESCRIPTION' => array_key_exists('description', $details) ? $details['description'] : '', 'FILTERS' => $filters, 'BUTTONS' => $buttons, 'TOPIC_WRAPPER' => $topic_wrapper, 'TREE' => $tree, 'CATEGORIES' => $categories);
    $content = do_template('OCF_FORUM', $map);
    $ltitle = do_lang_tempcode('NAMED_FORUM', escape_html($details['name']));
    return array($content, $ltitle, $tree, $forum_name);
}
Example #16
0
 /**
  * The actualiser to edit a configuration page.
  *
  * @return tempcode		The UI
  */
 function config_set()
 {
     $page = get_param('id', 'MAIN');
     $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false);
     // Make sure we haven't locked ourselves out due to clean URL support
     if (post_param_integer('mod_rewrite', 0) == 1 && substr(ocp_srv('SERVER_SOFTWARE'), 0, 6) == 'Apache' && (!file_exists(get_file_base() . '/.htaccess') || strpos(file_get_contents(get_file_base() . '/.htaccess'), 'RewriteEngine on') === false)) {
         warn_exit(do_lang_tempcode('BEFORE_MOD_REWRITE'));
     }
     // Make sure we haven't just locked staff out
     $new_site_name = substr(post_param('site_name', ''), 0, 200);
     if ($new_site_name != '' && get_option('is_on_sync_staff', true) === '1') {
         $admin_groups = array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), $GLOBALS['FORUM_DRIVER']->get_moderator_groups());
         $staff = $GLOBALS['FORUM_DRIVER']->member_group_query($admin_groups, 100);
         if (count($staff) < 100) {
             foreach ($staff as $row_staff) {
                 $member = $GLOBALS['FORUM_DRIVER']->pname_id($row_staff);
                 if ($GLOBALS['FORUM_DRIVER']->is_staff($member)) {
                     $sites = get_ocp_cpf('sites');
                     $sites = str_replace(', ' . get_site_name(), '', $sites);
                     $sites = str_replace(',' . get_site_name(), '', $sites);
                     $sites = str_replace(get_site_name() . ', ', '', $sites);
                     $sites = str_replace(get_site_name() . ',', '', $sites);
                     $sites = str_replace(get_site_name(), '', $sites);
                     if ($sites != '') {
                         $sites .= ', ';
                     }
                     $sites .= $new_site_name;
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($member, 'sites', $sites);
                 }
             }
         }
     }
     // Empty thumbnail cache if needed
     if (get_option('is_on_gd') == '1' && function_exists('imagetypes')) {
         if (!is_null(post_param('thumb_width', NULL)) && post_param('thumb_width') != get_option('thumb_width')) {
             $thumb_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%thumb_url') . '\'');
             $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
             foreach ($thumb_fields as $field) {
                 if ($field['m_table'] == 'videos') {
                     continue;
                 }
                 $GLOBALS['SITE_DB']->query_update($field['m_table'], array($field['m_name'] => ''));
             }
             $GLOBALS['NO_DB_SCOPE_CHECK'] = false;
         }
     }
     $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page));
     if ($page == 'SITE') {
         $rows[] = array('the_name' => 'timezone', 'shared_hosting_restricted' => 0, 'the_type' => 'special', 'eval' => '');
     }
     foreach ($rows as $myrow) {
         if ($myrow['eval'] != '') {
             if (defined('HIPHOP_PHP')) {
                 require_code('hooks/systems/config_default/' . $myrow['the_name']);
                 $hook = object_factory('Hook_config_default_' . $myrow['the_name']);
                 if (is_null($hook->get_default())) {
                     continue;
                 }
             } else {
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 10;
                 // LEGACY Workaround for corrupt webhost installers
                 if (is_null(@eval($myrow['eval'] . ';'))) {
                     continue;
                 }
                 // @'d in case default is corrupt, don't want it to give errors forever
                 $GLOBALS['REQUIRE_LANG_LOOP'] = 0;
                 // LEGACY
             }
         }
         if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) {
             continue;
         }
         if ($myrow['the_type'] == 'tick') {
             $value = strval(post_param_integer($myrow['the_name'], 0));
         } elseif ($myrow['the_type'] == 'date') {
             $date_value = get_input_date($myrow['the_name']);
             $value = is_null($date_value) ? '' : strval($date_value);
         } elseif (($myrow['the_type'] == 'forum' || $myrow['the_type'] == '?forum') && get_forum_type() == 'ocf') {
             $value = post_param($myrow['the_name']);
             if (is_numeric($value)) {
                 $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => post_param_integer($myrow['the_name'])));
             }
             if (is_null($value)) {
                 $value = '';
             }
         } elseif ($myrow['the_type'] == 'category' && get_forum_type() == 'ocf') {
             $value = post_param($myrow['the_name']);
             if (is_numeric($value)) {
                 $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'c_title', array('id' => post_param_integer($myrow['the_name'])));
             }
             if (is_null($value)) {
                 $value = '';
             }
         } elseif ($myrow['the_type'] == 'usergroup' && get_forum_type() == 'ocf') {
             $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'text_original', array('g.id' => post_param_integer($myrow['the_name'])));
             if (is_null($value)) {
                 $value = '';
             }
         } else {
             $value = post_param($myrow['the_name'], '');
         }
         if ($myrow['the_type'] == 'special') {
             if ($myrow['the_name'] == 'timezone') {
                 set_value('timezone', $value);
             }
         } else {
             if (($myrow['the_type'] == 'transline' || $myrow['the_type'] == 'transtext') && is_numeric($myrow['config_value'])) {
                 $old_value = get_translated_text(intval($myrow['config_value']));
             } else {
                 $old_value = $myrow['config_value'];
             }
             // If the option was changed
             if ($old_value != $value || $myrow['c_set'] == 0) {
                 set_option($myrow['the_name'], $value, $myrow['the_type'], $myrow['config_value']);
             }
         }
     }
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones2');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     // Show it worked / Refresh
     $redirect = get_param('redirect', NULL);
     if ($redirect === NULL) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         // ,'type'=>'category','id'=>$page
     } else {
         $url = make_string_tempcode($redirect);
     }
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #17
0
 /**
  * The actualiser for deleting all the ticked messages in a room.
  *
  * @return tempcode	The UI.
  */
 function _chat_delete_many_messages()
 {
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     $title = get_page_title('DELETE_SOME_MESSAGES');
     $room_id = get_param_integer('room_id');
     check_chatroom_access($room_id);
     $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1);
     if (!array_key_exists(0, $room_details)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $room_details[0];
     $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms');
     if (!$has_mod_access) {
         access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content');
     }
     // Actualiser
     $count = 0;
     foreach (array_keys($_REQUEST) as $key) {
         if (substr($key, 0, 4) == 'del_') {
             delete_chat_messages(array('room_id' => $room_id, 'id' => intval(substr($key, 4))));
             $count++;
         }
     }
     if ($count == 0) {
         warn_exit(do_lang_tempcode('NOTHING_SELECTED'));
     }
     decache('side_shoutbox');
     $num_remaining = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id));
     if ($num_remaining == 0) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     } else {
         $url = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => $room_id, 'start' => get_param_integer('start'), 'max' => get_param_integer('max')), '_SELF');
     }
     // Redirect
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #18
0
 /**
  * The actualiser for a gift point transaction.
  *
  * @return tempcode		The UI
  */
 function do_give()
 {
     $member_id_of = get_param_integer('id');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USER_POINT_FIND')), array('_SELF:_SELF:member:id=' . strval($member_id_of), do_lang_tempcode('_POINTS', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id_of))))));
     $title = get_page_title('POINTS');
     $trans_type = post_param('trans_type', 'gift');
     $amount = post_param_integer('amount');
     $reason = post_param('reason');
     $worked = false;
     $member_id_viewing = get_member();
     if ($member_id_of == $member_id_viewing && !has_specific_permission($member_id_viewing, 'give_points_self')) {
         $message = do_lang_tempcode('PE_SELF');
     } elseif (is_guest($member_id_viewing)) {
         $message = do_lang_tempcode('MUST_LOGIN');
     } else {
         if ($trans_type == 'gift') {
             $anonymous = post_param_integer('anonymous', 0);
             $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing);
             //$viewer_gift_points_used=get_gift_points_used($member_id_viewing);
             if ($viewer_gift_points_available < $amount && !has_specific_permission($member_id_viewing, 'have_negative_gift_points')) {
                 $message = do_lang_tempcode('PE_LACKING_GIFT_POINTS');
             } elseif ($amount < 0 && !has_specific_permission($member_id_viewing, 'give_negative_points')) {
                 $message = do_lang_tempcode('PE_NEGATIVE_GIFT');
             } elseif ($reason == '') {
                 $message = do_lang_tempcode('IMPROPERLY_FILLED_IN');
             } else {
                 // Write transfer
                 require_code('points2');
                 give_points($amount, $member_id_of, $member_id_viewing, $reason, $anonymous == 1);
                 // Randomised gifts
                 if (mt_rand(0, 4) == 1) {
                     $message = do_lang_tempcode('PR_LUCKY');
                     $_current_gift = point_info($member_id_viewing);
                     $current_gift = array_key_exists('points_gained_given', $_current_gift) ? $_current_gift['points_gained_given'] : 0;
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($member_id_viewing, 'points_gained_given', $current_gift + 25);
                     // TODO: 25 should be a config option
                 } else {
                     $message = do_lang_tempcode('PR_NORMAL');
                 }
                 $worked = true;
             }
         }
         if ($trans_type == 'refund') {
             $trans_type = 'charge';
             $amount = -$amount;
         }
         if ($trans_type == 'charge') {
             if (has_actual_page_access($member_id_viewing, 'adminzone')) {
                 require_code('points2');
                 charge_member($member_id_of, $amount, $reason);
                 $left = available_points($member_id_of);
                 $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
                 if (is_null($username)) {
                     $username = do_lang('UNKNOWN');
                 }
                 $message = do_lang_tempcode('USER_HAS_BEEN_CHARGED', escape_html($username), escape_html(integer_format($amount)), escape_html(integer_format($left)));
                 $worked = true;
             } else {
                 access_denied('I_ERROR');
             }
         }
     }
     if ($worked) {
         // Show it worked / Refresh
         $url = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $member_id_of), '_SELF');
         return redirect_screen($title, $url, $message);
     } else {
         return warn_screen($title, $message);
     }
 }
Example #19
0
 /**
  * The actualiser for managing banned IPs.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     require_code('failure');
     $old_bans = collapse_1d_complexity('ip', $GLOBALS['SITE_DB']->query_select('usersubmitban_ip'));
     $bans = post_param('bans');
     $_bans = explode(chr(10), $bans);
     foreach ($old_bans as $ban) {
         if (preg_match('#^' . preg_quote($ban, '#') . '(\\s|$)#m', $bans) == 0) {
             remove_ip_ban($ban);
         }
     }
     $matches = array();
     foreach ($_bans as $ban) {
         if (trim($ban) == '') {
             continue;
         }
         preg_match('#^([^\\s]+)(.*)$#', $ban, $matches);
         $ip = $matches[1];
         if (preg_match('#^[a-f0-9\\.\\*:]+$#U', $ip) == 0) {
             attach_message(do_lang_tempcode('IP_ADDRESS_NOT_VALID', $ban), 'warn');
         } else {
             if ($ip == get_ip_address()) {
                 attach_message(do_lang_tempcode('WONT_BAN_SELF', $ban), 'warn');
             } elseif ($ip == ocp_srv('SERVER_ADDR')) {
                 attach_message(do_lang_tempcode('WONT_BAN_SERVER', $ban), 'warn');
             }
             if (!in_array($ip, $old_bans)) {
                 ban_ip($ip, trim($matches[2]));
                 $old_bans[] = $ip;
             }
         }
     }
     // Show it worked / Refresh
     $title = get_page_title('IP_BANS');
     $refresh_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $refresh_url, do_lang_tempcode('SUCCESS'));
 }
Example #20
0
 /**
  * Save the user's options into a cookie.
  *
  * @return tempcode		The UI
  */
 function chat_options()
 {
     $title = get_page_title('ROOM');
     $value = post_param('text_colour', get_option('chat_default_post_colour')) . ';' . post_param('font_name', get_option('chat_default_post_font')) . ';';
     require_code('users_active_actions');
     ocp_setcookie('ocp_chat_prefs', $value);
     $url = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => get_param('id'), 'no_reenter_message' => 1), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #21
0
 /**
  * The actualiser to send a newsletter.
  *
  * @return tempcode		The UI
  */
 function send_message()
 {
     $title = get_page_title('NEWSLETTER_SEND');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     if (get_param('old_type', '') == 'whatsnew') {
         set_value('newsletter_whatsnew', strval(time()));
     }
     $message = post_param('message');
     $subject = post_param('subject');
     $csv_data = post_param('csv_data', '');
     // serialized PHP array
     $template = post_param('template', 'MAIL');
     $in_full = post_param_integer('in_full', 0);
     $html_only = post_param_integer('html_only', 0);
     $from_email = post_param('from_email', '');
     $from_name = post_param('from_name', '');
     $priority = post_param_integer('priority', 3);
     $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id'));
     $send_details = array();
     foreach ($newsletters as $newsletter) {
         $send_details[strval($newsletter['id'])] = post_param_integer(strval($newsletter['id']), 0);
     }
     if (get_forum_type() == 'ocf') {
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         foreach (array_keys($groups) as $id) {
             $send_details['g' . strval($id)] = post_param_integer('g' . strval($id), 0);
         }
         $send_details['-1'] = post_param_integer('-1', 0);
     }
     if (post_param_integer('make_periodic', 0) == 1) {
         // We're a periodic newsletter, so we don't actually want to be sent
         // out now. Rather, we store the newsletter settings so that it can be
         // regenerated as needed.
         // Next we store all of our settings in the newsletter_periodic table
         $when = post_param('periodic_when');
         $day = 1;
         if ($when == 'monthly') {
             $day = post_param_integer('periodic_monthly') % 29;
         } elseif ($when == 'biweekly') {
             $day = post_param_integer('periodic_weekday_biweekly', 5);
         } elseif ($when == 'weekly') {
             $day = post_param_integer('periodic_weekday_weekly', 5);
         }
         $map = array('np_message' => post_param('chosen_categories', ''), 'np_subject' => $subject, 'np_lang' => $lang, 'np_send_details' => serialize($send_details), 'np_html_only' => $html_only, 'np_from_email' => $from_email, 'np_from_name' => $from_name, 'np_priority' => $priority, 'np_csv_data' => $csv_data, 'np_frequency' => $when, 'np_day' => $day, 'np_in_full' => $in_full, 'np_template' => $template);
         require_lang('dates');
         $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY'));
         if ($when == 'weekly') {
             $each = $week_days[$day];
         } elseif ($when == 'biweekly') {
             $each = $week_days[$day];
         } else {
             $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $day, 1990));
             $each = strval($day) . $suffix;
         }
         $matches = array();
         if (preg_match('#^replace_existing\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) {
             if (post_param('periodic_for') != 'future') {
                 $map['np_last_sent'] = 0;
             }
             $GLOBALS['SITE_DB']->query_update('newsletter_periodic', $map, array('id' => intval($matches[1])), '', 1);
             $message = do_lang('PERIODIC_SUCCESS_MESSAGE_EDIT', $when, $each);
         } else {
             $last_sent = post_param('periodic_for') == 'future' ? time() : 0;
             $map['np_last_sent'] = $last_sent;
             $GLOBALS['SITE_DB']->query_insert('newsletter_periodic', $map, true);
             $message = do_lang('PERIODIC_SUCCESS_MESSAGE_ADD', $when, $each);
         }
         $url = build_url(array('page' => 'admin_newsletter', 'type' => 'misc', 'redirected' => '1'), get_module_zone('admin_newsletter'));
         return redirect_screen(do_lang('SUCCESS'), $url, $message, false, 'inform');
     }
     if (addon_installed('calendar')) {
         $schedule = get_input_date('schedule');
         if (!is_null($schedule)) {
             require_code('calendar');
             require_code('calendar2');
             $send_details_string_exp = '';
             foreach ($send_details as $key => $val) {
                 $send_details_string_exp .= '"' . str_replace(chr(10), '\\n', addslashes($key)) . '"=>"' . str_replace(chr(10), '\\n', addslashes($val)) . '",';
             }
             $schedule_code = ':require_code(\'newsletter\'); actual_send_newsletter("' . php_addslashes($message) . '","' . php_addslashes($subject) . '","' . php_addslashes($lang) . '",array(' . $send_details_string_exp . '),' . strval($html_only) . ',"' . php_addslashes($from_email) . '","' . php_addslashes($from_name) . '",' . strval($priority) . ',"' . php_addslashes($template) . '");';
             $start_year = post_param_integer('schedule_year');
             $start_month = post_param_integer('schedule_month');
             $start_day = post_param_integer('schedule_day');
             $start_hour = post_param_integer('schedule_hour');
             $start_minute = post_param_integer('schedule_minute');
             $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('NEWSLETTER_SEND', $subject), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute);
             regenerate_event_reminder_jobs($event_id);
             return inform_screen($title, do_lang_tempcode('NEWSLETTER_DEFERRED', get_timezoned_date($schedule)));
         }
     }
     actual_send_newsletter($message, $subject, $lang, $send_details, $html_only, $from_email, $from_name, $priority, $csv_data, $template);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:new', do_lang_tempcode('NEWSLETTER_SEND'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('SENDING_NEWSLETTER'));
 }
Example #22
0
 /**
  * Actualiser to delete some unwanted alerts.
  *
  * @return tempcode		The success/redirect screen
  */
 function clean_alerts()
 {
     $title = get_page_title('SECURITY_LOGGING');
     // Actualiser
     $count = 0;
     foreach (array_keys($_REQUEST) as $key) {
         if (substr($key, 0, 4) == 'del_') {
             $GLOBALS['SITE_DB']->query_delete('hackattack', array('id' => intval(substr($key, 4))), '', 1);
             $count++;
         }
     }
     if ($count == 0) {
         warn_exit(do_lang_tempcode('NOTHING_SELECTED'));
     }
     // Redirect
     $url = build_url(array('page' => '_SELF', 'type' => 'misc', 'start' => get_param_integer('start'), 'max' => get_param_integer('max')), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #23
0
 /**
  * Standard modular UI/actualiser to edit an entry.
  *
  * @return tempcode	The UI
  */
 function __ed()
 {
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     if ($this->second_stage_preview && get_param_integer('preview', 0) == 1) {
         return $this->preview_intercept($title);
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
         if (!is_null($date_and_time) && addon_installed('points')) {
             $reverse = post_param_integer('reverse_point_transaction', 0);
             if ($reverse == 1) {
                 $points_test = $GLOBALS['SITE_DB']->query_select('gifts', array('*'), array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
                 if (array_key_exists(0, $points_test)) {
                     $amount = $points_test[0]['amount'];
                     $sender_id = $points_test[0]['gift_from'];
                     $recipient_id = $points_test[0]['gift_to'];
                     $GLOBALS['SITE_DB']->query_delete('gifts', array('id' => $points_test[0]['id']), '', 1);
                     if (!is_guest($sender_id)) {
                         $_sender_gift_points_used = point_info($sender_id);
                         $sender_gift_points_used = array_key_exists('gift_points_used', $_sender_gift_points_used) ? $_sender_gift_points_used['gift_points_used'] : 0;
                         $GLOBALS['FORUM_DRIVER']->set_custom_field($sender_id, 'gift_points_used', strval($sender_gift_points_used - $amount));
                     }
                     require_code('points');
                     $temp_points = point_info($recipient_id);
                     $GLOBALS['FORUM_DRIVER']->set_custom_field($recipient_id, 'points_gained_given', strval((array_key_exists('points_gained_given', $temp_points) ? $temp_points['points_gained_given'] : 0) - $amount));
                 }
             }
         }
     } else {
         $submitter = NULL;
     }
     breadcrumb_set_parents(array_merge($GLOBALS['BREADCRUMB_SET_PARENTS'], array(array('_SELF:_SELF:_e' . $this->type_code . ':' . $id, strpos($doing, ' ') !== false ? protect_from_escaping($doing) : do_lang_tempcode($doing)))));
     $delete = post_param_integer('delete', 0);
     if ($delete == 1 || $delete == 2) {
         if (!is_null($this->permissions_require)) {
             check_delete_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
         }
         $doing = 'DELETE_' . $this->lang_type;
         if ($this->catalogue && get_param('catalogue_name', '') != '') {
             $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
             if ($this->type_code == 'd') {
                 $doing = do_lang('CATALOGUE_GENERIC_DELETE', escape_html($catalogue_title));
             } elseif ($this->type_code == 'c') {
                 $doing = do_lang('CATALOGUE_GENERIC_DELETE_CATEGORY', escape_html($catalogue_title));
             }
         }
         $title = get_page_title($doing);
         $test = $this->handle_confirmations($title);
         if (!is_null($test)) {
             return $test;
         }
         $this->delete_actualisation($id);
         // Delete custom fields
         if ($this->has_tied_catalogue()) {
             require_code('fields');
             delete_form_custom_fields($this->award_type, $id);
         }
         /*if ((!is_null($this->redirect_type)) || ((!is_null(get_param('redirect',NULL)))))		No - resource is gone now, and redirect would almost certainly try to take us back there
         		{
         			$url=(($this->redirect_type=='!') || (is_null($this->redirect_type)))?get_param('redirect'):build_url(array('page'=>'_SELF','type'=>$this->redirect_type),'_SELF');
         			return redirect_screen($title,$url,do_lang_tempcode('SUCCESS'));
         		}*/
         clear_ocp_autosave();
         $description = is_null($this->do_next_description) ? do_lang_tempcode('SUCCESS') : $this->do_next_description;
         return $this->do_next_manager($title, $description, NULL);
     } else {
         if (!is_null($this->permissions_require)) {
             check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
         }
         $test = $this->handle_confirmations($title);
         if (!is_null($test)) {
             return $test;
         }
         if ($this->user_facing && !is_null($this->permissions_require) && array_key_exists('validated', $_POST)) {
             if (!has_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? '' : post_param($this->permissions_cat_name), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? '' : post_param($this->permissions_cat_name_b)))) {
                 $_POST['validated'] = '0';
             }
         }
         if (!is_null($this->upload)) {
             require_code('uploads');
         }
         $description = $this->edit_actualisation($id);
         if (!is_null($this->new_id)) {
             $id = $this->new_id;
         }
         // Save custom fields
         if ($this->has_tied_catalogue()) {
             require_code('fields');
             save_form_custom_fields($this->award_type, $id);
         }
         if ($this->output_of_action_is_confirmation && !is_null($description)) {
             return $description;
         }
         if (is_null($description)) {
             $description = do_lang_tempcode('SUCCESS');
         }
         if (addon_installed('awards')) {
             if (!is_null($this->award_type)) {
                 require_code('awards');
                 handle_award_setting($this->award_type, $id);
             }
         }
         if ($this->user_facing) {
             if ($this->check_validation && post_param_integer('validated', 0) == 0) {
                 require_code('submit');
                 if ($this->send_validation_request) {
                     $edit_url = build_url(array('page' => '_SELF', 'type' => '_e' . $this->type_code, 'id' => $id, 'validated' => 1), '_SELF', NULL, false, false, true);
                     if (addon_installed('unvalidated')) {
                         send_validation_request($doing, $this->table, $this->non_integer_id, $id, $edit_url);
                     }
                 }
                 $description->attach(paragraph(do_lang_tempcode('SUBMIT_UNVALIDATED')));
             }
         }
     }
     if (!is_null($this->redirect_type) || !is_null(get_param('redirect', NULL))) {
         $url = $this->redirect_type == '!' || is_null($this->redirect_type) ? make_string_tempcode(get_param('redirect')) : build_url(array('page' => '_SELF', 'type' => $this->redirect_type), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     clear_ocp_autosave();
     decache('main_awards');
     return $this->do_next_manager($title, $description, $id);
 }
Example #24
0
 /**
  * The actualiser to edit a zone.
  *
  * @return tempcode		The UI
  */
 function __edit_zone()
 {
     $zone = post_param('zone');
     $delete = post_param_integer('delete', 0);
     if ($delete == 1) {
         $title = get_page_title('DELETE_ZONE');
         actual_delete_zone($zone);
         // Show it worked / Refresh
         $_url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF');
         return redirect_screen($title, $_url, do_lang_tempcode('SUCCESS'));
     } else {
         $_title = post_param('title');
         $default_page = post_param('default_page');
         $header_text = post_param('header_text');
         $theme = post_param('theme');
         $wide = post_param_integer('wide');
         if ($wide == -1) {
             $wide = NULL;
         }
         $require_session = post_param_integer('require_session', 0);
         $displayed_in_menu = post_param_integer('displayed_in_menu', 0);
         $new_zone = post_param('new_zone');
         actual_edit_zone($zone, $_title, $default_page, $header_text, $theme, $wide, $require_session, $displayed_in_menu, $new_zone);
         if ($new_zone != '') {
             $this->set_permissions($new_zone);
         }
         $title = get_page_title('EDIT_ZONE');
         // Get title late, as we might be changing the theme this title is got from
         // Handle logos
         if (addon_installed('zone_logos')) {
             require_code('themes2');
             require_code('uploads');
             $themes = find_all_themes();
             foreach (array_keys($themes) as $theme) {
                 $iurl = '';
                 if (is_swf_upload() || array_key_exists('logo_upload_' . $theme, $_FILES) && is_uploaded_file($_FILES['logo_upload_' . $theme]['tmp_name'])) {
                     $urls = get_url('', 'logo_upload_' . $theme, 'themes/' . $theme . '/images_custom', 0, OCP_UPLOAD_IMAGE);
                     $iurl = $urls[0];
                 }
                 if ($iurl == '') {
                     $theme_img_code = post_param('logo_select_' . $theme, '');
                     if ($theme_img_code == '') {
                         continue;
                         // Probably a theme was added half-way
                         //warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
                     }
                     $iurl = find_theme_image($theme_img_code, false, true, $theme);
                 }
                 $GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => 'logo/' . $new_zone . '-logo', 'theme' => $theme, 'lang' => get_site_default_lang()), '', 1);
                 $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => 'logo/' . $new_zone . '-logo', 'theme' => $theme, 'path' => $iurl, 'lang' => get_site_default_lang()));
                 persistant_cache_delete('THEME_IMAGES');
             }
         }
         // Show it worked / Refresh
         $url = get_param('redirect', NULL);
         if (is_null($url)) {
             $_url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF');
             $url = $_url->evaluate();
         }
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
 }
Example #25
0
 /**
  * The actualiser for managing redirects.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     $title = get_page_title('REDIRECTS');
     $found = array();
     foreach ($_POST as $key => $val) {
         if (!is_string($val)) {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $val = stripslashes($val);
         }
         if (substr($key, 0, 10) == 'from_page_' && $val != '') {
             $their_i = array_search($val, $found);
             $i = substr($key, 10);
             if ($their_i !== false && post_param('from_zone_' . $i) == post_param('from_zone_' . strval($their_i))) {
                 warn_exit(do_lang_tempcode('DUPLICATE_PAGE_REDIRECT', post_param('from_zone_' . $i) . ':' . $val));
             }
             $found[$i] = $val;
         }
     }
     $GLOBALS['SITE_DB']->query_delete('redirects');
     persistant_cache_empty();
     foreach ($found as $i => $val) {
         if (!is_string($i)) {
             $i = strval($i);
         }
         if ($val != '') {
             $GLOBALS['SITE_DB']->query_insert('redirects', array('r_from_page' => post_param('from_page_' . $i), 'r_from_zone' => post_param('from_zone_' . $i), 'r_to_page' => post_param('to_page_' . $i), 'r_to_zone' => post_param('to_zone_' . $i), 'r_is_transparent' => post_param_integer('is_transparent_' . $i, 0)), false, true);
             // Avoid problem when same key entered twice
         }
     }
     require_code('view_modes');
     erase_tempcode_cache();
     // Personal notes
     if (!is_null(post_param('notes', NULL))) {
         $notes = post_param('notes');
         set_long_value('notes', $notes);
     }
     // Redirect them back to editing screen
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #26
0
/**
 * Entry script to process a form that needs to be emailed.
 */
function form_to_email_entry_script()
{
    require_lang('mail');
    form_to_email();
    global $PAGE_NAME_CACHE;
    $PAGE_NAME_CACHE = '_form_to_email';
    $title = get_page_title('MAIL_SENT');
    $text = do_lang_tempcode('MAIL_SENT_TEXT', escape_html(post_param('to_written_name', get_site_name())));
    $redirect = get_param('redirect', NULL);
    if (!is_null($redirect)) {
        require_code('site2');
        $GLOBALS['NON_PAGE_SCRIPT'] = 0;
        $tpl = redirect_screen($title, $redirect, $text);
    } else {
        $tpl = do_template('INFORM_SCREEN', array('_GUID' => 'e577a4df79eefd9064c14240cc99e947', 'TITLE' => $title, 'TEXT' => $text));
    }
    $echo = globalise($tpl, NULL, '', true);
    $echo->evaluate_echo();
}
Example #27
0
 /**
  * Function to hold an order
  *
  * @return tempcode	The interface.
  */
 function hold_order()
 {
     $title = get_page_title('ORDER_STATUS_onhold');
     $id = get_param_integer('id');
     $GLOBALS['SITE_DB']->query_update('shopping_order', array('order_status' => 'ORDER_STATUS_onhold'), array('id' => $id), '', 1);
     $GLOBALS['SITE_DB']->query_update('shopping_order_details', array('dispatch_status' => 'ORDER_STATUS_onhold'), array('order_id' => $id), '', 1);
     $add_note_url = build_url(array('page' => '_SELF', 'type' => 'order_act', 'action' => 'add_note', 'last_act' => 'onhold', 'id' => $id), get_module_zone('admin_orders'));
     return redirect_screen($title, $add_note_url, do_lang_tempcode('SUCCESS'));
 }
Example #28
0
 /**
  * The actualiser to contact a member.
  *
  * @return tempcode		The UI
  */
 function actual()
 {
     if (addon_installed('captcha')) {
         require_code('captcha');
         enforce_captcha();
     }
     $member_id = get_param_integer('id');
     $email_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_email_address');
     if (is_null($email_address)) {
         fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     $to_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('EMAIL_MEMBER', escape_html($to_name)))));
     if (is_null($to_name)) {
         warn_exit(do_lang_tempcode('USER_NO_EXIST'));
     }
     $from_email = trim(post_param('email_address'));
     require_code('type_validation');
     if (!is_valid_email_address($from_email)) {
         warn_exit(do_lang_tempcode('INVALID_EMAIL_ADDRESS'));
     }
     $from_name = post_param('name');
     $title = get_page_title('EMAIL_MEMBER', true, array(escape_html($GLOBALS['FORUM_DRIVER']->get_username($member_id))));
     require_code('mail');
     $attachments = array();
     $size_so_far = 0;
     require_code('uploads');
     is_swf_upload(true);
     foreach ($_FILES as $file) {
         if (is_swf_upload() || is_uploaded_file($file['tmp_name'])) {
             $attachments[$file['tmp_name']] = $file['name'];
             $size_so_far += $file['size'];
         } else {
             if (defined('UPLOAD_ERR_NO_FILE') && array_key_exists('error', $file) && $file['error'] != UPLOAD_ERR_NO_FILE) {
                 warn_exit(do_lang_tempcode('ERROR_UPLOADING_ATTACHMENTS'));
             }
         }
     }
     $size = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_max_email_attach_size_mb');
     if ($size_so_far > $size * 1024 * 1024) {
         warn_exit(do_lang_tempcode('EXCEEDED_ATTACHMENT_SIZE', integer_format($size)));
     }
     mail_wrap(do_lang('EMAIL_MEMBER_SUBJECT', get_site_name(), post_param('subject'), NULL, get_lang($member_id)), post_param('message'), array($email_address), $to_name, $from_email, $from_name, 3, $attachments, false, get_member());
     log_it('EMAIL', strval($member_id), $to_name);
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     $url = get_param('redirect');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #29
0
 /**
  * The actualiser to resign from a usergroup.
  *
  * @return tempcode		The UI
  */
 function resign()
 {
     $title = get_page_title('RESIGN_FROM_GROUP');
     $id = post_param_integer('id', NULL);
     if (is_null($id)) {
         $id = get_param_integer('id');
         $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
         $hidden = form_input_hidden('id', strval($id));
         return do_template('YESNO_SCREEN', array('_GUID' => 'd9524899fbc243247a9d253cf93c8aa2', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden));
     }
     ocf_member_leave_group($id, get_member());
     $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
Example #30
0
 /**
  * The actualiser for setting up account confirmation.
  *
  * @return tempcode		The UI
  */
 function step4()
 {
     $title = get_page_title('_JOIN');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('_JOIN'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Check confirm code correct
     $_code = get_param('code', '-1');
     // -1 allowed because people often seem to mess the e-mail link up
     $code = intval($_code);
     if ($code <= 0) {
         require_code('form_templates');
         $fields = new ocp_tempcode();
         $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), '', 'email', '', true));
         $fields->attach(form_input_integer(do_lang_tempcode('CODE'), '', 'code', NULL, true));
         $submit_name = do_lang_tempcode('PROCEED');
         return do_template('FORM_SCREEN', array('_GUID' => 'e2c8c3762a308ac7489ec3fb32cc0cf8', 'TITLE' => $title, 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => get_self_url(false, false, NULL, false, true), 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name));
     }
     $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => strval($code), 'm_email_address' => trim(get_param('email'))));
     if (!array_key_exists(0, $rows)) {
         $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_validated'), array('m_validated_email_confirm_code' => '', 'm_email_address' => trim(get_param('email'))));
         if (!array_key_exists(0, $rows)) {
             warn_exit(do_lang_tempcode('INCORRECT_CONFIRM_CODE'));
         } else {
             $redirect = get_param('redirect', '');
             $map = array('page' => 'login', 'type' => 'misc');
             if ($redirect != '') {
                 $map['redirect'] = $redirect;
             }
             $url = build_url($map, get_module_zone('login'));
             return redirect_screen($title, $url, do_lang_tempcode('ALREADY_CONFIRMED_THIS'));
         }
     }
     $id = $rows[0]['id'];
     $validated = $rows[0]['m_validated'];
     // Activate user
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => ''), array('id' => $id), '', 1);
     if ($validated == 0) {
         return inform_screen($title, do_lang_tempcode('AWAITING_MEMBER_VALIDATION'));
     }
     // Alert user to situation
     $redirect = get_param('redirect', '');
     $map = array('page' => 'login', 'type' => 'misc');
     if ($redirect != '') {
         $map['redirect'] = $redirect;
     }
     $url = build_url($map, get_module_zone('login'));
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESSFUL_CONFIRM'));
 }