Example #1
0
/**
 * Script to make a bookmark add-form popup.
 */
function bookmarks_script()
{
    require_lang('bookmarks');
    $type = get_param('type');
    switch ($type) {
        case '_ad':
            $title = get_page_title('ADD_BOOKMARK');
            $folder = post_param('folder_new', '');
            if ($folder == '') {
                $folder = post_param('folder');
            }
            if ($folder == '!') {
                $folder = '';
            }
            add_bookmark(get_member(), $folder, post_param('title'), post_param('page_link'));
            $content = inform_screen($title, do_lang_tempcode('SUCCESS'));
            $content->attach('<script type="text/javascript">// <![CDATA[
				if (window.opener) window.close();
			//]]></script>');
            break;
        default:
            $url = find_script('bookmarks') . '?no_redirect=1&type=_ad';
            $keep = symbol_tempcode('KEEP');
            $url .= $keep->evaluate();
            $content = add_bookmark_form($url);
            break;
    }
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('ADD_BOOKMARK'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Example #2
0
 /**
  * The actualiser for a manually triggered transaction.
  *
  * @return tempcode	The result of execution.
  */
 function _trigger()
 {
     $title = get_page_title('MANUAL_TRANSACTION');
     $item_name = post_param('item_name');
     breadcrumb_set_parents(array(array('_SELF:_SELF:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:trigger', do_lang_tempcode('PRODUCT')), array('_SELF:_SELF:trigger:item_name=' . $item_name, do_lang_tempcode('MANUAL_TRANSACTION'))));
     $purchase_id = post_param('purchase_id', '');
     $memo = post_param('memo');
     $mc_gross = post_param('amount', '');
     $object = find_product($item_name);
     $products = $object->get_products(true);
     if ($mc_gross == '') {
         $mc_gross = $products[$item_name][1];
     }
     $payment_status = 'Completed';
     $reason_code = '';
     $pending_reason = '';
     $mc_currency = get_option('currency');
     $txn_id = 'manual-' . substr(uniqid('', true), 0, 10);
     $parent_txn_id = '';
     /*if ($products[$item_name][0]==PRODUCT_SUBSCRIPTION)
     		{
     			$payment_status='SCancelled';
     		}*/
     $_item_name = $products[$item_name][4];
     if ($products[$item_name][0] == PRODUCT_SUBSCRIPTION) {
         if ($purchase_id == '') {
             $purchase_id = strval($GLOBALS['SITE_DB']->query_insert('subscriptions', array('s_type_code' => $item_name, 's_member_id' => get_member(), 's_state' => 'new', 's_amount' => $products[$item_name][1], 's_special' => $purchase_id, 's_time' => time(), 's_auto_fund_source' => '', 's_auto_fund_key' => '', 's_via' => 'manual'), true));
         }
         $_item_name = '';
         // Flag for handle_confirmed_transaction to know it's a subscription
     }
     handle_confirmed_transaction($purchase_id, $_item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
     $url = get_param('redirect', NULL);
     if (!is_null($url)) {
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     return inform_screen($title, do_lang_tempcode('SUCCESS'));
 }
Example #3
0
 /**
  * View survey results.
  *
  * @return tempcode	The result of execution.
  */
 function _survey_results()
 {
     $title = get_page_title('SURVEY_RESULTS');
     breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES'))));
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results';
     $id = get_param_integer('id');
     // quiz ID
     $fields = new ocp_tempcode();
     require_code('templates_results_table');
     require_code('templates_view_space');
     // Show summary
     $question_rows = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY id');
     foreach ($question_rows as $q) {
         $question = get_translated_text($q['q_question_text']);
         $answers = new ocp_tempcode();
         $answer_rows = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $q['id']), 'ORDER BY id');
         $all_answers = array();
         foreach ($answer_rows as $i => $a) {
             $answer = get_translated_text($a['q_answer_text']);
             $count = $GLOBALS['SITE_DB']->query_value('quiz_entry_answer', 'COUNT(*)', array('q_answer' => strval($a['id'])));
             $all_answers[serialize(array($answer, $i))] = $count;
         }
         arsort($all_answers);
         foreach ($all_answers as $bits => $count) {
             list($answer, $i) = unserialize($bits);
             $answers->attach(paragraph(do_lang_tempcode('SURVEY_ANSWER_RESULT', escape_html($answer), integer_format($count), integer_format($i + 1))));
         }
         if ($answers->is_empty()) {
             $answers = do_lang_tempcode('FREE_ENTRY_ANSWER');
         }
         $fields->attach(view_space_field($question, $answers, true));
     }
     $summary = do_template('VIEW_SPACE', array('_GUID' => '2b0c2ba0070ba810c5e4b5b4aedcb15f', 'WIDTH' => '300', 'FIELDS' => $fields));
     // Show results table
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('q_time' => do_lang_tempcode('DATE'));
     $test = explode(' ', get_param('sort', 'q_time DESC'), 2);
     if (count($test) == 1) {
         $test[1] = 'DESC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'sort';
     $max_rows = $GLOBALS['SITE_DB']->query_value('quiz_entries', 'COUNT(*)', array('q_quiz' => $id));
     $rows = $GLOBALS['SITE_DB']->query_select('quiz_entries', array('id', 'q_time', 'q_member'), array('q_quiz' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     if (count($rows) == 0) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     $fields = new ocp_tempcode();
     $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('USERNAME')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     foreach ($rows as $myrow) {
         $date_link = hyperlink(build_url(array('page' => '_SELF', 'type' => '__survey_results', 'id' => $myrow['id']), '_SELF'), escape_html(get_timezoned_date($myrow['q_time'])));
         $member_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['q_member']);
         $fields->attach(results_entry(array($date_link, $member_link), false));
     }
     if ($fields->is_empty()) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $results = results_table(do_lang_tempcode('SURVEY_RESULTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('SURVEY_RESULTS_SCREEN', array('_GUID' => '3f38ac1b94fb4de8219b8f7108c7b0a3', 'TITLE' => $title, 'SUMMARY' => $summary, 'RESULTS' => $results));
 }
Example #4
0
 /**
  * Get some XHTML for a form to choose a catalogue out of all the available ones.
  *
  * @param  tempcode		The get_page_title converted title for this page
  * @return ?tempcode		The tempcode for the catalogue chooser (NULL: already chosen)
  */
 function choose_catalogue($title)
 {
     if (!$this->catalogue) {
         return NULL;
     }
     $catalogue_name = get_param('catalogue_name', '');
     if ($catalogue_name != '') {
         return NULL;
     }
     $tree = nice_get_catalogues(NULL, false, true);
     if ($tree->is_empty()) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     require_code('form_templates');
     $fields = form_input_list(do_lang_tempcode('CATALOGUE'), '', 'catalogue_name', $tree, NULL, true);
     $post_url = get_self_url(false, false, NULL, false, true);
     $submit_name = do_lang_tempcode('PROCEED');
     $hidden = build_keep_post_fields();
     return do_template('FORM_SCREEN', array('_GUID' => '22812ac8056903811f444682d45ee448' . get_class($this), 'GET' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => paragraph(do_lang_tempcode('CHOOSE_CATALOGUE')), 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'SKIP_VALIDATION' => true));
 }
Example #5
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 #6
0
 /**
  * The actualiser for unbanning a chatter.
  *
  * @return tempcode	The UI.
  */
 function chat_unban()
 {
     $title = get_page_title('CHAT_UNBAN');
     $id = get_param_integer('id');
     $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $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', $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');
     }
     check_specific_permission('ban_chatters_from_rooms');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:room:id=' . strval($id), do_lang_tempcode('CHAT_MOD_PANEL'))));
     $member_id = post_param_integer('member_id', NULL);
     if (is_null($member_id)) {
         $member_id = get_param_integer('member_id');
         $confirm_needed = true;
     } else {
         $confirm_needed = false;
     }
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
     if (is_null($username)) {
         $username = do_lang('UNKNOWN');
     }
     if ($confirm_needed) {
         $hidden = form_input_hidden('member_id', strval($member_id));
         return do_template('YESNO_SCREEN', array('TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE_UNBAN', escape_html($username)), 'URL' => get_self_url(), 'HIDDEN' => $hidden));
     }
     chatroom_unban_to($member_id, $id);
     return inform_screen($title, do_lang_tempcode('SUCCESS'));
 }
Example #7
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'));
 }
Example #8
0
 /**
  * The UI to either show an existing ticket and allow a reply, or to start a new ticket.
  *
  * @return tempcode		The UI
  */
 function do_ticket()
 {
     require_lang('comcode');
     $id = get_param('id', NULL);
     if ($id == '') {
         $id = NULL;
     }
     if (!is_null($id)) {
         $_temp = explode('_', $id);
         if (!isset($_temp[1])) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         // Normal topic, not a ticket!
         $ticket_owner = intval($_temp[0]);
         $ticket_id = $_temp[1];
         if (is_guest()) {
             access_denied('NOT_AS_GUEST');
         }
         $this->check_id($id);
     } else {
         $ticket_owner = get_member();
         $ticket_id = uniqid('', true);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS'))));
     $poster = '';
     $new = true;
     $serialized_options = mixed();
     $hash = mixed();
     if (!is_guest() || is_null($id)) {
         $member = get_member();
         $new = is_null($id);
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         $start = get_param_integer('start_comments', 0);
         if ($new) {
             $id = strval($member) . '_' . $ticket_id;
             $title = get_page_title('ADD_TICKET');
         } else {
             $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id));
             $ticket_type_text = get_translated_text($ticket_type);
             $ticket_type_details = get_ticket_type($ticket_type);
             $forum = 1;
             $topic_id = 1;
             $_ticket_type = 1;
             // These will be returned by reference
             $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit);
             $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type);
             if (!is_array($_comments) || !array_key_exists(0, $_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $ticket_title = $_comments[0]['title'];
             if ($ticket_title == '') {
                 $ticket_title = do_lang('UNKNOWN');
             }
             $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text)));
             breadcrumb_set_self($ticket_title);
         }
         $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true);
         $staff_details = new ocp_tempcode();
         $types = $this->build_types_list(get_param('default', ''));
         $results_browser = NULL;
         if (!$new) {
             require_code('templates_internalise_screen');
             $test_tpl = internalise_own_screen($title, 30, $_comments_all);
             if (is_object($test_tpl)) {
                 return $test_tpl;
             }
             if (is_null($_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             if (has_specific_permission(get_member(), 'support_operator')) {
                 $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name'))));
             } else {
                 $staff_details = new ocp_tempcode();
             }
             require_code('topics');
             $renderer = new OCP_Topic();
             $renderer->_inject_posts_for_scoring_algorithm($_comments);
             $renderer->topic_id = $topic_id;
             // Posts
             $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth')));
             list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum);
             // Pagination
             if (!$renderer->is_threaded) {
                 if (count($_comments_all) > $num_to_show_limit) {
                     require_code('templates_results_browser');
                     $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true);
                 }
             }
             $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets'));
             // "Staff only reply" tickbox
             if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) {
                 require_code('form_templates');
                 $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false);
             } else {
                 $staff_only = new ocp_tempcode();
             }
         } else {
             $comments = new ocp_tempcode();
             $staff_only = new ocp_tempcode();
             $ticket_type_details = get_ticket_type(NULL);
         }
         if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) {
             $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
             require_javascript('javascript_editing');
             require_javascript('javascript_validation');
             require_javascript('javascript_posting');
             require_javascript('javascript_swfupload');
             require_css('swfupload');
             require_code('form_templates');
             list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL);
             if (addon_installed('captcha')) {
                 require_code('captcha');
                 $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
                 if ($use_captcha) {
                     generate_captcha();
                 }
             } else {
                 $use_captcha = false;
             }
             $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST')));
         } else {
             $comment_form = new ocp_tempcode();
         }
         $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF');
         require_code('form_templates');
         require_code('feedback');
         list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true);
         $other_tickets = new ocp_tempcode();
         $our_topic = NULL;
         if (!is_guest($ticket_owner)) {
             $tickets_of_member = get_tickets($ticket_owner, NULL, true);
             if (!is_null($tickets_of_member)) {
                 foreach ($tickets_of_member as $topic) {
                     $ticket_id = extract_topic_identifier($topic['description']);
                     if ($id != $ticket_id) {
                         $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF');
                         $_title = $topic['firsttitle'];
                         $date = get_timezoned_date($topic['lasttime']);
                         $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner);
                         if (is_null($ticket_owner_name)) {
                             $profile_link = '';
                         } else {
                             $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true);
                         }
                         $last_poster = $topic['lastusername'];
                         $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']);
                         $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed);
                         $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params));
                     } else {
                         $our_topic = $topic;
                     }
                 }
             }
         }
         $toggle_ticket_closed_url = NULL;
         if (get_forum_type() == 'ocf' && !$new) {
             $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF');
         }
         $map = array('page' => '_SELF', 'type' => 'ticket');
         if (get_param('default', '') != '') {
             $map['default'] = get_param('default');
         }
         $add_ticket_url = build_url($map, '_SELF');
         return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser));
     } else {
         return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS'));
     }
 }
