function view() { $post_id = $this->params[0]; $this->post = get_first("SELECT * FROM post NATURAL JOIN user WHERE post_id='{$post_id}'"); $this->tags = get_all("SELECT * FROM post_tags NATURAL JOIN tag WHERE post_id='{$post_id}'"); $this->comments = get_all("SELECT * FROM comment WHERE post_id ='{$post_id}'"); }
/** * Verifies if the user is logged in and authenticates if not and POST contains username, else displays the login form * @return bool Returns true when the user has been logged in */ function require_auth() { global $errors; // If user has already logged in... if ($this->logged_in) { return TRUE; } // Authenticate by POST data if (isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; $user = get_first("SELECT user_id, is_admin FROM user\n WHERE username = '******'\n AND password = '******'\n AND deleted = 0"); if (!empty($user['user_id'])) { $_SESSION['user_id'] = $user['user_id']; $this->load_user_data($user); return true; } else { $errors[] = "Vale kasutajanimi või parool"; } } // Display the login form require 'templates/auth_template.php'; // Prevent loading the requested controller (not authenticated) exit; }
function view() { // TODO: Protect against SQL injections some day $course_id = $this->params[0]; $this->course = get_first("SELECT * FROM course WHERE course_id = '{$course_id}'"); $this->lessons = get_all("SELECT * FROM lesson WHERE course_id = '{$course_id}'"); }
function edit() { $broneering_id = $this->params[0]; $this->broneering = get_first("SELECT * FROM broneering WHERE broneering_id = '{$broneering_id}'"); $this->dates = get_all("SELECT * FROM kuupaev"); $this->times = get_all("SELECT * FROM kellaeg"); }
function greedy_search($start, $end) { $first = array(); for ($i = 0; $i < count($end); $i++) { $temp = get_first($start, $end, $first); $first[] = $temp; } var_dump($first); }
public function findTime() { $time = get_first($this->request->get('subscr_date'), $this->request->get('payment_date')); if (!$time) { return parent::findTime(); } $d = new DateTime($time); $d->setTimezone(new DateTimeZone(date_default_timezone_get())); return $d; }
/** * Validate key and UID with database and return code instance if valid. * Returns false if combination is invalid. * * @param string $key * @param string $uid * @return System\User\Auth\Code|false */ public static function validate($key, $uid) { $conds = array("valid" => true, "key" => $key, "uid" => $uid); $code = get_first('\\System\\User\\Auth\\Code')->where($conds)->fetch(); if ($code) { if ($code->used == 0 || !$code->one_time) { $code->used = $code->used + 1; if ($code->one_time) { $code->drop(); } else { $code->save(); } return $code; } else { $code->drop(); } } return false; }
function get_income_report() { global $t, $vars, $db, $config; $report_days = get_first($GLOBALS['config']['payment_report_num_days'], 7); // get income $beg_tm = date('Y-m-d 00:00:00', time() - 3600 * $report_days * 24); $end_tm = date('Y-m-d 23:59:59', time()); $res = array(); $q = $db->query("SELECT FROM_DAYS(TO_DAYS(tm_added)) as date,\n count(payment_id) as added_count, sum(amount) as added_amount\n FROM {$db->config[prefix]}payments p\n WHERE tm_added BETWEEN '{$beg_tm}' AND '{$end_tm}'\n GROUP BY date\n "); while ($x = mysql_fetch_assoc($q)) { $res[$x['date']] = $x; } $q = $db->query("SELECT FROM_DAYS(TO_DAYS(tm_completed)) as date,\n count(payment_id) as completed_count, sum(amount) as completed_amount\n FROM {$db->config[prefix]}payments p\n WHERE tm_completed BETWEEN '{$beg_tm}' AND '{$end_tm}'\n AND completed>0\n GROUP BY date\n "); $max_total = 0; while ($x = mysql_fetch_assoc($q)) { $res[$x['date']] = array_merge((array) $x, (array) $res[$x['date']]); $total_completed += $x['completed_amount']; if ($x['completed_amount'] > $max_total) { $max_total = $x['completed_amount']; } } $res1 = array(); list($ty, $tm, $td) = split('-', date('Y-m-d')); $rtime = mktime(12, 0, 0, $tm, $td, $ty); for ($i = 0; $i < $report_days; $i++) { $dp = strftime("%a " . $config['date_format'], $rtime - $i * 3600 * 24); $d = date('Y-m-d', $rtime - $i * 3600 * 24); $res1[$d]['date'] = $d; $res1[$d]['date_print'] = $dp; $res1[$d]['added_count'] = intval($res[$d]['added_count']); $res1[$d]['completed_count'] = intval($res[$d]['completed_count']); $res1[$d]['added_amount'] = number_format($res[$d]['added_amount'], 2, '.', ','); $res1[$d]['completed_amount'] = number_format($res[$d]['completed_amount'], 2, '.', ','); if ($max_total) { $res1[$d]['percent_v'] = round(100 * $res[$d]['completed_amount'] / $max_total); $res1[$d]['percent'] = round(100 * $res[$d]['completed_amount'] / $total_completed); } } ksort($res1); return $res1; }
public function getOkUrl() { return get_first($this->redirect_url, $this->getConfiguredRedirect()); }
public function getOkUrl() { $event = new Am_Event(Am_Event::AUTH_GET_OK_REDIRECT, array('user' => $this->getDi()->user)); $event->setReturn($this->getConfiguredRedirect()); $this->getDi()->hook->call($event); return get_first($this->redirect_url, $event->getReturn()); }
function log($invoice_id, $paysys_id, $title, $vars = null, $type = 'info', $remote_addr = null, $tm = null) { $r = $this->createRecord(); if ($invoice = $this->getDi()->invoiceTable->load($invoice_id, false)) { $r->setInvoice($invoice); } $r->paysys_id = $paysys_id; $r->title = $title; $r->remote_addr = get_first($remote_addr, $_SERVER['REMOTE_ADDR']); $r->add($vars, false); $r->insert(); return $r; }
function doWork() { foreach ($this->groups as $group_id => $list) { $txn_types = array(); $currency = ""; $product_ids = array(); foreach ($list as $p) { $signup_params = array(); foreach ($p['data'] as $k => $d) { if (is_int($k) && !empty($d['txn_type'])) { @$txn_types[$d['txn_type']]++; } if (is_int($k) && !empty($d['mc_currency'])) { $currency = $d['mc_currency']; } if (@$d['txn_type'] == 'subscr_signup') { $signup_params = $d; } elseif (@$d['txn_type'] == 'web_accept') { $signup_params = $d; } } @$product_ids[$p['product_id']]++; } $invoice = $this->getDi()->invoiceRecord; $invoice->user_id = $this->user->pk(); foreach ($product_ids as $pid => $count) { $newP = $this->_translateProduct($pid); if ($newP) { $item = $invoice->createItem(Am_Di::getInstance()->productTable->load($newP)); } else { $item = $invoice->createItem(new ImportedProduct($pid)); } $item->_calculateTotal(); $invoice->addItem($item); } $invoice->paysys_id = 'paypal'; $invoice->tm_added = $list[0]['tm_added']; $invoice->tm_started = $list[0]['tm_completed']; $invoice->public_id = $signup_params['invoice'] ? $signup_params['invoice'] : $list[0]['payment_id']; $invoice->currency = $currency ? $currency : $item->currency; // Set currency; if (!empty($txn_types['web_accept'])) { $invoice->first_total = $signup_params['mc_gross']; $item = current($invoice->getItems()); $invoice->first_period = $item->first_period; $invoice->status = Invoice::PAID; } else { // recurring if ($signup_params) { $invoice->first_period = $invoice->second_period = strtolower(str_replace(' ', '', $signup_params['period3'])); $invoice->first_total = $invoice->second_total = $signup_params['mc_amount3']; if (!empty($signup_params['mc_amount1'])) { $invoice->first_total = $signup_params['mc_amount1']; $invoice->first_period = strtolower(str_replace(' ', '', $signup_params['period1'])); } if (!$signup_params['recurring']) { $invoice->rebill_times = 1; } elseif ($signup_params['recur_times']) { $invoice->rebill_times = $signup_params['recur_times']; } else { $invoice->rebill_times = IProduct::RECURRING_REBILLS; } } else { // get terms from products foreach ($product_ids as $pid => $count) { $newPid = $this->_translateProduct($pid); if (!$newPid) { continue; } $pr = Am_Di::getInstance()->productTable->load($newPid); $invoice->first_total += $pr->getBillingPlan()->first_price; $invoice->first_period = $pr->getBillingPlan()->first_period; $invoice->second_total += $pr->getBillingPlan()->second_price; $invoice->second_period = $pr->getBillingPlan()->second_period; $invoice->rebill_times = max(@$invoice->rebill_times, $pr->getBillingPlan()->rebill_times); } $invoice->rebill_times = IProduct::RECURRING_REBILLS; } if (@$txn_types['subscr_eot']) { $invoice->status = Invoice::RECURRING_FINISHED; } elseif (@$txn_types['subscr_cancel']) { $invoice->status = Invoice::RECURRING_CANCELLED; foreach ($list as $p) { if (!empty($p['data']['CANCELLED_AT'])) { $invoice->tm_cancelled = sqlTime($p['data']['CANCELLED_AT']); } } } elseif (@$txn_types['subscr_payment']) { $invoice->status = Invoice::RECURRING_ACTIVE; } $invoice->data()->set('paypal_subscr_id', $group_id); } foreach ($list as $p) { $pidlist[] = $p['payment_id']; } $invoice->data()->set('am3:id', implode(',', $pidlist)); $invoice->insert(); // insert payments and access foreach ($list as $p) { $newP = $this->_translateProduct($p['product_id']); $tm = null; $txnid = null; foreach ($p['data'] as $k => $d) { if (is_int($k) && !empty($d['payment_date'])) { $tm = $d['payment_date']; } if (is_int($k) && !empty($d['txn_id'])) { $txnid = $d['txn_id']; } } $tm = new DateTime(get_first(urldecode($tm), urldecode($p['tm_completed']), urldecode($p['tm_added']), urldecode($p['begin_date']))); $payment = $this->getDi()->invoicePaymentRecord; $payment->user_id = $this->user->user_id; $payment->invoice_id = $invoice->pk(); $payment->amount = $p['amount']; $payment->paysys_id = 'paypal'; $payment->dattm = $tm->format('Y-m-d H:i:s'); if ($txnid) { $payment->receipt_id = $txnid; } $payment->transaction_id = $txnid ? $txnid : 'import-paypal-' . mt_rand(10000, 99999); $payment->insert(); $this->getDi()->db->query("INSERT INTO ?_data SET\n `table`='invoice_payment',`id`=?d,`key`='am3:id',`value`=?", $payment->pk(), $p['payment_id']); if ($newP) { $a = $this->getDi()->accessRecord; $a->user_id = $this->user->user_id; $a->setDisableHooks(); $a->begin_date = $p['begin_date']; /// @todo handle payments that were cancelled but still active in amember 3. Calculate expire date in this case. if (($p['expire_date'] == self::AM3_RECURRING_DATE || $p['expire_date'] == self::AM3_LIFETIME_DATE) && array_key_exists('subscr_cancel', $txn_types)) { $a->expire_date = $invoice->calculateRebillDate(count($list)); } else { $a->expire_date = $p['expire_date']; } $a->invoice_id = $invoice->pk(); $a->invoice_payment_id = $payment->pk(); $a->product_id = $newP; $a->insert(); } } } }
function update() { $this->status = get_first($this->status, self::STATUS_CHANGED); parent::update(); }
function scan_file($filename, $use_chunks = true, $max_chunks = 255, $chunk_size = 256, $progresslistener = null) { global $verbose; if ($verbose) { print "Scanning file..." . PHP_EOL; } // Filename and size $this->filename = basename($filename); if (!$this->hashes->filename) { $this->hashes->filename = $this->filename; } $size = filesize($filename); $this->size = (string) $size; $piecelength_ed2k = 9728000; $known_hashes = $this->hashes->get_multiple('ed2k md5 sha1 sha256'); // If all hashes and pieces are already known, do nothing if (4 == sizeof($known_hashes) && $this->hashes->pieces) { return true; } // Calculate piece $length if ($use_chunks) { $minlength = $chunk_size * 1024; $this->hashes->piecelength = 1024; while ($size / $this->hashes->piecelength > $max_chunks || $this->hashes->piecelength < $minlength) { $this->hashes->piecelength *= 2; } if ($verbose) { print "Using piecelength " . $this->hashes->piecelength . " (" . $this->hashes->piecelength / 1024 . " KiB)" . PHP_EOL; } $numpieces = $size / $this->hashes->piecelength; if ($numpieces < 2) { $use_chunks = false; } } $hashes = array(); // Try to use hash extension if (extension_loaded('hash')) { $hashes['md4'] = hash_init('md4'); $hashes['md5'] = hash_init('md5'); $hashes['sha1'] = hash_init('sha1'); $hashes['sha256'] = hash_init('sha256'); $piecehash = hash_init('sha1'); $md4piecehash = null; if ($size > $piecelength_ed2k) { $md4piecehash = hash_init('md4'); $length_ed2k = 0; } } else { print "Hash extension not available. No support for SHA-256 and ED2K." . PHP_EOL; $hashes['md4'] = null; $hashes['md5'] = null; $hashes['sha1'] = null; $hashes['sha256'] = null; $piecehash = ''; } $piecenum = 0; $length = 0; // If some hashes are already available, do not calculate them if (isset($known_hashes['ed2k'])) { $known_hashes['md4'] = $known_hashes['ed2k']; unset($known_hashes['ed2k']); } foreach (array_keys($known_hashes) as $hash) { $hashes[$hash] = null; } // TODO: Don't calculate pieces if already known $this->hashes->pieces = array(); if (!$this->hashes->piecetype) { $this->hashes->piecetype = "sha1"; } $num_reads = ceil($size / 4096.0); $reads_per_progress = (int) ceil($num_reads / 100.0); $reads_left = $reads_per_progress; $progress = 0; $fp = fopen($filename, "rb"); while (true) { $data = fread($fp, 4096); if ($data == "") { break; } // Progress updating if ($progresslistener) { $reads_left -= 1; if ($reads_left <= 0) { $reads_left = $reads_per_progress; $progress += 1; $result = $progresslistener->Update($progress); if (get_first($result) == false) { if ($verbose) { print "Cancelling scan!" . PHP_EOL; } return false; } } } // Process the $data if ($hashes['md5']) { hash_update($hashes['md5'], $data); } if ($hashes['sha1']) { hash_update($hashes['sha1'], $data); } if ($hashes['sha256']) { hash_update($hashes['sha256'], $data); } $left = strlen($data); if ($hashes['md4']) { if ($md4piecehash) { $l = $left; $numbytes_ed2k = 0; while ($l > 0) { if ($length_ed2k + $l <= $piecelength_ed2k) { if ($numbytes_ed2k) { hash_update($md4piecehash, substr($data, $numbytes_ed2k)); } else { hash_update($md4piecehash, $data); } $length_ed2k += $l; $l = 0; } else { $numbytes_ed2k = $piecelength_ed2k - $length_ed2k; hash_update($md4piecehash, substr($data, 0, $numbytes_ed2k)); $length_ed2k = $piecelength_ed2k; $l -= $numbytes_ed2k; } if ($length_ed2k == $piecelength_ed2k) { hash_update($hashes['md4'], hash_final($md4piecehash, true)); $md4piecehash = hash_init('md4'); $length_ed2k = 0; } } } else { hash_update($hashes['md4'], $data); } } while ($use_chunks && $left > 0) { if ($length + $left <= $this->hashes->piecelength) { if (is_string($piecehash)) { $piecehash .= $data; } else { hash_update($piecehash, $data); } $length += $left; $left = 0; } else { $numbytes = $this->hashes->piecelength - $length; if (is_string($piecehash)) { $piecehash .= substr($data, 0, $numbytes); } else { hash_update($piecehash, substr($data, 0, $numbytes)); } $length = $this->hashes->piecelength; $data = substr($data, $numbytes); $left -= $numbytes; } if ($length == $this->hashes->piecelength) { if ($verbose) { print "Done with piece hash" . sizeof($this->hashes->pieces) . PHP_EOL; } $this->hashes->pieces[] = is_string($piecehash) ? sha1($piecehash) : hash_final($piecehash); $piecehash = is_string($piecehash) ? '' : hash_init('sha1'); $length = 0; } } } if ($use_chunks) { if ($length > 0) { if ($verbose) { print "Done with piece hash" . sizeof($this->hashes->pieces) . PHP_EOL; } $this->hashes->pieces[] = is_string($piecehash) ? sha1($piecehash) : hash_final($piecehash); } if ($verbose) { print "Total number of pieces:" . sizeof($this->hashes->pieces) . PHP_EOL; } } fclose($fp); if ($hashes['md4']) { if ($md4piecehash && $length_ed2k) { hash_update($hashes['md4'], hash_final($md4piecehash, true)); } $this->hashes['ed2k'] = hash_final($hashes['md4']); } foreach (explode(' ', 'md5 sha1 sha256') as $hash) { if ($hashes[$hash]) { $this->hashes[$hash] = hash_final($hashes[$hash]); } elseif (function_exists($function = $hash . '_file')) { $this->hashes[$hash] = call_user_func($function, $filename); } } if (sizeof($this->hashes->pieces) < 2) { $this->hashes->pieces = array(); } // Convert to string $this->hashes->piecelength = (string) $this->hashes->piecelength; if ($verbose) { print "done" . PHP_EOL; } if ($progresslistener) { $progresslistener->Update(100); } return true; }
function edit() { $user_id = $this->params[0]; $this->user = get_first("SELECT * FROM user WHERE user_id = '{$user_id}'"); }
protected function handleEmail(SavedForm $form, &$vars) { /* @var $user User */ $user = $this->user; $bricks = $form->getBricks(); foreach ($bricks as $brick) { if ($brick->getClass() == 'email' && $brick->getConfig('validate') && $vars['email'] != $user->email) { $code = $this->getDi()->app->generateRandomString(self::EMAIL_CODE_LEN); $data = array('security_code' => $code, 'email' => $vars['email']); $this->getDi()->store->setBlob(self::SECURITY_CODE_STORE_PREFIX . $this->user_id, serialize($data), sqlTime(Am_Di::getInstance()->time + self::SECURITY_CODE_EXPIRE * 3600)); $tpl = Am_Mail_Template::load('verify_email_profile', get_first($user->lang, Am_Di::getInstance()->app->getDefaultLocale(false)), true); $cur_email = $user->email; $user->email = $vars['email']; $tpl->setUser($user); $tpl->setCode($code); $tpl->setUrl($this->getDi()->config->get('root_surl') . '/profile/confirm-email?em=' . $user->pk() . ':' . $code); $tpl->send($user); $user->email = $cur_email; unset($vars['email']); return true; } } return false; }
public function _valuesToForm(array &$values, Am_Record $record) { parent::_valuesToForm($values, $record); switch (get_first(@$values['name'], @$_GET['name'])) { case EmailTemplate::AUTORESPONDER: $values['day'] = empty($values['day']) || $values['day'] == 1 ? array('count' => 1, 'type' => '1') : array('count' => $values['day'], 'type' => ''); break; case EmailTemplate::EXPIRE: $day = @$values['day']; $values['day'] = array('count' => $day, 'type' => ''); if ($day > 0) { $values['day']['type'] = '+'; } elseif ($day < 0) { $values['day']['type'] = '-'; $values['day']['count'] = -$day; } else { $values['day']['type'] = '0'; } break; } $values['attachments'] = explode(',', @$values['attachments']); $values['_not_conditions'] = explode(',', @$values['not_conditions']); if (!empty($values['recipient_emails'])) { $values['recipient_other'] = 1; } if (!$record->isLoaded()) { $values['recipient_user'] = 1; $values['format'] = 'html'; } }
<?php $film_id = !empty($_GET['id']) ? $_GET['id'] : 1; //Connect to database $db = mysqli_connect('127.0.0.1', 'root', '', 'filmibaas') or die(mysqli_error($db)); mysqli_query($db, "SET NAMES 'utf8'"); //Retrieve film data from database $film = get_first("SELECT *, film.name as name, country.name as country\n FROM film\n JOIN country on film.country_id = country.country_id\n WHERE film_id={$film_id}"); //Retrieve price and copies information from database $products = get_first("SELECT*, FORMAT as format\n FROM products\n JOIN film on film.film_id = products.film_id\n WHERE film.film_id = {$film_id}"); //Retrieve all relationships for the film from database $relationships = get_all("SELECT link_type.name as type, author.name as author\n FROM l_author_film\n JOIN author ON author.author_id = l_author_film.author_id\n JOIN link_type ON link_type.type_id = l_author_film.type_id\n WHERE film_id={$film_id}"); //Retrieve all genres for the film from database $genres = get_all("SELECT genre.name as genre\n FROM l_film_genre\n JOIN film ON film.film_id = l_film_genre.film_id\n JOIN genre ON genre.genre_id = l_film_genre.genre_id\n WHERE film.film_id={$film_id}");
function edit() { $product_id = $this->params[0]; $this->product = get_first("SELECT * FROM product WHERE product_id = '{$product_id}'"); }
public function _valuesToForm(array &$values) { parent::_valuesToForm($values); switch (get_first(@$values['name'], @$_GET['name'])) { case EmailTemplate::AUTORESPONDER: $values['day'] = empty($values['day']) || $values['day'] == 1 ? array('count' => 1, 'type' => '1') : array('count' => $values['day'], 'type' => ''); break; case EmailTemplate::EXPIRE: $day = @$values['day']; $values['day'] = array('count' => $day, 'type' => ''); if ($day > 0) { $values['day']['type'] = '+'; } elseif ($day < 0) { $values['day']['type'] = '-'; $values['day']['count'] = -$day; } else { $values['day']['type'] = '0'; } break; } }
function edit() { $module_id = $this->params[0]; $this->module = get_first("SELECT * FROM module WHERE module_id = '{$module_id}'"); }
function edit() { $author_id = $this->params[0]; $this->author = get_first("SELECT * FROM author WHERE author_id = '{$author_id}'"); }
function getConfigPageId() { return get_first($this->defaultTitle, $this->getId(true)); }
function log($message, $tablename = '', $record_id = 0, $admin_id = 0) { $admin_id = get_first($admin_id, $this->getDi()->authAdmin->getUserId()); $admin_login = $admin_id ? $this->getDi()->adminTable->load($admin_id)->login : $this->getDi()->authAdmin->getUsername(); $this->_db->query("INSERT INTO ?_admin_log\n SET dattm=?,\n admin_id=?,admin_login=?,ip=?,\n tablename=?,record_id=?,message=?", $this->getDi()->sqlDateTime, $admin_id, $admin_login, $_SERVER['REMOTE_ADDR'], $tablename, $record_id, $message); }
} } } if ($view) { $v++; print "<TR>"; // メモ内容 print "<TD VALIGN=TOP>"; print "・<A HREF=\"./workflow/result/?p=top&no=" . $row["seqno"] . "\">"; $subject = mb_strcut($row["subject"], 0, 60, "EUC-JP"); if (trim($subject) == "") { $subject = "(no subject)"; } print $subject; print "</A>"; print "(" . get_first("users", "name_ryaku", "id='" . $row["user_id"] . "'", "不明または削除") . ")"; print " <FONT COLOR=#666666>" . date("n/j", datetime2timestamp($row["createstamp"])) . "<BR>"; print " (" . mb_strcut(preg_replace("/\r\n|\r|\n|\r\n/", " ", $row["body1"]), 0, 60, "EUC-JP") . ")"; print "</TD></TR>\n"; if ($i < $cnt - 1) { print "<TR BGCOLOR={$bg_dark}><TD HEIGHT=1><IMG SRC=\"./image/{$borderwidth}.gif\" WIDTH=100% HEIGHT={$borderwidth}></TD></TR>"; } } } print "</TABLE>"; if ($v == 0) { print "<FONT COLOR=#CCCCCC>未決裁なし</FONT>\n"; } // } print "</TD></TR></TABLE>";
$flow_ids = $row_pre["flow_ids"]; $flow_arr = split(",", $flow_ids); $flow_cnt = sizeof($flow_arr); if ($flow_cnt > 0) { for ($c = 0; $c < $flow_cnt; $c++) { if ($flow_arr[$c] == $login_id) { $flow_no = $c + 1; break; } } } $status = "0"; //未分類とする if ($row_pre["result_sign"] == "") { // 承認が完了していないデータ $recognize_sign = get_first("workflow_ret", "recognize_sign", "refno=" . $row_pre["seqno"] . " AND seqno=" . $flow_no, ""); if ($recognize_sign == "") { if ($flow_no == 1) { $status = "1"; } else { $before_res_cnt = get_count("workflow_ret", "refno=" . $row_pre["seqno"] . " AND seqno=" . ($flow_no - 1)); if ($before_res_cnt > 0) { $status = "1"; } } } else { if ($recognize_sign == "t") { $status = "2"; } elseif ($recognize_sign == "f") { $status = "3"; }
public function expressCheckoutAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs) { $invoiceLog = $this->_logDirectAction($request, $response, $invokeArgs); $token = $request->getFiltered('token'); if (!$token) { throw new Am_Exception_InputError("No required [token] provided, internal error"); } $log = $this->getDi()->invoiceLogRecord; $log->title = ""; $log->paysys_id = $this->getId(); if ($request->getInt('do')) { $invoice = current($this->getDi()->invoiceTable->findByData(self::PAYPAL_EXPRESS_TOKEN, $token)); if (!$invoice) { throw new Am_Exception_InternalError("Could not find invoice by token [{$token}]"); } $invoiceLog->setInvoice($invoice); $this->_setInvoice($invoice); $log->setInvoice($invoice); if ($invoice->first_total > 0) { // bill initial amount @todo free trial $log->title .= " doExpressCheckout"; $apireq = new Am_Paysystem_PaypalApiRequest($this); $apireq->doExpressCheckout($invoice, $token, $request->getFiltered('PayerID')); $vars = $apireq->sendRequest($log); $transaction = new Am_Paysystem_Transaction_PayPalExpress_DoExpressCheckout($this, $vars); $transaction->setInvoice($invoice); $transaction->process(); } if ($invoice->rebill_times) { $log->title .= " createRecurringPaymentProfile"; $apireq = new Am_Paysystem_PaypalApiRequest($this); $apireq->createRecurringPaymentProfile($invoice, null, $token, $request->getFiltered('PayerID')); $vars = $apireq->sendRequest($log); if (!in_array($vars['ACK'], array('Success', 'SuccessWithWarning'))) { $this->logError("Not Success response to CreateRecurringPaymentProfile request", $vars); } else { $invoice->data()->set(self::PAYPAL_PROFILE_ID, $vars['PROFILEID'])->update(); if ($invoice->first_total <= 0) { $transaction = new Am_Paysystem_Transaction_PayPalExpress_CreateRecurringPaymentProfile($this, $vars); $transaction->setInvoice($invoice); $transaction->process(); } } } return Am_Controller::redirectLocation($this->getReturnUrl()); } else { $log->title .= " getExpressCheckoutDetails"; $apireq = new Am_Paysystem_PaypalApiRequest($this); $apireq->getExpressCheckoutDetails($token); $vars = $apireq->sendRequest($log); $invoiceId = filterId(get_first(@$vars['INVNUM'], @$vars['L_PAYMENTREQUEST_0_INVNUM'], $this->getDi()->session->paypal_invoice_id)); if (!$invoiceId || !($invoice = $this->getDi()->invoiceTable->findBySecureId($invoiceId, 'paypal'))) { throw new Am_Exception_InputError("Could not find invoice related to given payment. Internal error. Your account was not billed, please try again"); } $invoiceLog->setInvoice($invoice); $log->setInvoice($invoice); $log->update(); $this->_setInvoice($invoice); /* @var $invoice Invoice */ if ($invoice->isPaid()) { return Am_Controller::redirectLocation($this->getReturnUrl()); } $invoice->data()->set(self::PAYPAL_EXPRESS_TOKEN, $token)->update(); $view = new Am_View(); $view->invoice = $invoice; $view->url = $this->getPluginUrl(self::PAYPAL_EXPRESS_CHECKOUT); $view->hidden = array('do' => '1', 'token' => $request->getFiltered('token'), 'PayerID' => $request->getFiltered('PayerID')); $view->display("payment-confirm.phtml"); } }
function log($user_id = null, $ip = null, $url = null, $referer = null) { $this->_db->query("INSERT INTO ?_access_log\n (time, user_id, remote_addr, url, referrer)\n VALUES\n (?, ?d, ?, ?, ?)", $this->getDi()->sqlDateTime, get_first($user_id, $this->getDi()->auth->getUserId()), get_first($ip, $_SERVER['REMOTE_ADDR']), get_first($url, $_SERVER['REQUEST_URI']), get_first($referer, @$_SERVER['HTTP_REFERER'])); }
<?php $author_id = !empty($_GET['id']) ? $_GET['id'] : 1; //Retrieve author data from database $author = get_first("SELECT *, author.name as name, country.name as country,\n gender.name as gender\n FROM author\n JOIN country on author.country_id = country.country_id\n JOIN gender on author.gender_id = gender.gender_id\n WHERE author_id={$author_id}"); //Retrieve all relationships for the author from database $relationships = get_all("SELECT link_type.name as type, film.name as film\n FROM l_author_film\n JOIN film ON film.film_id = l_author_film.film_id\n JOIN link_type ON link_type.type_id = l_author_film.type_id\n WHERE author_id={$author_id}");
function edit() { $admin_id = $this->params[0]; $this->admin = get_first("SELECT * FROM admin WHERE admin_id = '{$admin_id}'"); }