1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237:
<?php
class PHPShopPricemail extends PHPShopShopCore {
private $productId;
function __construct($productId = null) {
$this->debug = false;
$this->action = array("nav" => "index", "post" => "send_price_link");
parent::__construct();
if(is_null($productId)) {
$productId = $this->PHPShopNav->getId();
}
$this->productId = $productId;
}
function index() {
if (PHPShopSecurity::true_num($this->PHPShopNav->getId()))
$this->forma();
else
$this->setError404();
}
function security($option = array('url' => false, 'captcha' => true, 'referer' => true)) {
global $PHPShopRecaptchaElement;
return $PHPShopRecaptchaElement->security($option);
}
function send_price_link() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST))
return true;
if ($this->security()) {
$this->send();
$this->lead();
$this->set('Error', PHPShopText::alert(__(""), 'success'));
} else
$this->set('Error', PHPShopText::alert(__("")));
$this->index();
}
function lead() {
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['notes']);
$content="".$_SERVER['SERVER_NAME'] . "/shop/UID_" . $this->PHPShopNav->getId() . ".html"."".$_POST['link_to_page'].' '.$_POST['adr_name'];
$insert = array('date_new' => time(), 'message_new' => __(''), 'name_new' => $_POST['name_person'], 'mail_new' => $_POST['mail'], 'tel_new' => $_POST['tel_name'], 'content_new' => PHPShopSecurity::TotalClean($content));
$PHPShopOrm->insert($insert);
}
function send() {
if ($this->setHook(__CLASS__, __FUNCTION__, $_POST, 'START'))
return true;
if (PHPShopSecurity::true_param($_POST['mail'], $_POST['name_person'], $_POST['link_to_page'])) {
if(isset($_REQUEST['ajax'])) {
$_POST['name_person'] = PHPShopString::utf8_win1251($_POST['name_person']);
$_POST['link_to_page'] = PHPShopString::utf8_win1251($_POST['link_to_page']);
$_POST['org_name'] = PHPShopString::utf8_win1251($_POST['org_name']);
$_POST['adr_name'] = PHPShopString::utf8_win1251($_POST['adr_name']);
}
$this->title_mail = __('');
$this->set('user_name', $_POST['name_person']);
$this->set('user_org_name', $_POST['org_name']);
$this->set('user_tel_code', $_POST['tel_code']);
$this->set('user_tel', $_POST['tel_name']);
$this->set('user_info', $_POST['adr_name']);
$this->set('user_mail', $_POST['mail']);
$this->set('link_to_page', $_POST['link_to_page']);
$PHPShopProduct = new PHPShopProduct($this->productId);
$this->set('product_name', $PHPShopProduct->getName());
$this->set('product_art', $PHPShopProduct->getParam('uid'));
$this->set('product_id', $this->productId);
$this->set('product_link', $_SERVER['SERVER_NAME'] . "/shop/UID_" . $this->productId . ".html");
$this->setHook(__CLASS__, __FUNCTION__, $_POST, 'END');
$content = ParseTemplateReturn(dirname(__DIR__) . '/lib/templates/users/mail_pricemail.tpl', true);
if (PHPShopSecurity::true_email($_POST['mail'])) {
PHPShopObj::loadClass('mail');
new PHPShopMail($this->PHPShopSystem->getEmail(), $this->PHPShopSystem->getEmail(), $this->title_mail, $content, true);
}
if(!isset($_REQUEST['ajax'])) {
$this->redirect();
}
}
}
function redirect() {
if ($this->setHook(__CLASS__, __FUNCTION__))
return true;
header("Location: ../shop/UID_" . $this->PHPShopNav->getId() . ".html?pricemail=done");
}
function currency($name = 'code') {
if (isset($_SESSION['valuta']))
$currency = $_SESSION['valuta'];
else
$currency = $this->PHPShopSystem->getParam('dengi');
$PHPShopOrm = new PHPShopOrm($this->getValue('base.currency'));
$row = $PHPShopOrm->select(array('*'), array('id' => '=' . intval($currency)), false, array('limit' => 1), __FUNCTION__, array('base' => $this->getValue('base.currency'), 'cache' => 'true'));
if ($name == 'code' and ( $row['iso'] == 'RUR' or $row['iso'] == "RUB"))
return 'p';
return $row[$name];
}
function forma() {
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
$PHPShopProduct = new PHPShopProduct($this->PHPShopNav->getId());
$PHPShopPromotions = new PHPShopPromotions();
$promotions = $PHPShopPromotions->getPrice($PHPShopProduct->objRow);
if (is_array($promotions)) {
$this->set('productPrice', $promotions['price']);
$this->set(array('productPriceRub', 'productPriceOld'), number_format($promotions['price_n'], $this->format, '.', ' ') . ' ' . $this->PHPShopSystem->getValutaIcon());
} else {
$this->set('productPrice', number_format($PHPShopProduct->getPrice(), $this->format, '.', ' '));
if ($PHPShopProduct->getPriceOld() > 0)
$this->set(array('productPriceRub', 'productPriceOld'), number_format($PHPShopProduct->getPriceOld(), $this->format, '.', ' ') . ' ' . $this->PHPShopSystem->getValutaIcon());
else
$this->set(array('productPriceRub', 'productPriceOld'), '');
}
$this->set('productName', $PHPShopProduct->getName());
$this->set('productDes', $PHPShopProduct->getParam('description'));
$this->set('productImg', $PHPShopProduct->getImage());
$this->set('productUid', $this->PHPShopNav->getId());
$this->set('productValutaName', $this->currency());
if (PHPShopSecurity::true_num($_SESSION['UsersId'])) {
$PHPShopUsers = new PHPShopUser($_SESSION['UsersId']);
$this->set('UserMail', $PHPShopUsers->getParam('mail'));
$this->set('UserName', $PHPShopUsers->getParam('name'));
$this->set('UserTel', $PHPShopUsers->getParam('tel'));
$this->set('UserTelCode', $PHPShopUsers->getParam('tel_code'));
$this->set('UserAdres', $PHPShopUsers->getParam('adres'));
$this->set('UserComp', $PHPShopUsers->getParam('company'));
$this->set('formaLock', 'readonly=1');
}
elseif (!empty($_POST['send_price_link'])) {
$this->set('UserMail', $_POST['mail']);
$this->set('UserName', $_POST['name_person']);
$this->set('UserTel', $_POST['tel_name']);
$this->set('UserTelCode', $_POST['tel_code']);
$this->set('UserAdres', $_POST['adr_name']);
$this->set('UserComp', $_POST['org_name']);
$this->set('UserLink', $_POST['link_to_page']);
}
$this->title = $PHPShopProduct->getName() . ' - ' . __('') . " - " . $this->PHPShopSystem->getName();
$this->description = __('') . ': ' . $PHPShopProduct->getName();
$this->keywords = $PHPShopProduct->getName();
$this->setHook(__CLASS__, __FUNCTION__, $PHPShopProduct, 'END');
$this->ParseTemplate($this->getValue('templates.pricemail_forma'));
}
}
?>