Example #1
0
 function process()
 {
     global $lr_session;
     $payments = array();
     $paypal = new PaypalHandler();
     $talkback_results = $paypal->talkback('pdt');
     if (!$talkback_results || $talkback_results['status'] == false) {
         return false;
     }
     // confirm that data from PayPal matches registrations
     $item_numbers = preg_grep_keys('/item_number[0-9]*/', $talkback_results['message']);
     foreach ($item_numbers as $key => $value) {
         // get current Item # from PayPal, which is the last character in $key
         $item = substr($key, -1);
         $status = $paypal->validatePayment($value, $talkback_results['message']['mc_gross_' . $item], $lr_session->user->user_id);
         if ($status['status'] == false) {
             error_exit($status['message']);
         } else {
             // PaymentRegistration object passed back in message on success
             array_push($payments, $status['message']);
         }
     }
     // output confirmation view
     $this->smarty->assign('payments', $payments);
     $this->smarty->assign('order_id_format', variable_get('order_id_format', '%d'));
     $this->title = 'Registration ' . $this->registration->formatted_order_id() . '- Payment Received';
     $this->template_name = 'pages/registration/paypal.tpl';
     return true;
 }
Example #2
0
function trouverVilleIlleEtVilaine($monCp)
{
    $villesIlleEtVilaine = villeIlleEtVilaine();
    $length = 5 - intval(strlen($monCp));
    $completionRegexp = $length == 0 ? "" : str_repeat("\\d", $length);
    $regexp = "/^{$monCp}{$completionRegexp}\$/";
    $villeMatch = preg_grep_keys($regexp, $villesIlleEtVilaine);
    return json_encode(array_values($villeMatch));
}
Example #3
0
function expandTemplate($containerArrayTemplate)
{
    global $XMLarray;
    $containerArray = array();
    foreach ($containerArrayTemplate as $container) {
        if (strpos($container, "|n*|")) {
            $base = trim(preg_replace("/(.*?)\\|n\\*\\|.*/u", '${1}', $container));
            $n_array = $XMLarray['node_export']['node'][$base];
            $n_keys_array = array_keys(preg_grep_keys("/n[0-9]+/u", $n_array));
            foreach ($n_keys_array as $oneKey) {
                $replacement = "|{$oneKey}|";
                $term = preg_replace("/\\|n\\*\\|/u", $replacement, $container);
                $containerArray[] = $term;
            }
        } else {
            $containerArray[] = $container;
        }
    }
    return $containerArray;
}
 public function validate_options($input)
 {
     $new_input = $input;
     $db_options = get_option('wpUI_options');
     $reset = !empty($input['reset']) ? true : false;
     if ($reset) {
         $defaults = get_wpui_default_options();
         return $defaults;
     }
     $reset_tmpls = preg_grep_keys('/^reset_post_template_[3-9]{1,2}$/', $input);
     if ($reset_tmpls) {
         foreach ($reset_tmpls as $tmpls => $data) {
             $template_num = str_ireplace('reset_', '', $tmpls);
             unset($new_input[$template_num]);
         }
     }
     if (!empty($input['script_conditionals'])) {
         $cond = $input['script_conditionals'];
         if (preg_match('/(x=x\\s--|1=1|Or\\s?1=1\\s--|$_GET|SELECT|DROP\\sTABLE|base64)/im', $cond)) {
             wp_die('UN SAFE code detected in the conditionals.');
         }
     }
     foreach ($this->fields as $option => $opt) {
         if ($opt['type'] == 'checkbox' && !isset($input[$opt['id']])) {
             $new_input[$opt['id']] = 'off';
         }
     }
     $new_input['version'] = WPUI_VER;
     /*		die();*/
     /*		parent::validate_options( $input );*/
     return $new_input;
 }