Example #9
0
    /**
     * The actualiser to edit a template. Always saves to the most overridden version.
     *
     * @return tempcode		The UI
     */
    function __edit_templates()
    {
        // Erase cache
        $theme = filter_naughty(post_param('theme'));
        //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
        erase_cached_templates();
        require_code('view_modes');
        erase_tempcode_cache();
        $title = get_page_title('EDIT_TEMPLATES');
        foreach (array_keys($_REQUEST) as $_i) {
            $matches = array();
            if (preg_match('#f(\\d+)file#', $_i, $matches) != 0) {
                $i = $matches[1];
            } else {
                continue;
            }
            $_file = substr(str_replace('/default/', '/' . $theme . '/', '/' . filter_naughty(post_param('f' . $i . 'file', ''))), 1);
            if ($_file == '') {
                continue;
            }
            if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($_file, 'BANNER_TYPED') !== false) {
                warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
            }
            $file = str_replace('templates/', 'templates_custom/', $_file);
            $file = str_replace('css/', 'css_custom/', $file);
            $fullpath = get_custom_file_base() . '/themes/' . $file;
            // Make backup
            if (file_exists($fullpath) && get_option('templates_store_revisions') == '1') {
                @copy($fullpath, $fullpath . '.' . strval(time())) or intelligent_write_error($fullpath . '.' . strval(time()));
                fix_permissions($fullpath . '.' . strval(time()));
                sync_file($fullpath . '.' . strval(time()));
            }
            // Save
            $new = post_param('f' . $i . '_new', false, true);
            $fullpath_orig = preg_replace('#/themes/[^/]*/(.*)(\\_custom)?/#U', '/themes/default/${1}/', $fullpath);
            if (file_exists($fullpath_orig) && $new == file_get_contents($fullpath_orig)) {
                if (file_exists($fullpath)) {
                    unlink($fullpath);
                    sync_file($fullpath);
                }
                if (file_exists($fullpath . '.editfrom')) {
                    unlink($fullpath . '.editfrom');
                    sync_file($fullpath . '.editfrom');
                }
                $_file = preg_replace('#[^/]*/(.*)(\\_custom)?/#U', 'default/${1}/', $_file);
                $file = $_file;
            } else {
                $myfile = @fopen($fullpath, 'wt');
                if ($myfile === false) {
                    intelligent_write_error($fullpath);
                }
                if (fwrite($myfile, $new) < strlen($new)) {
                    fclose($myfile);
                    unlink($fullpath);
                    warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                }
                fclose($myfile);
                fix_permissions($fullpath);
                sync_file($fullpath);
                if (file_exists(get_file_base() . '/themes/' . post_param('f' . $i . 'file'))) {
                    // Make base-hash-thingy
                    $myfile = @fopen($fullpath . '.editfrom', 'wt');
                    if ($myfile === false) {
                        intelligent_write_error($fullpath);
                    }
                    $hash = file_get_contents(get_file_base() . '/themes/' . post_param('f' . $i . 'file'), FILE_TEXT);
                    if (fwrite($myfile, $hash) < strlen($hash)) {
                        warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                    }
                    fclose($myfile);
                    fix_permissions($fullpath . '.editfrom');
                    sync_file($fullpath . '.editfrom');
                }
            }
            log_it('EDIT_TEMPLATES', $file, $theme);
        }
        breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:edit_templates:theme=' . $theme, do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:_edit_templates:theme=' . $theme . ':file=' . $file, do_lang_tempcode('EDIT_TEMPLATES'))));
        breadcrumb_set_self(do_lang_tempcode('DONE'));
        if (get_param_integer('save_and_stay', 0) == 1) {
            return inform_screen($title, protect_from_escaping('
				<script type="text/javascript">// <![CDATA[
					window.fauxmodal_alert(\'' . addslashes(do_lang('SUCCESS')) . '\');
				//]]></script>
			'));
        }
        return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), $theme, '', 'templates', $file);
    }
Example #10
0
 /**
  * UI for a logo wizard step (set).
  *
  * @return tempcode		The UI
  */
 function __make_logo()
 {
     $title = get_page_title('_LOGOWIZARD', true, array(integer_format(3), integer_format(3)));
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/logowizard';
     $theme = post_param('theme');
     // Do it
     require_code('themes2');
     $rand = uniqid('', true);
     foreach (array($theme, 'default') as $logo_save_theme) {
         $path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png';
         $img = generate_logo(post_param('name'), post_param('title'), false, $logo_save_theme, 'logo-template');
         @imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
         imagedestroy($img);
         actual_edit_theme_image('logo/-logo', $logo_save_theme, user_lang(), 'logo/-logo', $path);
         if (addon_installed('collaboration_zone')) {
             actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, user_lang(), 'logo/collaboration-logo', $path);
         }
         $rand = uniqid('', true);
         $path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png';
         $img = generate_logo(post_param('name'), post_param('title'), false, NULL, 'trimmed-logo-template');
         @imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
         imagedestroy($img);
         actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, user_lang(), 'logo/trimmed-logo', $path);
     }
     persistant_cache_delete('THEME_IMAGES');
     breadcrumb_set_parents(array(array('_SELF:_SELF:make_logo', do_lang_tempcode('START'))));
     $message = do_lang_tempcode('LOGOWIZARD_3_DESCRIBE', escape_html($theme));
     return inform_screen($title, $message);
 }
Example #11
0
 /**
  * E-mails staff and receipt notice to user, and saves everything.
  *
  * @return tempcode	The result of execution.
  */
 function thanks()
 {
     $title = get_page_title('CREATE_BOOKING');
     // Finish join operation, if applicable
     if (is_guest()) {
         list($messages) = ocf_join_actual(true, false, false, true, false, false, false, true);
         if (!$messages->is_empty()) {
             return inform_screen($title, $messages);
         }
     }
     // Read request
     $request = get_booking_request_from_form();
     // Save
     $test = save_booking_form_to_db($request, array());
     if (is_null($test)) {
         warn_exit(do_lang_tempcode('BOOKING_ERROR'));
     }
     // Send emails
     send_booking_emails($request);
     // Show success
     return inform_screen($title, do_lang_tempcode('BOOKING_SUCCESS', escape_html($GLOBALS['FORUM_DRIVER']->get_username(get_member()))));
 }
