Пример #1
0
 public static function getInstance($prefix = null)
 {
     if ($prefix == null) {
         $prefix = CShop::app()->getConfig('database');
         $prefix = $prefix['prefix'];
     }
     return new self($prefix);
 }
Пример #2
0
 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);
 }
Пример #3
0
 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));
 }
Пример #4
0
    public function sendingMail(&$payment, &$items)
    {
        $body = '<meta charset="utf-8"><div style="direction: rtl; width: 500px; margin-top: 20px; margin-right: auto; margin-bottom: 20px; margin-left: auto;">';
        foreach ($items as $item) {
            $body .= '<div style="direction: rtl; font-family: tahoma; margin-top: 20px;">
				<div style="direction: rtl; height: 25px; line-height: 27px; text-align: center; color: #fff; font-size: 16px; border-top-color: #eaeaea; border-right-color: #eaeaea; border-bottom-color: #eaeaea; border-left-color: #eaeaea; border-top-style: solid; border-right-style: solid; border-bottom-style: none; border-left-style: solid; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; background-color: #10BBE6;" align="center">' . $item[0]['name'] . '</div>
				<div style="direction: rtl; border-top-color: #eaeaea; border-right-color: #eaeaea; border-bottom-color: #eaeaea; border-left-color: #eaeaea; border-top-style: dashed; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px;">
					<table style="width: 100%; border-collapse: collapse; border-top-style: hidden; border-left-style: hidden; border-right-style: hidden; border-bottom-style: hidden; table-layout: fixed;">';
            $td = $th = '';
            foreach ($item as $i) {
                if (!isset($i['value'])) {
                    continue;
                }
                $th .= '<th style="height: 20px; text-align: center; white-space: nowrap; border-top-color: #b7b7b7; border-right-color: #b7b7b7; border-bottom-color: #b7b7b7; border-left-color: #b7b7b7; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: #ccc;" align="center" bgcolor="#ccc">' . $i['fieldname'] . '</th>';
                $td .= '<td style="height: 30px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; border-top-color: #b7b7b7; border-right-color: #b7b7b7; border-bottom-color: #b7b7b7; border-left-color: #b7b7b7; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;" align="center" valign="middle">' . Item::proccess($i['type'], $i['value']) . '</td>';
            }
            $body .= '<tr>' . $th . '</tr>';
            $body .= '<tr>' . $td . '</tr>';
            $body .= '</table>	
				</div>
				<div class="bottom" style="direction: rtl; font-size: 14px; font-style: italic; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px;">' . $item[0]['description'] . '</div>';
        }
        $body .= '</div>';
        CShop::import(CShop::$librarypath . '/PHPMailer.php', true);
        if ($this->signature) {
            $body = $body . '<br/><hr>' . $this->signature;
        }
        $mail = new PHPMailer(true);
        try {
            if ($this->smtpauth == 1) {
                $mail->IsSMTP();
            }
            $mail->SMTPAuth = $this->smtpauth == 1 ? true : false;
            $mail->Username = $this->smtpusername;
            $mail->Password = $this->smtppassword;
            $mail->Host = $this->smtphost;
            $mail->Port = $this->smtpport;
            $mail->SMTPSecure = $this->smtpsecure;
            $mail->AddReplyTo($this->from, $this->fromname);
            $mail->SetFrom($this->from, $this->fromname);
            $mail->AddAddress($payment['input'][$this->input]['value'], $payment['input'][$this->input]['value']);
            $mail->CharSet = 'UTF-8';
            $mail->Subject = $this->subject;
            $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
            // optional - MsgHTML will create an alternate automatically
            $mail->MsgHTML($body);
            $mail->Send();
            return true;
        } catch (phpmailerException $e) {
            $return = $e->errorMessage();
            //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            $return = $e->getMessage();
            //Boring error messages from anything else!
        }
        return $return;
    }
Пример #5
0
 /**
  *
  * @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();
 }
Пример #6
0
 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']);
 }
Пример #7
0
 /**
  * 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;
 }
Пример #8
0
 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;
 }
Пример #9
0
 /**
  * @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;
     }
 }
Пример #10
0
    /**
     *
     * @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));
    }
Пример #11
0
	<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 
Пример #12
0
 /**
  * 
  * @return Applicaton
  */
 public static function create($config)
 {
     self::initialise($config);
     return self::$_application = new Application($config);
 }
Пример #13
0
 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;
 }
Пример #14
0
 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));
 }
Пример #15
0
    /**
     * @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);
    }
Пример #16
0
<?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 
Пример #17
0
 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();
 }
Пример #18
0
<?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>
Пример #19
0
<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>
Пример #20
0
 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));
         }
     }
 }
Пример #21
0
function os_poker_shop_admin_page()
{
    require_once drupal_get_path('module', 'os_poker') . "/shop.class.php";
    drupal_set_message(t('Usage of this interface is discouraged as it has not been thougfully designed or tested.'), 'warning');
    $cats = CShop::ListCategories();
    $vcats = array_keys($cats);
    $form .= "<table><tr><td>category</td><td>name</td><td>picture</td><td>price</td><td>expiry</td><td>av.</td></tr>";
    foreach ($vcats as $catid) {
        $items = CShop::ListItems($catid);
        if ($items) {
            foreach ($items as $item) {
                $form .= "<tr>" . drupal_get_form("os_poker_shop_admin_form_" . $item->id_item, array($item->id_item, $cats, $catid)) . "</tr>";
            }
        }
    }
    $form .= "<tr><td>ADD NEW</td></tr><tr>" . drupal_get_form("os_poker_shop_admin_form_" . 0, array(0, $cats, $catid)) . "</tr>";
    $form .= "</table>";
    return $form;
}
Пример #22
0
 public static function deleteInput($id)
 {
     $input = array();
     $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('input')->where('id=?'));
     $sql->execute(array($id));
 }
Пример #23
0
        $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>
Пример #24
0
 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));
 }