Page 1 of 1
help if you can
Posted: Fri Jan 23, 2004 7:57 am
by doggy
Could some one please help me out .. i have a phpnuke system and i am custemasion it for a company .. and i re did the your_account module the saveuser function but now if i save a user it gives me Sorry, such file doesn't exist... . but it does exist. now i want to know how i can put a script in to show if there is any errors. cos there must be a error some where. thanks
Posted: Fri Jan 23, 2004 8:16 am
by malcolmboston
are you specifying the right path and/or making allowances in syntax for changes with windows and linux systems?
Posted: Fri Jan 23, 2004 8:27 am
by doggy
here is the forum and script
// forum //
function edituser() {
global $user, $userinfo, $cookie, $module_name, $bgcolor2, $bgcolor3;
getusrinfo($user);
if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
include("header.php");
OpenTable();
echo "<center><font class=\"title\"><b>"._PERSONALINFO."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
nav();
CloseTable();
echo "<br>";
OpenTable();
echo "<table cellpadding=\"3\" border=\"0\" width=\"100%\">"
."<tr><td bgcolor='$bgcolor2'>"
."<form name=\"Register\" action=\"modules.php?name=$module_name\" method=\"post\">"
."<b>"._USRACCOUNT."</b>:"
."</td><td bgcolor='$bgcolor3'>"
."<b>$userinfo[username]</b>"
."</td></tr><tr>"
."<td bgcolor='$bgcolor2'><b>"._USRNAME."</b>:<br>"._REQUIRED."</td>"
."<td><input type=\"text\" name=\"name\" value=\"$userinfo[name]\" size=\"50\" maxlength=\"50\"></td></tr>"
."<tr><td bgcolor='$bgcolor2'><b>"._USRSURNAME."</b>:<br>"._REQUIRED."</td>"
."<td><input type=\"text\" name=\"surname\" value=\"$userinfo[at_surname]\" size=\"50\" maxlength=\"50\"></td></tr>"
."<tr><td bgcolor='$bgcolor2'><b>"._USREMAIL."</b>:<br>"._OPTIONAL."</td>"
."<td><input type=\"text\" name=\"email\" value=\"$userinfo[at_email]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRHOMEA."</b>:<br>"._REQUIRED."</td>"
."<td><input type=\"text\" name=\"homea\" value=\"$userinfo[at_homea]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRHOMET."</b>:<br>"._REQUIRED."</td>"
."<td><input type=\"text\" name=\"homet\" value=\"$userinfo[at_homet]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRWORKA."</b>:<br>"._OPTIONAL."</td>"
."<td><input type=\"text\" name=\"worka\" value=\"$userinfo[at_worka]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRWORKT."</b>:<br>"._OPTIONAL."</td>"
."<td><input type=\"text\" name=\"workt\" value=\"$userinfo[at_workt]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRPOSTA."</b>:<br>"._REQUIRED."</td>"
."<td><input type=\"text\" name=\"posta\" value=\"$userinfo[at_postala]\" size=\"50\" maxlength=\"50\"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRPASSWORD."</b>:<br>"._TYPENEWPASS."</td>"
."<td><input type=\"password\" name=\"user_password\" size=\"20\" maxlength=\"20\"> <input type=\"password\" name=\"vpass\" size=\"20\" maxlength=\"20\"></td></tr>"
."<input type=\"hidden\" name=\"username\" value=\"$userinfo[username]\">"
."<input type=\"hidden\" name=\"user_id\" value=\"$userinfo[user_id]\">"
."<input type=\"hidden\" name=\"op\" value=\"saveuser\">"
."<tr><td></td><td><input type=\"submit\" value=\""._SAVECHANGES."\"></td></tr>"
."</form></td></tr></table>";
CloseTable();
include("footer.php");
} else {
main($user);
}
}
// script //
function saveuser($name, $surname, $email, $homea, $homet, $worka, $workt, $posta, $user_password, $vpass, $username, $user_id) {
Global $user, $cookie, $userinfo, $user_prefix, $db, $module_name, $minpass;
cookiedecode($user);
$check = $cookie[1];
$check2 = $cookie[2];
$sql = "SELECT user_id, user_password FROM ".$user_prefix."_users WHERE username='$check'";
$result = $db->sql_query($sql);
$row = $db->sql_fetch($result);
$vuid = $row[user_id];
$ccpass = $row[user_password];
$atl_name = "$name";
$atl_surname = "$surname";
$atl_email = "$email";
$atl_homea = "$homea";
$atl_homet = "$homet";
$atl_worka = "$worka";
$atl_workt = "$workt";
$atl_posta = "$posta";
$atl_idnb = "$idnb";
if ((isset($user_password)) && ("$user_pass" != "$vpass")) {
echo "<center>"._PASSDIFFERENT."</center>";
} elseif (($user_password != "") && (strlen($user_password) < $minpass)) {
echo "<center>"._YOUPASSMUSTBE."<b>$minpass</b>"._CHARLONG."</center>";
} else {
if ($user_password != "") {
cookiedecode($user);
$db->sql_query("LOCK TABLES ".$user_prefix."_users WRITE");
$user_password = md5($user_password);
$db->sql_query("UPDATE ".$user_prefix."_users SET name='$atl_name', surname='$atl_surname', email='$atl_email', homea='$atl_homea', homet='$atl_homet', worka='$atl_worka', workt='$atl_workt', posta='$atl_posta',user_password='$user_password' WHERE user_id='$user_id'");
$sql = "SELECT user_id, username, user_password FROM ".$user_prefix."_users WHERE username='$username' AND user_password='$user_password'";
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) == 1) {
$userinfo = $db->sql_fetch(result);
decookie($userinfo[user_id],$userinfo[username],$userinfo[user_password]);
} else {
echo "<center>"._SOMETHIGNWRONG."</center><br>";
}
$db->sql_query("UNLOCK TABLES");
} else {
$db->sql_query("UPDATE ".$user_prefix."_users SET name='$atl_name', surname='$atl_surname', email='$atl_email', homea='$atl_homea', homet='$atl_homet', worka='$atl_worka', workt='$atl_workt', posta='$atl_posta',user_password='$user_password' WHERE user_id='$user_id'");
}
Header("Location: modules.php?name=$module_name");
}
}
Posted: Sat Jan 24, 2004 5:53 am
by malcolmboston
just making it easier on the eye
Code: Select all
function edituser() {
global $user, $userinfo, $cookie, $module_name, $bgcolor2, $bgcolor3;
getusrinfo($user);
if (($userinfo[username] != $cookie[1]) AND ($userinfo[user_password] != $cookie[2])) {
include("header.php");
OpenTable();
echo "<center><font class="title"><b>"._PERSONALINFO."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
nav();
CloseTable();
echo "<br>";
OpenTable();
echo "<table cellpadding="3" border="0" width="100%">"
."<tr><td bgcolor='$bgcolor2'>"
."<form name="Register" action="modules.php?name=$module_name" method="post">"
."<b>"._USRACCOUNT."</b>:"
."</td><td bgcolor='$bgcolor3'>"
."<b>$userinfo[username]</b>"
."</td></tr><tr>"
."<td bgcolor='$bgcolor2'><b>"._USRNAME."</b>:<br>"._REQUIRED."</td>"
."<td><input type="text" name="name" value="$userinfo[name]" size="50" maxlength="50"></td></tr>"
."<tr><td bgcolor='$bgcolor2'><b>"._USRSURNAME."</b>:<br>"._REQUIRED."</td>"
."<td><input type="text" name="surname" value="$userinfo[at_surname]" size="50" maxlength="50"></td></tr>"
."<tr><td bgcolor='$bgcolor2'><b>"._USREMAIL."</b>:<br>"._OPTIONAL."</td>"
."<td><input type="text" name="email" value="$userinfo[at_email]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRHOMEA."</b>:<br>"._REQUIRED."</td>"
."<td><input type="text" name="homea" value="$userinfo[at_homea]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRHOMET."</b>:<br>"._REQUIRED."</td>"
."<td><input type="text" name="homet" value="$userinfo[at_homet]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRWORKA."</b>:<br>"._OPTIONAL."</td>"
."<td><input type="text" name="worka" value="$userinfo[at_worka]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRWORKT."</b>:<br>"._OPTIONAL."</td>"
."<td><input type="text" name="workt" value="$userinfo[at_workt]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRPOSTA."</b>:<br>"._REQUIRED."</td>"
."<td><input type="text" name="posta" value="$userinfo[at_postala]" size="50" maxlength="50"></td>"
."</tr><tr><td bgcolor='$bgcolor2'><b>"._USRPASSWORD."</b>:<br>"._TYPENEWPASS."</td>"
."<td><input type="password" name="user_password" size="20" maxlength="20"> <input type="password" name="vpass" size="20" maxlength="20"></td></tr>"
."<input type="hidden" name="username" value="$userinfo[username]">"
."<input type="hidden" name="user_id" value="$userinfo[user_id]">"
."<input type="hidden" name="op" value="saveuser">"
."<tr><td></td><td><input type="submit" value=""._SAVECHANGES.""></td></tr>"
."</form></td></tr></table>";
CloseTable();
include("footer.php");
} else {
main($user);
}
}
// script
function saveuser($name, $surname, $email, $homea, $homet, $worka, $workt, $posta, $user_password, $vpass, $username, $user_id) {
Global $user, $cookie, $userinfo, $user_prefix, $db, $module_name, $minpass;
cookiedecode($user);
$check = $cookie[1];
$check2 = $cookie[2];
$sql = "SELECT user_id, user_password FROM ".$user_prefix."_users WHERE username='$check'";
$result = $db->sql_query($sql);
$row = $db->sql_fetch($result);
$vuid = $row[user_id];
$ccpass = $row[user_password];
$atl_name = "$name";
$atl_surname = "$surname";
$atl_email = "$email";
$atl_homea = "$homea";
$atl_homet = "$homet";
$atl_worka = "$worka";
$atl_workt = "$workt";
$atl_posta = "$posta";
$atl_idnb = "$idnb";
if ((isset($user_password)) && ("$user_pass" != "$vpass")) {
echo "<center>"._PASSDIFFERENT."</center>";
} elseif (($user_password != "") && (strlen($user_password) < $minpass)) {
echo "<center>"._YOUPASSMUSTBE."<b>$minpass</b>"._CHARLONG."</center>";
} else {
if ($user_password != "") {
cookiedecode($user);
$db->sql_query("LOCK TABLES ".$user_prefix."_users WRITE");
$user_password = md5($user_password);
$db->sql_query("UPDATE ".$user_prefix."_users SET name='$atl_name', surname='$atl_surname', email='$atl_email', homea='$atl_homea', homet='$atl_homet', worka='$atl_worka', workt='$atl_workt', posta='$atl_posta',user_password='$user_password' WHERE user_id='$user_id'");
$sql = "SELECT user_id, username, user_password FROM ".$user_prefix."_users WHERE username='$username' AND user_password='$user_password'";
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) == 1) {
$userinfo = $db->sql_fetch(result);
decookie($userinfo[user_id],$userinfo[username],$userinfo[user_password]);
} else {
echo "<center>"._SOMETHIGNWRONG."</center><br>";
}
$db->sql_query("UNLOCK TABLES");
} else {
$db->sql_query("UPDATE ".$user_prefix."_users SET name='$atl_name', surname='$atl_surname', email='$atl_email', homea='$atl_homea', homet='$atl_homet', worka='$atl_worka', workt='$atl_workt', posta='$atl_posta',user_password='$user_password' WHERE user_id='$user_id'");
}
Header("Location: modules.php?name=$module_name");
}
}
Posted: Sat Jan 24, 2004 5:58 am
by malcolmboston
i cant see anything about it in the code but..........
.....you saying
and i re did the your_account module the saveuser function but now if i save a user it gives me Sorry, such file doesn't exist
made me wonder if you were trying to create a text file with the info on?
i could be way of the mark here but if you are there are some things to be aware of
mode Description
'r'
Open for reading only; place the file pointer at the beginning of the file.
'r+'
Open for reading and writing; place the file pointer at the beginning of the file.
'w'
Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+'
Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a'
Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+'
Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x'
Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
'x+'
Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.
[/quote]
Posted: Sat Jan 24, 2004 6:06 am
by malcolmboston
you should use
w+
because if you are adding a new user then obviously there file will not previously exist, like i said though, this may not be your problem, it just sounds like it