Example #12
0
 /**
  * The actualiser to import news
  *
  * @return tempcode		The UI
  */
 function _import_news()
 {
     check_specific_permission('mass_import');
     $title = get_page_title('IMPORT_NEWS');
     require_code('rss');
     require_code('news');
     require_code('files');
     $GLOBALS['LAX_COMCODE'] = true;
     disable_php_memory_limit();
     $rss_url = post_param('rss_feed_url', NULL);
     require_code('uploads');
     if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
         $rss_url = $_FILES['file_novalidate']['tmp_name'];
     }
     if (is_null($rss_url)) {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
     }
     $is_validated = post_param_integer('auto_validate', 0);
     $download_images = post_param_integer('download_images', 0);
     $rss = new rss($rss_url, true);
     if (!is_null($rss->error)) {
         warn_exit($rss->error);
     }
     $submitter = get_member();
     $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
     $NEWS_CATS = list_to_map('id', $NEWS_CATS);
     $extra_post_data = array();
     foreach ($rss->gleamed_items as $i => $item) {
         if (!array_key_exists('category', $item)) {
             $item['category'] = do_lang('NC_general');
         }
         $extra_post_data[] = $item;
         $cats_to_process = array($item['category']);
         if (array_key_exists('extra_categories', $item)) {
             $cats_to_process = array_merge($cats_to_process, $item['extra_categories']);
         }
         $cat_id = mixed();
         $extra_categories = array();
         foreach ($cats_to_process as $j => $cat) {
             $_cat_id = mixed();
             foreach ($NEWS_CATS as $_cat => $news_cat) {
                 if (get_translated_text($news_cat['nc_title']) == $cat) {
                     $_cat_id = $_cat;
                 }
             }
             if (is_null($_cat_id)) {
                 $_cat_id = add_news_category($cat, 'newscats/general', '', NULL);
                 // Need to reload now
                 $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
                 $NEWS_CATS = list_to_map('id', $NEWS_CATS);
             }
             if ($j == 0) {
                 $cat_id = $_cat_id;
             } else {
                 $extra_categories[] = $_cat_id;
             }
         }
         $rep_image = '';
         if (array_key_exists('rep_image', $item)) {
             $rep_image = $item['rep_image'];
             if ($download_images == 1) {
                 $stem = 'uploads/grepimages/' . basename(urldecode($rep_image));
                 $target_path = get_custom_file_base() . '/' . $stem;
                 $rep_image = 'uploads/grepimages/' . basename($rep_image);
                 while (file_exists($target_path)) {
                     $uniqid = uniqid('');
                     $stem = 'uploads/grepimages/' . $uniqid . '_' . basename(urldecode($rep_image));
                     $target_path = get_custom_file_base() . '/' . $stem;
                     $rep_image = 'uploads/grepimages/' . $uniqid . '_' . basename($rep_image);
                 }
                 $target_handle = fopen($target_path, 'wb') or intelligent_write_error($target_path);
                 $result = http_download_file($item['rep_image'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $target_handle);
                 fclose($target_handle);
             }
         }
         // Add news
         $ts = array_key_exists('clean_add_date', $item) ? $item['clean_add_date'] : (array_key_exists('add_date', $item) ? strtotime($item['add_date']) : time());
         if ($ts === false) {
             $ts = time();
         }
         // Seen in error email, it's if the add date won't parse by PHP
         $edit_date = array_key_exists('clean_edit_date', $item) ? $item['clean_edit_date'] : (array_key_exists('edit_date', $item) ? strtotime($item['edit_date']) : NULL);
         if ($edit_date === false) {
             $edit_date = NULL;
         }
         $news = array_key_exists('news', $item) ? html_to_comcode($item['news']) : '';
         $news_article = array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '';
         $news_id = add_news($item['title'], $news, array_key_exists('author', $item) ? $item['author'] : $GLOBALS['FORUM_DRIVER']->get_username(get_member()), $is_validated, 1, 1, 1, '', $news_article, $cat_id, $extra_categories, $ts, $submitter, 0, $edit_date, NULL, $rep_image);
         $rss->gleamed_items[$i]['import_id'] = $news_id;
         $rss->gleamed_items[$i]['import__news'] = $news;
         $rss->gleamed_items[$i]['import__news_article'] = $news_article;
     }
     foreach ($rss->gleamed_items as $i => $item) {
         $news = $item['import__news'];
         $news_article = $item['import__news_article'];
         $this->_grab_images_and_fix_links($download_images == 1, $news, $rss->gleamed_items);
         $this->_grab_images_and_fix_links($download_images == 1, $news_article, $rss->gleamed_items);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news', array('id' => $item['import_id'])), $news);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news_article', array('id' => $item['import_id'])), $news_article);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWS')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_NEWS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     if (url_is_local($rss_url)) {
         // Means it is a temp file
         @unlink($rss_url);
     }
     return inform_screen($title, do_lang_tempcode('IMPORT_NEWS_DONE'));
 }
Example #13
0
 /**
  * The UI to show the member directory.
  *
  * @return tempcode		The UI
  */
 function directory()
 {
     require_javascript('javascript_ajax');
     require_javascript('javascript_ajax_people_lists');
     $title = get_page_title('MEMBERS');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     if (running_script('iframe')) {
         $get_url = find_script('iframe');
     } else {
         $get_url = find_script('index');
     }
     $hidden = new ocp_tempcode();
     $hidden->attach(build_keep_form_fields('_SELF', true, array('filter')));
     $hidden->attach(form_input_hidden('zone', get_zone_name()));
     $start = get_param_integer('md_start', 0);
     $max = get_param_integer('md_max', 50);
     $sortables = array('m_username' => do_lang_tempcode('USERNAME'), 'm_primary_group' => do_lang_tempcode('PRIMARY_GROUP'), 'm_cache_num_posts' => do_lang_tempcode('COUNT_POSTS'), 'm_join_time' => do_lang_tempcode('JOIN_DATE'));
     $default_sort_order = get_value('md_default_sort_order');
     if (is_null($default_sort_order)) {
         $default_sort_order = 'm_join_time DESC';
     }
     $test = explode(' ', get_param('md_sort', $default_sort_order), 2);
     if (count($test) == 1) {
         $test[] = 'ASC';
     }
     list($sortable, $sort_order) = $test;
     if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
         log_hack_attack_and_exit('ORDERBY_HACK');
     }
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'md_sort';
     $group_filter = get_param('group_filter', '');
     $_usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, $group_filter == '' ? NULL : array(intval($group_filter)));
     $usergroups = array();
     require_code('ocf_groups2');
     foreach ($_usergroups as $group_id => $group) {
         $num = ocf_get_group_members_raw_count($group_id, true);
         $usergroups[$group_id] = array('USERGROUP' => $group, 'NUM' => strval($num));
     }
     $query = 'FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id());
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $query .= ' AND m_validated=1';
     }
     if ($group_filter != '') {
         if (is_numeric($group_filter)) {
             $title = get_page_title('USERGROUP', true, array(escape_html($usergroups[intval($group_filter)]['USERGROUP'])));
         }
         require_code('ocfiltering');
         $filter = ocfilter_to_sqlfragment($group_filter, 'm_primary_group', 'f_groups', NULL, 'm_primary_group', 'id');
         $query .= ' AND ' . $filter;
     }
     $search = get_param('filter', '');
     $sup = $search != '' ? ' AND m_username LIKE \'' . db_encode_like(str_replace('*', '%', $search)) . '\'' : '';
     if ($sortable == 'm_join_time') {
         $query .= $sup . ' ORDER BY m_join_time ' . $sort_order . ',' . 'id ' . $sort_order;
     } else {
         $query .= $sup . ' ORDER BY ' . $sortable . ' ' . $sort_order;
     }
     $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
     $rows = $GLOBALS['FORUM_DB']->query('SELECT * ' . $query, $max, $start);
     if (count($rows) == 0) {
         return inform_screen($title, do_lang_tempcode('NO_RESULTS'));
     }
     $members = new ocp_tempcode();
     $member_boxes = array();
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('COUNT_POSTS'), do_lang_tempcode('JOIN_DATE')), $sortables, 'md_sort', $sortable . ' ' . $sort_order);
     require_code('ocf_members2');
     foreach ($rows as $row) {
         $link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'], true, $row['m_username']);
         if ($row['m_validated'] == 0) {
             $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED'));
         }
         if ($row['m_validated_email_confirm_code'] != '') {
             $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED'));
         }
         $member_primary_group = ocf_get_member_primary_group($row['id']);
         $primary_group = ocf_get_group_link($member_primary_group);
         $members->attach(results_entry(array($link, $primary_group, escape_html(integer_format($row['m_cache_num_posts'])), escape_html(get_timezoned_date($row['m_join_time'])))));
         $member_boxes[] = ocf_show_member_box($row['id'], true);
     }
     $results_table = results_table(do_lang_tempcode('MEMBERS'), $start, 'md_start', $max, 'md_max', $max_rows, $fields_title, $members, $sortables, $sortable, $sort_order, 'md_sort');
     $results_browser = results_browser(do_lang_tempcode('MEMBERS'), NULL, $start, 'md_start', $max, 'md_max', $max_rows, NULL, NULL, true, true);
     $symbols = NULL;
     if (get_option('allow_alpha_search') == '1') {
         $alpha_query = $GLOBALS['FORUM_DB']->query('SELECT m_username FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id<>' . strval(db_get_first_id()) . ' ORDER BY m_username ASC');
         $symbols = array(array('START' => '0', 'SYMBOL' => do_lang('ALL')), array('START' => '0', 'SYMBOL' => '#'));
         foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z') as $s) {
             foreach ($alpha_query as $i => $q) {
                 if (strtolower(substr($q['m_username'], 0, 1)) == $s) {
                     break;
                 }
             }
             if (substr(strtolower($q['m_username']), 0, 1) != $s) {
                 $i = intval($symbols[count($symbols) - 1]['START']);
             }
             $symbols[] = array('START' => strval(intval($max * floor(floatval($i) / floatval($max)))), 'SYMBOL' => $s);
         }
     }
     return do_template('OCF_MEMBER_DIRECTORY_SCREEN', array('_GUID' => '096767e9aaabce9cb3e6591b7bcf95b8', 'MAX' => strval($max), 'RESULTS_BROWSER' => $results_browser, 'MEMBER_BOXES' => $member_boxes, 'USERGROUPS' => $usergroups, 'HIDDEN' => $hidden, 'SYMBOLS' => $symbols, 'SEARCH' => $search, 'GET_URL' => $get_url, 'TITLE' => $title, 'RESULTS_TABLE' => $results_table));
 }
