public function execute(Request $request, Response $response) { $userID = $request->getParameter("userID"); $helper = new CommandHelper(); $password = $helper->createRandomPassword(8); // Result data for AJAX response $result = array("id" => $request->getParameter("senderID"), "command" => "resetPassword"); $GLOBALS["USERMANAGEMENT_DATA_ACCESS"]->changePassword($userID, $password); $result["state"] = "ok"; $result["password"] = $password; return $result; }
private function __construct() { $this->file = pathinfo(__FILE__); if (!file_exists($this->file['dirname'] . '/../../data/config/settings.ini')) { CommandHelper::settingsNotice(); exit(1); } $this->settings = parse_ini_file($this->file['dirname'] . '/../../data/config/settings.ini', true); $this->support = $this->settings['general']['support']; if ($this->settings['db']['enabled']) { $driver = $this->settings['db']['driver']; if ($driver == 'mysql') { $charset = ';charset=utf8'; } else { $charset = ''; } try { $this->db = new PDO($driver . ':host=' . $this->settings['db']['host'] . ';dbname=' . $this->settings['db']['dbname'] . $charset, $this->settings['db']['user'], $this->settings['db']['password']); $this->db->exec("set names utf8"); $this->db->exec("set group_concat_max_len = 1000000"); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); } catch (PDOException $e) { CommandHelper::activateNotice('database'); exit(1); } } if ($this->settings['mail']['enabled']) { $this->mail = $this->settings['mail']; } if ($this->settings['amocrm']['enabled']) { $this->amocrm = $this->settings['amocrm']; } // Paths $this->logDir = $this->file['dirname'] . '/../../data/logs/'; $this->saveDir = $this->file['dirname'] . '/../../data/upload/'; $this->icml = $this->saveDir . $this->settings['general']['icml_file']; $this->bundle = $this->file['dirname'] . '/../../bundle/'; // ICML $this->shopName = $this->settings['general']['shop_name']; $this->shopUrl = $this->settings['general']['shop_url']; $this->domain = $this->settings['general']['domain']; $this->date = date('Y-m-d H:i:s'); // Logs $this->logformat = "[{$this->date}][{$this->domain}] "; $this->errorLog = $this->logDir . 'error/error.log'; $this->mailLog = $this->logDir . 'mail/mail.log'; $this->ordersLog = $this->logDir . 'order/order.log'; $this->ordersUpdatesLog = $this->logDir . 'order/update.log'; $this->ordersHistoryLog = $this->logDir . 'order/history.log'; $this->customersLog = $this->logDir . 'customer/customer.log'; $this->customersUpdatesLog = $this->logDir . 'customer/update.log'; $this->customersHistoryLog = $this->logDir . 'customer/history.log'; }
public function getHandler($handlerClass) { if (!class_exists($handlerClass)) { CommandHelper::implementationNotice($handlerClass, ' class'); exit(1); } else { $handler = new $handlerClass(); } if (!in_array('HandlerInterface', class_implements($handler))) { CommandHelper::implementationError($handlerClass, 'HandlerInterface'); exit(1); } return $handler; }
public function __construct($mailBox) { $this->container = Container::getInstance(); $this->rule = new Rule(); $this->mailBox = $mailBox; if (is_array($this->container->mail)) { if (isset($this->container->mail[$mailBox])) { $this->mailSettings = explode(',', $this->container->mail[$mailBox]); } else { CommandHelper::settingsFailure($mailBox); exit(1); } } else { CommandHelper::activateNotice('mail'); exit(1); } }
<?php if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) { date_default_timezone_set(@date_default_timezone_get()); } require_once 'bootstrap.php'; $shortopts = 'dluce:m:p:r:h:'; $options = getopt($shortopts); if (isset($options['e'])) { $command = new Command($options); $command->run(); } else { CommandHelper::runHelp(); }
public function runAmo() { if (!isset($this->container->amocrm)) { CommandHelper::activateNotice('amocrm'); exit(1); } $amo = new AmoRestApi($this->container->amocrm['domain'], $this->container->amocrm['login'], $this->container->amocrm['key']); $rule = new Rule(); $handler = $rule->getHandler('AmoHandler'); $data = $handler->prepare($amo); if (!empty($data) && !empty($data['customers'])) { $this->requestHelper->uploadCustomers($data['customers']); if (!empty($data['orders'])) { $this->requestHelper->uploadOrders($data['orders'], true); } } }