function ea_email_sent_shortcode() { ob_start(); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Reading from superglobals $tCallerSkypeNameSg = esc_sql($_POST["skype_name"]); // ..verifying that the skype name exists if (verifyUserNameExists($tCallerSkypeNameSg) === false) { echo "<h3><i><b>Incorrect Skype name</b> - email not sent. Please go back and try again.</i></h3>"; exit; } $tLengthNr = $_POST["length"]; if (is_numeric($tLengthNr) === false) { handleError("Length variable was not numeric - possible SQL injection attempt"); } // Setting up variables based on the superglobals $tCallerIdNr = getIdByUserName($tCallerSkypeNameSg); $tUniqueDbIdentifierSg = uniqid("id-", true); // http://php.net/manual/en/function.uniqid.php $tCallerDisplayNameSg = getDisplayNameById($tCallerIdNr); $tCallerEmailSg = getEmailById($tCallerIdNr); $tEmpathizerDisplayNameSg = getDisplayNameById(get_current_user_id()); // If this is the first call: reduce the donation amount. $tAdjustedLengthNr = $tLengthNr; if (isFirstCall($tCallerIdNr) == true) { $tAdjustedLengthNr = $tAdjustedLengthNr - Constants::initial_call_minute_reduction; } $tRecDonationNr = (int) round(get_donation_multiplier() * $tAdjustedLengthNr); // Create the contents of the email message. $tMessageSg = "Hi " . $tCallerDisplayNameSg . ",\n\nThank you so much for your recent empathy call! Congratulations on contributing to a more empathic world. :)\n\nYou talked with: {$tEmpathizerDisplayNameSg}\nYour Skype session duration was: {$tLengthNr} minutes\nYour recommended contribution is: \${$tRecDonationNr}\n\nPlease follow this link to complete payment within 24 hours: " . getBaseUrl() . pages::donation_form . "?recamount={$tRecDonationNr}&dbToken={$tUniqueDbIdentifierSg}\n\nSee you next time!\n\nThe Empathy Team\n\nPS\nIf you have any feedback please feel free to reply to this email and tell us your ideas or just your experience!\n"; // If the donation is greater than 0: send an email to the caller. if ($tRecDonationNr > 0) { ea_send_email($tCallerEmailSg, "Empathy App Payment", $tMessageSg); echo "<h3>Email successfully sent to caller.</h3>"; } else { echo "<h4>No email sent: first time caller and call length was five minutes or less.</h4>"; } // Add a new row to the db CallRecords table. db_insert(array(DatabaseAttributes::date_and_time => current_time('mysql', 1), DatabaseAttributes::recommended_donation => $tRecDonationNr, DatabaseAttributes::call_length => $tLengthNr, DatabaseAttributes::database_token => $tUniqueDbIdentifierSg, DatabaseAttributes::caller_id => $tCallerIdNr, DatabaseAttributes::empathizer_id => get_current_user_id())); $ob_content = ob_get_contents(); //+++++++++++++++++++++++++++++++++++++++++ ob_end_clean(); return $ob_content; }
function performLogout() { $expire = time() - 60 * 60 * 24 * 365; $domainName = getDomainName(); setcookie(COOKIE_SESSION_ID, "", $expire, "/", $domainName); header("Location: " . getBaseUrl() . "/"); }
/** * @return Payment * @throws CheckoutException */ public function startPayment() { $total_amount = ($this->request->amount + $this->request->tax_amount - $this->request->discount_amount) * 100; $apiContext->setConfig(array('service.EndPoint' => "https://test-api.sandbox.paypal.com")); $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item1 = new Item(); $item1->setName('Product1')->setCurrency('EUR')->setPrice(10.0)->setQuantity(2)->setTax(3.0); $itemList = new ItemList(); $itemList->setItems(array($item1)); $details = new Details(); $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5); $amount = new Amount(); $amount->setCurrency('EUR')->setTotal(20)->setDetails($details); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription('Payment')->setInvoiceNumber('transactionid'); $baseUrl = getBaseUrl(); $redir = new RedirectUrls(); $redir->setReturnUrl($baseUrl . '/'); $redir->setCancelUrl($baseUrl . '/'); $payment = new Payment(); $payment->setIntent('sale')->setPayer($payer)->setRedirectUrls($redir)->setTransactions(array($transaction)); $request = clone $payment; try { $payment->create($apiContext); } catch (\Exception $e) { throw new CheckoutException('Paypal error', 500, $e); } $approvalUrl = $payment->getApprovalLink(); ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment); return $payment; }
function __construct() { $this->settings['notify_url'] = getBaseUrl() . '/paypal_ipn/process'; $this->settings['return'] = getBaseUrl() . '/payment-done'; $this->testSettings['notify_url'] = getBaseUrl() . '/paypal_ipn/process'; $this->testSettings['return'] = getBaseUrl() . '/payment-done'; }
function renderHeader() { global $base; echo $base[0]; echo getBaseUrl(); echo $base[1]; }
function test() { global $apiContext; // IncludeConfig('paypal/bootstrap.php'); $payer = new Payer(); $payer->setPaymentMethod("paypal"); $item1 = new Item(); $item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5); $item2 = new Item(); $item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2)); $details = new Details(); $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5); $amount = new Amount(); $amount->setCurrency("USD")->setTotal(20)->setDetails($details); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid()); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl("{$baseUrl}/donate.php/execute_payment_test?success=true")->setCancelUrl("{$baseUrl}/donate.php/execute_payment_test?success=false"); $payment = new Payment(); $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); $request = clone $payment; try { $payment->create($apiContext); } catch (Exception $ex) { ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex); exit(1); } $approvalUrl = $payment->getApprovalLink(); ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment); return $payment; }
/** * Pydio authentication * * @param int $userId ftp username * @return bool FALSE on failure */ function client_pydioAuth($userId) { if (file_exists(GUI_ROOT_DIR . '/data/tmp/failedAJXP.log')) { @unlink(GUI_ROOT_DIR . '/data/tmp/failedAJXP.log'); } $credentials = _client_pydioGetLoginCredentials($userId); if (!$credentials) { set_page_message(tr('Unknown FTP user.'), 'error'); return false; } $contextOptions = array(); // Prepares Pydio absolute Uri to use if (isSecureRequest()) { $contextOptions = array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true)); } $pydioBaseUrl = getBaseUrl() . '/ftp/'; $port = getUriPort(); // Pydio authentication $context = stream_context_create(array_merge($contextOptions, array('http' => array('method' => 'GET', 'protocol_version' => '1.1', 'header' => array('Host: ' . $_SERVER['SERVER_NAME'] . ($port ? ':' . $port : ''), 'User-Agent: i-MSCP', 'Connection: close'))))); # Getting secure token $secureToken = file_get_contents("{$pydioBaseUrl}/index.php?action=get_secure_token", false, $context); $postData = http_build_query(array('get_action' => 'login', 'userid' => $credentials[0], 'login_seed' => '-1', "remember_me" => 'false', 'password' => stripcslashes($credentials[1]), '_method' => 'put')); $contextOptions = array_merge($contextOptions, array('http' => array('method' => 'POST', 'protocol_version' => '1.1', 'header' => array('Host: ' . $_SERVER['SERVER_NAME'] . ($port ? ':' . $port : ''), 'Content-Type: application/x-www-form-urlencoded', 'X-Requested-With: XMLHttpRequest', 'Content-Length: ' . strlen($postData), 'User-Agent: i-MSCP', 'Connection: close'), 'content' => $postData))); stream_context_set_default($contextOptions); # TODO Parse the full response and display error message on authentication failure $headers = get_headers("{$pydioBaseUrl}?secure_token={$secureToken}", true); _client_pydioCreateCookies($headers['Set-Cookie']); redirectTo($pydioBaseUrl); exit; }
function commons_def($registry) { $config = $registry->get('config'); $urls = $config->get('config_ssl'); $url = $config->get('config_url'); $ssl = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == '1'); if (empty($url) && !$ssl) { $config->set('config_url', getBaseUrl()); } else { if (empty($urls) && $ssl) { $config->set('config_ssl', getBaseUrl()); } } if (!defined('HTTP_SERVER')) { define('HTTP_SERVER', $config->get('config_url')); if ($config->get('config_ssl')) { define('HTTPS_SERVER', 'https://' . substr($config->get('config_url'), 7)); } else { define('HTTPS_SERVER', HTTP_SERVER); } } if (!defined('HTTP_IMAGE')) { define('HTTP_IMAGE', HTTP_SERVER . 'image/'); if ($config->get('config_ssl')) { define('HTTPS_IMAGE', HTTPS_SERVER . 'image/'); } else { define('HTTPS_IMAGE', HTTP_IMAGE); } } $version = get_project_version(); define('KC_CART_VERSION', $version); }
public function fillToWholePath($path) { if (stristr($path, "http") < 0) { $filname = $path; $path = getBaseUrl() . "photo/" . $filname; } return $path; }
/** * While cache file not exists, create cache and file. * @param String $file_path * @return array of huge pics */ private function createDefaultCache($file_path) { $json_str = '[{"area_id":8,"path":"' . getBaseUrl() . 'casarover/website/image/lbt/01.jpg"},' . '{"area_id":9,"path":"' . getBaseUrl() . 'casarover/website/image/lbt/02.jpg"}]'; $cacheFile = fopen($this->filepath, 'w') or die('File: ' . $this->filepath . ' open failed!'); fwrite($cacheFile, $json_str); fclose($cacheFile); return json_decode($json_str); }
public function __construct($realm = null, $return_to = null) { global $SCOPES; global $CONSUMER_KEY; $this->openIdParams['openid.ext2.consumer'] = $CONSUMER_KEY; $this->openIdParams['openid.ext2.scope'] = implode('+', $SCOPES); $this->openIdParams['openid.return_to'] = $return_to ? $return_to : constructPageUrl(); $this->openIdParams['openid.realm'] = $realm ? $realm : getBaseUrl(); }
/** * Gets the xnatview configuration options. * * Intended to be serialized to the client-side scripts, but may also be * used for server-side options. Session handling must be started * for authentication info to be included. * * @return array nested associative arrays */ function getXnatViewOptions() { static $xnatview = null; if ($xnatview === null) { $base_url = getBaseUrl(); $auth = $_SESSION['xnatview.authinfo']; if (!is_array($auth)) { $auth = array_fill_keys(array('user', 'pass', 'server'), ''); } $xnatview_path = $base_url . '../python/xnatview_backend.py'; // pass server options to included javascript $xnatview = array('config' => array('projectUrl' => "{$xnatview_path}/get_projects", 'subjectUrl' => "{$xnatview_path}/get_subjects", 'experimentUrl' => "{$xnatview_path}/get_experiments", 'scanUrl' => "{$xnatview_path}/get_scans", 'dicomUrl' => "{$xnatview_path}/get_dicom_scans", 'authUrl' => "{$xnatview_path}/authenticate", 'scanGalleryUrl' => $base_url . 'scan_gallery.php')); } return $xnatview; }
function js_out() { $edit = (bool) $_REQUEST['edit']; $files = array(DOKU_INC . '/includes/scripts/events.js', DOKU_INC . '/includes/scripts/script.js', DOKU_INC . '/includes/scripts/domLib.js', DOKU_INC . '/includes/scripts/domTT.js'); if ($edit) { $files[] = DOKU_INC . 'includes/scripts/edit.js'; } ob_start(); print "var DOKU_BASE = '" . getBaseUrl() . "../admin/" . "';"; foreach ($files as $file) { @readfile($file); } if ($edit) { require_once DOKU_INC . 'includes/toolbar.php'; toolbar_JSdefines('toolbar'); } $js = ob_get_contents(); ob_end_clean(); print $js; }
/** * Runs this installation script * @return null */ function run() { $action = null; if (array_key_exists('action', $_GET)) { $action = $_GET['action']; } try { $baseUrl = getBaseUrl(); $url = getBaseUrl() . str_replace(__DIR__, '', __FILE__); $content = '<p>This script will help you download and launch the latest Zibo installation.</p>'; $requirements = checkRequirements(); if ($requirements) { $content .= '<div class="error">'; $content .= '<p>Not all requirements are met, please solve the following issues:</p>'; $content .= '<ul>'; foreach ($requirements as $requirement) { $content .= '<li>' . $requirement . '</li>'; } $content .= '</ul>'; $content .= '</div>'; $content .= '<form action="' . $url . '"><input type="submit" value="Check again" /></form>'; } else { if (!$action) { $content .= '<p class="success">All the requirements are met.</p>'; $content .= '<p>The script is ready to download Zibo.</p>'; $content .= '<p>Zibo download:<br /><code><a href="' . PACKAGE . '">' . PACKAGE . '</a></code></p>'; $content .= '<p>Installation directory:<br /><code>' . getInstallationDirectory() . '</code></p>'; $content .= '<form action="' . $url . '?action=download" method="post"><input type="submit" value="Proceed" /></form>'; } elseif ($action == 'download') { downloadAndUnpack(); header('Location: ' . $baseUrl); } } } catch (Exception $exception) { $content = '<div class="error"><pre>'; $content .= $exception->getMessage() . "\n" . $exception->getTraceAsString(); $content .= '</pre></div>'; } echo renderOutput($content); }
function ea_email_form_shortcode() { ob_start(); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Check user access level. $tContributorBl = hasCurrentUserRole(array(WPUserRoles::contributor)); if ($tContributorBl == false) { // Exit if not empathizer or admin. echo "<strong>Oops! This page is only for our empathizers</strong>"; exit; } $tMaxLengthNr = floor(get_max_donation() / get_donation_multiplier()); ?> <form id="empathizerForm" action=<?php echo getBaseUrl() . pages::email_sent; ?> type="hidden" method="POST" > <label for="skype_name">Skype Name</label> <input name="skype_name" id="skype_name" type="text" style="display:block"> <label for="length">Call Duration</label> <input name="length" id="length" type="number" pattern="\d*" min="1" max="<?php echo $tMaxLengthNr; ?> " style="display:block"> <input type="submit" value="Send donation email to caller" id="submit" style="display:block"> </form> <?php $ob_content = ob_get_contents(); //+++++++++++++++++++++++++++++++++++++++++ ob_end_clean(); return $ob_content; }
$_SESSION['orderinfo']['price'] = $amount; $_SESSION['orderinfo']['daylimit'] = (int) $prices['MonthNumber'] * 30; // Figure out what funding instruments are available for this buyer if ($_SERVER['REQUEST_METHOD'] == 'POST') { try { $order = $_POST["order"]; $id = $orderInfo['id']; /* try { $recoderId = insertKey($orderInfo["email"], $orderInfo["ime"], $orderInfo["deviceid"], $orderInfo["devicetype"]); } catch (Exception $ex) { $message = $ex->getMessage(); $messageType = "error"; }*/ // Create the payment and redirect buyer to paypal for payment approval. if (isset($id)) { $baseUrl = getBaseUrl() . "/order_completion.php?orderid={$id}"; $payment = makePaymentUsingPayPal($order['amount'], 'USD', sprintf("Payment license %s Months - \$%s ", $prices["MonthNumber"], $order['amount']), "{$baseUrl}&success=true", "{$baseUrl}&success=false"); $_SESSION['orderinfo']['payment_id'] = $payment->getId(); header("Location: " . getLink($payment->getLinks(), "approval_url")); exit; } } catch (\PayPal\Exception\PPConnectionException $ex) { $message = parseApiError($ex->getData()); $messageType = "error"; } } } ?> <!DOCTYPE html> <html lang='en'> <head>
/** * @brief epay.getPaymentForm 에서 호출됨 */ function dispPaypalForm() { $oEpayController = getController('epay'); $oNcartModel = getModel('ncart'); $oModuleModel = getModel('module'); $oPaypalModuleConfig = $oModuleModel->getModuleConfig('paypal'); $oPaypalModel = getModel('paypal'); $paypalhome = sprintf(_XE_PATH_ . "files/epay/%s", $this->module_info->module_srl); $logged_info = Context::get('logged_info'); if ($logged_info) { $oEpayModel = getModel('epay'); $transaction_count = $oEpayModel->getTransactionCountByMemberSrl($logged_info->member_srl); if ($transaction_count < $oPaypalModuleConfig->minimum_transactions) { Context::set('error_code', '3'); Context::set('minimum_transactions_count', $oPaypalModuleConfig->minimum_transactions); $this->setTemplateFile('error'); return; } } // get products info using cartnos $output = $oEpayController->reviewOrder(); if (!$output->toBool()) { return $output; } Context::set('review_form', $output->review_form); //$cart_info = $output->cart_info; $transaction_srl = $output->transaction_srl; $order_srl = $output->order_srl; //Context::set('cart_info', $cart_info); Context::set('price', $output->price); Context::set('transaction_srl', $transaction_srl); Context::set('order_srl', $order_srl); require __DIR__ . '/bootstrap.php'; // Paypal account - 'paypal' / Credit card - 'credit_card' $payer = new Payer(); $payer->setPaymentMethod("paypal"); $item = new Item(); $item_name = $output->item_name; $item->setName($item_name)->setCurrency($oPaypalModuleConfig->currency_code)->setQuantity(1)->setPrice($oPaypalModel->getConvertedPrice($output->price, $oPaypalModuleConfig->conversion_rate)); $itemList = new ItemList(); $itemList->setItems(array($item)); /* $details = new Details(); $details->setShipping(number_format($cart_info->delivery_fee, 2)) ->setTax(number_format($cart_info->vat, 2)) ->setSubtotal(number_format($cart_info->supply_amount, 2)); */ $amount = new Amount(); $amount->setCurrency($oPaypalModuleConfig->currency_code)->setTotal($oPaypalModel->getConvertedPrice($output->price, $oPaypalModuleConfig->conversion_rate)); // ->setDetails($details); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description"); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $returnURL = getNotEncodedFullUrl('', 'module', $this->module_info->module, 'act', 'procPaypalExecutePayment', 'success', 'true', 'order_srl', $order_srl, 'transaction_srl', $transaction_srl); $cancelURL = getNotEncodedFullUrl('', 'module', $this->module_info->module, 'act', 'procPaypalExecutePayment', 'success', 'false', 'order_srl', $order_srl, 'transaction_srl', $transaction_srl); $redirectUrls->setReturnUrl($returnURL)->setCancelUrl($cancelURL); $payment = new Payment(); $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); try { $output = $payment->create($apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirectUrl = $link->getHref(); break; } } $_SESSION['paymentId'] = $payment->getId(); Context::set('redirectUrl', $redirectUrl); Context::set('payment_method', $payment_method); $this->setTemplateFile('formdata'); }
if (empty($config['api_root'])) { displaySetup(); } $message = ''; $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; $accessToken = !empty($_REQUEST['access_token']) ? $_REQUEST['access_token'] : ''; switch ($action) { case 'callback': // step 3 if (empty($_REQUEST['code'])) { $message = 'Callback request must have `code` query parameter!'; break; } $tokenUrl = sprintf('%s/index.php?oauth/token', $config['api_root']); $postFields = array('grant_type' => 'authorization_code', 'client_id' => $config['api_key'], 'client_secret' => $config['api_secret'], 'code' => $_REQUEST['code'], 'redirect_uri' => getCallbackUrl()); if (isLocal($config['api_root']) && !isLocal(getBaseUrl())) { $message = renderMessageForPostRequest($tokenUrl, $postFields); $message .= '<br />Afterwards, you can test JavaScript by clicking the link below.'; break; } // step 4 $json = makeCurlPost($tokenUrl, $postFields); $message = renderAccessTokenMessage($tokenUrl, $json); break; case 'refresh': // this is the refresh token flow if (empty($_REQUEST['refresh_token'])) { $message = 'Refresh request must have `refresh_token` query parameter!'; break; } $tokenUrl = sprintf('%s/index.php?oauth/token', $config['api_root']);
/* * Store user is redirected here once he has chosen * a payment method. */ require_once __DIR__ . '/../bootstrap.php'; session_start(); if (!isOrdered()) { header('Location: ../index.php'); exit; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $order = $_POST["order"]; try { $orderInfo = getOrderInfo(); //$recoderId = insertKey($orderInfo["email"],$orderInfo["ime"],$orderInfo["deviceid"],$orderInfo["devicetype"]); // Create the payment and redirect buyer to paypal for payment approval. $recoderId = 0; $baseUrl = getBaseUrl() . "/order_completion.php?paymentId={$recoderId}"; $payment = makePaymentUsingPayPal($order['amount'], 'USD', $order['description'], "{$baseUrl}&success=true", "{$baseUrl}&success=false"); header("Location: " . getLink($payment->getLinks(), "approval_url")); exit; } catch (\PayPal\Exception\PPConnectionException $ex) { $message = parseApiError($ex->getData()); $messageType = "error"; } catch (Exception $ex) { $message = $ex->getMessage(); $messageType = "error"; } } require_once 'index.php';
function jsUrl($url) { return getBaseUrl() . '/js/' . $url; }
<?php if (!isset($_SESSION['user'])) { return false; } $base_url = rtrim(getBaseUrl(), '/') . '/'; $download_url = $base_url . 'download/tweets/?format='; ?> <div id="modalDownloadTweets" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog modal-sm" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Download</h4> </div> <div class="modal-body"> <div class="row"> <div class="col-xs-6"><a href="<?php echo $download_url . 'json'; ?> " target="_blank" class="btn btn-primary btn-block">JSON</a></div> <div class="col-xs-6"><a href="<?php echo $download_url . 'xml'; ?> " target="_blank" class="btn btn-primary btn-block">XML</a></div> </div> <div class="row margin-top-xs"> <div class="col-xs-6"><a href="<?php echo $download_url . 'csv'; ?> " target="_blank" class="btn btn-primary btn-block">CSV</a></div>
<?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\OpenIdSession; $baseUrl = getBaseUrl() . '/UserConsentRedirect.php?success=true'; // ### Get User Consent URL // The clientId is stored in the bootstrap file //Get Authorization URL returns the redirect URL that could be used to get user's consent $redirectUrl = OpenIdSession::getAuthorizationUrl($baseUrl, array('openid', 'profile', 'address', 'email', 'phone', 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout', 'https://uri.paypal.com/services/invoicing'), null, null, null, $apiContext); // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Generated the User Consent URL", "URL", '<a href="' . $redirectUrl . '" >Click Here to Obtain User Consent</a>', $baseUrl, $redirectUrl);
function showTags($tags, $out) { foreach ($tags as $t) { $out .= "\t<li style=\"float: left;margin-right: 15px;\"><a href=\"" . getBaseUrl() . "tag/" . trim($t) . "\">" . trim($t) . "</a></li>\n"; } if ($out != "") { echo "<ul style=\"font-size: 10px;list-style: none;\">\n" . $out . "</ul>\n<br />\n"; } }
function isValidUrl($url) { /* validate base of url */ $url = getBaseUrl($url); /* make sure there is at least 1 dot */ if (!strpos($url, ".")) { return FALSE; } $urlregex = "^(https?|ftp)\\:\\/\\/([a-z0-9+!*(),;?&=\$_.-]+(\\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\\.[a-z0-9+\$_-]+)*(\\:[0-9]{2,5})?(\\/([a-z0-9+\$_-]\\.?)+)*\\/?(\\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$"; if (eregi($urlregex, $url)) { return TRUE; } return FALSE; }
} if ($_SERVER['REQUEST_METHOD'] == 'POST') { $order = $_REQUEST['order']; try { if ($order['payment_method'] == 'credit_card') { // Make a payment using credit card. $user = getUser(getSignedInUser()); $payment = makePaymentUsingCC($user['creditcard_id'], $order['amount'], 'USD', $order['description']); $orderId = addOrder(getSignedInUser(), $payment->getId(), $payment->getState(), $order['amount'], $order['description']); $message = "Your order has been placed successfully. Your Order id is <b>{$orderId}</b>"; $messageType = "success"; } else { if ($order['payment_method'] == 'paypal') { $orderId = addOrder(getSignedInUser(), NULL, NULL, $order['amount'], $order['description']); // Create the payment and redirect buyer to paypal for payment approval. $baseUrl = getBaseUrl() . "/order_completion.php?orderId={$orderId}"; $payment = makePaymentUsingPayPal($order['amount'], 'USD', $order['description'], "{$baseUrl}&success=true", "{$baseUrl}&success=false"); updateOrder($orderId, $payment->getState(), $payment->getId()); header("Location: " . getLink($payment->getLinks(), "approval_url")); exit; } } } catch (\PayPal\Exception\PPConnectionException $ex) { $message = parseApiError($ex->getData()); $messageType = "error"; } catch (Exception $ex) { $message = $ex->getMessage(); $messageType = "error"; } } require_once 'orders.php';
function getNewUrl($column) { global $_SERVER; global $columns; $newUrl = getBaseUrl(); $newUrl .= "?"; if (is_array($column)) { $i = 0; foreach ($column as $col) { if (is_array($col)) { $newUrl .= "column{$i}="; foreach ($col as $url) { if ($url["url"] != "") { $newUrl .= rawurlencode($url["url"]); $newUrl .= rawurlencode(" ") . rawurlencode($url["maxItems"]); $newUrl .= rawurlencode("\n"); } } $newUrl .= "&"; $i++; } } } return $newUrl; }
// ### Amount // Lets you specify a payment amount. // You can also specify additional details // such as shipping, tax. $amount = new Amount(); $amount->setCurrency("USD")->setTotal(20)->setDetails($details); // ### Transaction // A transaction defines the contract of a // payment - what is the payment for and who // is fulfilling it. $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid()); // ### Redirect urls // Set the urls that the buyer must be redirected to after // payment approval/ cancellation. $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl("{$baseUrl}/ExecutePayment.php?success=true")->setCancelUrl("{$baseUrl}/ExecutePayment.php?success=false"); // ### Payment // A Payment Resource; create one using // the above types and intent set to 'sale' $payment = new Payment(); $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); // For Sample Purposes Only. $request = clone $payment; // ### Create Payment // Create a payment by calling the 'create' method // passing it a valid apiContext. // (See bootstrap.php for more on `ApiContext`) // The return object contains the state and the // url to which the buyer must be redirected to
<?php require '../utilities/init.php'; require '../utilities/tools.php'; $data = Database::runQuery("SELECT * FROM ingredient WHERE id = :id", array("id" => $_GET['ingredientId'])); $data = $data[0]; // Grab the first result (should only be one) ?> <form id="updateIngredientForm" method="post" action="<?php echo getBaseUrl(); ?> api/ingredient/update.php"> <input type="hidden" name="id" id="ingredientId" value="<?php echo $data['id']; ?> "> <div id="errorMessage" class="alert alert-danger text-center" role="alert" style="display: none;"></div> <div class="form-group"> <label for="name">Ingredient Name</label> <input type="text" class="form-control" id="name" name="name" maxlength="30" required value="<?php echo $data['name']; ?> "> </div> <div class="form-group"> <label for="supplier">Supplier</label> <input type="text" class="form-control" id="supplier" name="supplier" maxlength="30" value="<?php echo $data['supplier']; ?> "> </div>
if ($r = $server->store_result()) { $r->free(); } } while ($server->more_results() && $server->next_result()); $result = $server->query("SELECT id FROM settings WHERE name='title'"); if ($result->num_rows == 1) { if (!@chmod('../install', 0777)) { echo "PLEASE DELETE install/ FOLDER MANUALLY. THEN GO TO yourwebsite.com/feedback/admin/ TO LOG IN."; exit; } //In case of success (by using previously set parameters), delete the content of installation folder unlink('index.php'); unlink('install1.php'); unlink('database_tables.sql'); unlink('index2.php'); unlink('install2.php'); header('Location: ../admin'); exit; } else { $server->query("INSERT INTO users(id,name,email,pass,votes,isadmin,banned) VALUES('','" . $_POST['adminname'] . "','" . $_POST['adminemail'] . "','" . $hashing->hash($_POST['adminpass']) . "', 20, 3,0)"); if (!@chmod('../install', 0777)) { $url = getBaseUrl(); displayMessage("PLEASE DELETE install/index.php, install/install1.php AND install/database_tables.sql FILES MANUALLY.<br />\n THEN GO TO <a href='" . $url . "/install/index2.php'>yourwebsite.com/feedback/install/index2.php</a> TO CONTINUE THE INSTALLATION."); exit; } //In case of success, delete the installation files of the first step unlink('index.php'); unlink('install1.php'); unlink('database_tables.sql'); header('Location: index2.php'); }
public function order() { $paypalConf = $this->config->item('paypal'); $clientId = $paypalConf['clientId']; $clientSecret = $paypalConf['clientSecret']; $appName = $paypalConf['appName']; $price = $paypalConf['price']; $shiping = 0; $tax = 0; $mode = "sandbox"; //or live $apiContext = new ApiContext(new OAuthTokenCredential($clientId, $clientSecret)); $apiContext->setConfig(array('mode' => $mode, 'log.LogEnabled' => false)); $payer = new Payer(); $payer->setPaymentMethod("paypal"); $item1 = new Item(); $item1->setName($appName)->setCurrency('USD')->setQuantity(1)->setPrice($price); $itemList = new ItemList(); $itemList->setItems(array($item1)); $details = new Details(); $details->setShipping($shiping)->setTax($tax)->setSubtotal($price); $amount = new Amount(); $amount->setCurrency("USD")->setTotal($price + $shiping + $tax)->setDetails($details); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid()); $token = $this->createToken(); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl("{$baseUrl}/paypal/ordersucess?success=true&tk1=" . $token[0] . "&tk2=" . $token[1])->setCancelUrl("{$baseUrl}/paypal/orderfailed?success=false"); $payment = new Payment(); $payment->setIntent("order")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); // For Sample Purposes Only. $request = clone $payment; try { $payment->create($apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex); exit(1); } $approvalUrl = $payment->getApprovalLink(); header("Location: " . $approvalUrl . ""); die; }