本文整理汇总了PHP中send_error函数的典型用法代码示例。如果您正苦于以下问题:PHP send_error函数的具体用法?PHP send_error怎么用?PHP send_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: myquery
function myquery($query)
{
global $time_mysql_query;
global $numsql;
global $debuginfo;
$backtrace = debug_backtrace();
$back1 = $backtrace;
$backtrace = " in : " . $backtrace[0]["file"] . ", on line: " . $backtrace[0]["line"] . "";
if (debug_run == 1) {
$MyTimerSQL = new Timer();
$MyTimerSQL->Init();
//$result = mysql_query($query) or trigger_error(mysql_errno() . ": <b>" . mysql_error() . $backtrace . format_query($query) , E_USER_ERROR);
$result = mysql_query($query) or send_error(mysql_errno() . ": <b>" . mysql_error() . $backtrace . "<br /><br /><p>Query: " . $query . "</p>", $backtrace);
$exec_time_mysql = $MyTimerSQL->GetTime(5);
$GLOBALS['numsql']++;
$time_mysql_query += $exec_time_mysql;
$GLOBALS['debuginfo'] .= '<tr><td>' . $query . '</td><td><span style="color:#C0FFFF">' . $exec_time_mysql . '</span></td><td><span style="color:lightgrey">' . $backtrace . '</span></tr>';
if (isset($GLOBALS['debug'][$back1[0]['file']])) {
$GLOBALS['debug'][$back1[0]['file']]['time_sql'] += $exec_time_mysql;
$GLOBALS['debug'][$back1[0]['file']]['count_sql'] += 1;
}
} else {
$result = mysql_query($query);
}
/*
if (strpos($query,"EXP")!==FALSE AND strpos($query,"game_users")!==FALSE AND strpos($query,"UPDATE")!==FALSE)
{
mysql_query("INSERT INTO query_log (query,timestamp,filename) VALUES ('$query',".time().",'$backtrace')");
}
*/
return $result;
}
示例2: myquery
function myquery($query)
{
$backtrace = debug_backtrace();
$back1 = $backtrace;
$backtrace = " in : " . $backtrace[0]["file"] . ", on line: " . $backtrace[0]["line"] . "";
$result = mysql_query($query) or send_error(mysql_errno() . ": <b>" . mysql_error() . $backtrace . "<br /><br /><br />" . $query . "");
return $result;
}
示例3: check_user_exists
function check_user_exists($uname, $uemail)
{
$DB = new database_class();
$sql = "SELECT COUNT(id) as count FROM User_table WHERE user_name = '{$uname}' LIMIT 1;";
$retval = mysql_query($sql, $DB->db_conn);
if (!$retval) {
die("ERROR :" . mysql_error());
}
while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
$count = $row['count'];
}
if ($count == 1) {
$mgs = "USER ALREADY EXISTS";
send_error($mgs);
// exit();
} else {
return true;
}
}
示例4: init_saml2_auth
function init_saml2_auth()
{
global $sessionmanager_url;
$sm = new SessionManager($sessionmanager_url);
$ret = $sm->query('auth_params');
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($ret);
if (!$buf) {
send_error("Unable to retrieve the SAML parameters");
}
if (!$dom->hasChildNodes()) {
send_error("Unable to retrieve the SAML parameters");
}
$saml2 = $dom->getElementsByTagname('SAML2')->item(0);
$url = $saml2->getElementsByTagname('idp_url')->item(0)->textContent;
$fingerprint = $saml2->getElementsByTagname('idp_fingerprint')->item(0)->textContent;
$cert = $saml2->getElementsByTagname('idp_cert')->item(0)->textContent;
$settings = build_saml_settings($url, $fingerprint, $cert);
return new OneLogin_Saml2_Auth($settings);
}
示例5: send_result
$object = $class_to_call::load($id_to_load);
$result = $object->{$method_to_call}($params);
break;
/* call the given normal method */
/* call the given normal method */
default:
$object = new $class_to_call();
$result = $object->{$method_to_call}($params);
}
send_result($result);
send_log('end of server process');
echo json_encode($global_result);
} catch (Error $e) {
if (!headers_sent()) {
header('HTTP/1.0 ' . $e->http_code . ' ' . $e->http_status, TRUE, $e->http_code);
}
send_log('Backtrace: ' . $e->getTraceAsString());
send_error($e->getMessage());
echo json_encode($global_result);
} catch (Exception $e) {
if (!headers_sent()) {
header('HTTP/1.0 500 Internal Server Error', TRUE, 500);
header('Content-type: text/plain', TRUE);
}
echo 'Exception:' . TUNA_NEWLINE . $e->getMessage() . TUNA_NEWLINE . TUNA_NEWLINE;
echo 'Code:' . TUNA_NEWLINE . $e->getCode() . TUNA_NEWLINE . TUNA_NEWLINE;
echo 'Line:' . TUNA_NEWLINE . $e->getLine() . TUNA_NEWLINE . TUNA_NEWLINE;
echo 'Backtrace:' . TUNA_NEWLINE . $e->getTraceAsString() . TUNA_NEWLINE . TUNA_NEWLINE;
echo 'Request vars:' . TUNA_NEWLINE . print_r($_REQUEST, TRUE);
}
closelog();
示例6: do_trackback
function do_trackback($formatter, $options)
{
global $DBInfo, $_release;
$entry = '';
if (!$formatter->page->exists()) {
$pos = strrpos($formatter->page->name, '/');
if ($pos > 0) {
$entry = substr($formatter->page->name, $pos + 1);
$pagename = substr($formatter->page->name, 0, $pos);
$page = new WikiPage($pagename);
$formatter = new Formatter($page, $options);
$options['page'] = $pagename;
} else {
$options['msg'] = _("Error: Page Not found !");
send_error(1, $options['msg']);
}
}
if (empty($options['url'])) {
$anchor = '';
if ($options['value']) {
$anchor = '/' . $options['value'];
}
$formatter->send_header("", $options);
if ($DBInfo->use_trackback) {
$ping_url = qualifiedUrl($formatter->link_url($formatter->page->urlname . $anchor, "?action=trackback"));
} else {
$ping_url = _("TrackBack is not activated !");
}
$sendping_action = $formatter->link_tag($formatter->page->urlname, "?action=sendping&value={$options['value']}", _("send ping"));
$tb_cache = new Cache_text('trackback');
if ($tb_cache->exists($options['page'])) {
$formatter->send_title(sprintf(_("TrackBack list of %s"), $options['page']), "", $options);
$trackbacks = explode("\n", $tb_cache->fetch($options['page']));
unset($trackbacks[sizeof($trackbacks) - 1]);
# trim the last empty line
print "<div class='trackback-hint'><b>" . _("TrackBack URL for this page:") . "</b><br />\n{$ping_url}<br /><br />\n";
print "<b>" . _("Send TrackBack Ping to another Blog:") . "</b> {$sendping_action}</div>\n<br />";
foreach ($trackbacks as $trackback) {
list($dummy, $entry, $url, $date, $sitename, $title, $excerpt) = explode("\t", $trackback);
if ($anchor and '/' . $entry != $anchor) {
continue;
}
$date[10] = " ";
# 2003-07-11T12:08:33+09:00
# $time=strtotime($date);
$time = strtotime($date);
$date = date("@ m-d [h:i a]", $time);
print "<div class='blog'>\n";
print "<div class='blog-title'><a href='{$url}'>{$title}</a></div>\n";
print "<div class='blog-user'>Submitted by <a href='{$url}'>{$sitename}</a> {$date}</div>\n";
print "<div class='blog-comment'>{$excerpt}</div>\n</div><br />\n";
}
} else {
$formatter->send_title(sprintf(_("No TrackBack entry found for %s"), $options['page']), "", $options);
print "<div class='trackback-hint'><b>" . _("TrackBack URL for this page:") . "</b><br />\n{$ping_url}<br /><br />\n";
print "<b>" . _("Send TrackBack Ping to another Blog:") . "</b> {$sendping_action}</div>\n";
}
$formatter->send_footer("", $options);
return;
}
if (!$DBInfo->use_trackback) {
send_error(1, "TrackBack is not enabled");
}
if (empty($options['title']) or empty($options['excerpt']) or empty($options['blog_name']) or empty($options['url'])) {
send_error(1, "Invalid TrackBack Ping");
}
# receivie Trackback ping
# strip \n
$title = strtr(_stripslashes($options['title']), "\t\n", " \r");
$excerpt = strtr(_stripslashes($options['excerpt']), "\t\n", " \r");
$blog_name = strtr(_stripslashes($options['blog_name']), "\t\n", " \r");
$url = strtr(_stripslashes($options['url']), "\t\n", " \r");
$timestamp = time();
$date = gmdate("Y-m-d\\TH:i:s", $timestamp);
$receive = $timestamp . "\t" . $entry . "\t" . $url . "\t" . $date . "\t" . $blog_name . "\t" . $title . "\t" . $excerpt . "\n";
$tb_cache = new Cache_text('trackback');
$old = $tb_cache->fetch($options['page']);
$ret = $tb_cache->update($options['page'], $old . $receive, time());
if ($ret === false) {
send_error(0, "Can't update Trackback list. Please try again");
}
send_error(0, 'Successfully added');
}
示例7: handle_paypal_ipn
function handle_paypal_ipn()
{
ob_end_clean();
if (!isset($_REQUEST['custom'])) {
return;
}
$paypal_bits = explode("|", $_REQUEST['custom']);
$user_id = (int) $paypal_bits[0];
$payment_id = (int) $paypal_bits[1];
$invoice_id = (int) $paypal_bits[2];
$invoice_payment_subscription_id = false;
if (count($paypal_bits) == 4) {
// normal IPN, single payment.
} else {
if (count($paypal_bits) == 5) {
// subscription IPN, with subscription id.
$invoice_payment_subscription_id = (int) $paypal_bits[3];
$invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
}
}
//send_error('bad?');
if ($payment_id && $invoice_id) {
$hash = $this->paypal_custom($user_id, $payment_id, $invoice_id, $invoice_payment_subscription_id);
if ($hash != $_REQUEST['custom']) {
send_error("PayPal IPN Error (incorrect hash) it should be " . $hash);
exit;
}
/*$sql = "SELECT * FROM `"._DB_PREFIX."user` WHERE user_id = '$user_id' LIMIT 1";
$res = qa($sql);
if($res){
$user = array_shift($res);
if($user && $user['user_id'] == $user_id){*/
// check for payment exists
$payment = module_invoice::get_invoice_payment($payment_id);
$invoice = module_invoice::get_invoice($invoice_id);
if ($payment && $invoice) {
/*if(isset($_REQUEST['fakepay'])){
if($invoice_payment_subscription_id){
// we have a subscription payment. woo!
// this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
// if this invoice hasn't been generated yet then we have to generate it.
// pass this back to the invoice class so we can reuse this feature in the future.
$data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $payment_id, $invoice_payment_subscription_id);
if($data && $data['invoice_id'] && $data['invoice_payment_id']){
$next_time = time();
$next_time = strtotime('+'.abs((int)$invoice_payment_subscription['days']).' days',$next_time);
$next_time = strtotime('+'.abs((int)$invoice_payment_subscription['months']).' months',$next_time);
$next_time = strtotime('+'.abs((int)$invoice_payment_subscription['years']).' years',$next_time);
update_insert('invoice_payment_subscription_id',$invoice_payment_subscription_id,'invoice_payment_subscription',array(
'date_last_pay' => date('Y-m-d'),
'date_next' => date('Y-m-d',$next_time),
));
$new_payment_details = array(
'date_paid' => date('Y-m-d'),
'amount' => $_REQUEST['mc_gross'],
'method' => 'PayPal (Subscription)',
'invoice_payment_subscription_id' => $invoice_payment_subscription_id,
);
foreach(array('fee_percent','fee_amount','fee_description','fee_total') as $fee_field){
if(isset($payment[$fee_field])) {
$new_payment_details[ $fee_field ] = $payment[ $fee_field ];
}
}
update_insert("invoice_payment_id",$data['invoice_payment_id'],"invoice_payment",$new_payment_details);
module_invoice::save_invoice($data['invoice_id'],array());
echo "Successful Subscription Payment!";
}else{
send_error("PayPal IPN Subscription Error (failed to generate new invoice!) ".var_export($result,true));
}
}else{
// mark a normal payment as paid
update_insert("invoice_payment_id",$payment_id,"invoice_payment",array(
'date_paid' => date('Y-m-d'),
'amount' => $_REQUEST['mc_gross'],
'method' => 'PayPal (IPN)',
));
module_invoice::save_invoice($invoice_id,array());
echo "Successful Payment!";
}
echo 'fakepay done';exit;
}*/
$invoice_currency = module_config::get_currency($invoice['currency_id']);
$invoice_currency_code = $invoice_currency['code'];
// check correct business
if (!$_REQUEST['business'] && $_REQUEST['receiver_email']) {
$_REQUEST['business'] = $_REQUEST['receiver_email'];
}
if ($_REQUEST['business'] != module_config::c('payment_method_paypal_email', _ERROR_EMAIL)) {
send_error('PayPal error! Paid the wrong business name. ' . $_REQUEST['business'] . ' instead of ' . module_config::c('payment_method_paypal_email', _ERROR_EMAIL));
exit;
//.........这里部分代码省略.........
示例8: dirname
* as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__) . '/common.inc.php';
try {
$auth = init_saml2_auth();
$auth->processResponse();
} catch (Exception $e) {
send_error($e->getMessage());
}
$errors = $auth->getErrors();
if (!empty($errors)) {
send_error(implode(', ', $errors));
}
if (!$auth->isAuthenticated()) {
send_error("Not authenticated");
}
$_SESSION['SAML2'] = true;
$_SESSION['SAML2_login'] = $auth->getNameId();
$_SESSION['SAML2_ticket'] = $_POST['SAMLResponse'];
setcookie('ovd-sso', 'true', 0, '/ovd/');
$auth->redirectTo(SAML2_REDIRECT_URI . '/ovd/');
示例9: resize_images
function resize_images()
{
global $xoopsUser, $xoopsLogger, $xoopsSecurity;
set_time_limit(0);
error_reporting(0);
$xoopsLogger->activated = false;
$params = rmc_server_var($_GET, 'data', '');
$id = rmc_server_var($_GET, 'img', 0);
if ($params == '') {
send_error(__('Unauthorized!', 'rmcommon'));
}
if ($id <= 0) {
send_error(__('Invalid image!', 'rmcommon'));
}
$params = TextCleaner::decrypt($params);
$data = explode('|', $params);
if ($data[0] != $xoopsUser->uid()) {
send_error(__('Unauthorized!', 'rmcommon'));
}
if ($data[1] != RMCURL . '/images.php') {
send_error(__('Unauthorized!', 'rmcommon'));
}
if (!$xoopsSecurity->check(false, $data[2])) {
send_error(__('Unauthorized!', 'rmcommon'));
}
$image = new RMImage($id);
if ($image->isNew()) {
send_error(__('Image not found!', 'rmcommon'));
}
// Resize image
$cat = new RMImageCategory($image->getVar('cat'));
if (!$cat->user_allowed_toupload($xoopsUser)) {
send_error(__('Unauthorized', 'rmcommon'));
}
$sizes = $cat->getVar('sizes');
$updir = XOOPS_UPLOAD_PATH . '/' . date('Y', $image->getVar('date')) . '/' . date('m', time());
$upurl = XOOPS_UPLOAD_URL . '/' . date('Y', $image->getVar('date')) . '/' . date('m', time());
$width = 0;
$tfile = '';
foreach ($sizes as $size) {
if ($size['width'] <= 0 && $size['height'] <= 0) {
continue;
}
$fd = pathinfo($updir . '/' . $image->getVar('file'));
$name = $updir . '/sizes/' . $fd['filename'] . '_' . $size['width'] . 'x' . $size['height'] . '.' . $fd['extension'];
$sizer = new RMImageResizer($updir . '/' . $image->getVar('file'), $name);
switch ($size['type']) {
case 'crop':
$sizer->resizeAndCrop($size['width'], $size['height']);
break;
default:
if ($size['width'] <= 0 || $size['height'] <= 0) {
$sizer->resizeWidth($size['width']);
} else {
$sizer->resizeWidthOrHeight($size['width'], $size['height']);
}
break;
}
if ($size['width'] <= $width || $width == 0) {
$width = $size['width'];
$tfile = str_replace(XOOPS_UPLOAD_PATH, XOOPS_UPLOAD_URL, $name);
}
}
$ret['message'] = sprintf(__('%s done!', 'rmcommon'), $image->getVar('file'));
$ret['done'] = 1;
$ret['file'] = $tfile;
$ret['title'] = $image->getVar('title');
echo json_encode($ret);
die;
}
示例10: get_list
public function get_list()
{
global $user;
if ($this->cleanfile) {
$table = $this->vars_table_cleanfiles;
$root_path = $this->vars_cleanfiles_root;
} else {
$table = $this->vars_table_samples;
$root_path = $this->vars_dirty_root;
}
// Configure to collect files from local storage using the preferred hash
if ($this->cleanfile) {
$type = 'Clean';
$res = $this->sql->query("SELECT md5_scl as md5, file_size_scl 'size' FROM {$table} WHERE " . $this->virex_ExtraConditions['clean'] . ' GROUP BY md5_scl');
} else {
$type = 'Detected';
$res = $this->sql->query("SELECT md5_sde as md5, file_size_sde 'size' FROM {$table} WHERE " . $this->virex_ExtraConditions['detected'] . ' GROUP BY md5_sde');
}
if (!$res) {
$this->send_error($this->sql->error);
}
$plaintext = tempnam(VIREX_TEMP_PATH, "HashList");
$this->virex_register_list_download($res->num_rows, $type);
$fout = fopen($plaintext, "w");
if (!$fout) {
send_error("Unable to create {$plaintext}");
}
if ($res) {
while ($row = $res->fetch_object()) {
if ($row->size > 0) {
$hex = $this->ascii2hex($row->md5);
if ($row->md5 == "") {
continue;
}
$this->virex_add_file_to_list($row->md5, $row->size);
$part1 = substr($hex, 0, 3);
$part2 = substr($hex, 3, 3);
$part3 = substr($hex, 6, 3);
$file = $root_path . "/{$part1}/{$part2}/{$part3}/{$hex}";
if (!file_exists($file)) {
continue;
}
fwrite($fout, "{$row->md5}:{$row->size}\r\n");
}
}
}
fclose($fout);
return $plaintext;
}
示例11: send_error
include "../app/models/lesson_composition.php";
include "../app/models/video.php";
// NO ACTION PROVIDED
if (!isset($_GET['action'])) {
send_error();
}
// ACTIONS, OUR CONTROLLER
switch ($_GET['action']) {
case 'loadcomposers':
$composer = new Composer();
$data = $composer->loadComposers();
send_json($data);
break;
case 'getnextcomposition':
$composition = new Composition();
$data = $composition->getNextComposition();
send_json($data);
break;
default:
send_error();
}
// AUXILIAR
function send_error()
{
send_json(array('success' => false));
}
function send_json($data)
{
header('Content-Type: application/json');
echo json_encode($data);
}
示例12: send_error
send_error("authentication", $e);
} catch (Stripe_ApiConnectionError $e) {
send_error("network", $e);
} catch (Stripe_Error $e) {
send_error("generic", $e);
} catch (Exception $e) {
if ($e->getMessage() == "zip_check_invalid") {
$smartyvalues["processingerror"] = 'Error: The address information on your account does not match that of the credit card you are trying to use. Please try again or contact us if the problem persists.';
} else {
if ($e->getMessage() == "address_check_invalid") {
$smartyvalues["processingerror"] = 'The address information on your account does not match that of the credit card you are trying to use. Please try again or contact us if the problem persists.';
} else {
if ($e->getMessage() == "cvc_check_invalid") {
$smartyvalues["processingerror"] = 'The credit card information you specified is not valid. Please try again or contact us if the problem persists.';
} else {
send_error("unkown", $e);
}
}
}
}
}
// end of if to check if this is a token acceptance for recurs
}
} else {
// User is logged in but they shouldn't be here (i.e. they weren't here from an invoice)
header("Location: clientarea.php?action=details");
}
} else {
header("Location: index.php");
}
# Define the template filename to be used without the .tpl extension
示例13: apply_filter
function apply_filter()
{
global $C, $I, $U, $db, $memcached;
if ($U['poststatus'] !== 9 && preg_match('~^/me~i', $U['message'])) {
$U['displaysend'] = substr($U['displaysend'], 0, -3);
$U['message'] = preg_replace("~^/me~i", '', $U['message']);
}
$U['message'] = preg_replace_callback('/\\@([a-z0-9]{1,})/i', function ($matched) {
global $A, $P;
if (isset($P[$matched[1]])) {
return style_this($matched[0], $P[$matched[1]][1]);
}
$nick = strtolower($matched[1]);
foreach ($P as $user) {
if (strtolower($user[0]) === $nick) {
return style_this($matched[0], $user[1]);
}
}
read_members();
if (isset($A[$matched[1]])) {
return style_this($matched[0], $A[$matched[1]][2]);
}
foreach ($A as $user) {
if (strtolower($user[0]) === $nick) {
return style_this($matched[0], $user[2]);
}
}
return "{$matched['0']}";
}, $U['message']);
if ($C['memcached']) {
$filters = $memcached->get("{$C['dbname']}-{$C['prefix']}filter");
}
if (!$C['memcached'] || $memcached->getResultCode() !== Memcached::RES_SUCCESS) {
$filters = array();
$result = $db->query("SELECT id, filtermatch, filterreplace, allowinpm, regex, kick FROM {$C['prefix']}filter;");
while ($filter = $result->fetch(PDO::FETCH_ASSOC)) {
$filters[] = array('id' => $filter['id'], 'match' => $filter['filtermatch'], 'replace' => $filter['filterreplace'], 'allowinpm' => $filter['allowinpm'], 'regex' => $filter['regex'], 'kick' => $filter['kick']);
}
if ($C['memcached']) {
$memcached->set("{$C['dbname']}-{$C['prefix']}filter", $filters);
}
}
foreach ($filters as $filter) {
if ($U['poststatus'] !== 9) {
$U['message'] = preg_replace("/{$filter['match']}/i", $filter['replace'], $U['message'], -1, $count);
} elseif (!$filter['allowinpm']) {
$U['message'] = preg_replace("/{$filter['match']}/i", $filter['replace'], $U['message'], -1, $count);
}
if (isset($count) && $count > 0 && $filter['kick']) {
kick_chatter(array($U['nickname']), '', false);
send_error("{$I['kicked']}");
}
}
}
示例14: external_hook
public function external_hook($hook)
{
switch ($hook) {
case 'event_ipn':
require_once 'includes/plugin_paymethod_stripe/stripe-php/lib/Stripe.php';
$stripe = array("secret_key" => module_config::c('payment_method_stripe_secret_key'), "publishable_key" => module_config::c('payment_method_stripe_publishable_key'));
Stripe::setApiKey($stripe['secret_key']);
$body = @file_get_contents('php://input');
$event_json = json_decode($body);
ob_start();
// echo "INPUT: <br>\n";
// print_r($body);
// echo "<br><br>\n";
echo "UCM STRIPE DEBUG:<br><br>JSON: <br>\n";
print_r($event_json);
echo "<br><br>\n";
$event_id = $event_json->id;
try {
$event = Stripe_Event::retrieve($event_id);
// This will send receipts on succesful invoices
if ($event->type == 'charge.succeeded' && $event->data->object->invoice) {
$paid_amount = $event->data->object->amount / 100;
// get the invoice.
$invoice = Stripe_Invoice::retrieve($event->data->object->invoice);
echo "INVOICE: <br>\n";
print_r($invoice);
echo "<br><br>\n";
if ($invoice && $invoice->subscription && $invoice->paid) {
// this payment was for a subscription! which one though?
$customer = Stripe_Customer::retrieve($invoice->customer);
echo "CUSTOMER: <br>\n";
print_r($customer);
echo "<br><br>\n";
$subscription = $customer->subscriptions->retrieve($invoice->subscription);
echo "SUBSCRIPTION: <br>\n";
print_r($subscription);
echo "<br><br>\n";
// now we have the Customer and Subscription we can look through our invoice_payment_subscription table for those values.
/*update_insert('invoice_payment_subscription_id',$invoice_payment_subscription_id,'invoice_payment_subscription',array(
'status' => _INVOICE_SUBSCRIPTION_ACTIVE,
'date_start' => date('Y-m-d'),
// we also have to store the stripe details here so we can easily search for them later on.
'stripe_customer' => $stripe_customer->id,
'stripe_subscription' => $stripe_subscription->id,
));*/
$invoice_payment_subscription = get_single('invoice_payment_subscription', array('stripe_customer', 'stripe_subscription'), array($customer->id, $subscription->id));
if ($invoice_payment_subscription) {
// FIND THE linked invoice_payment for this original invoice payment subscription, this allows us to perform the same creatE_new_invoice as paypal below:
$invoice_payment_subscription_id = $invoice_payment_subscription['invoice_payment_subscription_id'];
$invoice_payment = get_single('invoice_payment', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
if ($invoice_payment) {
$payment_id = $invoice_payment['invoice_payment_id'];
$invoice_id = $invoice_payment['invoice_id'];
// we have a subscription payment. woo!
// this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
// if this invoice hasn't been generated yet then we have to generate it.
// pass this back to the invoice class so we can reuse this feature in the future.
$data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $payment_id, $invoice_payment_subscription_id);
if ($data && $data['invoice_id'] && $data['invoice_payment_id']) {
$next_time = time();
$next_time = strtotime('+' . abs((int) $invoice_payment_subscription['days']) . ' days', $next_time);
$next_time = strtotime('+' . abs((int) $invoice_payment_subscription['months']) . ' months', $next_time);
$next_time = strtotime('+' . abs((int) $invoice_payment_subscription['years']) . ' years', $next_time);
update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('date_last_pay' => date('Y-m-d'), 'date_next' => date('Y-m-d', $next_time)));
update_insert("invoice_payment_id", $data['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $paid_amount, 'method' => 'Stripe (Subscription)', 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
module_paymethod_stripe::add_payment_data($data['invoice_payment_id'], 'log', "Payment Received via Webhook: " . var_export(array('event.type' => $event->type, 'invoice.id' => $invoice->id, 'subscription.id' => $subscription->id, 'customer.id' => $customer->id, '$invoice_payment_subscription_id' => $invoice_payment_subscription_id, '$invoice_payment_id' => $payment_id), true));
module_invoice::save_invoice($data['invoice_id'], array());
echo "Successful Subscription Payment For Invoice " . $data['invoice_id'];
} else {
send_error("Stripe Webhook Subscription Error (failed to generate new invoice!) " . var_export($data, true));
}
} else {
echo 'Failed to find matching invoice payment in db';
}
} else {
echo 'Failed to find matching subscription payment in db';
}
}
}
} catch (Exception $e) {
$body = $e->getJsonBody();
$err = $body['error'];
$error = "Sorry: Webhook failed. <br><br>\n\n";
$error .= $err['message'];
$error .= "\n\n\n" . var_export($e, true);
echo $error;
}
$debug = ob_get_clean();
//mail('dtbaker@gmail.com','Stripe Webhook debug',$debug);
if (module_config::c('stripe_payment_debug', 0)) {
echo $debug;
}
echo "Thanks! (set stripe_payment_debug to 1 in UCM to see more data here)";
exit;
break;
case 'pay_subscription':
$invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
$invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
$invoice_payment_subscription_id = isset($_REQUEST['invoice_payment_subscription_id']) ? $_REQUEST['invoice_payment_subscription_id'] : false;
$stripe_plan_id = isset($_REQUEST['stripe_plan_id']) ? $_REQUEST['stripe_plan_id'] : false;
//.........这里部分代码省略.........
示例15: saveBulkImages
/**
* @desc Almacena la información del grupo de imágenes
**/
function saveBulkImages()
{
global $util, $mc, $xoopsUser;
XoopsLogger::getInstance()->activated = false;
XoopsLogger::getInstance()->renderingEnabled = false;
set_time_limit(0);
foreach ($_POST as $k => $v) {
${$k} = $v;
}
$ruta = "page={$page}&search={$search}&owner={$uid}&sort={$sort}&mode={$mode}";
if ($xoopsUser->uid() == $uid) {
$xu = $xoopsUser;
} else {
$xu = new XoopsUser($uid);
}
//Verificamos si el usuario se encuentra registrado
$user = new GSUser($xu->uname());
if ($user->isNew()) {
//Insertamos información del usuario
$user->setUid($uid);
$user->setUname($xu->uname());
$user->setQuota($mc['quota'] * 1024 * 1024);
$user->setDate(time());
if (!$user->save()) {
send_error(__('User owner could not be created!', 'galleries') . "<br />" . $user->errors());
die;
} else {
mkdir($mc['storedir'] . "/" . $user->uname());
mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
}
} else {
@mkdir($mc['storedir'] . "/" . $user->uname());
@mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
@mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
}
// Insertamos las etiquetas
$tgs = explode(",", $tags);
/**
* @desc Almacena los ids de las etiquetas que se asignarán a la imágen
*/
$ret = array();
foreach ($tgs as $k) {
$k = trim($k);
if ($k == '') {
continue;
}
// Comprobamos que la palabra tenga la longitud permitida
if (strlen($k) < $mc['min_tag'] || strlen($k) > $mc['max_tag']) {
continue;
}
// Creamos la etiqueta
$tag = new GSTag($k);
if (!$tag->isNew()) {
// Si ya existe nos saltamos
$ret[] = $tag->id();
continue;
}
$tag->setTag($k);
if ($tag->save()) {
$ret[] = $tag->id();
}
}
$errors = '';
$k = 1;
include_once RMCPATH . '/class/uploader.php';
$updir = $mc['storedir'] . "/" . $xu->uname();
$upths = $mc['storedir'] . "/" . $xu->uname() . "/ths";
// Cargamos la imágen
if (!file_exists($updir)) {
mkdir($updir, 511);
}
if (!file_exists($upths)) {
mkdir($upths, 511);
}
$uploader = new RMFileUploader($updir, $mc['size_image'] * 1024, array('gif', 'jpg', 'jpeg', 'png'));
$err = array();
if (!$uploader->fetchMedia('Filedata')) {
send_error($uploader->getErrors());
}
if (!$uploader->upload()) {
send_error($uploader->getErrors());
}
// Insertamos el archivo en la base de datos
$img = new GSImage();
$img->setTitle($uploader->savedFileName);
$img->setOwner($uid);
$img->setPublic(2);
$img->setCreated(time());
$img->setImage($uploader->getSavedFileName());
if (!$image->save()) {
unlink($uploader->savedDestination);
send_error(__('File could not be inserted to database!', 'galleries'));
}
$ret['message'] = '1';
$ret['id'] = $image->id();
echo json_encode($ret);
//.........这里部分代码省略.........