Newbie
Покинул форум
Сообщений всего: 30
Дата рег-ции: Дек. 2010
Репутация: 1
|
ghSugar пишет:Возможно ли что бы при регистрации эти данные сохранялись так же и на форуме и как примерно это сделать?
Добавление пользователя на форум, тут не пишутся данные для вывода у кого день рождение. Можно поставить после успешной записи в базу данных
CODE:
//-------==============--------запись на форум нового пользователя-----=============----------
define("FM_BOARDSTATS", "../FORUMFOLDER/data/boardstats.php");
function _Read($filename,$newfile = TRUE) {
if (!file_exists($filename)/* && $newfile === TRUE*/) {
return array();
//fclose(fopen($filename,'a+'));
//@chmod($filename,$this->exbb['ch_files']);
}
$fp = @fopen($filename,'r') or die('Could not read from the file <b>'.$filename.'</b>');
//$this->_Flock($fp,$filename);
flock($fp, 1);
$filesize = filesize($filename);
$filesize = ($filesize ===0) ? 1:$filesize-8;
fseek($fp,8);
$str = fread($fp,$filesize);
flock($fp, 3);
fclose($fp);
return (!empty($str))?unserialize($str):array();
}
function _Read2Write(&$fp,$filename,$newfile = TRUE) {
if (!file_exists($filename)/* && $newfile === TRUE*/) {
@fclose(@fopen($filename,'a+'));
//@chmod($filename,$this->exbb['ch_files']);
}
$fp = @fopen($filename,'a+') or die('Could not write in the file <b>'.$filename.'</b>');
//$this->_Flock($fp,$filename,LOCK_EX);
flock($fp, /*1*/2);
$filesize = filesize($filename);
$filesize = ($filesize ===0) ? 1:$filesize-8;
fseek($fp,8);
$str = fread($fp,$filesize);
//flock($fp, 2);
$_FilePointers[$fp] = $fp;
return (!empty($str))?unserialize($str):array();
}
function _Write(&$fp,$arr) {
fseek ($fp,0);
ftruncate ($fp,0);
fwrite($fp,'<?die;?>'.serialize($arr));
fflush($fp);
flock($fp,3);
fclose($fp);
unset($arr,$_FilePointers[$fp]);
return;
}
function _BOARDSTATS() {
$_Stats = _Read(FM_BOARDSTATS);
}
function _SAVE_STATS($array) {
$stats = _Read2Write($fp_stats,FM_BOARDSTATS,FALSE);
foreach ($array as $key => $value) {
switch ($value[1]) {
case -1: $stats[$key] = $stats[$key] - $value[0];
break;
case 0: $stats[$key] = $value[0];
break;
case 1: $stats[$key] = $stats[$key] + $value[0];
break;
}
}
_Write($fp_stats,$stats);
return;
}
function _LowerCase($var) {
//return (_RuLocale === FALSE) ? _strtolower($var):strtolower($var);
return strtolower($var);
}
$user = array();
$user['id'] = 0;
$user['status'] = 'me';
$user['name'] = iconv('utf-8', 'windows-1251', $login);
$user['pass'] = md5(iconv('utf-8', 'windows-1251', $psw));
$user['mail'] = iconv('utf-8', 'windows-1251', $mail);
$user['title'] = '';
$user['posts'] = 0;
$user['joined'] = time();
$user['ip'] = "127.0.0.1";
$user['showemail'] = FALSE;
$user['www'] = iconv('utf-8', 'windows-1251', $homepage);
$user['icq'] = iconv('utf-8', 'windows-1251', $icq);
$user['aim'] = '';
$user['location'] = iconv('utf-8', 'windows-1251', $town);
$user['interests'] = iconv('utf-8', 'windows-1251', $about);
$user['sig'] = '';
$user['sig_on'] = TRUE;//FALSE;
$user['lang'] = 'russian';
$user['skin'] = 'GreyExBB';
$user['timedif'] = 0;
$user['avatar'] = 'noavatar.gif';
$user['upload'] = FALSE;
$user['visible'] = FALSE;
$user['new_pm'] = FALSE;
$user['sendnewpm'] = FALSE;
$user['posts2page'] = 10;
$user['topics2page']= 15;
$user['last_visit'] = 0;
$allusers =_Read2Write($fp_allusers,"../FORUMFOLDER/data/users.php");
// foreach ($allusers as $u_id=>$info) {
// echo($info['n']."-".$info['m']."-".$info['p']."<br>");
// }
ksort($allusers, SORT_NUMERIC);
end($allusers);
$id = key($allusers) + 1;
_BOARDSTATS();
//$_Stats = _Read("data/boardstats.php");
$id = ($_Stats['last_id'] === $id) ? $id + 1:$id;
$allusers[$id]['n'] = strtolower($user['name']);
$allusers[$id]['m'] = $user['mail'];
$allusers[$id]['p'] = 0;
$allusers[$id]['h'] = $uid;
_Write($fp_allusers,$allusers);
unset($allusers);
$user['id'] = $id;
//$user['pass'] = md5($user['pass']);
//$user['last_visit'] = $fm->_Nowtime;
_Read2Write($fp_user,'../FORUMFOLDER/members/'.$id.'.php');
_Write($fp_user,$user);
_SAVE_STATS(array ('totalmembers' => array(1, 1),'lastreg' => array($user['name'], 0),'last_id' => array($id, 0)));
//--------------------------============================--------------------------------
(Отредактировано автором: 23 декабря 2011 — 20:39) |