Example #14
0
 /**
  * The UI for having confirmed an e-mail address onto the newsletter.
  *
  * @return tempcode		The UI
  */
 function newsletter_confirm_joining()
 {
     $title = get_page_title(get_option('newsletter_title'), false);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', get_option('newsletter_title'))));
     $code_confirm = get_param_integer('confirm');
     $email = trim(get_param('email'));
     $correct_confirm = $GLOBALS['SITE_DB']->query_value('newsletter', 'code_confirm', array('email' => $email));
     if ($correct_confirm == $code_confirm) {
         $GLOBALS['SITE_DB']->query_update('newsletter', array('code_confirm' => 0), array('email' => $email), '', 1);
         return inform_screen($title, do_lang_tempcode('NEWSLETTER_CONFIRMED'));
     }
     return warn_screen($title, do_lang_tempcode($correct_confirm == 0 ? 'ALREADY_CONFIRMED' : 'INCORRECT_CONFIRMATION'));
 }
Example #15
0
 /**
  * The actualiser to move a page.
  *
  * @return tempcode		The UI
  */
 function _move()
 {
     $title = get_page_title('MOVE_PAGES');
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/move';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     $zone = post_param('zone', NULL);
     if (is_null($zone)) {
         $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
         $hidden = build_keep_form_fields('', true);
         return do_template('YESNO_SCREEN', array('_GUID' => 'c6e872cc62bdc7cf1c5157fbfdb2dfd6', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('Q_SURE'), 'URL' => $post_url, 'HIDDEN' => $hidden));
     }
     $new_zone = post_param('destination_zone', '');
     if (substr($new_zone, -1) == ':') {
         $new_zone = substr($new_zone, 0, strlen($new_zone) - 1);
     }
     //$pages=find_all_pages_wrap($zone);
     $pages = array();
     require_code('site');
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 6) == 'page__' && $val === '1') {
             $page = substr($key, 6);
             $page_details = _request_page($page, $zone, NULL, NULL, true);
             if ($page_details === false) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $pages[$page] = strtolower($page_details[0]);
             if (array_key_exists(3, $page_details)) {
                 $pages[$page] .= '/' . $page_details[3];
             }
         }
     }
     $afm_needed = false;
     foreach ($pages as $page => $type) {
         if (post_param_integer('page__' . $page, 0) == 1) {
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     $cannot_move = new ocp_tempcode();
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if (!$cannot_move->is_empty()) {
                     $cannot_move->attach(do_lang_tempcode('LIST_SEP'));
                 }
                 $cannot_move->attach(do_lang_tempcode('PAGE_WRITE', escape_html($page)));
                 continue;
             }
         }
     }
     $moved_something = NULL;
     foreach ($pages as $page => $type) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             $moved_something = $page;
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 continue;
             }
             if (file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page));
                 }
             }
             // If a non-overridden one is there too, need to move that too
             if (strpos($type, '_custom') !== false && file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page)) && !file_exists(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page))) {
                 if ($afm_needed) {
                     afm_move(zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true), zone_black_magic_filterer(filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page, true));
                 } else {
                     rename(zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page), zone_black_magic_filterer(get_custom_file_base() . '/' . filter_naughty($new_zone) . ($new_zone != '' ? '/' : '') . 'pages/' . filter_naughty(str_replace('_custom', '', $type)) . '/' . $_page));
                 }
             }
             log_it('MOVE_PAGES', $page);
         }
     }
     if (is_null($moved_something)) {
         warn_exit(do_lang_tempcode('NOTHING_SELECTED'));
     }
     persistant_cache_empty();
     require_lang('addons');
     if ($cannot_move->is_empty()) {
         $message = do_lang_tempcode('SUCCESS');
     } else {
         $message = do_lang_tempcode('WOULD_NOT_OVERWRITE_BUT_SUCCESS', $cannot_move);
     }
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:move', do_lang_tempcode('MOVE_PAGES'))));
     decache('main_sitemap');
     if (has_js()) {
         return inform_screen($title, $message);
         // Came from site-tree editor, so want to just close this window when done
     }
     return $this->do_next_manager($title, $moved_something, $new_zone, new ocp_tempcode());
 }
