���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /var/www/nitsch.de/wp-includes/php-compat/classes.tar
���ѧ٧ѧ�
customer.class.php 0000775 00000006005 00000000000 0010171 0 ustar 00 <?php class Customer{ private $sql = false; private $mailer = false; function __construct(){ global $sql; $this->sql = $sql; global $mailer; $this->mailer = $mailer; } /** * Add Customer * @param object $p * @return boolean */ public function add($p){ $color = generateLightColor(); return $this->sql->insert('customer','customerNr,company,name,firstName,email,phone,color,created,changed',[$p->customerNr,$p->company,$p->name,$p->firstName,$p->email,$p->phone,$color,NOW,NOW]); } /** * Change Customer * @param object $p * @return boolean */ public function change($p){ return $this->sql->update('customer','customerNr,company,name,firstName,email,phone,color,changed',[$p->customerNr,$p->company,$p->name,$p->firstName,$p->email,$p->phone,$p->color,NOW],'id=?',$p->customerID); } /** * Get all Customers * @return array */ public function getAll(){ return $this->sql->select('c.id, c.customerNr,c.company, c.name, c.firstName,IF(c.company != "",c.company,CONCAT(c.firstName," ",c.name)) AS nameShow, c.email, c.phone, c.color, count(p.id) AS countProducts','customer c LEFT JOIN product p ON c.id = p.customerID GROUP BY c.id ORDER BY c.company ASC'); } /** * Get Customer by ID * @param int $customerID * @return object */ public function getCustomer($customerID){ return $this->sql->select('id, loginActive, customerNr, company, name, firstName,IF(company != "",company,CONCAT(firstName," ",name)) AS nameShow, email, phone, color','customer','id=?',$customerID,1); } /** * Login Active * @param object $p * @return boolean */ public function loginActive($p){ $customer = $this->getCustomer($p->customerID); $pw = createStr(20, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()_+'); $password = $this->createHash($pw); $customer->email = 'jt@kockzius.de'; $hash = md5(date('YmdHis').mt_rand(0,999999)); if($this->sql->insert('customer_login','customerID,email,firstName,name,rights,hash,active,password,forceChangePW,color',[$p->customerID,$customer->email,$customer->firstName,$customer->name,1,$hash,1,$password,1,$customer->color])){ $this->sendPwMail($customer,$pw); return $this->sql->update('customer','loginActive,changed',[1,NOW],'id=?',$p->customerID); } return false; } /** * Send Password Mail * @param object $p * @param string $pw * @return boolean */ private function sendPwMail($p,$pw){ $subject = 'Ihr Zugang für das Kockzius Kundenportal'; $message = '<p>Hallo '.$p->firstName.' '.$p->name.',<br /><br /> wir haben einen Account für Sie angelegt.<br /> Ihr Benutzername lautet: '.$p->email.'<br /> Ihr Passwort lautet: '.$pw.'</p> <p>Nach dem Login müssen Sie Ihr Passwort ändern.</p> <p><a href="https://kunde.kockzius.de/">Zum Login</a><br /></p> Viele Grüße<br /> Ihre Firma Kockzius'; return $this->mailer->myMail($p->email,$subject,$message); } private function createHash($input){ $hash = hash('whirlpool', $input); return hash('sha256', $hash); } } ?>