public static function getInstance($prefix = null) { if ($prefix == null) { $prefix = CShop::app()->getConfig('database'); $prefix = $prefix['prefix']; } return new self($prefix); }
public static function loadPlugin($id) { $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('*')->from('plugin')->leftJoin('option')->on('category = `class`')->where('plugin.id = ?')); $sql->execute(array($id)); $sql = $sql->fetchAll(); $class = $sql[0]['class']; return new $class($sql[0]['id'], $sql); }
public static function getParameters() { $inputs = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('input')->order('`order`'))->fetchAll(); $range = array('' => 'میتوانید خالی باشد'); foreach ($inputs as $input) { $range[$input['id']] = $input['name']; } return array('merchant' => array('name' => 'شناسه درگاه'), 'pass' => array('name' => 'رمز'), 'title' => array('name' => 'عنوان خرید'), 'email' => array('name' => 'فیلد ایمیل', 'type' => 'select', 'range' => $range), 'mobile' => array('name' => 'فیلد شماره تماس', 'type' => 'select', 'range' => $range)); }
public static function getParameters() { $inputs = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('input')->order('`order`'))->fetchAll(); $range = array(); foreach ($inputs as $input) { $range[$input['id']] = $input['name']; } return array('input' => array('name' => 'فیلد ورودی', 'type' => 'select', 'range' => $range), 'from' => array('name' => 'ایمیل فرستنده'), 'fromname' => array('name' => 'نام فرستنده'), 'subject' => array('name' => 'موضوع ایمیل'), 'signature' => array('name' => 'امضا', 'type' => 'textarea'), 'smtpauth' => array('name' => 'ارسال با SMTP', 'type' => 'select', 'range' => array(0 => 'غیر فعال', 1 => 'فعال')), 'smtpusername' => array('name' => 'نام کاربری SMTP'), 'smtppassword' => array('name' => 'کلمه عبور SMTP', 'type' => 'password'), 'smtphost' => array('name' => 'سرور SMTP'), 'smtpport' => array('name' => 'پورت SMTP'), 'smtpsecure' => array('name' => 'امنیت SMTP')); }
/** * * @param Payment $payment * @see GatewayBase::sendToGateway() */ public function sendToGateway($payment, $callback) { $AccountNumber = trim($this->AccountNumber); $Amount = round($payment['amout']); $RequestId = $payment['id']; $BackUrl = $callback; echo "<form name='myform' method='post' action='http://www.sharjiran.net/sharjiran/PayInfo.php' >\n\t <input type='hidden' name='AccountNumber' value={$AccountNumber} >\n\t <input type='hidden' name='Amount' value={$Amount} >\n\t <input type='hidden' name='RequestId' value={$RequestId} >\n\t <input type='hidden' name='BackUrl' value={$BackUrl} >\n </form>\n\t\t\t <script language='javascript'>document.myform.submit();</script>"; CShop::app()->end(); }
public function updateUser(&$payment, &$items) { $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('field.name,item.id')->from('item')->leftJoin('product')->on('product.id = item.productid')->leftJoin('field')->on('field.productid = product.id')->where('paymentid = ? AND type="ibsnggroup"')); $sql->execute(array($payment['id'])); $sql = $sql->fetch(); $group = $sql['name']; $ibs = new IBSngHelper($this->username, $this->password, $this->server); $ibs->chargeUser($group, $payment['input'][$this->usernameinput]['value'], $payment['input'][$this->passwordinput]['value']); $items[$sql['id']][] = array('fieldname' => $payment['input'][$this->usernameinput]['name'], 'type' => 'text', 'value' => $payment['input'][$this->usernameinput]['value']); $items[$sql['id']][] = array('fieldname' => $payment['input'][$this->passwordinput]['name'], 'type' => 'text', 'value' => $payment['input'][$this->passwordinput]['value']); }
public function __construct($total = null, $page = false, $pageLimit = false) { $this->total = $total; if ($page === false) { $page = isset($_GET[self::$pageVar]) ? $_GET[self::$pageVar] : 1; } $this->current = $page; if ($pageLimit === false) { $pageLimit = CShop::app()->systemOption()->pagelimit; } $this->pageLimit = $pageLimit; }
/** * Be Carefull, if $redirect be null, you must check return value * @param string $redirect * @return boolean * */ public function isLogin($redirect = NULL) { if (!isset($this->logged_in)) { $this->checkLogin(); } if ($this->loggedin == false) { if ($redirect) { CShop::app()->redirect($redirect); } } return $this->loggedin; }
/** * @param Payment $payment * @see GatewayBase::sendToGateway() */ public function sendToGateway($payment, $callback) { $merchantID = trim($this->merchant); $amount = round($payment['amount'] / 10); $invoice_id = $payment['id']; $callBackUrl = $callback; $client = new nusoap_client('http://jahanpay.com/webservice?wsdl', 'wsdl'); $res = $client->call('requestpayment', array($merchantID, $amount, $callBackUrl, $invoice_id, urlencode($this->title))); if ($res > 0) { $sql = CShop::app()->getDb()->prepare("UPDATE `payment` SET `reference` = ? WHERE `reference` = ? LIMIT 1"); $sql->execute(array($res, $invoice_id)); Cshop::app()->redirect('http://jahanpay.com/pay_invoice/' . $res); } else { $data = array(); $data['status'] = 'error'; $data['content'] = 'خطا در اتصال به جهان پی کد خطا'; $data['message'] = '<font color="red">خطا در اتصال به جهان پی کد خطا</font>' . $res; return $data; } }
/** * * @param Controller $controller */ public function actionVoucher($controller) { $message = $controller->getUser()->message(); if (isset($_POST['remove'])) { foreach ($_POST['delete'] as $value) { $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('voucher')->where('id = ?')); $sql->execute(array($value)); } $message['content'] = 'تغییرات با موفقیت ذخیره شد'; $message['type'] = 'success'; $controller->getUser()->message($message); CShop::app()->redirect($_SERVER['REQUEST_URI']); } $sql = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('voucher')); $content = '<div class="title">مدیریت کد های تخفیف</div> <div class="content"> <form action="" method="post"> <table> <tr> <th>ردیف</th> <th>کد</th> <th>ارزش</th> <th>زمان پایان</th> <th>تعداد باقی مانده</th> <th>مدیریت</th> <th><a href="#" onclick="check(this)">انتخاب</a></th> </tr>'; $i = 1; while ($item = $sql->fetch()) { $content .= '<tr>'; $content .= '<td>' . $i++ . '</td>'; $content .= '<td>' . $item['code'] . '</td>'; $content .= '<td>' . $item['value'] . '%</td>'; $content .= '<td>' . jDateTime::date(CShop::app()->systemConfig()->timeformat, $item['paymenttime'] ? $item['paymenttime'] : $item['time']) . '</td>'; $content .= '<td>' . $item['maxuse'] . '</td>'; $content .= '<td><a href="' . self::getActionLink('editvoucher', $this->id) . '&vid=' . $item['id'] . '">ویرایش</a></td>'; $content .= '<td><input type="checkbox" name="delete[]" value="' . $item['id'] . '"></td>'; $content .= '</tr>'; } $content .= '</table><div style="text-align: left"><input type="submit" value="ذخیره" name="update"><input type="submit" value="حذف" name="remove"></div></form></div>'; $controller->renderWithContent($content, array('message' => $message)); }
<table> <tr> <th>ردیف</th> <th>تاریخ</th> <th>مبلغ</th> <th>وضعیت</th> <th>مدیریت</th> <th><a href="#" onclick="check(this)">انتخاب</a></th> </tr> <?php $td = $th = ''; $i = 1 + $this->pagination->offset(); foreach ($items as $item) { echo '<tr>'; echo '<td>' . $i++ . '</td>'; echo '<td>' . jDateTime::date(CShop::app()->systemConfig()->timeformat, $item['paymenttime'] ? $item['paymenttime'] : $item['requesttime']) . '</td>'; echo '<td>' . $item['amount'] . '</td>'; echo '<td>'; echo $item['status'] == Application::STATUS_COMPLETE ? 'پرداخت شده' : 'پرداخت نشده'; echo '</td>'; echo '<td><a href="viewpayment.php?id=' . $item['id'] . '">مشاهده</a></td>'; echo '<td><input type="checkbox" name="delete[]" value="' . $item['id'] . '"></td>'; echo '</tr>'; } ?> </table> <?php if ($this->pagination->total) { ?> <div class="pagination"> <?php
public function renderWithContent($content, $data = array()) { CShop::app()->raise(Application::EVENT_BEFORE_RENDER, array($this, null, &$data)); if ($this->layout !== false) { $data['content'] = $content; $content = $this->renderInternal($this->layout . '.php', $data, true); } CShop::app()->raise(Application::EVENT_AFTER_RENDER, array($this, &$content, null, &$data)); echo $content; }
public function actionStatistic() { $message = $this->user->message(); if (isset($_POST['update'])) { foreach ($_POST['order'] as $key => $value) { $sql = $this->db->prepare(QueryBuilder::getInstance()->update('category')->set('`order` = ?')->where('id = ?')); $sql->execute(array($value, $key)); } $message['content'] = 'تغییرات با موفقیت ذخیره شد'; $message['type'] = 'success'; $this->user->message($message); CShop::app()->redirect('category.php'); } elseif (isset($_POST['remove'])) { foreach ($_POST['delete'] as $value) { $sql = $this->db->prepare(QueryBuilder::getInstance()->delete('category')->where('id = ?')); $sql->execute(array($value)); } $message['content'] = 'تغییرات با موفقیت ذخیره شد'; $message['type'] = 'success'; $this->user->message($message); CShop::app()->redirect('category.php'); } $categories = new Model($this->db->query(QueryBuilder::getInstance()->select()->from('category')->order('`order`'))); $this->render('admin/category', array('message' => $message, 'items' => $categories)); }
/** * @param Controller $controller */ public function actionImport($controller) { $content = '<div class="title">انتفال</div>'; $db = CShop::app()->getDb(); $lasterrormode = $db->getAttribute(PDO::ATTR_ERRMODE); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); if (isset($_POST['start'])) { try { $freerdb = new Database(true, $this->dbname, $this->dbserver, $this->dbusername, $this->dbpassword); //Payment import $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('payment')); $paymentids = array(); while ($row = $items->fetch()) { $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment')->into(array('amount', 'requesttime', 'status', 'clientip', 'paymenttime', 'reference', 'gatewayid'), true, false)); $status = $row['payment_status'] == 1 ? Application::STATUS_PENDING : Application::STATUS_COMPLETE; $sql->execute(array($row['payment_amount'], $row['payment_time'], $status, $row['payment_ip'], $row['payment_time'], $row['payment_res_num'], $this->gatewayid)); $paymentids[$row['payment_id']] = $db->lastInsertId(); if ($this->email) { $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment_meta')->into(array('inputid', 'paymentid', 'value'), true, false)); $sql->execute(array($this->email, $paymentids[$row['payment_id']], $row['payment_email'])); } if ($this->mobile) { $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment_meta')->into(array('inputid', 'paymentid', 'value'), true, false)); $sql->execute(array($this->mobile, $paymentids[$row['payment_id']], $row['payment_mobile'])); } } //Category import $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('category')); $categoryids = array(); while ($row = $items->fetch()) { $sql = $db->prepare(QueryBuilder::getInstance()->insert('category')->into(array('name', 'description', '`order`'), true, false)); $sql->execute(array($row['category_title'], '', $row['category_order'])); $categoryids[$row['category_id']] = $db->lastInsertId(); } //Product AND item import $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('product')); while ($row = $items->fetch()) { $sql = $db->prepare(QueryBuilder::getInstance()->insert('product')->into(array('name', 'description', 'price', '`order`', 'categoryid'), true, false)); $sql->execute(array($row['product_title'], $row['product_body'], $row['product_price'], 0, $categoryids[$row['product_category']])); $productid = $db->lastInsertId(); $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false)); $sql->execute(array($productid, $row['product_first_field_title'], 'text')); $field1 = $db->lastInsertId(); $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false)); $sql->execute(array($productid, $row['product_second_field_title'], 'text')); $field2 = $db->lastInsertId(); $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false)); $sql->execute(array($productid, $row['product_third_field_title'], 'text')); $field3 = $db->lastInsertId(); $cards = $freerdb->query(QueryBuilder::getInstance('')->select("*,DECODE(card_first_field,'{$this->salt}') AS card_first_field,DECODE(card_second_field,'{$this->salt}') AS card_second_field,DECODE(card_third_field,'{$this->salt}') AS card_third_field")->from('card')->where('card_product=' . $row['product_id'])); while ($card = $cards->fetch()) { //pament id $sql = $db->prepare(QueryBuilder::getInstance()->insert('item')->into(array('productid', 'status', 'createtime', 'paymentid'), true, false)); $status = $card['card_status'] == 1 ? Application::STATUS_PENDING : Application::STATUS_COMPLETE; $sql->execute(array($productid, $status, $card['card_time'], $paymentids[$card['card_payment_id']])); $itemid = $db->lastInsertId(); $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false)); $sql->execute(array($field1, $itemid, $card['card_first_field'])); $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false)); $sql->execute(array($field2, $itemid, $card['card_second_field'])); $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false)); $sql->execute(array($field3, $itemid, $card['card_third_field'])); } } $content .= 'انتقال انجام شد'; } catch (Exception $e) { $content .= 'خطا! ' . $e->getMessage(); } } else { $content .= '<form method="post"> <input type="submit" value="شروع" name="start"> </form>'; } $db->setAttribute(PDO::ATTR_ERRMODE, $lasterrormode); $controller->renderWithContent($content); }
<?php $menus = array('خرید ها' => array('لیست پرداخت ها' => CShop::$baseurl . '/admin/' . 'payment.php'), 'دسته ها' => array('دسته جدید' => CShop::$baseurl . '/admin/' . 'createcategory.php', 'لیست دسته ها' => CShop::$baseurl . '/admin/' . 'category.php'), 'محصولات' => array('محصول جدید' => CShop::$baseurl . '/admin/' . 'createproduct.php', 'لیست محصولات' => CShop::$baseurl . '/admin/' . 'product.php'), 'کارت ها' => array('کارت جدید' => CShop::$baseurl . '/admin/' . 'createitem.php', 'لیست کارت ها' => CShop::$baseurl . '/admin/' . 'item.php'), 'ورودی ها' => array('فیلد جدید' => CShop::$baseurl . '/admin/' . 'createinput.php', 'لیست فیلد ها' => CShop::$baseurl . '/admin/' . 'input.php'), 'تنظیمات' => array('لیست درگاه ها' => CShop::$baseurl . '/admin/' . 'gateway.php', 'لیست پلاگین ها' => CShop::$baseurl . '/admin/' . 'plugin.php', 'تنظیمات' => CShop::$baseurl . '/admin/' . 'setting.php')); CShop::app()->raise(Application::EVENT_MENU, array(&$menus)); ?> <div id="sidebar"> <div class="top"> <div class="title"> <a href="index.php"><img alt="" src="<?php echo CShop::$baseurl; ?> /static/images/main.png"></a> <a href="index.php?logout"><img alt="" src="<?php echo CShop::$baseurl; ?> /static/images/logout.png"></a> </div> </div> <?php foreach ($menus as $title => $items) { ?> <div class="menu"> <div class="title"><?php echo $title; ?> </div> <div class="content"> <?php foreach ($items as $item => $link) { ?> <a href="<?php
public function showPage($pageid) { $page = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('page')->where('id = ? AND (type = ? OR type = ?)')); $page->execute(array($pageid, self::TYPE_PAGE, self::TYPE_PAGE_CUSTOM)); if ($page->rowCount() != 1) { CShop::app()->redirect(CShop::$baseurl); } $page = $page->fetch(); if ($page['type'] == self::TYPE_PAGE_CUSTOM) { echo $page['content']; } else { CShop::app()->getController()->renderWithContent($page['content']); } CShop::app()->end(); }
<?php $pages = array(CShop::app()->systemOption()->sitetitle => CShop::$baseurl); CShop::app()->raise(Application::EVENT_PAGE, array(&$pages)); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta content="no-cache" http-equiv="Pragma"></meta> <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"></meta> <meta content="0" http-equiv="Expires"></meta> <title><?php echo CShop::app()->systemOption()->sitetitle . ' - ' . $this->pageTitle; ?> </title> <link rel="stylesheet" href="<?php echo Cshop::$baseurl; ?> /static/cache/final.css" type="text/css"/> <script type="text/javascript" src="<?php echo Cshop::$baseurl; ?> /static/cache/final.js"></script> </head> <body>
<div id="header"> <div class="inner-header"> <div class="toplogo" onclick="window.location = '<?php echo CShop::$baseurl; ?> ';" style="cursor:pointer;"> </div> <div id ="topmenu"> <div class="menu"> <div class="menu-main-container"> <ul id="menu-main" class="menu"> <li class="menu-item "><a href="<?php echo CShop::$baseurl; ?> " class="active"><?php echo CShop::app()->systemOption()->sitetitle; ?> </a></li> </ul> </div> </div> </div> </div> </div> <div id="content"> <?php echo $content; ?> </div> <div id="footer"><a href="http://irprog.com" target="_blank">Cshop</a></div> </body>
public function run($action, $param = array()) { $this->initialise(); if (is_array($action)) { $this->_action = $action[1]; $action[0] .= 'Controller'; CShop::import(Cshop::$corepath . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . $action[0] . '.php', true); $this->_controller = new $action[0](); $this->_controller->init(); if (method_exists($this->_controller, 'action' . $action[1])) { call_user_func_array(array($this->_controller, 'runAction'), array('action' => $action[1], $param)); } } else { $this->_action = $action; CShop::import(Cshop::$corepath . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'Controller.php', true); $this->_controller = new Controller(); $this->_controller->init(); if (isset($this->_externalActions[$action])) { foreach ($this->_externalActions[$action] as $a) { if (isset($_GET[$a['param']])) { call_user_func_array($a['callback'], array($_GET[$a['param']])); CShop::app()->end(); } } } if (method_exists($this->_controller, 'action' . $action)) { call_user_func_array(array($this->_controller, 'runAction'), array($action, $param)); } } }
public static function deleteInput($id) { $input = array(); $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('input')->where('id=?')); $sql->execute(array($id)); }
$selected = ''; } echo "<option value='{$c['id']}' {$selected}>{$c['name']}</option>"; } ?> </select></div> </div> <div id="fields"> </div> <div class="formrow"> <select id="type"> <?php CShop::app()->raise(Application::EVENT_ITEM_TYPE); foreach (Item::types() as $type => $value) { ?> <option value="<?php echo $type; ?> "><?php echo $value['description']; ?> </option> <?php } ?> </select> <input type="button" value="اضافه کردن" id="add"> </div>
public function actionPayment() { $message['content'] = ''; $this->pageTitle = 'پرداخت'; $items = array(); try { if (!isset($_GET['gateway'])) { throw new Exception('اطلاعات پرداخت کامل نمی باشد'); } $gateway = $this->db->prepare(QueryBuilder::getInstance()->select()->from('gateway')->leftJoin('option')->on('class = category')->where('gateway.id = ?')); $gateway->execute(array($_GET['gateway'])); $gateway = $gateway->fetchAll(); if (!$gateway[0]) { throw new Exception('اطلاعات پرداخت کامل نمی باشد'); } CShop::import(Cshop::$gatewaypath . DIRECTORY_SEPARATOR . $gateway[0]['class'] . '.php'); /* @var $plugin GatewayBase */ $plugin = new $gateway[0]['class']($gateway[0]['id'], $gateway); $payment = $plugin->callbackGateway(); if (!$payment) { throw new Exception('اطلاعات پرداخت کامل نمی باشد'); } if ($payment['status'] == Application::STATUS_PENDING) { $sql = $this->db->prepare(QueryBuilder::getInstance()->update('payment')->set('status = ?,paymenttime=?')->where('id = ?')); $sql->execute(array($payment['status'] = Application::STATUS_COMPLETE, time(), $payment['id'])); $sql = $this->db->prepare(QueryBuilder::getInstance()->update('item')->set('status = ?')->where('paymentid = ?')); $sql->execute(array(Application::STATUS_COMPLETE, $payment['id'])); $sql = $this->db->prepare(QueryBuilder::getInstance()->select('item.*,value.fieldid,value,field.name AS fieldname,field.type,product.name,product.description')->from('item')->leftJoin('product')->on('product.id = item.productid')->leftJoin('value')->on('item.id = itemid')->leftJoin('field')->on('fieldid = field.id')->where('paymentid = ?')); $sql->execute(array($payment['id'])); while ($item = $sql->fetch()) { $items[$item['id']][] = $item; } $message['content'] = 'پرداخت با موفقیت انجام شد'; $message['type'] = 'success'; $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('input.*,value')->from('payment_meta')->leftJoin('input')->on('inputid = input.id')->where('paymentid = ?')); $sql->execute(array($payment['id'])); $payment['input'] = array(); while ($row = $sql->fetch()) { $row['data'] = unserialize($row['data']); $payment['input'][$row['id']] = $row; } CShop::app()->raise(Application::EVENT_AFTER_PAYMENT, array(&$payment, &$items)); } else { throw new Exception('این سفارش قبلا پرداخت شده است.'); } } catch (Exception $e) { $message['content'] = $e->getMessage(); } $this->layout = 'layout/payment'; CShop::app()->raise(Application::EVENT_ITEM_TYPE); $this->render('site/payment', array('message' => $message, 'items' => $items)); }