function order_placed($secret, $get, $cookie, $order_no, $amount, $email, $name, $customer_id) { global $affiliate_cookie, $commission_percent, $commission_fixed, $lifetime_revenue_share; if ($error = check_secret($secret)) { return $error; } $affiliate = null; $db = new Database(); if (isset($cookie[$affiliate_cookie])) { $affiliate = preg_split('/,/', $cookie[$affiliate_cookie], 2); } if ($affiliate == null && $lifetime_revenue_share && $customer_id != '') { $stmt = $db->get_pdo()->prepare('select affiliate, affiliate_data from orders ' . 'where customer_id = :customer_id ' . 'order by date_entered desc limit 1'); $stmt->execute(array('customer_id' => $customer_id)); $row = $stmt->fetch(); if ($row) { $affiliate = $row; } } if ($affiliate != null) { $row = $db->get_row_by_key('affiliates', 'id', $affiliate[0]); if ($row) { $fixed = $commission_fixed; $percent = $commission_percent; if (!$row['default_commission']) { $fixed = $row['commission_fixed']; $percent = $row['commission_percent']; } $commission = $amount * $percent / 100 + $fixed; $data = array('id' => $order_no, 'affiliate' => $affiliate[0], 'affiliate_data' => $affiliate[1], 'total' => $amount, 'commission' => $commission, 'status' => 'new', 'customer_email' => $email, 'customer_name' => $name, 'customer_id' => $customer_id); $db->insert('orders', $data); } } }
public function __construct($file) { global $admin_required; $this->file = $file; $this->show_menu = true; $this->variables = array(); $this->admin = isset($admin_required); try { $db = new Database(); $result = $db->get_pdo()->query('select count(*) from banners'); if ($result) { $result = $result->fetch(); $this->offer_banners = $result[0] > 0; } else { $this->set('reason', 'This may be because the table definitions have not been ' . 'loaded into the database.'); $this->fatal('Unable to read the banners table.'); } } catch (PDOException $ex) { $this->set('reason', 'This probably means that the database details in ' . 'config.inc are incorrect.'); $this->fatal($ex->getMessage()); } $this->set('key', Template::get_ajax_key()); }
*/ $admin_required = TRUE; require_once '../lib/bootstrap.php'; $db = new Database(); $template = new Template('admin-banners'); $banners = __('Banners'); $template->set('title', "{$affiliate_programme_name}: {$banners}"); $template->set('start', 'normal'); if (isset($_FILES['file'])) { $template->set('new_file', $_FILES['file']['name']); $template->set('new_name', $_POST['new_name']); $template->set('new_linktarget', $_POST['new_linktarget']); $row = $db->get_row_by_key('banners', 'name', $_POST['new_name']); if ($row != null) { $template->set('start', 'duplicate'); } else { $image = file_get_contents($_FILES['file']['tmp_name']); $db->insert('banners', array('name' => $_POST['new_name'], 'link_target' => $_POST['new_linktarget'], 'enabled' => 1, 'banner' => $image, 'mime_type' => $_FILES['file']['type'])); $template->set('start', 'success'); } } else { $template->set('new_file', ''); $template->set('new_name', ''); $template->set('new_linktarget', ''); } $rows = $db->get_pdo()->query('select id, name, link_target, enabled from banners order by id'); $rows = $rows->fetchAll(); $template->set('banners', $rows); $slash = substr($store_home, -1) == '/' ? '' : '/'; $template->set('store_home', $store_home . $slash); $template->render();
} $variable = 'Something'; $column = 'total'; switch ($_GET['variable']) { case 'commission': $variable = 'Commission'; $column = 'commission'; break; case 'orders': $variable = 'Orders'; $column = 'count'; break; } if (isset($_GET['fromcache'])) { $db = new Database(); $stmt = $db->get_pdo()->query('select * from daily_orders where affiliate = ' . $_SESSION['affiliate_id'] . ' and ' . 'date_sub(curdate(), interval 90 day) <= date_entered'); $rows = $stmt->fetchAll(); $days = array(); foreach ($rows as $row) { $days[$row['date_entered']] = $row; } $_SESSION['order_graph_cache'] = $days; } else { $days = $_SESSION['order_graph_cache']; } $data = array(); for ($day = 1 - $days_back; $day <= 0; $day++) { $timestamp = time() + $day * 60 * 60 * 24; $date_str = date('Y-m-d', $timestamp); $value = isset($days[$date_str]) ? $days[$date_str][$column] : 0.0; $bar = array($value, 0xc0, 0xe0, 0xff);
Affiliates For All is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Affiliates For All 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 Affiliates For All. If not, see <http://www.gnu.org/licenses/>. */ $admin_required = TRUE; require_once '../lib/bootstrap.php'; $db = new Database(); $stmt = $db->get_pdo()->prepare('select id, paypal, local_username, ( select sum(commission) from orders where orders.affiliate=affiliates.id and orders.status in (\'refund\', \'refunded\', \'shipped\') and orders.date_entered < :date + interval 1 day ) as commission, ( select sum(amount) from payments where payments.affiliate=affiliates.id ) as already_paid from affiliates'); $date = Database::format_date($_GET['end']); $stmt->execute(array('date' => $date)); $rows = $stmt->fetchAll(); header('Content-Type: text/plain'); foreach ($rows as $row) { $amount = sprintf('%2.2f', $row[3] - $row[4]); $id = preg_replace('/[^A-Za-z0-9]/', '', $row[2]);
$success = 0; $failure = 0; $payments = file($_FILES['file']['tmp_name']); foreach ($payments as $payment) { $fields = preg_split("/\t/", $payment); $identifiers = preg_split('/_/', $fields[3]); $id = $identifiers[1]; if ($fields[1] && $id) { $db->insert('payments', array('affiliate' => $id, 'amount' => $fields[1])); $success++; } else { $failure++; } } $template->set('message', ' <div id="message" class="dialogue" title="Payment Upload"> Upload completed. ' . $success . ' payments created, ' . $failure . ' errors. </div>'); } else { $template->set('message', ''); } $stmt = $db->get_pdo()->query('select sum(total), sum(commission) from orders ' . "where status in ('shipped', 'refunded', 'refund')"); $row = $stmt->fetch(); $template->set('total_orders', $row ? $db->format_currency($row[0]) : '0.00'); $template->set('total_commission', $row ? $db->format_currency($row[1]) : '0.00'); $pay_stmt = $db->get_pdo()->query('select sum(amount) from payments'); $pay_row = $pay_stmt->fetch(); $template->set('total_payments', $db->format_currency($pay_row[0])); $template->set('total_payable', $db->format_currency($row[1] - $pay_row[0])); $template->render();
Affiliates For All is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Affiliates For All 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 Affiliates For All. If not, see <http://www.gnu.org/licenses/>. */ $wizard_not_required = TRUE; require_once '../lib/bootstrap.php'; $template = new Template('account'); $title = __('Account Settings'); $template->set('title', "{$affiliate_programme_name}: {$title}"); $template->set('terms', $terms_of_business); $template->set('wizard', isset($_SESSION['wizard_incomplete'])); if (isset($_SESSION['wizard_incomplete'])) { $template->suppress_menu(); } $db = new Database(); $stmt = $db->get_pdo()->query('select * from affiliates where id = ' . $_SESSION['affiliate_id']); $row = $stmt->fetch(); foreach ($row as $key => $value) { $template->set("user_{$key}", $value); } $stmt = $db->get_pdo()->query('select * from countries order by name'); $template->set("countries", $stmt->fetchAll()); $template->render();
Affiliates For All is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Affiliates For All 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 Affiliates For All. If not, see <http://www.gnu.org/licenses/>. */ require_once '../lib/bootstrap.php'; $template = new Template('overview'); $overview = __('Overview'); $template->set('title', "{$affiliate_programme_name}: {$overview}"); $template->set('currency', $currency); $link = $store_home . '?' . $affiliate_referrer_parameter . '=' . $_SESSION['affiliate_id']; $template->set('link', $link); $template->set('link2', $link . '&' . $affiliate_data_parameter . '=your_data'); $template->set('id', $_SESSION['affiliate_id']); $db = new Database(); $stmt = $db->get_pdo()->query('select total, commission from affiliate_totals where affiliate = ' . $_SESSION['affiliate_id']); $row = $stmt->fetch(); $template->set('total_orders', $row ? $db->format_currency($row[0]) : '0.00'); $template->set('total_commission', $row ? $db->format_currency($row[1]) : '0.00'); $pay_stmt = $db->get_pdo()->query('select sum(amount) from payments where affiliate = ' . $_SESSION['affiliate_id']); $pay_row = $pay_stmt->fetch(); $template->set('total_payments', $db->format_currency($pay_row[0])); $template->set('total_payable', $db->format_currency($row[1] - $pay_row[0])); $template->render();