function updateDictValues() { $module = _post("moduleName"); $ds = GetCfg($module . ".dictionaries"); $res = ""; if ($ds) { $dict = _post("dict"); if (isset($ds[$dict])) { $d = $ds[$dict]; $dname = $d[0]; $dcols = $d[1]; //$q = "DELETE FROM $dict WHERE {$dcols[id][0]}=" . _get("id"); $ids = _postByPattern("/" . $dcols["id"][0] . "_\\d+/"); foreach ($ids as $id) { $vals = ""; $cl = ""; foreach ($dcols as $cname => $col) { if ($col[2]) { if ($vals) { $vals .= ", "; } $vals .= $col[0] . "=" . prepareVar(_post($col[0] . "_" . $id)); } } $q = "UPDATE {$dict} SET {$vals} WHERE " . $dcols["id"][0] . "={$id}"; //print "$q<br>"; $qr = mysql_query($q); if (!$qr) { trigger_error("Error updating a value in a dictionary [{$dict}] for module [{$module}]", PM_FATAL); } } header("Status: 302 Moved"); header("Location: /admin/?cmd=editDict&moduleName={$module}&dict={$dict}"); exit(0); } else { trigger_error("Undefined dictionary [{$dict}] for module [{$module}]", PM_FATAL); } } else { trigger_error("Undefined module [{$module}]", PM_FATAL); } }
function getRegForm($pageID) { global $structureMgr, $templatesMgr, $authenticationMgr; $doRegister = 0; $msg = ""; if ($authenticationMgr->getUserID() <= 1) { // return "Незарегистрированные пользователи даже попасть сюда не должны!"; header("Status: 302 Moved"); $msg = "Для подписки на рассылку предложений по распродаже, нужна регистрация"; header("Location: /registration?msg=" . $msg . "&email=" . _post("email")); exit; } if (_post("action") == "doUpdate") { if (_post("login") != "") { $ud = array(); // $authenticationMgr->getUserData(-1, _post("login")); if (count($ud) == 0) { $vals = array("firstname", "lastname", "surname", "email", "phone", "address", "car", "car_type"); $names = array("Имя", "Фамилия", "Отчество", "E-mail", "Контактный телефон", "Адрес доставки", "Ваш автомобиль", "Марка автомобиля"); for ($i = 0; $i < count($vals); $i++) { if ($vals[$i] != "car_type") { if (_post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br>"; } } else { $pcar = _post("car"); if (($pcar == "0" || $pcar > 15 && $pcar < 24) && _post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br>"; } } } if (_post("psw") != _post("psw2") && _post("psw")) { $msg .= "Пароли не совпадают."; } if (!$msg) { $updateInfo = array(); if (_post("login")) { $updateInfo[] = "login = "******"login")); } if (_post("psw")) { $updateInfo[] = "`password` = MD5(" . prepareVar(_post("psw")) . ")"; } if (_post("firstname")) { $updateInfo[] = "FirstName = " . prepareVar(_post("firstname")); } if (_post("lastname")) { $updateInfo[] = "LastName = " . prepareVar(_post("lastname")); } if (_post("surname")) { $updateInfo[] = "SurName = " . prepareVar(_post("surname")); } if (_post("email")) { $updateInfo[] = "Email = " . prepareVar(_post("email")); } if (_post("sex")) { $updateInfo[] = "sex = " . prepareVar(_post("sex")); } if (_post("phone")) { $updateInfo[] = "phone = " . prepareVar(_post("phone")); } if (_post("region")) { $updateInfo[] = "region = " . prepareVar(_post("region")); } if (_post("city")) { $updateInfo[] = "city = " . prepareVar(_post("city")); } if (_post("address")) { $updateInfo[] = "address = " . prepareVar(_post("address")); } if (_post("carID")) { $updateInfo[] = "carID = " . prepareVar(_post("carID")); } if (_post("carType")) { $updateInfo[] = "carType = " . prepareVar(_post("carType")); } if (_post("subscribe")) { $updateInfo[] = "subscribe = " . prepareVar(_post("subscribe")); } if (count($updateInfo)) { $q = "UPDATE pm_users SET\n\t\t\t\t\t\t\t\t" . implode(",", $updateInfo) . "\n\t\t\t\t\t\t\t\tWHERE userID ='" . $authenticationMgr->getUserID() . "'"; //echo $q; $qr = mysql_query($q); } if ($qr) { $msg = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmsg.txt"); $subj = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmailsubj.txt"); $body = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmail.txt"); $body = str_replace("%login%", _post("login"), $body); $body = str_replace("%psw%", _post("psw"), $body); $body = str_replace("%firstname%", _post("firstname"), $body); $body = str_replace("%lastname%", _post("lastname"), $body); $body = str_replace("%car_type%", _post("car_type"), $body); mail(_post("email"), $subj, $body, "From: info@carumba.ru\r\n"); $doUpdate = 1; } else { $msg = mysql_error(); } } } else { $msg .= "Уже существует пользователь с логином `" . _post("login") . "`.<br>"; } } else { $msg .= "Заполните, пожалуйста, поле "Логин".<br>"; } } if ($doUpdate == 0) { $js = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "reg.js"); $form = <<<FORM <TABLE class="" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD class="" width=8><IMG height=8 src="/images/pix.gif" width=8></TD> <TD class="" vAlign=top> <TABLE class="" cellSpacing=1 cellPadding=5 width="100%" bgColor=#dcdde0 border=0> <TBODY> <TR bgColor=#ffffff> <TD class="" vAlign=top width="50%"> <TABLE class="" cellSpacing=0 cellPadding=10 width="100%" border=0> <TBODY> <TR vAlign=top> <TD class="" width=65><IMG height=85 alt="Полезная информация" src="/images/minime.gif" width=65 align=absMiddle border=0></TD> <TD class=""> <P><STRONG>Внимание:</STRONG></P> <UL> <LI>После отправки анкеты, на Ваш e-mail будет отослано письмо</LI> <LI>Указанная вами марка автомобиля поможет улучшить качество получаемой Вами информации о распродаже</LI> <LI>Все поля данной анкеты обязательны для заполнения </LI></UL></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD> <TD class="" width=8><IMG height=8 src="/images/pix.gif" width=8></TD></TR></TBODY></TABLE><BR>%MSG% <TABLE class="" cellSpacing=0 cellPadding=0 width="100%" border=0> <FORM onsubmit="return checkReg();" method=post><INPUT type=hidden value=doUpdate name=action> <TBODY> <TR> <TD class="" width=8><IMG height=8 src="/images/pix.gif" width=8></TD> <TD class="" vAlign=top> <TABLE class="" cellSpacing=0 cellPadding=0 width="100%" bgColor=#f2f2f2 border=0> <TBODY> <TR> <TD class="" width=10 height=10><IMG height=10 src="/images/t_01.gif" width=10></TD> <TD class="" background=/images/tb_01.gif height=10><IMG height=10 src="/images/pix.gif" width=10></TD> <TD class="" width=10 height=10><IMG height=10 src="/images/t_02.gif" width=10></TD></TR> <TR> <TD class="" width=10 background=/images/tb_02.gif><IMG height=10 src="/images/pix.gif" width=10></TD> <TD class="" vAlign=top> <TABLE class="" cellSpacing=1 cellPadding=5 bgColor=#cccccc border=0> <TBODY> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Логин:</TD> <TD class=""><INPUT class=input03 value=%login% name=login></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Пароль:</TD> <TD class=""><INPUT class=input03 type=password value=%psw% name=psw></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Пароль повторно:</TD> <TD class=""><INPUT class=input03 type=password value=%psw2% name=psw2></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>E-mail:</TD> <TD class=""><INPUT class=input03 value=%email% name=email></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Фамилия:</TD> <TD class=""><INPUT class=input03 value=%lastname% name=lastname></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Имя:</TD> <TD class=""><INPUT class=input03 value=%firstname% name=firstname></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Отчество:</TD> <TD class=""><INPUT class=input03 value=%surname% name=surname></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Ваш пол:</TD> <TD class=""><INPUT type=radio %male% value=m name=sex> Мужской <INPUT type=radio %female% value=f name=sex> Женский </TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Контактный телефон:</TD> <TD class=""><INPUT class=input03 value=%phone% name=phone></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Регион:</TD> <TD class=""><SELECT class=input03 name=region> <OPTION value=Санкт-Петербург selected>Санкт-Петербург</OPTION></SELECT></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Город:</TD> <TD class=""><SELECT class=input03 name=city> <OPTION value=Санкт-Петербург selected>Санкт-Петербург</OPTION></SELECT></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Адрес доставки:</TD> <TD class=""><TEXTAREA class=input05 name=address>%address%</TEXTAREA></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Ваш автомобиль:</TD> <TD class="" bgColor=#f2f2f2> <SELECT class=input03 name=car> <OPTION value="">-------------- <OPTION value=1>ВАЗ 2101</OPTION> <OPTION value=2>ВАЗ 2102</OPTION> <OPTION value=3>ВАЗ 2103</OPTION> <OPTION value=4>ВАЗ 2104</OPTION> <OPTION value=5>ВАЗ 2105</OPTION> <OPTION value=6>ВАЗ 2106</OPTION> <OPTION value=7>ВАЗ 2107</OPTION> <OPTION value=8>ВАЗ 2108</OPTION> <OPTION value=9>ВАЗ 2109</OPTION> <OPTION value=10>ВАЗ 21099</OPTION> <OPTION value=11>ВАЗ 2110</OPTION> <OPTION value=12>ВАЗ 2112</OPTION> <OPTION value=13>Ока</OPTION> <OPTION value=14>Нива</OPTION> <OPTION value="">-------------- <OPTION value=16>Honda</OPTION> <OPTION value=17>Infiniti</OPTION> <OPTION value=18>Lexus</OPTION> <OPTION value=19>Mazda</OPTION> <OPTION value=20>Mitsubishi</OPTION> <OPTION value=21>Nissan</OPTION> <OPTION value=22>Subaru</OPTION> <OPTION value=23>Toyota</OPTION> <OPTION value="">--------------</OPTION> <OPTION value=0>Другой</OPTION> </SELECT> </TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Модель автомобиля<br>(заполняется, если указана иномарка либо Ваш автомобиль не входит в список):</TD> <TD class="" bgColor=#f2f2f2><input type="text" class="input03" name="car_type" value="%car_type%"></TD></TR> <TR bgColor=#f2f2f2> <TD class="" align=right width=160>Подписаться на e-mail рассылку предложений по распродаже:</TD> <TD class=""><INPUT type=checkbox %subscribe% value=1 name=subscribe></TD></TR></TBODY></TABLE><BR> <TABLE class="" height=15 cellSpacing=0 cellPadding=0 width=116 border=0> <TBODY> <TR> <TD class="" vAlign=top bgColor="#676971" height=15><INPUT type=image src="images/reg.gif"></TD></TR></TBODY></TABLE><BR></TD> <TD class="" width=10 background=/images/tb_03.gif><IMG height=10 src="/images/pix.gif" width=10></TD></TR> <TR> <TD class="" width=10 height=10><IMG height=10 src="/images/t_03.gif" width=10></TD> <TD class="" background=/images/tb_04.gif height=10><IMG height=10 src="/images/pix.gif" width=10></TD> <TD class="" width=10 height=10><IMG height=10 src="/images/t_04.gif" width=10></TD></TR></TBODY></TABLE></TD> <TD class="" width=8><IMG height=8 src="/images/pix.gif" width=8></TD></TR></TBODY></FORM></TABLE> FORM; if ($msg) { $msg = "<div style=\"color: red; text-align: center\">{$msg}<br><br></div>"; } $user = $this->getUserData($authenticationMgr->getUserID()); $form = str_replace("%MSG%", $msg, $form); $form = str_replace("%login%", "\"" . str_replace("\"", """, _post("login") ? _post("login") : $user['Login']) . "\"", $form); $form = str_replace("%psw%", "\"" . str_replace("\"", """, _post("psw") ? _post("psw") : "") . "\"", $form); $form = str_replace("%psw2%", "\"" . str_replace("\"", """, _post("psw2") ? _post("psw2") : "") . "\"", $form); $form = str_replace("%firstname%", "\"" . str_replace("\"", """, _post("firstname") ? _post("firstname") : $user['FirstName']) . "\"", $form); $form = str_replace("%lastname%", "\"" . str_replace("\"", """, _post("lastname") ? _post("lastname") : $user['LastName']) . "\"", $form); $form = str_replace("%surname%", "\"" . str_replace("\"", """, _post("surname") ? _post("surname") : $user['SurName']) . "\"", $form); $form = str_replace("%email%", "\"" . str_replace("\"", """, _post("email") ? _post("email") : $user['Email']) . "\"", $form); $form = str_replace("%phone%", "\"" . str_replace("\"", """, _post("phone") ? _post("phone") : $user['phone']) . "\"", $form); $form = str_replace("%address%", str_replace("\"", """, _post("address") ? _post("address") : $user['address']), $form); $form = str_replace("%car_type%", str_replace("\"", """, _post("car_type") ? _post("car_type") : $user['carType']), $form); $form = str_replace("%subscribe%", (_post("subscribe") ? _post("subscribe") : $user['subscribe']) == 1 ? "checked" : "", $form); if ((_post("sex") ? _post("sex") : $user['sex']) == 'm') { $male = "checked"; $female = ""; } else { $male = ""; $female = "checked"; } $form = str_replace("%male%", $male, $form); $form = str_replace("%female%", $female, $form); return "<script>{$js}</script>" . $form; } else { return $msg; } }
function updateAdditionalColumns($args) { global $structureMgr; $sID = $args[0]; $qSet = ""; if ($sID != -1) { $md = $structureMgr->getMetaData($sID); } else { trigger_error("pageID must be specified", PM_WARNING); return false; } //WE MUST UPDATE switch ($md["DataType"]) { case "CatItem": foreach ($this->additionalColumns[$md["DataType"]] as $ac => $acv) { $nv = _post("{$ac}{$sID}"); if ($acv == "checkbox") { if ($nv == "") { $nv = "0"; } else { $nv = "1"; } } $v = prepareVar($nv); if ($qSet) { $qSet .= ", "; } $qSet .= $ac . "=" . $v; } $q = "UPDATE pm_as_parts SET {$qSet} WHERE sID = " . $sID; $qr = mysql_query($q); break; case "Category": $qr = 1; break; } if (!$qr) { trigger_error("Error while trying to update AdditionalColumns [{$q}] - " . mysql_error(), PM_FATAL); return false; } return true; }
function getRegForm($pageID) { global $structureMgr, $templatesMgr, $authenticationMgr; $doRegister = 0; $msg = ""; if ($authenticationMgr->getUserID() > 1) { // return "Зарегистрированные пользователи даже попасть сюда не должны!"; header("Status: 302 Moved"); header("Location: /"); exit; } $msg .= _get("msg"); if (_post("action") == "doRegister") { if (_post("login") != "") { $ud = $authenticationMgr->getUserData(-1, _post("login")); echo "<!--"; print_r($ud); $usersWithSameEmail = $authenticationMgr->getUserData(-1, 0, _post("email")); print_r($usersWithSameEmail); echo ' -->'; if (!count($ud) && !count($usersWithSameEmail)) { $vals = array("psw", "firstname", "lastname", "surname", "email", "phone", "address", "car", "carType"); $names = array("Пароль", "Имя", "Фамилия", "Отчество", "E-mail", "Контактный телефон", "Адрес доставки", "Ваш автомобиль", "Марка автомобиля"); for ($i = 0; $i < count($vals); $i++) { if ($vals[$i] != "carType") { if (_post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br />"; } } else { $pcar = _post("car"); if (($pcar == "0" || $pcar > 15 && $pcar < 24) && _post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br />"; } } } if (_post("psw") != _post("psw2")) { $msg .= "Пароли не совпадают."; } if (!$msg) { $q = "INSERT INTO pm_users (login,`password`,FirstName,LastName,SurName,Email,sex,phone,region,city,address,carID,carType,subscribe) \n VALUES (\n " . prepareVar(_post("login")) . ",\n MD5(" . prepareVar(_post("psw")) . "),\n " . prepareVar(_post("firstname")) . ",\n " . prepareVar(_post("lastname")) . ",\n " . prepareVar(_post("surname")) . ",\n " . prepareVar(_post("email")) . ",\n " . prepareVar(_post("sex")) . ",\n " . prepareVar(_post("phone")) . ",\n " . prepareVar(_post("region")) . ",\n " . prepareVar(_post("city")) . ",\n " . prepareVar(_post("address")) . ",\n " . prepareVar(_post("car")) . ",\n " . prepareVar(_post("carType")) . ",\n " . prepareVar(_post("subscribe")) . "\n )"; $qr = mysql_query($q); if ($qr) { $msg = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmsg.txt"); $subj = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmailsubj.txt"); $body = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmail.txt"); $body = str_replace("%login%", _post("login"), $body); $body = str_replace("%psw%", _post("psw"), $body); $body = str_replace("%firstname%", _post("firstname"), $body); $body = str_replace("%lastname%", _post("lastname"), $body); $body = str_replace("%car_type%", _post("carType"), $body); //mail(_post("email"), $subj, $body, "From: info@carumba.ru\r\n"); $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "localhost"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $mail->From = "*****@*****.**"; $mail->FromName = "Carumba.ru"; $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $subj; $mail->Body = $body; $mail->AddAddress(_post("email")); if (!@$mail->Send()) { trigger_error("Message could not be sent.Mailer Error: " . $mail->ErrorInfo, PM_WARNING); } $mail->ClearAddresses(); $doRegister = 1; } else { $msg = mysql_error(); } } } elseif (count($usersWithSameEmail)) { $msg .= "Уже существует пользователь с email `" . _post("email") . "`.<br />"; } else { $msg .= "Уже существует пользователь с логином `" . _post("login") . "`.<br />"; } } else { $msg .= "Заполните, пожалуйста, поле "Логин".<br />"; } } if ($doRegister == 0) { //$js = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "reg.js"); $form = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regform.html"); if ($msg) { $msg = "<div class=\"podbor\" style=\"color: red; text-align: center\">{$msg}</div>"; } $form = str_replace("%MSG%", $msg, $form); $form = str_replace("%login%", _post("login"), $form); $form = str_replace("%psw%", _post("psw"), $form); $form = str_replace("%psw2%", _post("psw2"), $form); $form = str_replace("%firstname%", _post("firstname"), $form); $form = str_replace("%lastname%", _post("lastname"), $form); $form = str_replace("%surname%", _post("surname"), $form); if (_get("email")) { $form = str_replace("%email%", _get("email"), $form); } else { $form = str_replace("%email%", _post("email"), $form); } $form = str_replace("%phone%", _post("phone"), $form); $form = str_replace("%address%", _post("address"), $form); $form = str_replace("%car_type%", _post("carType"), $form); $form = str_replace("%city%", _post("city"), $form); return $form; } else { return "<div class=\"podbor\">" . $msg . "</div>"; } }
/** * Вернет ID страницы из параметров URI * * В функцию передается URI текущей страницы. * * Возвращает ID страницы из базы. Судя по всему для дальнейшей идетнификации шаблона. * * @param string $path * @return integer */ function getPageIDByPath($path) { global $classErrorMessage; $pNumber = 1; if ($path == '/') { return $this->getDefaultPageID(); } else { $path = rtrim($path, '/'); $pathComponents = explode('/', $path); $parent = $this->getRootPageID(); $cnt = count($pathComponents); /** * Begin debugging code */ //print_r($pathComponents); //preg_match('/^pageID=(\d+)$/', $pathComponents[1], $match); //print_r($match); //die(); /** * End debugging code */ for ($i = 1; $i < $cnt; $i++) { //we must skip page number in URL if ($i == $cnt - 1 && preg_match('/^page(\\d+)$/', $pathComponents[$i], $match)) { $this->pageNumber[$parent] = $match[1]; break; } $v = prepareVar($pathComponents[$i]); $q = 'SELECT `sID` FROM `pm_structure` WHERE (`pms_sID`=\'' . $parent . '\' AND `URLName`=' . $v . ') OR (`URLName`=\'\' AND `sID`=' . $v . ') LIMIT 1'; $qr = mysql_query($q, $this->dblink); if (!$qr) { trigger_error(mysql_error($this->dblink), PM_FATAL); } if (mysql_num_rows($qr) == 1) { list($parent) = mysql_fetch_row($qr); } else { $classErrorMessage = 'Couldn\'t find the specified URL - ' . $path . '<b>'; $parent = NULL; break; } } return $parent; } }
function getRegForm($pageID) { global $structureMgr, $templatesMgr, $authenticationMgr; $doRegister = 0; $msg = ""; if ($authenticationMgr->getUserID() <= 1) { // return "Незарегистрированные пользователи даже попасть сюда не должны!"; header("Status: 302 Moved"); $msg = "Для подписки на рассылку предложений по распродаже, нужна регистрация"; header("Location: /registration?msg=" . $msg . "&email=" . _post("email")); exit; } if (_post("action") == "doUpdate") { if (_post("login") != "") { $ud = array(); // $authenticationMgr->getUserData(-1, _post("login")); if (count($ud) == 0) { $vals = array("firstname", "lastname", "surname", "email", "phone", "address", "carID", "carType"); $names = array("Имя", "Фамилия", "Отчество", "E-mail", "Контактный телефон", "Адрес доставки", "Ваш автомобиль", "Марка автомобиля"); for ($i = 0; $i < count($vals); $i++) { if ($vals[$i] != "carType") { if (_post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br>"; } } else { $pcar = _post("carID"); if (($pcar == "0" || $pcar > 15 && $pcar < 24) && _post($vals[$i]) == "") { $msg .= "Заполните, пожалуйста, поле `{$names[$i]}`.<br>"; } } } if (_post("psw") != _post("psw2") && _post("psw")) { $msg .= "Пароли не совпадают."; } if (!$msg) { $updateInfo = array(); if (_post("login")) { $updateInfo[] = "login = "******"login")); } if (_post("psw")) { $updateInfo[] = "`password` = MD5(" . prepareVar(_post("psw")) . ")"; } if (_post("firstname")) { $updateInfo[] = "FirstName = " . prepareVar(_post("firstname")); } if (_post("lastname")) { $updateInfo[] = "LastName = " . prepareVar(_post("lastname")); } if (_post("surname")) { $updateInfo[] = "SurName = " . prepareVar(_post("surname")); } if (_post("email")) { $updateInfo[] = "Email = " . prepareVar(_post("email")); } if (_post("sex")) { $updateInfo[] = "sex = " . prepareVar(_post("sex")); } if (_post("phone")) { $updateInfo[] = "phone = " . prepareVar(_post("phone")); } if (_post("region")) { $updateInfo[] = "region = " . prepareVar(_post("region")); } if (_post("city")) { $updateInfo[] = "city = " . prepareVar(_post("city")); } if (_post("address")) { $updateInfo[] = "address = " . prepareVar(_post("address")); } if (_post("carID")) { $updateInfo[] = "carID = " . prepareVar(_post("carID")); } if (_post("carType")) { $updateInfo[] = "carType = " . prepareVar(_post("carType")); } if (_post("subscribe")) { $updateInfo[] = "subscribe = " . prepareVar(_post("subscribe")); } if (count($updateInfo)) { $q = "UPDATE pm_users SET\n\t\t\t\t\t\t\t\t" . implode(",", $updateInfo) . "\n\t\t\t\t\t\t\t\tWHERE userID ='" . $authenticationMgr->getUserID() . "'"; //echo $q; $qr = mysql_query($q); } if ($qr) { $msg = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmsg.txt"); $subj = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmailsubj.txt"); $body = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "regmail.txt"); $body = str_replace("%login%", _post("login"), $body); $body = str_replace("%psw%", _post("psw"), $body); $body = str_replace("%firstname%", _post("firstname"), $body); $body = str_replace("%lastname%", _post("lastname"), $body); $body = str_replace("%carType%", _post("carType"), $body); //mail(_post("email"), $subj, $body, "From: info@carumba.ru\r\n"); $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "localhost"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $mail->From = "*****@*****.**"; $mail->FromName = "Carumba.ru"; $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $subj; $mail->Body = $body; $mail->AddAddress(_post("email")); if (!@$mail->Send()) { trigger_error("Message could not be sent.Mailer Error: " . $mail->ErrorInfo, PM_WARNING); } $mail->ClearAddresses(); $doUpdate = 1; } else { $msg = mysql_error(); } } } else { $msg .= "Уже существует пользователь с логином `" . _post("login") . "`.<br>"; } } else { $msg .= "Заполните, пожалуйста, поле &quot;Логин&quot;.<br>"; } } if ($doUpdate == 0) { //$js = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "reg.js"); $form = $templatesMgr->getTemplate(-1, GetCfg("TemplatesPath") . "/Register/" . "profile.html"); if ($msg) { $msg = "<div class=\"podbor\" style=\"color: red; text-align: center\">{$msg}<br><br></div>"; } $user = $this->getUserData($authenticationMgr->getUserID()); $form = str_replace("%MSG%", $msg, $form); $form = str_replace("%login%", _post("login") ? _post("login") : $user['Login'], $form); $form = str_replace("%psw%", str_replace("\"", "&quot;", _post("psw") ? _post("psw") : ""), $form); $form = str_replace("%psw2%", str_replace("\"", "&quot;", _post("psw2") ? _post("psw2") : ""), $form); $form = str_replace("%firstname%", str_replace("\"", "&quot;", _post("firstname") ? _post("firstname") : $user['FirstName']), $form); $form = str_replace("%lastname%", str_replace("\"", "&quot;", _post("lastname") ? _post("lastname") : $user['LastName']), $form); $form = str_replace("%surname%", str_replace("\"", "&quot;", _post("surname") ? _post("surname") : $user['SurName']), $form); $form = str_replace("%email%", str_replace("\"", "&quot;", _post("email") ? _post("email") : $user['Email']), $form); $form = str_replace("%phone%", str_replace("\"", "&quot;", _post("phone") ? _post("phone") : $user['phone']), $form); $form = str_replace("%address%", str_replace("\"", "&quot;", _post("address") ? _post("address") : $user['address']), $form); $form = str_replace("%city%", str_replace("\"", "&quot;", _post("city") ? _post("city") : $user['city']), $form); $form = str_replace("%carType%", str_replace("\"", "&quot;", _post("carType") ? _post("carType") : $user['carType']), $form); $form = str_replace("%subscribe%", (_post("subscribe") ? _post("subscribe") : $user['subscribe']) == 1 ? "checked" : "", $form); if ((_post("sex") ? _post("sex") : $user['sex']) == 'm') { $male = "checked"; $female = ""; } else { $male = ""; $female = "checked"; } $form = str_replace("%male%", $male, $form); $form = str_replace("%female%", $female, $form); $form = str_replace("%sel_" . $user['carID'] . "%", "selected=\"selected\"", $form); for ($i = 0; $i < 24; $i++) { $form = str_replace("%sel_" . $i . "%", "", $form); } return $form; } else { return $msg; } }
/** * Вернет ID страницы из параметров URI * * В функцию передается URI текущей страницы. * * Возвращает ID страницы из базы. Судя по всему для дальнейшей идетнификации шаблона. * * @param string $path * @return integer */ function getPageIDByPath($path) { global $classErrorMessage; $pNumber = 1; if ($path == '/') { return $this->getDefaultPageID(); } else { $path = rtrim($path, '/'); $pathComponents = explode('/', $path); $parent = $this->getRootPageID(); $cnt = count($pathComponents); /** * Begin debugging code */ //print_r($pathComponents); //print $parent; //preg_match('/^pageID=(\d+)$/', $pathComponents[1], $match); //print_r($match); //die(); /** * End debugging code */ for ($i = 1; $i < $cnt; $i++) { //print $parent; //we must skip page number in URL if ($i == $cnt - 1 && preg_match('/^page(\\d+)$/', $pathComponents[$i], $match)) { $this->pageNumber[$parent] = $match[1]; break; } // пропускаем подкатегории каталога ссылок /* if (preg_match('/^item(\d+)$/', $pathComponents[$i], $match)) { $this->itemPart[$parent] = $match[1]; continue; } */ $v = prepareVar($pathComponents[$i]); //print $v; // пропускаем добавление ссылки /* if ($v == "'add'") { $this->itemPart[$parent] = 'add'; break; } */ $q = 'SELECT `sID` FROM `pm_structure` WHERE (`pms_sID`="' . $parent . '" AND `URLName`=' . $v . ') OR (`URLName`="" AND `sID`=' . $v . ') LIMIT 1'; $qr = mysql_query($q); if (!$qr) { trigger_error(mysql_error(), PM_FATAL); } if (mysql_num_rows($qr) == 1) { list($parent) = mysql_fetch_row($qr); } else { $classErrorMessage = 'Couldn\'t find the specified URL - ' . $path . '<b>'; $parent = NULL; break; } } return $parent; } }