Example #1
0
 public function _new($forum_id, $title, $category_id)
 {
     $this->title($this('new_topic'))->_breadcrumb($category_id, $forum_id)->breadcrumb($this('new_topic'))->css('wbbtheme')->js('jquery.wysibb.min')->js('jquery.wysibb.fr')->js_load('$(\'textarea.editor\').wysibb({lang: "fr"});')->load->library('form')->add_rules(array('title' => array('rules' => 'required'), 'message' => array('type' => 'editor', 'rules' => 'required')));
     if ($this->access('forum', 'category_announce', $category_id)) {
         $this->form->add_rules(array('announce' => array('type' => 'checkbox')));
     }
     if ($this->form->is_valid($post)) {
         $topic_id = $this->model()->add_topic($forum_id, $post['title'], $post['message'], !empty($post['announce']) && in_array('on', $post['announce']));
         add_alert('Succes', 'Sujet ajouté');
         redirect('forum/topic/' . $topic_id . '/' . url_title($post['title']) . '.html');
     }
     $panels = array();
     if ($errors = $this->form->get_errors()) {
         $panels[] = new Row(new Col(new Panel(array('title' => $this('fill_all_fields'), 'icon' => 'fa-warning', 'style' => 'panel-danger'))));
     }
     $panels[] = new Panel(array('title' => $this('new_topic'), 'icon' => 'fa-file-text-o', 'body' => FALSE, 'content' => $this->load->view('new', array('form_id' => $this->form->id, 'forum_id' => $forum_id, 'category_id' => $category_id, 'title' => $title))));
     return $panels;
 }
Example #2
0
 public function create($group_id = 2)
 {
     // Initialize
     global $template, $config;
     // Validate profile
     $this->validate_profile();
     if ($template->has_errors == 1) {
         return 0;
     }
     // Set variables
     $reg_ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     $full_name = isset($_POST['full_name']) ? $_POST['full_name'] : '';
     // Get custom fields
     $custom_fields = array();
     $rows = DB::query("SELECT * FROM users_custom_fields ORDER BY id");
     foreach ($rows as $row) {
         $var = 'custom' . $row['id'];
         if (!isset($_POST[$var])) {
             continue;
         }
         $custom_fields[$var] = $_POST[$var];
     }
     // Add to DB
     DB::insert('users', array('username' => $_POST['username'], 'full_name' => $full_name, 'email' => $_POST['email'], 'password' => '*', 'group_id' => $group_id, 'reg_ip' => $reg_ip, 'custom_fields' => serialize($custom_fields)));
     $this->userid = DB::insertId();
     // Update password
     $client = new encrypt();
     $password = $client->get_password_hash($_POST['password'], $this->userid);
     DB::update('users', array('password' => $password), "id = %d", $this->userid);
     // Add alerts
     add_alert('new_user', $this->userid);
     // Execute hooks
     execute_hooks('new_user', $this->userid);
     // Return
     return $this->userid;
 }
