function xpress_debug($title = '',$ditail_show = false) { $module_dirpath = dirname(dirname(__FILE__)); $root_path = dirname(dirname(dirname(dirname(__FILE__)))); $_debug_file = $module_dirpath . '/wp-content/xpress_debug.log'; $_fp = fopen($_debug_file, 'a'); $stamp = date("Y/m/d G:i:s" , time()); $backtraces = array_reverse(debug_backtrace()); fwrite($_fp, "\n*********************************************************************************************************\n"); fwrite($_fp, $title . '(' . $stamp . ")\n"); fwrite($_fp, '$_SERVER[]' . "\n"); $srerver = "\t" . str_replace("\n","\n\t",sprint_r($_SERVER)); fwrite($_fp, $srerver . "\n\n"); fwrite($_fp, "BACK TRACE" . "\n"); foreach($backtraces as $backtrace){ $trace = $backtrace['file']. "\tLINE(" . $backtrace['line'] . ")\t" . $backtrace['function'] . "()\n"; $trace = str_replace($root_path,"",$trace); $trace = str_replace("\\","/",$trace); $trace = str_replace($root_path,"",$trace); $trace = "\t" . $trace; $trace_ditail = "\t" . str_replace("\n","\n\t\t",sprint_r($backtrace)); if ($ditail_show) fwrite($_fp, $trace . $trace_ditail . "\n"); else fwrite($_fp, $trace . "\n"); } fclose($_fp); }
public function is_valid_action() { $action = $_GET["action"]; debug("action=" . $action); debug("actions=" . sprint_r($this->actions)); $result = array_key_exists($action, $this->actions) || array_key_exists($action, $this->global_actions) || array_key_exists($action, $this->grouped_actions); return $result; }
function is_xmlrpc_call() { $ret = check_page_call('xmlrpc.php'); $xmlrpc_debug = 0; if ($xmlrpc_debug && $ret) { xpress_debug_message('is_xmlrpc_call()' . "\n" . sprint_r($_SERVER)); } return $ret; }
public function hydrate_from_form($i) { $this->name = $_GET['ticket_name_a'][$i]; $this->amount = $_GET['ticket_amount_a'][$i]; $this->tax_rate = $_GET['ticket_tax_a'][$i]; $this->max_quantity = $_GET['ticket_quantity_a'][$i]; $this->description = $_GET['ticket_description_a'][$i]; debug("hydrate_from_form=" . sprint_r($this)); }
public function load() { $filename = BASE_DIR . "/locale/" . $this->locale . "/messages.php"; if (!file_exists($filename)) { debug("Locale file does not exist."); return; } require $filename; debug("array=" . sprint_r($this->array)); }
function log_to_db($error_string, $environment_string = null) { if (is_object($error_string)) { ob_start(); var_dump(get_object_vars($error_string)); $output = ob_get_flush(); $input_row['error_string'] = 'OBJECT:' . htmlentities($output); } else { if (is_array($error_string)) { $input_row['error_string'] = htmlentities(sprint_r($error_string), ENT_QUOTES); } else { $input_row['error_string'] = htmlentities($error_string, ENT_QUOTES); } } if ($environment_string == '') { $environment_string_temp = str_replace("\\", "/", sprint_r(debug_backtrace()) . ' ' . sprint_r($_SESSION)); $input_row['environment_string'] = htmlentities($environment_string_temp, ENT_QUOTES); } else { $input_row['environment_string'] = $environment_string . ' ' . str_replace("\\", "/", sprint_r(debug_backtrace())); } Errorlog::insert($input_row); }
if (is_null_or_empty($_SESSION["state"])) { $_SESSION["state"] = "root"; } debug("Session before: " . $_SESSION["state"]); if (is_null_or_empty($_GET["action"])) { $_SESSION["state"] = "root"; $_GET["action"] = "none"; } // Allows to be redirected to the previous url when sign in or sign out save_previous_url(); try { action(); } catch (Exception $e) { $_SESSION["state"] = "error"; message_set_error($e->getMessage()); debug(sprint_r($e->getTrace())); } if (!in_array($_SESSION["state"], $g_states)) { message_set_error("Undeclared state: " . $_SESSION["state"] . "."); $_SESSION["state"] = "error"; } debug("SESSION['state']=" . $_SESSION["state"]); debug("g_page=" . $g_page); if ($_SESSION["state"] == "not_allowed") { $g_page = "error"; } if (!is_null_or_empty($g_page)) { $g_state = $g_page; $g_page = SKIN_DIR . "/" . $g_page . ".php"; } else { $g_state = $_SESSION["state"];
function implode_r($array, $levels_deep = 0) { if (is_array($array)) { ksort($array); reset($array); } for ($i = 0; $i < $levels_deep; ++$i) { $tabover .= ' '; } if (is_array($array)) { foreach ($array as $f_name => $f_value) { if (is_array($f_value)) { $strout .= sprint_r($f_value, ++$levels_deep); } else { $strout .= "&" . $tabover . $f_name . '='; $strout .= $f_value; } } } return $strout; }
<?php $event = $g_display["event"]; $tickets = $g_display["tickets"]; $user = $g_display["user"]; $tax_array = array(); foreach ($tickets as $ticket) { $tax_rate = $ticket->tax_rate; if (!in_array($tax_rate, $tax_array)) { $tax_array[] = $tax_rate; } } arsort($tax_array); debug(sprint_r($tax_array)); function command_nominative($tickets, $event, $user) { ?> <table class="evt_table inline"> <tr> <th>{{Categories}}</th> <th>{{Remaining}}</th> <th>{{Rate}} (€)</th> <th>{{Tax}}</th> <th>{{Total}} (€)</th> </tr> <?php foreach ($tickets as $ticket) { $event_title_js = addslashes($event->title); $event_title = $event->title; $amount_ht = curr($ticket->amount); $label = $ticket->name;
function widget_upload($name, $upload_path, $max_file_size, $mime_type, $submit_button_html, $uploaded_html) { $debug = 0; $p = ''; if (!$_FILES) { return '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST" enctype="multipart/form-data"' . ' style="display:inline;"' . '>' . '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_file_size . '">' . '<input type="file"' . ' name="' . $name . '"' . ($max_file_size ? ' maxlength="' . $max_file_size . '"' : '') . ($mime_type ? ' accept="' . $mime_type . '"' : '') . '>' . ($submit_button_html ? $submit_button_html : '<input type="submit" name="' . $name . '" value="Upload"') . '>' . '</form>'; } if ($debug) { $p .= '<pre><tt>' . sprint_r($_FILES); } $d = $upload_path . '/' . basename($_FILES['' . $name . '']['name']); if (file_exists($d)) { $p .= 'ERROR: file already exists'; } else { if (move_uploaded_file($_FILES['' . $name . '']['tmp_name'], $d) == FALSE) { $p .= 'ERROR: move_uploaded_file() failed'; } } $s = array(UPLOAD_ERR_OK => 'OK', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive (' . ini_get('upload_max_filesize') . ') in php.ini', UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive (' . $max_file_size . ') that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder'); if (!empty($_FILES['' . $name . '']) && $_FILES['' . $name . '']['error'] == UPLOAD_ERR_OK) { $p .= $uploaded_html; } else { $e = $s[$_FILES['' . $name . '']['error']]; if (!$e) { $e .= 'An unknown error occured'; } $p .= 'ERROR: ' . $e; } if ($debug) { $p .= '<pre><tt>' . sprint_r($s) . sprint_r($_FILES); } return $p; }
taxes = new Array( <?php $is_first = TRUE; foreach ($g_tax_rates as $name => $rate) { if ($is_first) { $is_first = FALSE; } else { echo ','; } echo "new Array('" . _t($name) . "', '{$rate}')"; } ?> ); <?php $i = 0; debug("tickets=" . sprint_r($tickets)); if ($tickets != NULL) { foreach ($tickets as $ticket) { $label = $ticket->name; $amount = $ticket->amount; $tax_rate = $ticket->tax_rate; $quantity = $ticket->max_quantity; $description = $ticket->description; $is_free = 'true'; if ($amount > 0) { $is_free = 'false'; } echo "eb_add_rate('tickets', '{$label}', '{$quantity}', '{$amount}', {$tax_rate}, '{$description}', {$is_free});"; $i++; } }
public static function create() { debug(sprint_r($_GET)); try { $record = Record::new_instance($_GET["type"]); $record->check_form(); $record->id = create_id(); $record->hydrate_from_form(); $record->store(); message_set_info(_t("Record successfully created.")); } catch (Exception $e) { message_set_error($e->getMessage()); } }
public static function import() { $event = Event::get_from_id($_SESSION["event_id"]); $file = Form::get_file("guest_filename"); $guest_array = file($file, FILE_IGNORE_NEW_LINES); debug('guest_array: ' . sprint_r($guest_array)); foreach ($guest_array as $line) { if (!Guest::valid_line($line)) { continue; } $guest = new Guest(); $guest->hydrate(); $guest->set_value("email", $line); $guest->store(); $guest->link_to_event($event->id); } }
function widget_video_youtube_download($media_url, $tor_enabled) { $p = ''; // $yt_array = youtube_download ($media_url, $tor_enabled, 0); $yt_array = youtube_get_download_urls($media_url, $tor_enabled, 0); // DEBUG // echo '<pre><tt>'; // echo $media_url."\n"; // print_r ($a); $yt = $yt_array[0]; if ($yt['status'] == 'fail') { $p .= $yt['errorcode'] . ': ' . $yt['reason']; switch ($yt['errorcode']) { case 150: // copyright $p .= '<br>' . ' Probably Naziwalled against access from your country<br>' . 'Try a proxy or service that is located in the country of the possible license owner'; break; case 100: // removed by user // removed by user default: break; } return $p; } // [fmt_list] => 35/854x480/9/0/115,34/640x360/9/0/115,18/640x360/9/0/115,5/320x240/7/0/0 $a = explode(',', $yt['fmt_list']); $p .= 'Download: <a href="' . $yt['video_url'] . '">Best</a>'; for ($q = 0; isset($yt[$q]); $q++) { $b = explode('/', $a[$q]); $fmt = substr($yt[$q], 0, strpos($yt[$q], '|')); $t = substr($yt[$q], strpos($yt[$q], '|') + 1); $p .= ' <a href="' . $t . '" title="&fmt=' . $fmt . '">' . $b[1] . '</a>'; } // direct link // $p .= ' <a href="'.$yt['ad_eurl'].'">Direct</a>'; $p .= '<br>'; $p .= '' . 'Name: <input type="text"' . ' value="' . $yt['title'] . '" readonly="readonly"' . '>'; $p .= '<br>'; // details $p .= widget_collapse('Details', '<!-- div style="width:200px;height:100px;overflow:auto;" --><pre><tt>' . sprint_r($yt) . '</tt></pre><!-- /div -->', 1); return $p; }
function widget_upload($name, $label, $tooltip, $upload_path, $max_file_size, $mime_type, $flags) { if (strcasecmp($this->method, "POST")) { return "widget_upload() requires method=\"POST\" and enctype=\"multipart/form-data\" in the form tag\n"; } if ($flags & WIDGET_FOCUS) { $this->focus = $name; } $p = $this->widget_hidden("MAX_FILE_SIZE", $max_file_size, 0) . "<input class=\"widget_upload\" type=\"file\"" . " name=\"" . $name . "\"" . " title=\"" . $tooltip . "\"" . ($max_file_size ? " maxlength=\"" . $max_file_size . "\"" : "") . ($mime_type ? " accept=\"" . $mime_type . "\"" : "") . ($flags & WIDGET_DISABLED ? " disabled" : "") . ">\n" . $this->widget_submit($name, $label, $tooltip, 0); if (!$_FILES) { return $p; } $p .= sprint_r($_FILES); // debug if (move_uploaded_file($_FILES[$name]["tmp_name"], $upload_path . "/" . basename($_FILES[$name]["name"])) == FALSE) { // FALSE } $s = array(); $s[UPLOAD_ERR_OK] = "OK"; $s[UPLOAD_ERR_INI_SIZE] = "The uploaded file exceeds the upload_max_filesize directive (" . ini_get("upload_max_filesize") . ") in php.ini"; $s[UPLOAD_ERR_FORM_SIZE] = "The uploaded file exceeds the MAX_FILE_SIZE directive (" . $max_file_size . ") that was specified in the HTML form"; $s[UPLOAD_ERR_PARTIAL] = "The uploaded file was only partially uploaded"; $s[UPLOAD_ERR_NO_FILE] = "No file was uploaded"; $s[UPLOAD_ERR_NO_TMP_DIR] = "Missing a temporary folder"; /* if (defined (UPLOAD_ERR_CANT_WRITE)) $s[UPLOAD_ERR_CANT_WRITE] = "Failed to write file to disk"; if (defined (UPLOAD_ERR_EXTENSION)) $s[UPLOAD_ERR_EXTENSION] = "File upload stopped by extension"; */ $e = $s[$_FILES[$name]["error"]]; if (!$e) { $e .= "Unknown File Error."; } $p .= $e; $p .= "\n\n\n" . sprint_r($s); // debug // print_r ($_FILES); // debug return $p; }
public function get_bill($type = BILL_TYPE_AUTODETECT, $target = BILL_TARGET_ATTENDEE) { global $g_pdo; if ($type == BILL_TYPE_AUTODETECT) { $type = BILL_TYPE_QUOTATION; if ($this->is_confirmed()) { $type = BILL_TYPE_INVOICE; } } $request = <<<EOF SELECT `id` FROM `bill` WHERE `id_event`= :id_event AND `type`= :type AND target = :target EOF; debug($request); $q = $g_pdo->prepare($request); $array = array(":id_event" => $this->id, ":type" => $type, ":target" => $target); $q->execute($array); $bill_array = array(); while (($record = $q->fetch()) != NULL) { debug("record=" . sprint_r($record)); $bill = Bill::get_from_id($record["id"]); $bill_array[] = $bill; } return $bill_array; }
<?php $bill = $_SESSION["bill"]; $link = $bill->url(); debug(sprint_r($bill)); debug(sprint_r($_GET)); debug(sprint_r($_POST)); debug(sprint_r($_SESSION)); $payment_html = "payment"; if ($bill->status == BILL_STATUS_PLANNED) { $payment_html = "payment authorization"; } ?> <span class="evt_title"><p>{{Order successfully processed!}}</p></span> {{You can access to this bill via this permalink:}} <a href="<?php echo $link; ?> " target="_blank"><?php echo $link; ?> </a>.<br/> <br/> {{Back to the}} <a href="<?php echo "event/" . $bill->event_id; ?> ">{{event page}}</a>
public function fill_address_from_participation() { $address = Address::get_from_id($this->address_id); $address->hydrate_from_form('billing_address'); debug('address=' . sprint_r($address)); $address->update(); }