Example #5
0
function pdf_heap_dump()
{
    global $g_canvas;
    $g_canvas->writeSection("Heap Dump");
    $dump = pdf_load_json_dump("Resin|HeapDump");
    if (!$dump) {
        $g_canvas->setTextFont();
        $g_canvas->newLine();
        $g_canvas->writeTextLineIndent(20, "A heap dump was not generated during the selected timeframe.");
        return;
    }
    $heap =& $dump["heap"];
    if (!$heap || !sizeof($heap)) {
        $g_canvas->setTextFont();
        $g_canvas->newLine();
        $g_canvas->writeTextLineIndent(20, "A heap dump was not generated during the selected timeframe.");
        return;
    }
    $timestamp = create_timestamp($dump);
    $g_canvas->setFont("Courier-Bold", "8");
    $g_canvas->writeTextLine("Timestamp: {$timestamp}");
    $primitive_filter = "/^(byte|short|int|long|float|double|boolean|char)\\[\\]/";
    $java_filter = "/^(java|javax|sun|com\\.sun)\\./";
    $caucho_filter = "/^com\\.caucho\\./";
    $classloader_filter = "/classloader/i";
    pdf_selected_heap_dump($heap, "Top Classes by Memory Usage", 59);
    $primitive_heap = preg_grep_keys($primitive_filter, $heap);
    pdf_selected_heap_dump($primitive_heap, "Primitive Memory Usage ", 50);
    $classloader_heap = preg_grep_keys($classloader_filter, $heap);
    pdf_selected_heap_dump($classloader_heap, "ClassLoader Memory Usage ", 50);
    $user_heap = preg_grep_keys($primitive_filter, $heap, 1);
    $user_heap = preg_grep_keys($java_filter, $user_heap, 1);
    $user_heap = preg_grep_keys($caucho_filter, $user_heap, 1);
    pdf_selected_heap_dump($user_heap, "User Memory Usage ", 50);
}
Example #6
0
function bi_HandleBlockIP($src, $auth = 'comment-approve')
{
    //action=bi_bip
    global $bi_Pages;
    $result = array('msg' => XL('Unable to block IP address.'), 'result' => 'error');
    if (PageTextVar($src, 'entrytype') == 'comment' && bi_Auth($auth . ' ' . $src)) {
        if ($_GET['bi_ip'] > '') {
            //either we have an IP, or need to find one
            Lock(2);
            $old = RetrieveAuthPage($bi_Pages['blocklist'], 'edit', false, READPAGE_CURRENT);
            if ($old) {
                $ip = explode(',', $_GET['bi_ip']);
                $blocked = array();
                $already = array();
                foreach ($ip as $key) {
                    //check to see if ip is already blocked
                    if (!preg_match('/\\nblock:' . preg_replace(array('/\\./', '/\\*/'), array('\\.', '\\*'), $key) . '\\n/', $old['text'])) {
                        $new = $old;
                        $blocked[] = $key;
                        $new['text'] .= (substr($new['text'], -1, 1) != "\n" ? "\n" : '') . 'block:' . $key . "\n";
                        //add newline to end of file, and then blocked ip
                    } else {
                        $already[] = $key;
                    }
                }
                if (!empty($blocked)) {
                    PostPage($bi_Pages['blocklist'], $old, $new);
                }
                $result = array('msg' => (!empty($blocked) ? XL('Blocked IP address: ') . implode(',', $blocked) : '') . (!empty($blocked) && !empty($already) ? '<br />' : '') . (!empty($already) ? XL('IP address is already being blocked: ') . implode(',', $already) : ''), 'result' => 'success');
                //removed , 'ip'=>$_GET['bi_ip'], not used
            } else {
                $result = array('result' => 'error', 'msg' => XL('Cannot edit ') . $bi_Pages['blocklist']);
            }
        } else {
            //No IP passed in, so determine who created page
            $ip = array();
            $pages = bi_GetPages($src);
            foreach ($pages as $p) {
                $page = RetrieveAuthPage($p, 'read', false);
                //read history
                if ($page) {
                    $x = preg_grep_keys('/^host:.*$/', $page, -1);
                    //find the last occurence of host: which stores creator IP
                    $ip[$x] = $x;
                    //store as key/value to ensure we don't store same IP multiple times
                }
                $result = array('result' => !$ip ? 'error' : 'success', 'ip' => implode($ip, "\n"), 'msg' => !$ip ? XL('Unable to determine IP address.') : '');
            }
        }
    }
    bi_Redirect(bi_Clean('mode', $_GET['bi_Mode']), $result);
}
Example #7
0
function getTypeArray($q)
{
    $x = preg_grep_keys("/t{$q}\\_\\d/", $_POST);
    unset($x["t" . $q . "_0"]);
    return $x;
}
Example #8
0
    return htmlspecialchars(trim($input));
}
header('Content-Type: application/json; Charset=UTF-8');
// Sanitize all the incoming data
$_POST = array_map('sanitize', $_POST);
$error_message = [];
if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'localhost') === FALSE && strpos($_SERVER['HTTP_REFERER'], 'ftof.herokuapp.com') === FALSE && strpos($_SERVER['HTTP_REFERER'], 'family2family.eu') === FALSE) {
    $error_message[] = "Technical error: not allowed to perform this action";
    goto theExit;
}
if (!isset($_POST['id']) || !(intval($_POST['id']) > 0)) {
    $error_message[] = "Technical error: unknown profile id";
    goto theExit;
}
$id = intval($_POST['id']);
$services = array_map("intval", preg_grep_keys("/service__\\d+/", $_POST));
if (!count($services) > 0) {
    $error_message[] = "You should select at least one service";
    goto theExit;
}
$qparams = [];
$sql = "select p.name, p.email, service_type, period, price_fix, price_per_day, service_desc " . "from offered_service s, profile p " . "where s.profile_id = :id " . "and s.profile_id = p.id " . "and available = TRUE " . "and s.service_type in (" . implode($services, ', ') . ")";
$qparams[":id"] = $id;
$q = $db->prepare($sql);
$q->execute($qparams);
$servicelist = [];
$overall_price = 0;
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
    $dest_name = $row['name'];
    $dest_email = $row['email'];
    $datespair = parse_and_validate_dates($_POST['arrival__' . $row['service_type']], $_POST['departure__' . $row['service_type']]);