Example #16
0
 /**
  * The actualiser for importing a CSV file.
  *
  * @return tempcode		The UI
  */
 function _import_csv()
 {
     $title = get_page_title('IMPORT_MEMBER_CSV');
     disable_php_memory_limit();
     // Even though we split into chunks, PHP does leak memory :(
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/import_csv';
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     require_lang('ocf');
     require_code('ocf_members_action');
     $default_password = post_param('default_password');
     $num_added = 0;
     $num_edited = 0;
     $done = 0;
     $headings = $this->_get_csv_headings();
     $all_cpfs = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_default', 'cf_type', 'cf_name'), NULL, 'ORDER BY cf_order');
     foreach ($all_cpfs as $i => $c) {
         $c['text_original'] = get_translated_text($c['cf_name'], $GLOBALS['FORUM_DB']);
         $all_cpfs[$i] = $c;
         $headings[$c['text_original']] = NULL;
     }
     $_all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, false, true);
     $all_groups = array_flip($_all_groups);
     $all_members = collapse_2d_complexity('id', 'm_username', $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_username')));
     $all_members_flipped = array_flip($all_members);
     // Import
     require_code('uploads');
     if (is_swf_upload(true) || array_key_exists('file', $_FILES) && is_uploaded_file($_FILES['file']['tmp_name'])) {
         $_csv_data = array();
         $fixed_contents = unixify_line_format(file_get_contents($_FILES['file']['tmp_name']));
         $myfile = @fopen($_FILES['file']['tmp_name'], 'wb');
         if ($myfile !== false) {
             fwrite($myfile, $fixed_contents);
             fclose($myfile);
         }
         $myfile = fopen($_FILES['file']['tmp_name'], 'rb');
         $del = ',';
         $csv_header = fgetcsv($myfile, 102400, $del);
         if ($csv_header === false) {
             warn_exit(do_lang_tempcode('NO_DATA_IMPORTED'));
         }
         if (count($csv_header) == 1 && strpos($csv_header[0], ';') !== false) {
             $del = ';';
             rewind($myfile);
             $csv_header = fgetcsv($myfile, 102400, $del);
         }
         while (($csv_line = fgetcsv($myfile, 102400, $del)) !== false) {
             $line = array();
             foreach ($csv_header as $i => $h) {
                 $extracted_value = trim(unixify_line_format(array_key_exists($i, $csv_line) ? $csv_line[$i] : ''));
                 if (strpos($h, ':') !== false) {
                     $parts = explode(':', $h, 2);
                     $h = trim($parts[0]);
                     if ($extracted_value != '') {
                         $extracted_value = $parts[1] . ': ' . $extracted_value;
                     }
                 }
                 if (array_key_exists($h, $line)) {
                     if ($extracted_value != '') {
                         $line[$h] .= ($line[$h] != '' ? chr(10) : '') . $extracted_value;
                     }
                 } else {
                     $line[$h] = $extracted_value;
                 }
             }
             if (!array_key_exists('Username', $line) || $line['Username'] == '') {
                 // Can we auto-generate it
                 $forename = NULL;
                 if (array_key_exists('Forenames', $line)) {
                     $forename = $line['Forenames'];
                 }
                 if (array_key_exists('Forename', $line)) {
                     $forename = $line['Forename'];
                 }
                 if (array_key_exists('First name', $line)) {
                     $forename = $line['First name'];
                 }
                 if (array_key_exists('First Name', $line)) {
                     $forename = $line['First Name'];
                 }
                 $surname = NULL;
                 if (array_key_exists('Surname', $line)) {
                     $surname = $line['Surname'];
                 }
                 if (array_key_exists('Last name', $line)) {
                     $surname = $line['Last name'];
                 }
                 if (array_key_exists('Last Name', $line)) {
                     $surname = $line['Last Name'];
                 }
                 if (!is_null($forename) || !is_null($surname)) {
                     // Can we get a year too?
                     $year = '';
                     foreach ($line as $tl_key => $tl_val) {
                         if (substr($tl_key, 0, 4) == 'Year') {
                             $year = $tl_val;
                             break;
                         }
                     }
                     if (strlen($year) == 4 && (substr($year, 0, 2) == '19' || substr($year, 0, 2) == '20')) {
                         $year = substr($year, 2);
                     }
                     // Tidy up forename
                     $_forename = preg_replace('#[^\\w]#', '', preg_replace('#[\\s\\.].*#', '', $forename));
                     // Tidy up surname (last bit strips like 'OBE')
                     $_surname = preg_replace('#[^\\w]#', '', trim(preg_replace('#\\s*[A-Z\\d][A-Z\\d]+#', '', $surname)));
                     // Put it together
                     $line['Username'] = ucfirst($_forename) . ucfirst($_surname) . $year;
                 } else {
                     continue;
                     // This field is needed
                 }
             }
             $username = $line['Username'];
             $linked_id = NULL;
             if (array_key_exists('ID', $line)) {
                 $linked_id = $line['ID'] != '' && array_key_exists(intval($line['ID']), $all_members) ? intval($line['ID']) : NULL;
             }
             if (is_null($linked_id)) {
                 $linked_id = array_key_exists($username, $all_members_flipped) ? $all_members_flipped[$username] : NULL;
             }
             $new_member = is_null($linked_id);
             $email_address_key = 'E-mail address';
             if (array_key_exists('Email address', $line)) {
                 $email_address_key = 'Email address';
             }
             if (array_key_exists('E-mail Address', $line)) {
                 $email_address_key = 'E-mail Address';
             }
             if (array_key_exists('Email Address', $line)) {
                 $email_address_key = 'Email Address';
             }
             if (array_key_exists('E-mail', $line)) {
                 $email_address_key = 'E-mail';
             }
             if (array_key_exists('Email', $line)) {
                 $email_address_key = 'Email';
             }
             $dob_key = 'Date of birth';
             if (array_key_exists('Date Of Birth', $line)) {
                 $dob_key = 'Date Of Birth';
             }
             if (array_key_exists('DOB', $line)) {
                 $dob_key = 'DOB';
             }
             // If it's an edited member, add in their existing CSV details, so that if it's a partial merge it'll still work without deleting anything!
             if (!$new_member) {
                 $member_groups = $GLOBALS['FORUM_DB']->query_select('f_group_members', array('gm_member_id', 'gm_group_id'), array('gm_validated' => 1, 'gm_member_id' => $linked_id));
                 $member_cpfs = list_to_map('mf_member_id', $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('*'), array('mf_member_id' => $linked_id), '', 1));
                 $this_record = $this->_get_csv_member_record($member_cpfs, $GLOBALS['FORUM_DRIVER']->get_member_row($linked_id), $_all_groups, $headings, $all_cpfs, $member_groups);
                 // Remember "+" in PHP won't overwrite existing keys
                 if (!array_key_exists($email_address_key, $line)) {
                     unset($this_record['E-mail address']);
                 }
                 if (!array_key_exists($dob_key, $line)) {
                     unset($this_record['Date of birth']);
                 }
                 $line += $this_record;
             }
             // Set up member row
             if (array_key_exists('Password', $line) && $line['Password'] != '') {
                 $parts = explode('/', $line['Password']);
                 $password = $parts[0];
                 $salt = array_key_exists(1, $parts) ? $parts[1] : NULL;
                 $password_compatibility_scheme = array_key_exists(2, $parts) ? $parts[2] : NULL;
             } else {
                 $password = NULL;
                 $salt = NULL;
                 $password_compatibility_scheme = NULL;
             }
             $matches = array();
             if (array_key_exists($email_address_key, $line)) {
                 $email_address = $line[$email_address_key];
             } else {
                 $email_address = NULL;
             }
             if (preg_match('#^([^\\s]*)\\s+\\(.*\\)$#', $email_address, $matches) != 0) {
                 $email_address = $matches[1];
             }
             if (preg_match('#^.*\\s+<(.*)>$#', $email_address, $matches) != 0) {
                 $email_address = $matches[1];
             }
             if (array_key_exists($dob_key, $line)) {
                 $parts = explode('/', $line[$dob_key]);
                 $dob_day = array_key_exists(2, $parts) ? intval($parts[2]) : NULL;
                 $dob_month = array_key_exists(1, $parts) ? intval($parts[1]) : NULL;
                 $dob_year = array_key_exists(0, $parts) ? intval($parts[0]) : NULL;
             } else {
                 $dob_day = NULL;
                 $dob_month = NULL;
                 $dob_year = NULL;
             }
             $validated = array_key_exists('Validated', $line) ? strtoupper($line['Validated']) == 'YES' || $line['Validated'] == '1' || strtoupper($line['Validated']) == 'Y' || strtoupper($line['Validated']) == 'ON' ? 1 : 0 : 1;
             if (array_key_exists('Join time', $line)) {
                 if (strpos($line['Join time'], '-') !== false) {
                     $parts = explode('-', $line['Join time']);
                 } else {
                     $parts = explode('/', $line['Join time']);
                 }
                 if (!array_key_exists(1, $parts)) {
                     $parts[1] = '1';
                 }
                 if (!array_key_exists(2, $parts)) {
                     $parts[2] = '1';
                 }
                 if (strlen($parts[2]) != 4) {
                     $join_time = mktime(0, 0, 0, intval($parts[1]), intval($parts[2]), intval($parts[0]));
                     // yy(yy)-mm-dd
                 } else {
                     $join_time = mktime(0, 0, 0, intval($parts[1]), intval($parts[0]), intval($parts[2]));
                     // dd-mm-yyyy
                 }
                 if ($join_time > time()) {
                     $join_time = time();
                 }
                 // Fixes MySQL out of range error that could happen
             } else {
                 $join_time = NULL;
             }
             $avatar_url = array_key_exists('Avatar', $line) ? $line['Avatar'] : '';
             if (!is_null($avatar_url)) {
                 if (substr($avatar_url, 0, strlen(get_base_url() . '/')) == get_base_url() . '/') {
                     $avatar_url = substr($avatar_url, strlen(get_base_url() . '/'));
                 }
             }
             $signature = array_key_exists('Signature', $line) ? $line['Signature'] : '';
             $is_perm_banned = array_key_exists('Banned', $line) ? strtoupper($line['Banned']) == 'YES' || $line['Banned'] == '1' || strtoupper($line['Banned']) == 'Y' || strtoupper($line['Banned']) == 'ON' ? 1 : 0 : 0;
             $reveal_age = array_key_exists('Reveal age', $line) ? strtoupper($line['Reveal age']) == 'YES' || $line['Reveal age'] == '1' || strtoupper($line['Reveal age']) == 'Y' || strtoupper($line['Reveal age']) == 'ON' ? 1 : 0 : 0;
             $language = array_key_exists('Language', $line) ? $line['Language'] : '';
             $allow_emails = array_key_exists('Accept member e-mails', $line) ? strtoupper($line['Accept member e-mails']) == 'YES' || $line['Accept member e-mails'] == '1' || strtoupper($line['Accept member e-mails']) == 'Y' || strtoupper($line['Accept member e-mails']) == 'ON' ? 1 : 0 : 0;
             $allow_emails_from_staff = array_key_exists('Opt-in', $line) ? strtoupper($line['Opt-in']) == 'YES' || $line['Opt-in'] == '1' || strtoupper($line['Opt-in']) == 'Y' || strtoupper($line['Opt-in']) == 'ON' ? 1 : 0 : 0;
             $primary_group = NULL;
             $groups = NULL;
             if (array_key_exists('Usergroup', $line)) {
                 $parts = explode('/', $line['Usergroup']);
                 foreach ($parts as $p) {
                     if (!array_key_exists($p, $all_groups)) {
                         require_code('ocf_groups_action');
                         $g_id = ocf_make_group($p, 0, 0, 0, '');
                         $all_groups[$p] = $g_id;
                         $_group_edit_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $g_id), get_module_zone('admin_ocf_groups'));
                         $group_edit_url = $_group_edit_url->evaluate();
                         attach_message(do_lang_tempcode('MEMBER_IMPORT_GROUP_ADDED', escape_html($p), escape_html($group_edit_url)), 'inform');
                     }
                 }
                 $primary_group = $all_groups[$parts[0]];
                 unset($parts[0]);
                 $groups = array();
                 foreach ($parts as $p) {
                     $groups[] = $all_groups[$p];
                 }
             }
             $photo_url = array_key_exists('Photo', $line) ? $line['Photo'] : '';
             if ($photo_url != '') {
                 require_code('images');
                 $photo_thumb_url = 'uploads/ocf_photos_thumbs/' . uniqid('', true) . '.png';
                 convert_image($photo_url, $photo_thumb_url, -1, -1, intval(get_option('thumb_width')), false);
             } else {
                 $photo_thumb_url = '';
             }
             $custom_fields = array();
             foreach ($all_cpfs as $cpf) {
                 $custom_fields[$cpf['id']] = array_key_exists($cpf['text_original'], $line) ? $line[$cpf['text_original']] : $cpf['cf_default'];
                 if (!array_key_exists($cpf['text_original'], $line) && $cpf['cf_type'] == 'list') {
                     $parts = explode($custom_fields[$cpf['id']], '|');
                     $custom_fields[$cpf['id']] = $parts[0];
                 }
                 if ($cpf['cf_type'] == 'integer') {
                     $custom_fields[$cpf['id']] = intval($custom_fields[$cpf['id']]);
                 } elseif ($cpf['cf_type'] == 'tick') {
                     $custom_fields[$cpf['id']] = strtoupper($custom_fields[$cpf['id']]) == 'YES' || strtoupper($custom_fields[$cpf['id']]) == 'Y' || strtoupper($custom_fields[$cpf['id']]) == 'ON' || $custom_fields[$cpf['id']] == '1' ? 1 : 0;
                 } elseif ($cpf['cf_type'] == 'short_text' || $cpf['cf_type'] == 'short_trans') {
                     $custom_fields[$cpf['id']] = substr(str_replace(chr(10), ', ', str_replace(',' . chr(10), chr(10), $custom_fields[$cpf['id']])), 0, 255);
                 } elseif ($cpf['cf_type'] == 'long_text' || $cpf['cf_type'] == 'long_trans') {
                     //$custom_fields[$cpf['id']]=$custom_fields[$cpf['id']];
                 } elseif ($cpf['cf_type'] == 'float') {
                     if (preg_match('#^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\n(\\d\\d\\d\\d)$#', $custom_fields[$cpf['id']]) != 0) {
                         $parts = explode(chr(10), $custom_fields[$cpf['id']], 2);
                         $month_lookup = array('Jan' => 0.1, 'Feb' => 0.2, 'Mar' => 0.3, 'Apr' => 0.4, 'May' => 0.5, 'Jun' => 0.6, 'Jul' => 0.7, 'Aug' => 0.8, 'Sep' => 0.9, 'Oct' => 0.1, 'Nov' => 0.11, 'Dec' => 0.12);
                         $custom_fields[$cpf['id']] = floatval($parts[1]) + $month_lookup[$parts[0]];
                     } else {
                         $custom_fields[$cpf['id']] = floatval($custom_fields[$cpf['id']]);
                     }
                 }
                 unset($line[$cpf['text_original']]);
             }
             foreach (array_keys($headings) as $h) {
                 unset($line[$h]);
             }
             unset($line[$email_address_key]);
             unset($line[$dob_key]);
             foreach ($line as $h => $f) {
                 $cf_id = ocf_make_custom_field($h, 0, '', '', 0, 0, 0, 0, 'long_text');
                 $_cpf_edit_url = build_url(array('page' => 'admin_ocf_customprofilefields', 'type' => '_ed', 'id' => $cf_id), get_module_zone('admin_ocf_customprofilefields'));
                 $cpf_edit_url = $_cpf_edit_url->evaluate();
                 attach_message(do_lang_tempcode('MEMBER_IMPORT_CPF_ADDED', escape_html($h), escape_html($cpf_edit_url)), 'inform');
                 $custom_fields[$cf_id] = $f;
                 $all_cpfs[] = array('id' => $cf_id, 'cf_default' => '', 'text_original' => $h, 'cf_type' => 'short_line');
             }
             if ($new_member) {
                 if (is_null($password)) {
                     $password = $default_password;
                 }
                 if (is_null($salt)) {
                     $salt = '';
                 }
                 if (is_null($password_compatibility_scheme)) {
                     $password_compatibility_scheme = '';
                 }
                 $linked_id = ocf_make_member($username, $password, is_null($email_address) ? '' : $email_address, $groups, $dob_day, $dob_month, $dob_year, $custom_fields, NULL, $primary_group, $validated, $join_time, NULL, '', $avatar_url, $signature, $is_perm_banned, get_option('default_preview_guests') == '1' ? 1 : 0, $reveal_age, '', $photo_url, $photo_thumb_url, 1, 1, $language, $allow_emails, $allow_emails_from_staff, '', NULL, '', false, $password_compatibility_scheme, $salt, 1, NULL, NULL, 0, '*', '');
                 $all_members[$linked_id] = $username;
                 $all_members_flipped[$username] = $linked_id;
                 $num_added++;
             } else {
                 $old_username = $GLOBALS['OCF_DRIVER']->get_member_row_field($linked_id, 'm_username');
                 if ($old_username == $username) {
                     $username = NULL;
                 }
                 ocf_edit_member($linked_id, $email_address, NULL, $dob_day, $dob_month, $dob_year, NULL, $primary_group, $custom_fields, NULL, $reveal_age, NULL, NULL, $language, $allow_emails, $allow_emails_from_staff, $validated, $username, $password, NULL, NULL, NULL, NULL, NULL, $join_time, $avatar_url, $signature, $is_perm_banned, $photo_url, $photo_thumb_url, $salt, $password_compatibility_scheme, true);
                 $num_edited++;
             }
             $done++;
         }
         fclose($myfile);
     } else {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
     }
     if ($done == 0) {
         warn_exit(do_lang_tempcode('NO_DATA_IMPORTED'));
     }
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')), array('_SEARCH:admin_ocf_join:import_csv', do_lang_tempcode('IMPORT_MEMBER_CSV'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('NUM_MEMBERS_IMPORTED', escape_html(integer_format($num_added)), escape_html(integer_format($num_edited))));
 }
