Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/storeTyd/controller/ |
Upload File : |
<?php
// TO DO: Get Prodct and current color choice
class tydstore_controller extends Controller {
protected $model_tyd;
public function __construct() {
parent::__construct(dirname(__DIR__));
$this->model_tyd = $this->LoadModel('tyd_model');
$model_product = $this->LoadModel('product_model', 'store');
$this->model_tyd->setModelProduct($model_product);
}
public function __Register() {
$this->RegisterView(__CLASS__ .'::color_selection', ['tyd_view' => ['storetyd_option']]);
$this->RegisterView(__CLASS__ .'::contact', ['tyd_view' => ['storetyd_contact']]);
}
/** everyone */
public function color_selection($guid = '', $ordernum = '') {
$base = $this->StaticUriModule(dirname(__DIR__));
$res = $this->DefaultResult(__METHOD__);
if ($guid != '') {
$this->model_tyd->StaticDir($base)
->Guid($guid);
$res['template'] = 'storetyd_option';
$res['list_lines'] = $this->model_tyd->AsDatatables();
$res['list_swatch'] = $this->model_tyd->AsDatatables_Swatch();
$res['length'] = $this->model_tyd->getLength();
$res['border'] = "$base/outline.png";
$res['num'] = $this->model_tyd->ItemCount();
$res['ajax'] = '/store/action-tyd/' . $guid;
$res['guid'] = $guid;
$res['ordernum'] = $ordernum;
// return to order page when done
if ($ordernum != '') {
$res['flag_edit'] = 1;
$model_order = $this->LoadModel('order_model', 'store');
} else {
$res['flag_edit'] = 0;
}
}
return $res;
}
/** everyone */
public function action_tyd($guid = '') {
if ($guid != '') {
$name = $this->post('name', '');
[$name, $index] = explode('_', $name, 2);
$tyd = [
'index' => (int) $index,
'color' => $this->post('color', ''),
];
$base = $this->StaticUriModule(dirname(__DIR__));
$this->model_tyd->StaticDir($base)
->Guid($guid)
->setItemColor($tyd) // save color
->guidSave();
$data = [ 'tyd' => $tyd ];
} else {
$data = [ 'result' => -9999, 'message' => 'unknown guid' ];
}
// return color details - png, product, uri
header('Content-type: application/json');
die(json_encode($data, JSON_UNESCAPED_SLASHES));
}
public function _getCompany() {
$settings = $this->SettingGet('config.module_info', NULL);
return $settings['companyname'] ?? 'Acme Corporation';
}
private function _safephone($phone) {
$result = '';
$phone = trim(strtolower($phone));
for($i = 0; $i < strlen($phone); $i++) {
$c = $phone[$i];
if ($c == '+') {
$result .= $c;
} elseif ($c < '0') {
$result .= '';
} elseif ($c <= '9') {
$result .= $c;
} elseif ($c <= 'a') {
$result .= '';
} elseif ($c <= 'c') {
$result .= '2';
} elseif ($c <= 'f') {
$result .= '3';
} elseif ($c <= 'i') {
$result .= '4';
} elseif ($c <= 'l') {
$result .= '5';
} elseif ($c <= 'o') {
$result .= '6';
} elseif ($c <= 's') {
$result .= '7';
} elseif ($c <= 'v') {
$result .= '8';
} elseif ($c <= 'z') {
$result .= '9';
}
}
return $result;
}
/** everyone */
public function contact() {
$res = $this->DefaultResult(__METHOD__);
$res['template'] = 'storetyd_contact';
$fields = [];
$fields[] = ['type' => 'string', 'id' => 'name', 'name'=>'name', 'caption' => 'Your Name', 'required' => 1];
$fields[] = ['type' => 'comment', 'caption' => 'How can we contact you? Please enter your email or phone number'];
$fields[] = ['type' => 'email', 'id' => 'email', 'name'=>'email', 'caption' => 'Email Address'];
$fields[] = ['type' => 'tel', 'id' => 'phone', 'name'=>'phone', 'caption' => 'Contact Phone'];
$fields[] = ['type' => 'text', 'id' => 'zip', 'name'=>'zip', 'caption' => 'Your Zip / Postal Code', 'class' => 'contact']; // this will never be seen. Bot honeypot.
$fields[] = ['type' => 'text', 'id' => 'message', 'name'=>'message', 'caption' => 'Message', 'class' => 'contact', 'required' => 1];
$res['fieldlist'] = $fields;
$res['coname'] = $this->_getCompany();
$settings = $this->GetModuleSettings();
$res['cophone'] = $settings['phone'] ?? '';
$res['safephone'] = $this->_safephone($res['cophone']);
$res['coemail'] = $settings['email'] ?? '';
if ($this->isPost) {
$param = [
'name' => trim($this->post('name', '')),
'email' => trim($this->post('email', '')),
'phone' => trim($this->post('phone', '')),
'zip' => trim($this->post('zip', '')),
'message' => trim($this->post('message', '')),
];
if ($param['zip'] != '') {
return [
'result' => 86600,
'message' => 'You are not authorized to run this function',
];
}
$errors = [];
if ($param['email'] == '' && $param['phone'] == '') {
$errors[] = 'email address or phone number';
}
if ($param['name'] == '') {
$errors[] = 'name';
}
if ($param['message'] == '') {
$errors[] = 'message';
}
if (count($errors)) {
return [
'result' => 86600,
'message' => 'Please enter your ' . join(', ', $errors),
];
}
$this->model_tyd->SendEmail($param, $res['coemail']); // send email
$res = array_merge($res, $param);
$res['result'] = -9999;
$res['message'] = 'Your request has been sent.';
}
return $res;
}
}