Example #9
0
 /**
  * Handles IPN messages.  IPN does not require a full UI, so it's a modified Handler
  *
  *  @return Status information on success or failure of the message handling
  */
 function process()
 {
     $status = array();
     $payments = array();
     // Get details back from PayPal
     $talkback_results = $this->talkback('ipn');
     if ($talkback_results['status'] != true) {
         $status = array('status' => false, 'message' => $talkback_results['message']);
         return $status;
     }
     // Check response for correct data
     if ($talkback_results['message']['payment_status'] != 'Completed') {
         $status = array('status' => false, 'message' => 'Payment status != Completed');
         return $status;
     }
     if (variable_get('paypal_url', '')) {
         $receiver_email = variable_get('paypal_sandbox_email', '');
     } else {
         $receiver_email = variable_get('paypal_live_email', '');
     }
     if ($talkback_results['message']['receiver_email'] != $this->account_email) {
         $status = array('status' => false, 'message' => 'Receiver Email does not match');
         return $status;
     }
     // basic data is confirmed, update db as required
     $item_numbers = preg_grep_keys('/item_number[0-9]*/', $talkback_results['message']);
     foreach ($item_numbers as $key => $value) {
         // get current Item # from PayPal, which is the last character in $key
         $item = substr($key, -1);
         // TODO FIXME Need some way to get a PayPal user account
         $status = $this->validatePayment($value, $talkback_results['message']['mc_gross_' . $item], 999);
         if ($status['status'] == false) {
             return $status;
         } else {
             // PaymentRegistration object passed back in message on success
             $payments[] = $status['message'];
         }
     }
     // successfully processed all payments, return to caller for output
     return array('status' => true, 'message' => $payments);
 }