Example #17
0
 /**
  * The actualiser to add a bookmark.
  *
  * @return tempcode		The UI
  */
 function _ad()
 {
     $title = get_page_title('ADD_BOOKMARK');
     $folder = post_param('folder_new', '');
     if ($folder == '') {
         $folder = post_param('folder');
     }
     if ($folder == '!') {
         $folder = '';
     }
     add_bookmark(get_member(), $folder, post_param('title'), post_param('page_link'));
     if (get_param_integer('do_redirect') == 1) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     } else {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     }
 }
Example #18
0
 /**
  * Standard stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function __newpop3()
 {
     if (get_option('is_on_pop3_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TITLE_NEWPOP3');
     $member_id = get_member();
     $pointsleft = available_points($member_id);
     // the number of points this member has left
     $time = time();
     // So we don't need to call these big ugly names, again...
     $prefix = post_param('prefix');
     $_suffix = post_param('suffix');
     $password = trim(post_param('password'));
     $suffix = 'pop3_' . $_suffix;
     $suffix_price = get_price($suffix);
     pointstore_handle_error_already_has('pop3');
     // If the price is more than we can afford...
     if ($suffix_price > $pointsleft && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('NOT_ENOUGH_POINTS', escape_html($_suffix)));
     }
     pointstore_handle_error_taken($prefix, $_suffix);
     // Add us to the database
     $sale_id = $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => $time, 'memberid' => get_member(), 'purchasetype' => 'pop3', 'details' => $prefix, 'details2' => '@' . $_suffix), true);
     $mail_server = get_option('mail_server');
     $pop3_url = get_option('pop_url');
     $initial_quota = intval(get_option('initial_quota'));
     $login = $prefix . '@' . $_suffix;
     $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
     // Mail off the order form
     $encoded_reason = do_lang('TITLE_NEWPOP3');
     $message_raw = do_template('POINTSTORE_POP3_MAIL', array('_GUID' => '19022c49d0bdde39735245850d04fca7', 'EMAIL' => $email, 'ENCODED_REASON' => $encoded_reason, 'LOGIN' => $login, 'QUOTA' => integer_format($initial_quota), 'MAIL_SERVER' => $mail_server, 'PASSWORD' => $password, 'PREFIX' => $prefix, 'SUFFIX' => $_suffix, 'POP3_URL' => $pop3_url, 'SUFFIX_PRICE' => integer_format($suffix_price)));
     require_code('notifications');
     dispatch_notification('pointstore_request_pop3', 'pop3_' . strval($sale_id), do_lang('MAIL_REQUEST_POP3', NULL, NULL, NULL, get_site_default_lang()), $message_raw->evaluate(get_site_default_lang(), false), NULL, NULL, 3, true);
     $text = do_lang_tempcode('ORDER_POP3_DONE', escape_html($prefix . '@' . $_suffix));
     return inform_screen($title, $text);
 }
Example #19
0
 /**
  * The actualiser to toggle a combined IP/member ban.
  *
  * @return tempcode		The UI
  */
 function multi_ban()
 {
     $title = get_page_title('BAN_USER');
     $id = either_param('id', NULL);
     $_ip = explode(':', strrev($id), 2);
     $ip = strrev($_ip[0]);
     $member = array_key_exists(1, $_ip) ? strrev($_ip[1]) : NULL;
     if (post_param_integer('confirm', 0) == 0) {
         $preview = do_lang_tempcode('BAN_USER_DESCRIPTION', is_null($member) ? do_lang_tempcode('NA_EM') : make_string_tempcode(strval($member)), make_string_tempcode(escape_html($ip)));
         $url = get_self_url(false, false);
         return do_template('CONFIRM_SCREEN', array('_GUID' => '3840c52b23d9034cb6f9dd529b236c97', 'TITLE' => $title, 'PREVIEW' => $preview, 'FIELDS' => form_input_hidden('confirm', '1'), 'URL' => $url));
     }
     if (!is_null($member)) {
         ocf_ban_member(intval($member));
     }
     require_code('failure');
     add_ip_ban($ip);
     return inform_screen($title, do_lang_tempcode('SUCCESS'));
 }
Example #20
0
 /**
  * The UI and actualisation for: accepting code if it is correct (and not ''), and setting password to something random, emailing it
  *
  * @return tempcode		The UI
  */
 function step3()
 {
     $title = get_page_title('RESET_PASSWORD');
     $code = get_param('code', '');
     if ($code == '') {
         require_code('form_templates');
         $fields = new ocp_tempcode();
         $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', NULL, 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' => '6e4db5c6f3c75faa999251339533d22a', '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));
     }
     $username = get_param('username', NULL);
     if (!is_null($username)) {
         $username = trim($username);
         $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username);
         if (is_null($member)) {
             warn_exit(do_lang_tempcode('PASSWORD_RESET_ERROR_2'));
         }
     } else {
         $member = get_param_integer('member');
     }
     $correct_code = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_change_code');
     if ($correct_code == '') {
         $_reset_url = build_url(array('page' => '_SELF', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), '_SELF');
         $reset_url = $_reset_url->evaluate();
         warn_exit(do_lang_tempcode('PASSWORD_ALREADY_RESET', escape_html($reset_url), get_site_name()));
     }
     if ($code != $correct_code) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'date_and_time', array('the_type' => 'RESET_PASSWORD', 'param_a' => strval($member), 'param_b' => $code));
         if (!is_null($test)) {
             warn_exit(do_lang_tempcode('INCORRECT_PASSWORD_RESET_CODE'));
         }
         log_hack_attack_and_exit('HACK_ATTACK_PASSWORD_CHANGE');
     }
     $email = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_email_address');
     $new_password = get_rand_password();
     // Send password in mail
     $_login_url = build_url(array('page' => 'login', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), get_module_zone('login'), NULL, false, false, true);
     $login_url = $_login_url->evaluate();
     $message = do_lang('MAIL_NEW_PASSWORD', comcode_escape($new_password), $login_url, get_site_name());
     require_code('mail');
     mail_wrap(do_lang('RESET_PASSWORD'), $message, array($email), $GLOBALS['FORUM_DRIVER']->get_username($member), '', '', 3, NULL, false, NULL, false, false, false, 'MAIL', true);
     if (get_value('no_password_hashing') === '1') {
         $password_compatibility_scheme = 'plain';
         $new = $new_password;
     } else {
         $password_compatibility_scheme = '';
         $salt = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_pass_salt');
         $new = md5($salt . md5($new_password));
     }
     unset($_GET['code']);
     $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_password_change_code' => '', 'm_pass_hash_salted' => $new), array('id' => $member), '', 1);
     return inform_screen($title, do_lang_tempcode('NEW_PASSWORD_MAILED', escape_html($email)));
 }
