if ($r)
{
$o = mysql_fetch_object($r);
$this->inform_id = $inform_id;
$this->part_id = $o->part_id;
$this->dt = $o->dt;
$this->title = $o->title;
$this->informfile = $o->informfile;
$this->typefile = $o->typefile;
$this->outnote = $o->outnote;
$this->txt = $o->txt;
$this->url = $o->url;
$this->ord = $o->ord;
$this->status = $o->status;
$this->empty = false;
return $this->inform_id;
}
}
function save()
{
if ($this->empty)
{
$q = "INSERT INTO inform (
part_id,
dt,
title,
informfile,
typefile,
outnote,
txt,
url,
ord,
status
)
VALUES (".$this->getPartId().",
now(),
'".$this->getTitle()."',
'".$this->getInformfile()."',
".$this->getTypefile().",
'".$this->getOutnote()."',
'".$this->getTxt()."',
'".$this->getUrl()."',
".$this->getOrd().",
".$this->getStatus()."
)";
}
else
{
$q = "UPDATE inform SET
part_id = ".$this->getPartId().",
title = '".$this->getTitle()."',
informfile = '".$this->getInformfile()."',
typefile = ".$this->getTypefile().",
outnote = '".$this->getOutnote()."',
txt = '".$this->getTxt()."',
url = '".$this->getUrl()."',
ord = ".$this->getOrd().",
status = ".$this->getStatus().",
dt = now()
WHERE inform_id = ".$this->getId();
}
//echo $q;
$r = mysql (DBName, $q);
if (mysql_affected_rows())
{
if ($this->empty)
{
$this->inform_id = mysql_insert_id();
}
return $this->load($this->inform_id);
}
return 0;
}
function setPartId($part_id)
{
$this->part_id = $part_id;
}
function setTitle($title)
{
$this->title = $title;
}
function setInformfile($informfile)
{
$this->informfile = $informfile;
}
function setTypefile($typefile)
{
$this->typefile = $typefile;
}
function setOutnote($outnote)
{
$this->outnote = $outnote;
}
function setTxt($txt)
{
$this->txt = $txt;
}
function setUrl($url)
{
$this->url = $url;
}
function setOrd($ord)
{
$this->ord = $ord;
}
function setStatus($status)
{
$this->status = $status;
}
function getId()
{
return $this->inform_id;
}
function getPartId()
{
return $this->part_id;
}
function getDT()
{
return $this->dt;
}
function getTitle()
{
return $this->title;
}
function getInformfile()
{
return $this->informfile;
}
function getTypefile()
{
return $this->typefile;
}
function getOutnote()
{
return $this->outnote;
}
function getTxt()
{
return $this->txt;
}
function getUrl()
{
return $this->url;
}
function getOrd()
{
return $this->ord;
}
function getStatus()
{
return $this->status;
}
}
////////////////////////////////////////////
/* function deleteInformfile
* удаляет
*/
function deleteInformfile ($inform_id) {
global $libpath;
$inform = new Inform ($inform_id);
if (trim($inform->getInformfile())) unlink ($libpath."/inform/".$inform->getInformfile());
$q = "DELETE FROM inform WHERE inform_id = $inform_id";
mysql (DBName, $q);
if (mysql_affected_rows()) return 1; else return 0;
}
////////////////////////////////////////////
/* function getAllInformfile
* возвращает массив id
*/
function getAllInformfile($part_id=-1)
{
if ($part_id > -1) $where = " WHERE part_id = $part_id"; else $where = "";
$q = "SELECT inform_id FROM inform $where ";
$q.= " ORDER BY ord ";
//echo $q;
$r = mysql (DBName, $q);
if ($r)
$n = mysql_num_rows($r);
else
$n = 0;
$res = array();
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object ($r);
$res[$i] = new Inform($o->inform_id);
}
return $res;
}
////////////////////////////////////////////
/* рекурсивно возвращает строку block_id
* от текущего до верхнего уровня с разделителем :
*/
function printParentId($block_id, $stop=0)
{
static $strparentid = "";
if($stop) $strparentid = "";
if($block_id > 0 ){
$part = new Info($block_id);
$strparentid.= $part->getBlockId();
if($part->getParentId() > 0) {$strparentid.= ":"; printParentId($part->getParentId());}
return $strparentid;
}
else return 0;
}
////////////////////////////////////////////
function getParts($info_type, $status=0, $parent_id = "IS NULL" )
{
if ($parent_id!= "IS NULL") $parent_id = " = ".$parent_id;
////$q = "SELECT block_id FROM info WHERE info_type=$info_type AND status = $status ";
$q = "SELECT block_id FROM info WHERE info_type=$info_type ";
$q.= " AND parent_block_id ".$parent_id;
$q.= " ORDER BY info_order";
//echo $q;
$r = mysql (DBName, $q);
$res = array();
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = new Info($o->block_id);
}
return $res;
}
//--
/* печать дерева подразделов
* islast - указывает, что подраздел -последний, т. е. длинную вертикаль не прорисовывать
*
*/
function printPartsTreeInform($oldchain,$chain, $user_id, $part_id = 0, $islast=0)
{
$oldchainarr = explode(":", $oldchain);
global $libpath;
$parentpart = new Info($part_id);
//выводим подразделы-----
$parts = getParts(INFORM, 0, $part_id);
$ifiles = getAllInformfile($part_id); //файлы
if(count($parts) || count($ifiles)) {
//длинную вертикаль не рисуем если это последний подраздел и если это основной Раздел
$bg = ($parentpart->getParentId()>0 && !$islast) ? " background=images/derevo3.gif ": "";
echo "<tr><td width=30 height=30 ".$bg."> </td><td>
<table border=0 width=100% cellpadding=0 cellspacing=0>";
for ($i = 0; $i < count($parts); $i++) {
$part = $parts[$i];
$title = $parttitle = "<span class=subpart>".$part->getTitle()."</span>";
if(in_array($part->getBlockId(),$oldchainarr)) {$title = $parttitle = "<b>".$title."</b>"; $nohref=1; $imgfolder = "<img border=0 src=images/folder2_small. gif width=15 height=14> ";}
else {$title = $parttitle = "<u>".$title."</u>"; $nohref=0; $imgfolder = "<img border=0 src=images/folger2_smallserii. gif width=15 height=14> ";}
$title = $parttitle = $imgfolder.$title;
$fullchainarrrev = explode(":",printParentId($part->getBlockId(), 1));
$fullchainarr=array();
$j=0;
for($k=count($fullchainarrrev)-1; $k>=0; $k--) {
$fullchainarr[$j] = $fullchainarrrev[$k];
$j++;
}
$fullchain = implode(":",$fullchainarr);
$islast = ($i==count($parts)-1 && !count($ifiles))?1:0;
if((count(getParts(INFORM,0, $part->getBlockId())) || count(getAllInformfile($part->getBlockId()))) && $nohref!=1) {
$closeinform=($part->getStatus()==1)?" title='только для зарегистрированных пользователей' ":"";
$title = "<a class=subpart $closeinform href=index. phtml? act=view&islast=".$islast."&chain=".$fullchain.">".$parttitle."</a>";
}
$bg = ($islast && !count($ifiles)) ? " background=images/derevo22-1.gif " : $bg = " background=images/derevo11-1.gif ";
echo "<tr><td width=30 height=30 ".$bg."> </td><td>";
echo $title;
echo "</td></tr>";
if(trim($chain) && in_array($part->getBlockId(),$oldchainarr)){
$chainarr = explode(":",$chain);
$newchainarr = array_slice($chainarr,1);
$strnewchain=implode(":",$newchainarr);
printPartsTreeInform($oldchain,$strnewchain, $user_id, $part->getBlockId(), $islast);
}
}
//выводим файлы
if(count($ifiles)){
for($j=0;$j<count($ifiles);$j++){
$ifile = $ifiles[$j];
$filename = "<font color=#1A3974><u>".$ifile->getTitle()."</font></u>";
$myurl="detailfile. phtml? ifile_id=".$ifile->getId();
$hrefmore = (trim($ifile->getOutnote()))? " <a href='javascript:openNewWin(\"".$myurl."\")'><font color=#777777><u>Прочитать аннотацию к файлу</u></font></a>":"";
if(trim($ifile->getInformfile()) && $ifile->getTypefile()!=4){
$isize = round(filesize($libpath.'/inform/'.$ifile->getInformfile())/1024,2)."K.";
if($user_id) $filename = "<a href=lib/inform/".$ifile->getInformfile().">".$filename."</a> (".$isize.")";
else $filename = "<a href=usernew. phtml title='Необходима регистрация'>".$filename."</a> (".$isize.")";
}
if($ifile->getTypefile()==0) $imgsrc = "xls. gif";
if($ifile->getTypefile()==1) $imgsrc = "pdf. gif";
if($ifile->getTypefile()==2) $imgsrc = "zip. gif";
if($ifile->getTypefile()==3) $imgsrc = "word. gif";
if($ifile->getTypefile()==4) {
$imgsrc = "ie. gif";
if($user_id){
if(trim($ifile->getUrl())) $filename = "<a target=_blank href=".$ifile->getUrl().">".$filename."</a> ";
elseif(trim($ifile->getTxt())) $filename = "<a target=_blank href=detailinform. phtml? ifile_id=".$ifile->getId().">".$filename."</a> ";
} else $filename = "<a href=usernew. phtml title='Необходима регистрация'>".$filename."</a> ";
}
$bg = ($j==count($ifiles)-1) ? " background=images/derevo22-1.gif " : " background=images/derevo11-1.gif ";
echo "
<tr><td width=30 height=30 ".$bg."> </td><td>
<img src=images/".$imgsrc." border=0> ".$filename.$hrefmore."
</td></tr>";
}
}
echo "</td></tr></table>";
}
}
//--
/* Поиск
*/
function searchInInform ($keytext) {
$resarr=array();
if(trim($keytext)){
$q = "SELECT DISTINCT inform_id FROM inform
WHERE ((lower(title) LIKE lower('%$keytext%') OR
lower(outnote) LIKE lower('%$keytext%') OR lower(txt) LIKE lower('%$keytext%'))) ";
//echo $q;
$r = mysql (DBName, $q);
if ($r>0)
{
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object ($r);
$resarr[$i] = new Inform($o->inform_id);
}
}
}
return $resarr;
}
//////////////////////////////////////////////////
?>
Модуль info
<?
/* Класс Info типизированный описывает блок информации
* @sql info. sql
*/
class Info {
var $block_id;
var $parent_block_id = "NULL";
var $info_type;
var $info_order = 0;
var $title;
var $txt;
var $modiftime;
var $link;
var $descr;
var $bigphoto;
var $status=0;
var $empty = true;
function Info($block_id = 0)
{
if ($block_id) $this->load($block_id);
}
function load($block_id)
{
$q = "SELECT * FROM info WHERE block_id = $block_id";
$r = mysql (DBName, $q);
if (mysql_num_rows($r))
{
$o = mysql_fetch_object ($r);
$this->block_id = $block_id;
$this->parent_block_id = $o->parent_block_id? $o->parent_block_id : "NULL";
$this->info_type = $o->info_type;
$this->info_order = $o->info_order;
$this->title = $o->title;
$this->txt = $o->txt;
$this->modiftime = $o->modiftime;
$this->link = $o->link;
$this->descr = $o->descr;
$this->bigphoto = $o->bigphoto;
$this->status = $o->status;
$this->empty = false;
return $block_id;
}
return 0;
}
function save ()
{
if ($this->empty)
{
$q = "INSERT INTO info (parent_block_id, info_type, info_order, title, txt, modiftime, link, descr, bigphoto, status)
VALUES (".$this->getParentId().",
".$this->getInfoType().",
".$this->getInfoOrder().",
'".$this->getTitle()."',
'".$this->getTxt()."',
'".date("Y-m-d H:i")."',
'".$this->link."',
'".$this->descr."',
'".$this->bigphoto."',
".$this->getStatus().")";
//echo $q;
$r = mysql (DBName, $q);
if (mysql_affected_rows())
{
$this->block_id = mysql_insert_id();
return $this->load($this->getBlockId());
}
}
else
{
$q = "UPDATE info SET parent_block_id = ".$this->getParentId().",
info_type = ".$this->getInfoType().",
info_order = ".$this->getInfoOrder().",
title = '".$this->getTitle()."',
txt = '".$this->getTxt()."',
modiftime = '".date("Y-m-d H:i")."',
link = '".$this->link."',
descr = '".$this->descr."',
bigphoto = '".$this->bigphoto."',
status = ".$this->getStatus()."
WHERE block_id = ".$this->getBlockId();
//echo $q;
$r = mysql (DBName, $q);
if (mysql_affected_rows())
{
return $this->load($this->getBlockId());
}
}
return 0;
}
function getBlockId()
{
return $this->block_id;
}
function getParentId()
{
return $this->parent_block_id;
}
function getInfoType()
{
return $this->info_type;
}
function getInfoOrder()
{
return $this->info_order;
}
function getTitle()
{
return $this->title;
}
function getTxt()
{
return $this->txt;
}
function getModifTime()
{
return $this->modiftime;
}
function getLink()
{
return $this->link;
}
function getDescr()
{
return $this->descr;
}
function getBigPhoto()
{
return $this->bigphoto;
}
function getStatus()
{
return $this->status;
}
function setParentId($parent_id)
{
$this->parent_block_id = $parent_id;
}
function setInfoType($info_type)
{
$this->info_type = $info_type;
}
function setInfoOrder($info_order)
{
$this->info_order = $info_order;
}
function setTitle($title)
{
$this->title = $title;
}
function setTxt($txt)
{
$this->txt = $txt;
}
function setLink($link)
{
$this->link = $link;
}
function setDescr($descr)
{
$this->descr = $descr;
}
function setBigPhoto($bigphoto)
{
$this->bigphoto = $bigphoto;
}
function setStatus($status)
{
$this->status = $status;
}
}
function deleteInfo($block_id)
{
$q = "DELETE FROM info WHERE block_id = $block_id";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
/* Находит все Info нужного типа по нужному parent_id
*/
function getInfos ($info_type, $parent_id = "IS NULL")
{
$res = array();
if ($parent_id!= "IS NULL") $parent_id = " = ".$parent_id;
$q = "SELECT block_id FROM info WHERE info_type = ".$info_type." AND parent_block_id ".$parent_id." ORDER BY info_order";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = new Info($o->block_id);
}
return $res;
}
/** Функции получения связей между инфоблоками и библиотечными элементами
*/
function getFilesForInfo($block_id)
{
$res = array();
$q = "SELECT file_name FROM file_to_info WHERE block_id = $block_id ORDER BY ord";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = $o->file_name;
}
return $res;
}
function getImagesForInfo($block_id)
{
$res = array();
$q = "SELECT img_name FROM img_to_info WHERE block_id = $block_id ORDER BY ord";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = $o->img_name;
}
return $res;
}
function getCodesForInfo($block_id)
{
$res = array();
$q = "SELECT code_name FROM code_to_info WHERE block_id = $block_id ORDER BY ord";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = $o->code_name;
}
return $res;
}
function getPagesForInfo($block_id)
{
$res = array();
$q = "SELECT page_id FROM page_to_info WHERE block_id = $block_id ORDER BY ord";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++)
{
$o = mysql_fetch_object($r);
$res[$i] = $o->page_id;
}
return $res;
}
/** Функции добавления связей между инфоблоками и библиотечными элементами
*/
function setImageForInfo($block_id, $image_name, $order=0)
{
$q = "INSERT INTO img_to_info VALUES ('$image_name', $block_id, $order)";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function setCodeForInfo($block_id, $code_name, $order=0)
{
$q = "INSERT INTO code_to_info VALUES ('$code_name', $block_id, $order)";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function setFileForInfo($block_id, $file_name, $order=0)
{
$q = "INSERT INTO file_to_info VALUES ('$file_name', $block_id, $order)";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function setPageForInfo($block_id, $page_id, $order=0)
{
$q = "INSERT INTO page_to_info VALUES ($page_id, $block_id, $order)";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
/** Функции удаления связей между инфоблоками и библиотечными элементами
*/
function deleteImageForInfo($block_id, $image_name = '')
{
if (trim($img_name)) $and = " AND image_name LIKE '$image_name'";
$q = "DELETE FROM img_to_info WHERE block_id = $block_id $and";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function deleteCodeForInfo($block_id, $code_name = '')
{
if (trim($code_name)) $and = " AND image_name LIKE '$code_name'";
$q = "DELETE FROM code_to_info WHERE block_id = $block_id $and";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function deleteFileForInfo($block_id, $file_name = '')
{
if (trim($file_name)) $and = " AND image_name LIKE '$file_name'";
$q = "DELETE FROM file_to_info WHERE block_id = $block_id $and";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
function deletePagesForInfo($block_id, $page_id = "")
{
if (trim($page_id)) $and = " AND part_id = $page_id";
$q = "DELETE FROM page_to_info WHERE block_id = $block_id $and";
mysql (DBName,$q);
if (mysql_affected_rows()) return 1; else return 0;
}
/** Возвращает максимальную дату модификации объекто
*/
function getMaxModifTime($in)
{
$q = "SELECT max(modiftime) AS modiftime FROM info WHERE block_id IN ($in)";
$r = mysql (DBName, $q);
if (mysql_num_rows($r))
{
$o = mysql_fetch_object($r);
return $o->modiftime;
}
return '';
}
/** Функции образования связей между объектами (table info_to_info. sql)
*/
function setInfoToInfo ($id1, $id2) {
$q = "INSERT INTO info_to_info VALUES ($id1, $id2)";
mysql (DBName, $q);
if (mysql_affected_rows()) return 1; else return 0;
}
function delInfoToInfo ($id1 = 0, $id2 = 0) {
if ($id1) $where = "WHERE id1 = $id1";
if ($id2) {
if (trim($where)) $where.= " AND id2 = $id2 ";
else $where = "WHERE id2 = $id2";
}
if (trim($where)) {
$q = "DELETE FROM info_to_info $where";
mysql (DBName, $q);
if (mysql_affected_rows()) return 1; else return 0;
} else return -1;
}
function getParentIds($id, $type = "") {
$res = array();
if (trim($type))
$q = "SELECT ii. id1 AS id
FROM info_to_info ii, info i
WHERE ii. id2 = $id AND ii. id1 = i. block_id AND i. info_type = $type";
else
$q = "SELECT id1 AS id FROM info_to_info WHERE id2 = $id";
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++) {
$o = mysql_fetch_object ($r);
$res [$i] = $o->id;
}
return $res;
}
function getChildIds($id, $type = "") {
$res = array();
if (trim($type))
$q = "SELECT ii. id2 AS id
FROM info_to_info ii, info i
WHERE ii. id1 = $id AND ii. id2 = i. block_id AND i. info_type = $type";
else
$q = "SELECT id2 AS id FROM info_to_info WHERE id1 = $id";
//echo $q;
$r = mysql (DBName, $q);
$n = mysql_num_rows($r);
for ($i = 0; $i < $n; $i++) {
$o = mysql_fetch_object ($r);
$res [$i] = $o->id;
}
return $res;
}
?>
Модуль index
l"
));
for ($i = 0; $i < count($regFormFields); $i++)
{
if ($regFormFields[$i][0] == DELIMETER)
{
$usertpl->assign("DELIMETER", $regFormFields[$i][1]);
$usertpl->parse("FIELDS",".delimeter");
}
if ($regFormFields[$i][0] == FIELD)
{
if ($regFormFields[$i][3] == F_REQUIRED)
$required = "<sup>*</sup>";
else
$required = "";
$fieldtext = $regFormFields[$i][2]." ".$required;
if ($failedFields[$regFormFields[$i][1]][0] == true)
$fieldtext = "<div style='color:red'>".$fieldtext."</div>";
else
$fieldtext = $fieldtext;
$usertpl->clear ("THISFIELD");
$readonly = "";
switch ($regFormFields[$i][4])
{
case F_TEXT : if ($regFormFields[$i][1] == "login")
$readonly = "readonly";
else $readonly = "";
$fieldval = $userarray[$regFormFields[$i][1]];
$usertpl->assign (array(
"FIELDNAME"=>$regFormFields[$i][1],
"FIELDVALUE"=>$fieldval,
"READONLY"=>$readonly));
$usertpl->parse ("THISFIELD","textfield");
$usertpl->assign (array (
"FIELDTEXT"=>$fieldtext,
"COLOR"=>$color,
"REQUIRED"=>$required));
$usertpl->parse ("FIELDS",".field");
break;
case F_PASS : $fieldval = $userarray["pass"];
$usertpl->assign (array("FIELDNAME"=>$regFormFields[$i][1], "FIELDVALUE"=>$fieldval));
$usertpl->parse ("THISFIELD","passfield");
$usertpl->assign (array ("FIELDTEXT"=>$fieldtext,"COLOR"=>$color,"REQUIRED"=>$required));
$usertpl->parse ("FIELDS",".field");
break;
case F_DATE : $fieldval_day = $userarray["day"];
$fieldval_month = $userarray["month"];
$fieldval_year = $userarray["year"];
$monthselect = "";
for($m=1; $m<13; $m++)
{
if($fieldval_month == $m) $sel="selected"; else $sel = "";
$monthselect.= "<option value=".$m." ".$sel.">".$months[$m-1];
}
$usertpl->assign(array("DAY"=>$fieldval_day,"MONTHSELECT"=>$monthselect,"YEAR"=>$fieldval_year));
$usertpl->parse("THISFIELD","datefield");
$usertpl->assign (array ("FIELDTEXT"=>$fieldtext,"COLOR"=>$color,"REQUIRED"=>$required));
$usertpl->parse ("FIELDS",".field");
break;
case F_TEXTAREA : $fieldval = $userarray[$regFormFields[$i][1]];
$usertpl->assign (array("FIELDNAME"=>$regFormFields[$i][1], "FIELDVALUE"=>$fieldval));
$usertpl->parse ("THISFIELD","areafield");
$usertpl->assign (array ("FIELDTEXT"=>$fieldtext,"COLOR"=>$color,"REQUIRED"=>$required));
$usertpl->parse ("FIELDS",".field");
break;
}
}
}
$usertpl->assign("STRHEADER","Изменение персональных данных");
$usertpl->assign("MES",$mes);
$usertpl->assign("USERID",$user_id);
$usertpl->assign("ACTION","upd");
$usertpl->assign("BUTTEXT","Принять изменения");
$usertpl->assign("RETURNURL",$returnUrl);
$usertpl->assign("GROUP",$group);
$usertpl->assign("BUTGENERATOR","<input style='border-style:solid; border-width:1px; FONT-SIZE: 8pt; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #F7F7F7' type=submit name=saction value='Изменить пароль'>");
$usertpl->parse("USERFORM","userform");
$usertpl->fastPrint("USERFORM");
}
}
// reminder
if ($action == 'reminder')
{
if (trim($password = getUsernewPassword($vars[email])))
{
$login = getUsernewLogin($vars[email]);
$mess = new Mail($vars[email],MAILFROM);
$mess->setBottom($mail_bottom);
$mess->setSubject("Напоминание пароля");
$body = "Ваши данные на сайте \n".
"Логин: $login\n".
"Пароль: $password\n\n";
$mess->setBody($body);
if ($mess->send())
$mes = "
<b>Уважаемый пользователь!</b> <br>На Ваш электронный адрес выслано письмо с регистрационными данными. <br><br>
<a href=usernew. phtml><font color=#1A3974><u>Перейти к странице авторизации</u></font></a>";
else
$mes = "<b>Не удалось выслать логин и пароль!</b><br><a href=usernew. phtml><font color=#1A3974><u>Вернуться в раздел Авторизации</u></font></a><br>";
}
else {
$mes = "
<b>Уважаемый пользователь!</b><br>Такого E-mail в базе нет!<br><br>
<a href=usernew. phtml><font color=#1A3974><u>Вернуться в раздел Авторизации</u></font></a>
";
}
$usertpl->define (array("message"=>"message. tpl"));
$usertpl->assign (array("MESSAGE"=>$mes,
"STRHEADER"=>"Напоминание пароля",
));
$usertpl->assign("RETURNURL",$returnUrl);
$usertpl->parse("MESSAGE","message");
$usertpl->fastPrint("MESSAGE");
}
/*****/
$tpl->parse("FOOTER","footer");
$tpl->fastPrint();
$tpl->parse("BOTTOM","bottom");
$tpl->fastPrint();
disconnect();
?>
Модуль Connect
?
define("SMHostName",$sm_dbhost);
define("SMUserName",$sm_dbuser);
define("SMPassword",$sm_dbpass);
define("SMDBName", $sm_dbname);
define("HostName",$dbhost);
define("UserName",$dbuser);
define("Password",$dbpass);
define("DBName", $dbname);
function connect()
{
global $link;
$link = mysql_connect(HostName, UserName, Password);
if(!$link)
{
echo "Can not connect to $dbname<br>";
exit;
}
else
{
mysql_select_db (DBName) or die ("Can't select common database");
}
}
function disconnect()
{
global $link;
if ($link) mysql_close($link);
}
function sm_connect()
{
global $sm_link, $link;
connect();
$sm_link = $link;
}
function sm_disconnect()
{
global $sm_link, $link;
disconnect();
}
?>
Модуль admin_user
<?
/**
* Модуль администрирования пользователей
*/
global $mainpath, $message, $action, $act, $user_id, $user_enable;
global $price_enable, $mail_bottom, $mailfrom, $mainurl, $regFormFields, $failedFields;
$months = array("Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь");
$gvars = $HTTP_GET_VARS;
$fvars = $HTTP_POST_FILES;
$pvars = $HTTP_POST_VARS;
if (count($gvars))
$vars = &$gvars;
else
$vars = &$pvars;
connect();
if(!$act || $act=="del")
{
echo "
<table border=0 cellpadding=10 cellspacing=0 style='border-collapse: collapse' bordercolor='#111111' >
<tr>
<td><font size=3>Пользователи </font></td>
<td align=right><a href=admin. phtml>Вернуться</a></td>
</tr>
<tr>
<td width=577 colspan=2>";
//--удаление пользователя
if($act=="del")
{
if (deleteUsernew($user_id)) echo "<font color=red><b>Пользователь удален</b><br><br></font>";
else echo "<font color=red><b>Пользователь НЕ удален</b><br><br></font>";
}
//--сколько всего юзеров
$users = getUsersnew();
$all = count($users);
$users = getUsersnew(0,$filter, $f_value, $sort);
$m = count($users);
$numuser = (isset($numuser))?$numuser:20;
$maxpage = ceil($m/$numuser);
if($m)
{
//--юзеры постранично
unset($users);
$limit = ($numuser == 0)?0:1;
$offset=(isset($vars[page]))?(($vars[page]-1)*$numuser):0;
$page=(isset($vars[page]))?$vars[page]:1;
$users = getUsersnew(0,$filter, $f_value, $vars[sort], $limit, $offset, $numuser);
$num_users = count($users);
echo "
<b>Зарегистрированные пользователи:
<font color='#FF0000'>".$all."<br></font></b><br>";
if($addfilter) echo "Результат поиска: ".$m;
echo "
<form action=admin. phtml method=post>
<input type=hidden name=action value=$action>
<input type=hidden name=act value=$act>";
$s20 = ($numuser==20)?"selected":"";
$s40 = ($numuser==40)?"selected":"";
$s50 = ($numuser==50)?"selected":"";
$s0 = ($numuser==0) ?"selected":"";
echo "
Показать:
<select size='1' name=numuser style='font-family: Tahoma; font-size: 8pt; border-style: solid; border-width: 1; background-color: #FFFFFF'>
<option value=2 ".$s20.">по 20 на странице</option>
<option value=40 ".$s40.">по 40 на странице</option>
<option value=50 ".$s50.">по 50 на странице</option>
<option value=0 ".$s0.">всех пользователей</option>
</select>
<input type=submit value='Применить' style='font-family: Tahoma; font-size: 8pt; border: 1px solid #111111; background-color: #F5B904'><br><br>
</form>
Стр. ".$page."
<div align=left>
<table border=0 cellpadding=5 cellspacing=1 style='border-collapse: collapse' bordercolor='#111111' width=100% bgcolor='#F7F7F7' >
<tr>
<td bgcolor='#F5B904' align=center height=13><b><a href=admin. phtml? action=user&sort=1 class=body>Дата</a></b></td>
<td bgcolor='#B5C7DB' align=center >ФИО</td>
<td bgcolor='#B5C7DB' align=center >E-mail</td>
<td bgcolor='#B5C7DB' align=center >Институт</td>
<td bgcolor='#B5C7DB' align=center >Факультет</td>
<td bgcolor='#B5C7DB' align=center >Курс</td>
<td bgcolor='#B5C7DB' align=center >Группа</td>
<td bgcolor='#B5C7DB' align=center ><u><b>Опции</b></u></td>
</tr>";
for ($j = 0; $j < $num_users; $j++)
{
$user = $users[$j];
echo "
<tr>
<td bgcolor='#DFDFDF' align=center height=13>".getDateFormated ($user->getRegdate(),3)."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getPerson()."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getEmail()."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getOrgname()."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getFaculty()."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getCourse()."</td>
<td bgcolor='#E8E8E8' align=center height=13>".$user->getGroups()."</td>
<td bgcolor='#E8E8E8' height=13 align=center>
<a class=body href=admin. phtml? action=$action&act=del&user_id=".$user->getUserId()." onclick='return confirm(\"Вы уверены?\")'>удл</a> |
<a class=body href=admin. phtml? action=$action&act=upd_form&user_id=".$user->getUserId()."&sort=".$sort."&page=".$page.">детали</a>
</td>
</tr>";
}
echo "</table></div>";
if($maxpage>1)
|
Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6 7 8 9 |