Example #3
0
    $details["email"] = trim(get_http_var("email"));
}
// MJ OA_437 add reccomend arg to indicate this alert is by way of a recommendation
$details['recommended'] = trim(get_http_var("r"));
$details['keyword'] = trim(get_http_var("keyword"));
$details['pid'] = trim(get_http_var("pid"));
if ($details['pid'] == 'Any') {
    $details['pid'] = '';
}
// Check the input.
// If there are any errors with the submission, $errors (an array)
// will have elements. The keys will be the name of form elements,
// and the values will be text to display when we show the form again.
$errors = check_input($details);
if (!sizeof($errors) && (get_http_var('submitted') && ($details['keyword'] || $details['pid']) || get_http_var('only') && ($details['keyword'] || $details['pid']) || $details['keyword'] && $details['pid'])) {
    add_alert($details);
} else {
    $PAGE->page_start();
    $PAGE->stripe_start();
    $PAGE->block_start(array('id' => 'alerts', 'title' => 'Request an OpenAustralia.org Email Alert'));
    display_form($details, $errors);
    $PAGE->block_end();
    $end = array();
    if (!get_http_var('only') || !$details['pid'] || $details['keyword']) {
        $end[] = array('type' => 'include', 'content' => 'search');
    }
    $PAGE->stripe_end($end);
    $PAGE->page_end();
}
function check_input($details)
{
Example #4
0
 public function add_input($address, $amount, $txid, $vout, $scriptsig = '', $confirmations = 0, $blocknum = 0)
 {
     // Initialize
     global $config;
     // Check mempool
     if ($row = DB::queryFirstRow("SELECT * FROM coin_mempool WHERE txid = %s AND vout = %d", $txid, $vout)) {
         return false;
     }
     DB::insert('coin_mempool', array('txid' => $txid, 'vout' => $vout));
     // Get address
     if (!($addr_row = DB::queryFirstRow("SELECT * FROM coin_addresses WHERE address = %s", $address))) {
         return false;
     }
     $is_confirmed = $confirmations >= $config['btc_minconf'] || $addr_row['is_change_address'] == 1 ? 1 : 0;
     // Check for invoice
     $product_id = 0;
     $invoice_id = 0;
     $order_id = 0;
     $order_complete = false;
     $overpayment = 0;
     if ($irow = DB::queryFirstRow("SELECT * FROM invoices WHERE payment_address = %s", $address)) {
         $invoice_id = $irow['id'];
         // Check for order
     } elseif ($prow = DB::queryFirstRow("SELECT * FROM coin_pending_payment WHERE payment_address = %s", $address)) {
         $prow['amount_received'] += $amount;
         if ($prow['amount_received'] >= $prow['amount_btc']) {
             DB::query("UPDATE coin_pending_payment SET status = 'approved', amount_received = amount_received + %d WHERE id = %d", $amount, $prow['id']);
             if ($prow['item_id'] > 0) {
                 $order_complete = true;
             }
         } else {
             DB::query("UPDATE coin_pending_payment SET amount_received = amount_received + %d WHERE id = %d", $amount, $prow['id']);
         }
         $product_id = $prow['item_id'];
         if ($prow['amount_received'] > $prow['amount_btc']) {
             $overpayment = $prow['amount_received'] - $prow['amount_btc'];
         }
     }
     // Check if exists
     if ($row = DB::queryFirstRow("SELECT * FROM coin_inputs WHERE txid = %s AND vout = %d", $txid, $vout)) {
         return false;
     }
     // Update invoice, if needed
     if ($invoice_id > 0) {
         $irow['amount_paid'] += $amount;
         $updates = array('amount_paid' => $irow['amount_paid']);
         if ($irow['amount_paid'] >= $irow['amount_btc']) {
             $updates['status'] = 'paid';
             $updates['date_paid'] = DB::sqleval('now()');
             DB::update('invoices', $updates, "id = %d", $invoice_id);
             if ($irow['amount_paid'] > $irow['amount_btc']) {
                 $overpayment = $irow['amount_paid'] - $irow['amount_btc'];
             }
         }
         // Add order, if needed
     } elseif ($order_complete === true) {
         DB::insert('orders', array('userid' => $addr_row['userid'], 'product_id' => $product_id, 'amount' => $prow['amount'], 'amount_btc' => $prow['amount_btc']));
         $order_id = DB::insertId();
     }
     // Add to DB
     $hash = $txid . ':' . $vout;
     DB::insert('coin_inputs', array('userid' => $addr_row['userid'], 'wallet_id' => $addr_row['wallet_id'], 'product_id' => $product_id, 'order_id' => $order_id, 'invoice_id' => $invoice_id, 'is_confirmed' => $is_confirmed, 'is_change' => $addr_row['is_change_address'], 'confirmations' => $confirmations, 'blocknum' => $blocknum, 'address' => $address, 'txid' => $txid, 'vout' => $vout, 'amount' => $amount, 'hash' => $hash));
     $input_id = DB::insertId();
     // Mark address as used
     DB::query("UPDATE coin_addresses SET is_used = 1, total_input = total_input + %d WHERE address = %s", $amount, $address);
     // Add overpayment, if needed
     if ($overpayment != 0) {
         DB::insert('coin_overpayments', array('userid' => $addr_row['userid'], 'input_id' => $input_id, 'amount_btc' => $overpayment));
     }
     // Add alerts
     if ($product_id > 0) {
         add_alert('product_purchase', $input_id, $amount);
     } elseif ($invoice_id > 0) {
         add_alert('invoice_paid', $input_id, $amount);
     } elseif ($addr_row['is_change_address'] != 1) {
         add_alert('new_deposit', $input_id, $amount);
     }
     // Process notifications
     if ($addr_row['is_change_address'] != 1) {
         send_notifications('new_deposit', $input_id);
     }
     if ($product_id > 0) {
         send_notifications('product_purchase', $input_id);
     }
     if ($invoice_id > 0) {
         send_notifications('invoice_paid', $input_id);
     }
     // Execute hooks, as needed
     if ($addr_row['is_change_address'] != 1) {
         execute_hooks('new_deposit', $input_id);
     }
     if ($is_confirmed == 1) {
         execute_hooks('confirmed_deposit', $input_id);
     }
     if ($product_id > 0) {
         execute_hooks('product_purchased', $input_id, $product_id);
     }
     if ($invoice_id > 0) {
         execute_hooks('invoice_paid', $input_id);
     }
     // Return
     return $input_id;
 }
Example #5
0
function do_change_theme_round()
{
    if ($_POST['xsrf_token'] != $_SESSION['xsrf_token']) {
        trigger_error('XSRF code incorrect', E_USER_ERROR);
    }
    if (!scoring_is_enabled()) {
        header('Location: ../Scoring_Frozen');
        die;
    }
    $score = intval($_POST['score']);
    if ($_POST['hasValue'] == 'Yes') {
        $score = $_POST['score'];
        $score_msg = validate_theme_score($score);
        if ($score_msg !== true) {
            display_individual($score_msg, 'document.forms[\'lmtDataThemeRoundScore\'].score.focus();');
        }
        DB::queryRaw('UPDATE individuals SET score_theme="' . mysqli_real_escape_string(DB::get(), $score) . '" WHERE id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" AND (score_theme <> "' . mysqli_real_escape_string(DB::get(), $score) . '" OR score_theme IS NULL) LIMIT 1');
    } else {
        DB::queryRaw('UPDATE individuals SET score_theme=NULL WHERE id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" AND score_theme IS NOT NULL LIMIT 1');
    }
    global $LMT_DB;
    if (mysqli_affected_rows($LMT_DB) == 1) {
        add_alert('lmt_data_individual_update_theme_score', 'Theme round score was changed');
    }
    header('Location: Individual?ID=' . $_GET['ID']);
}
Example #6
0
# If the above search returned one result for member or constituency search,
# use it immediately
if (isset($details['members']) && $details['members']->rows() == 1) {
    $details['pid'] = $details['members']->field(0, 'person_id');
    unset($details['members']);
    $details['alertsearch'] = '';
}
if (isset($details['constituencies']) && count($details['constituencies']) == 1 && $details['valid_postcode']) {
    $MEMBER = new MEMBER(array('constituency' => $details['constituencies'][0], 'house' => 1));
    $details['pid'] = $MEMBER->person_id();
    $details['pc'] = $details['alertsearch'];
    unset($details['constituencies']);
    $details['alertsearch'] = '';
}
if (!sizeof($errors) && ($details['keyword'] || $details['pid'])) {
    $message = add_alert($details);
    $details['keyword'] = '';
    $details['pid'] = '';
    $details['alertsearch'] = '';
    $details['pc'] = '';
}
$PAGE->page_start();
$PAGE->stripe_start();
if ($message) {
    $PAGE->informational($message);
}
$sidebar = null;
if ($details['email_verified']) {
    ob_start();
    if ($THEUSER->postcode()) {
        $current_mp = new MEMBER(array('postcode' => $THEUSER->postcode()));
Example #7
0
function do_set_team_round_long()
{
    if ($_POST['xsrf_token'] != $_SESSION['xsrf_token']) {
        trigger_error('XSRF code incorrect', E_USER_ERROR);
    }
    if (!scoring_is_enabled()) {
        header('Location: ../Scoring_Frozen');
        die;
    }
    if ($_POST['teamRoundLongHasValue'] == 'Yes') {
        $score = $_POST['teamRoundLongScore'];
        $score_msg = validate_team_long_score($score);
        if ($score_msg !== true) {
            display_team($score_msg, 'document.forms[\'lmtDataTeamRoundLongScore\'].teamRoundLongScore.focus();');
        }
        DB::queryRaw('UPDATE teams SET score_team_long="' . mysqli_real_escape_string(DB::get(), $score) . '" WHERE team_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" AND (score_team_long <> "' . mysqli_real_escape_string(DB::get(), $score) . '" OR score_team_long IS NULL) LIMIT 1');
    } else {
        DB::queryRaw('UPDATE teams SET score_team_long=NULL WHERE team_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" AND score_team_long IS NOT NULL LIMIT 1');
    }
    global $LMT_DB;
    if (mysqli_affected_rows($LMT_DB) == 1) {
        add_alert('lmt_data_team_update_team_score_long', 'Team round long answer score was changed');
    }
    header('Location: Team?ID=' . $_GET['ID']);
}