Example #21
0
 /**
  * The UI actualiser edit the breadcrumbs XML file.
  *
  * @return tempcode		The UI
  */
 function _xml_breadcrumbs()
 {
     $title = get_page_title('BREADCRUMB_OVERRIDES');
     $myfile = @fopen(get_custom_file_base() . '/data_custom/breadcrumbs.xml', 'wt');
     if ($myfile === false) {
         intelligent_write_error(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
     }
     $xml = post_param('xml');
     if (fwrite($myfile, $xml) < strlen($xml)) {
         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
     }
     fclose($myfile);
     fix_permissions(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
     sync_file(get_custom_file_base() . '/data_custom/breadcrumbs.xml');
     return inform_screen($title, do_lang_tempcode('SUCCESS'));
 }
Example #22
0
 /**
  * The actualiser to set sound effects.
  *
  * @return tempcode		The UI
  */
 function _set_effects()
 {
     $title = get_page_title('CHAT_SET_EFFECTS');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY'))));
     require_code('uploads');
     // Find all our suffixes to check for
     $buddy_count = $GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)', array('member_likes' => get_member()));
     $suffixes = array();
     if ($buddy_count < 200) {
         $buddies = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('member_liked'), array('member_likes' => get_member()));
         $suffixes = array('');
         foreach ($buddies as $buddy) {
             if (is_null($GLOBALS['FORUM_DRIVER']->get_username($buddy['member_liked']))) {
                 continue;
             }
             $suffixes[] = '_' . strval($buddy['member_liked']);
         }
     }
     $current_settings = collapse_2d_complexity('s_effect_id', 's_url', $GLOBALS['SITE_DB']->query_select('chat_sound_effects', array('s_url', 's_effect_id'), array('s_member' => get_member())));
     // Process data
     foreach ($suffixes as $suffix) {
         $effects = get_effect_set($suffix != '');
         foreach ($effects as $effect) {
             if (is_null($effect)) {
                 continue;
             }
             if (post_param('select_' . $effect . $suffix) == '-1' && is_null(post_param('hidFileID_upload_' . $effect . $suffix, NULL)) && isset($_FILES['upload_' . $effect . $suffix]) && !is_uploaded_file($_FILES['upload_' . $effect . $suffix]['tmp_name'])) {
                 $url = '-1';
             } else {
                 $url_bits = get_url('select_' . $effect . $suffix, 'upload_' . $effect . $suffix, 'uploads/personal_sound_effects', 0, OCP_UPLOAD_MP3);
                 $url = $url_bits[0];
             }
             // Delete existing upload, if appropriate
             if (array_key_exists($effect . $suffix, $current_settings) && substr($current_settings[$effect . $suffix], 0, 31) == 'uploads/personal_sound_effects/' && $current_settings[$effect . $suffix] != $url) {
                 @unlink(get_custom_file_base() . '/' . filter_naughty($current_settings[$effect . $suffix]));
             }
             // Delete existing setting
             $GLOBALS['SITE_DB']->query_delete('chat_sound_effects', array('s_member' => get_member(), 's_effect_id' => $effect . $suffix));
             if ($url != '-1') {
                 // Add new setting
                 $GLOBALS['SITE_DB']->query_insert('chat_sound_effects', array('s_member' => get_member(), 's_effect_id' => $effect . $suffix, 's_url' => $url));
             }
         }
     }
     $redirect = post_param('redirect', NULL);
     if (is_null($redirect)) {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     } else {
         require_code('site2');
         assign_refresh($redirect, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '6bcc5c60f9b75e9dca719a5db8d24491', 'URL' => $redirect, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('SUCCESS')));
     }
 }
Example #23
0
 /**
  * The actualiser for recommending the site.
  *
  * @return tempcode	The UI.
  */
 function actual()
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('RECOMMEND_SITE'))));
     $name = post_param('name');
     $message = post_param('message');
     $recommender_email_address = post_param('recommender_email_address');
     $invite = false;
     if (addon_installed('captcha')) {
         require_code('captcha');
         enforce_captcha();
     }
     require_code('type_validation');
     $email_adrs_to_send = array();
     $names_to_send = array();
     foreach ($_POST as $key => $email_address) {
         if (substr($key, 0, 14) != 'email_address_') {
             continue;
         }
         if ($email_address == '') {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $email_address = stripslashes($email_address);
         }
         if (!is_valid_email_address($email_address)) {
             attach_message(do_lang_tempcode('INVALID_EMAIL_ADDRESS'), 'warn');
             return $this->gui();
         } else {
             $email_adrs_to_send[] = $email_address;
             $names_to_send[] = $email_address;
         }
         if (is_guest()) {
             break;
         }
     }
     $adrbook_emails = array();
     $adrbook_names = array();
     $adrbook_use_these = array();
     foreach ($_POST as $key => $email_address) {
         if (preg_match('#details_email_|details_name_|^use_details_#', $key) == 0) {
             continue;
         }
         if (preg_match('#details_email_#', $key) != 0) {
             if (get_magic_quotes_gpc()) {
                 $email_address = stripslashes($email_address);
             }
             if (is_valid_email_address($email_address)) {
                 $curr_num = intval(preg_replace('#details_email_#', '', $key));
                 $adrbook_emails[$curr_num] = $email_address;
             }
         }
         if (preg_match('#details_name_#', $key)) {
             $curr_num = intval(preg_replace('#details_name_#', '', $key));
             $adrbook_names[$curr_num] = $email_address;
         }
         if (preg_match('#^use_details_#', $key)) {
             $curr_num = intval(preg_replace('#use_details_#', '', $key));
             $adrbook_use_these[$curr_num] = $curr_num;
         }
     }
     //add emails from address book file
     foreach ($adrbook_use_these as $key => $value) {
         $cur_email = array_key_exists($key, $adrbook_emails) && strlen($adrbook_emails[$key]) > 0 ? $adrbook_emails[$key] : '';
         $cur_name = array_key_exists($key, $adrbook_names) && strlen($adrbook_names[$key]) > 0 ? $adrbook_names[$key] : '';
         if (strlen($cur_email) > 0) {
             $email_adrs_to_send[] = $cur_email;
             $names_to_send[] = strlen($cur_name) > 0 ? $cur_name : $cur_email;
         }
     }
     if (count($email_adrs_to_send) == 0) {
         warn_exit(do_lang_tempcode('ERROR_NO_CONTACTS_SELECTED'));
     }
     foreach ($email_adrs_to_send as $key => $email_address) {
         if (get_magic_quotes_gpc()) {
             $email_address = stripslashes($email_address);
         }
         if (post_param_integer('wrap_message', 0) == 1) {
             $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name())));
             $referring_username = is_guest() ? NULL : get_member();
             $_url = post_param_integer('invite', 0) == 1 ? build_url(array('page' => 'join', 'email_address' => $email_address, 'keep_referrer' => $referring_username), get_module_zone('join')) : build_url(array('page' => '', 'keep_referrer' => $referring_username), '');
             $url = $_url->evaluate();
             $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
             $_message = do_lang(post_param_integer('invite', 0) == 1 ? 'INVITE_MEMBER_MESSAGE' : 'RECOMMEND_MEMBER_MESSAGE', $name, $url, array(get_site_name(), $join_url)) . $message;
         } else {
             $title = get_page_title('RECOMMEND_LINK');
             $_message = $message;
         }
         if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest() && post_param_integer('invite', 0) == 1) {
             $invites = get_num_invites(get_member());
             if ($invites > 0) {
                 send_recommendation_email($name, $email_address, $_message, true, $recommender_email_address, post_param('subject', NULL), $names_to_send[$key]);
                 $GLOBALS['FORUM_DB']->query_insert('f_invites', array('i_inviter' => get_member(), 'i_email_address' => $email_address, 'i_time' => time(), 'i_taken' => 0));
                 $invite = true;
             }
         } elseif (get_option('is_on_invites') == '0' && get_forum_type() == 'ocf') {
             $GLOBALS['FORUM_DB']->query_insert('f_invites', array('i_inviter' => get_member(), 'i_email_address' => $email_address, 'i_time' => time(), 'i_taken' => 0));
         }
         if (!$invite) {
             send_recommendation_email($name, $email_address, $_message, false, $recommender_email_address, post_param('subject', NULL), $names_to_send[$key]);
         }
     }
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('RECOMMENDATION_MADE'));
 }
Example #24
0
 /**
  * Install geolocation data.
  *
  * @return tempcode		The UI, showing the result of the installation
  */
 function install_geolocation_data()
 {
     $title = get_page_title('INSTALL_GEOLOCATION_DATA');
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     $last = 104295 - 1;
     // Index of the last line in the IP_Country.txt file
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/installgeolocationdata';
     $test = $GLOBALS['SITE_DB']->query_value('ip_country', 'COUNT(*)');
     if ($test >= $last) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     //We need to read in IP_Country.txt, line-by-line, for x lines
     $lines = get_param_integer('lines', 2000);
     $position = get_param_integer('position', 0);
     $i = 0;
     if ($position == 0) {
         $GLOBALS['SITE_DB']->query_delete('ip_country');
     }
     $path = get_file_base() . '/data/modules/admin_stats/IP_Country.txt';
     $file = @fopen($path, 'rt');
     if ($file === false) {
         warn_exit(do_lang_tempcode('READ_ERROR', escape_html($path)));
     }
     $to_insert = array('begin_num' => array(), 'end_num' => array(), 'country' => array());
     while (!feof($file) && $i < $position + $lines) {
         $data = fgets($file, 1024);
         if ($data === false) {
             break;
         }
         if ($i >= $position) {
             $_data = explode(',', $data);
             if (count($_data) == 3) {
                 $to_insert['begin_num'][] = $_data[0];
                 // FUDGEFUDGE. Intentionally passes in as strings, to workaround problem in PHP integer sizes (can't store unsigned data type)
                 $to_insert['end_num'][] = $_data[1];
                 $to_insert['country'][] = substr($_data[2], 0, 2);
                 if (count($to_insert['begin_num']) == 100) {
                     $GLOBALS['SITE_DB']->query_insert('ip_country', $to_insert);
                     $to_insert = array('begin_num' => array(), 'end_num' => array(), 'country' => array());
                 }
             }
         }
         $i++;
     }
     fclose($file);
     fix_permissions($path);
     if (count($to_insert['begin_num']) != 0) {
         $GLOBALS['SITE_DB']->query_insert('ip_country', $to_insert);
     }
     if ($i >= $last) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS'))));
     global $FORCE_META_REFRESH;
     $FORCE_META_REFRESH = true;
     require_code('site2');
     assign_refresh(build_url(array('page' => '_SELF', 'type' => 'install_data', 'lines' => $lines, 'position' => $position + $lines), 'adminzone'), $position == 0 ? 1.0 : 0.0);
     return inform_screen($title, do_lang_tempcode('INSTALLING_GEOLOCATION_DATA'));
 }
