/*$n = new Vopros(&$share);
if (count($PAGE_PATH_ARRAY) == 1) {
$n->form();
}
elseif ( $PAGE_PATH_ARRAY[1] == 'add') {
$n->voprosAdd();
}
else {
require_once("php/404.php");
exit;
}*/
class Vopros {
var $error = array();
function GetContent( &$share ) {
$this->share = &$share;
$this->self = $this->share->doc['module'];
if (@$_GET['action'] == 'add' AND isset($_GET['action'])) {
return $this->voprosAdd();
}
else {
return $this->form();
}
}
function form() {
//print_r( $this->error);
$this->share->tpl->assign('error', $this->error);
$vop = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$vop = $_POST;
$vop['vopros'] = @htmlspecialchars($vop['vopros']);
$vop['fio'] = @htmlspecialchars($vop['fio']);
$vop['email'] = @htmlspecialchars($vop['email']);
$vop['city'] = @htmlspecialchars($vop['city']);
$vop['company'] = @htmlspecialchars($vop['company']);
}
$res = $this->share->db->query("select id, name
from ".$this->share->vopros_otdel."
order by name
");
if (PEAR::isError($res)) { die(__FILE__ .": ".__LINE__.': '.$res->getMessage()); }
$otdels = array();
while ($row = $res->fetchRow()) {
$otdels[$row['id']] = $row['name'];
}
$this->share->tpl->assign('otdels', $otdels);
$this->share->tpl->assign('vop', $vop);
$this->share->doc['head'] = 'Вопрос к специалисту';
$this->share->doc['body'] = $this->share->tpl->fetch("vopros.tpl");
return true;
}
function voprosAdd() {
$email = strtolower(trim($_POST['email']));
$email = ereg_replace("\n", "", $email);
if (!preg_match("/^[.a-zA-Z0-9_-]+@[a-zA-Z0-9-.]+\.[a-zA-Z0-9]{2,}$/", $email)) {
$this->error[] = 'Введен неправильный e-mail.';
}
if (empty($_POST['fio']) ) {
$this->error[] = 'Не заполнено ФИО.';
}
if (empty($_POST['city']) ) {
$this->error[] = 'Введен город.';
}
if (empty($_POST['vopros']) ) {
$this->error[] = 'Введите текст сообщения.';
}
if (count($this->error) > 0) {
$this->form();
}
else {
$res = $this->share->db->getAll("select emails
from ".$this->share->vopros_otdel."
where id = ".intval($_POST['otdel']));
if (PEAR::isError($res)) { die(__FILE__ .": ".__LINE__.': '.$res->getMessage()); }
if (count($res) > 0) {
//пишем письма
$to_eml = $res[0]['emails'];
require_once( 'MailSend.class.php' );
$ms = new MailSend();
$status = $ms->send( $to_eml, "ФИО: ".$_POST['fio']."
"."Компания: ".$_POST['company']."
"."Город: ".$_POST['city']."
"."E-mail: ".$email."
".$_POST['vopros'], 'Вопрос специалисту' );
}
$sql = "INSERT INTO ".$this->share->vopros_query." SET
fio = ?,
email = ?,
vopros = ?,
city = ?,
company = ?,
otdel = ?,
added = NOW()";
$res = $this->share->db->query($sql, array($_POST['fio'], $_POST['email'], $_POST['vopros'],
$_POST['city'], $_POST['company'], $_POST['otdel']
) );
if (PEAR::isError($res)) { die(__FILE__ .": ".__LINE__.': '.$res->getMessage()); }
$this->share->tpl->assign('added', 'ok');
$_POST = array();
$this->form();
}
return true;
}
}
?>
Fatal error: Class 'Vopros' not found in /var/apache2/htdocs/page.php on line 39