Example #25
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 #26
0
 /**
  * The actualiser to import wordpress blog
  *
  * @return tempcode		The UI
  */
 function _import_wordpress()
 {
     check_specific_permission('mass_import', NULL, NULL, 'cms_news');
     $title = get_page_title('IMPORT_WP_DB');
     require_code('rss');
     require_code('news');
     require_code('news2');
     $GLOBALS['LAX_COMCODE'] = true;
     require_code('uploads');
     is_swf_upload(true);
     $is_validated = post_param_integer('wp_auto_validate', 0);
     $to_own_account = post_param_integer('wp_add_to_own', 0);
     //Wordpress post xml file importing method
     if (get_param('method') == 'xml') {
         $rss_url = post_param('xml_url', NULL);
         if (array_key_exists('file_novalidate', $_FILES)) {
             if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
                 $rss_url = $_FILES['file_novalidate']['tmp_name'];
             } else {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         $rss = new rss($rss_url, true);
         if (!is_null($rss->error)) {
             warn_exit($rss->error);
         }
         $cat_id = NULL;
         $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
         $NEWS_CATS = list_to_map('id', $NEWS_CATS);
         $extra_post_data = array();
         foreach ($rss->gleamed_items as $item) {
             if (!array_key_exists('category', $item)) {
                 $item['category'] = do_lang('NC_general');
             }
             $extra_post_data[] = $item;
             foreach ($NEWS_CATS as $_cat => $news_cat) {
                 if (get_translated_text($news_cat['nc_title']) == $item['category']) {
                     $cat_id = $_cat;
                 }
             }
             //Check for existing owner categories, if not create blog category for creator
             if ($to_own_account == 0) {
                 $creator = $item['author'];
                 $submitter_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($creator);
             } else {
                 $submitter_id = get_member();
             }
             //if(is_null($submitter_id))	continue;	//Skip importing posts of nonexisting users
             $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter_id));
             if (is_null($cat_id)) {
                 $cat_id = add_news_category($item['category'], 'newscats/general', '', NULL);
                 $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
                 $NEWS_CATS = list_to_map('id', $NEWS_CATS);
             }
             // Add news
             add_news($item['title'], html_to_comcode($item['news']), NULL, $is_validated, 1, 1, 1, '', array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '', $owner_category_id, array($cat_id), NULL, $submitter_id, 0, time(), NULL, '');
         }
         if (url_is_local($rss_url)) {
             // Means it is a temp file
             @unlink($rss_url);
         }
     } elseif (get_param('method') == 'db') {
         import_wordpress_db();
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_BLOGS')), array('_SELF:_SELF:import_wordpress', do_lang_tempcode('IMPORT_WORDPRESS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('IMPORT_WORDPRESS_DONE'));
 }
Example #27
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 #28
0
 /**
  * Payment step.
  *
  * @param  tempcode	The page title.
  * @return tempcode	The result of execution.
  */
 function pay($title)
 {
     $product = get_param('product');
     $object = find_product($product);
     if (method_exists($object, 'is_available') && !$object->is_available($product, get_member())) {
         warn_exit(do_lang_tempcode('PRODUCT_UNAVAILABLE'));
     }
     $temp = $object->get_products(true, $product);
     $price = $temp[$product][1];
     $item_name = $temp[$product][4];
     if (method_exists($object, 'set_needed_fields')) {
         $purchase_id = $object->set_needed_fields($product);
     } else {
         $purchase_id = strval(get_member());
     }
     if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
         $_purchase_id = $GLOBALS['SITE_DB']->query_value_null_ok('subscriptions', 'id', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new'));
         if (is_null($_purchase_id)) {
             $purchase_id = strval($GLOBALS['SITE_DB']->query_insert('subscriptions', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new', 's_amount' => $temp[$product][1], 's_special' => $purchase_id, 's_time' => time(), 's_auto_fund_source' => '', 's_auto_fund_key' => '', 's_via' => get_option('payment_gateway')), true));
         } else {
             $purchase_id = strval($_purchase_id);
         }
         $length = array_key_exists('length', $temp[$product][3]) ? $temp[$product][3]['length'] : 1;
         $length_units = array_key_exists('length_units', $temp[$product][3]) ? $temp[$product][3]['length_units'] : 'm';
     } else {
         $length = NULL;
         $length_units = '';
         //Add cataloue item order to shopping_orders
         if (method_exists($object, 'add_purchase_order')) {
             $purchase_id = strval($object->add_purchase_order($product, $temp[$product]));
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING'))));
     if ($price == '0') {
         $payment_status = 'Completed';
         $reason_code = '';
         $pending_reason = '';
         $mc_currency = get_option('currency');
         $txn_id = 'manual-' . substr(uniqid('', true), 0, 10);
         $parent_txn_id = '';
         $memo = 'Free';
         $mc_gross = '';
         handle_confirmed_transaction($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
         return inform_screen($title, do_lang_tempcode('FREE_PURCHASE'));
     }
     if (!array_key_exists(4, $temp[$product])) {
         $item_name = do_lang('CUSTOM_PRODUCT_' . $product, NULL, NULL, NULL, get_site_default_lang());
     }
     if (!perform_local_payment()) {
         if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
             $transaction_button = make_subscription_button($product, $item_name, $purchase_id, floatval($price), $length, $length_units, get_option('currency'));
         } else {
             $transaction_button = make_transaction_button($product, $item_name, $purchase_id, floatval($price), get_option('currency'));
         }
         $tpl = $temp[$product][0] == PRODUCT_SUBSCRIPTION ? 'PURCHASE_WIZARD_STAGE_SUBSCRIBE' : 'PURCHASE_WIZARD_STAGE_PAY';
         $logos = method_exists($object, 'get_logos') ? $object->get_logos() : new ocp_tempcode();
         $result = do_template($tpl, array('LOGOS' => $logos, 'TRANSACTION_BUTTON' => $transaction_button, 'CURRENCY' => get_option('currency'), 'ITEM_NAME' => $item_name, 'TITLE' => $title, 'LENGTH' => is_null($length) ? '' : strval($length), 'LENGTH_UNITS' => $length_units, 'PURCHASE_ID' => $purchase_id, 'PRICE' => float_to_raw_string(floatval($price))));
     } else {
         if (!tacit_https() && !ecommerce_test_mode()) {
             warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
         }
         $fields = get_transaction_form_fields(NULL, $purchase_id, $item_name, float_to_raw_string($price), $temp[$product][0] == PRODUCT_SUBSCRIPTION ? intval($length) : NULL, $temp[$product][0] == PRODUCT_SUBSCRIPTION ? $length_units : '');
         /*$via		=	get_option('payment_gateway');
         		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
         		$object	=	object_factory('Hook_'.$via);
         		$ipn_url	=	$object->get_ipn_url();*/
         $finish_url = build_url(array('page' => '_SELF', 'type' => 'finish'), '_SELF');
         $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('_GUID' => '15cbba9733f6ff8610968418d8ab527e', 'FIELDS' => $fields));
         return $this->wrap($result, $title, $finish_url);
     }
     return $this->wrap($result, $title, NULL);
 }
 /**
  * Show value statistics for a custom profile field (choose).
  *
  * @return tempcode		The UI
  */
 function stats()
 {
     $title = get_page_title('CUSTOM_PROFILE_FIELD_STATS');
     breadcrumb_set_parents(array());
     $fields = new ocp_tempcode();
     $rows = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_name', 'cf_type'));
     require_code('form_templates');
     require_code('fields');
     $list = new ocp_tempcode();
     $_list = array();
     foreach ($rows as $row) {
         $ob = get_fields_hook($row['cf_type']);
         list(, , $storage_type) = $ob->get_field_value_row_bits(NULL);
         if (strpos($storage_type, '_trans') === false) {
             $id = $row['id'];
             $text = get_translated_text($row['cf_name'], $GLOBALS['FORUM_DB']);
             $_list[$id] = $text;
         }
     }
     asort($_list);
     foreach ($_list as $id => $text) {
         $list->attach(form_input_list_entry(strval($id), false, $text));
     }
     if ($list->is_empty()) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     require_lang('dates');
     $fields->attach(form_input_list(do_lang_tempcode('NAME'), '', 'id', $list));
     $fields->attach(form_input_date(do_lang_tempcode('FROM'), do_lang_tempcode('DESCRIPTION_MEMBERS_JOINED_FROM'), 'start', true, false, false, time() - 60 * 60 * 24 * 30, 10, intval(date('Y')) - 10));
     $fields->attach(form_input_date(do_lang_tempcode('TO'), do_lang_tempcode('DESCRIPTION_MEMBERS_JOINED_TO'), 'end', true, false, false, time(), 10, intval(date('Y')) - 10));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_stats'), '_SELF', NULL, false, true);
     $submit_name = do_lang_tempcode('CUSTOM_PROFILE_FIELD_STATS');
     return do_template('FORM_SCREEN', array('_GUID' => '393bac2180c9e135ae9c31565ddf7761', 'GET' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => '', 'FIELDS' => $fields, 'TEXT' => '', 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
 }
Example #30
0
 /**
  * The actualiser to import ical for calendar
  *
  * @return tempcode		The UI
  */
 function _import_ical()
 {
     check_specific_permission('mass_import');
     $title = get_page_title('IMPORT_ICAL');
     require_code('calendar_ical');
     $ical_url = post_param('ical_feed_url', NULL);
     require_code('uploads');
     if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
         $ical_url = $_FILES['file_novalidate']['tmp_name'];
     }
     if (is_null($ical_url)) {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
     }
     ical_import($ical_url);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_CALENDARS')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_ICAL'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('IMPORT_ICAL_DONE'));
 }