improperly working delete function
the issue is that on my server it will remove pictures et al, infact the only thing it doesn't remove is the main user database file. but on the deployment server, the pictures and about half the table entries remain.
in both cases the pics are considered to be part of the server processes. (nobody on the deployment and apache on my server)
i am seeking advice on how to actually get the pictures deleted. i think the tables might be a result of the pictures not deleting
delete function code:
<?php
function misc(){ # misc controls
include(\"/home/dcfydllc/includes/fyd.altincs.php\"); # includes file (precautionary measure)
$un=$_COOKIE['un']; $pw=$_COOKIE['pw']; # variables to talk to the db
$db=mysql_connect($host, $login3, $pass3) or die(\"cannot access mysql\"); # connect to the db
$fyd=mysql_select_db($dbname, $db) or die(\"cannot access db\"); # get the db
$memfind=mysql_query(\"SELECT uid FROM users WHERE username='$un' AND password='$pw'\", $db);
if(mysql_num_rows($memfind)==0){ # problem
cae(); // call the forum access error page
}else{ # we found the user
$maininf=mysql_fetch_array($memfind); $uid=$maininf['uid']; $worked=0;
$result='<h1 class=\"require\">REPORT ALL ERRORS TO: ADMIN @ FindYourDesire.com</h1>';
if(isset($_POST['act'])&&($_POST['act']=='reset')){ # reset the votes on the user
$rstat=mysql_query(\"UPDATE stats SET pvt='0', pvc='0' WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)>'-1'){ $worked=1; } // did stats get reset
else{ // there was a problem
$errno=mysql_errno($db); $error=mysql_error($db); $result=\"<p>stats:$errno: $error\";
} // error has been recorded
$rvote=mysql_query(\"DELETE FROM votes WHERE voteeuid='$uid'\", $db);
if((mysql_affected_rows($db)>'-1')&&($worked)){ $result=\"<p>Your desirability has been reset.</p>\"; }
else{ // there was a problem
$errno=mysql_errno($db); $error=mysql_error($db); $result.=\"<br />votes:$errno: $error</p>\";
} // error has been recorded
}elseif(isset($_POST['act'])&&($_POST['act']=='delete')){ // deleting your profile
echo \" <p>Deleting $un...\n\"; $imgbase=$faup; $npib=$fuup;
foreach($images as $key=>$value){ # for each possible picture
echo \" <br />Checking for $value\n\"; flush(); $pica=$imgbase.$key.$un.'.jpg';
$picb=$imgbase.'old.'.$key.$un.'.jpg'; $picc=$npib.$key.$un.'.jpg';
/* delete the pics if they exist */
if(is_file($pica)){ unlink($pica); echo \" <br />Removing $pica\n\"; }
if(is_file($picb)){ unlink($picb); echo \" <br />Removing $picb\n\"; }
if(is_file($picc)){ unlink($picc); echo \" <br />Removing $picc\n\"; }
}
echo \" <br />Deleting you from table BIO\"; flush();
$dfs=mysql_query(\"DELETE FROM bio WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){ // successful deletion
echo \" <br />Removed $un (user # $uid) from table BIO\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Bio:$errno: $error\";
}
echo \" <br />Deleting you from table COMMENTS\"; flush();
$dfs=mysql_query(\"DELETE FROM comments WHERE ctuid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table COMMENTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Comments:$errno: $error\";
}
echo \" <br />Deleting you from table FRIENDS\"; flush();
$dfs=mysql_query(\"DELETE FROM friends WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table FRIENDS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Friends:$errno: $error\";
}
echo \" <br />Deleting you from table INTERESTS\"; flush();
$dfs=mysql_query(\"DELETE FROM interests WHERE uid='$uid\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table INTERESTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Interests:$errno: $error\";
}
echo \" <br />Deleting you from table MAIL\"; flush();
$dfs=mysql_query(\"DELETE FROM mail WHERE to_id='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table MAIL\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Mail:$errno: $error\";
}
echo \" <br />Deleting you from table MSGS\"; flush();
$dfs=mysql_query(\"DELETE FROM msgs WHERE to_id='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table MSGS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Msgs:$errno: $error\";
}
echo \" <br />Deleting you from table MATCH\"; flush();
$dfs=mysql_query(\"DELETE FROM personality WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table MATCH\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Match:$errno: $error\";
}
echo \" <br />Deleting you from table PESTS\"; flush();
$dfs=mysql_query(\"DELETE FROM pests WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table PESTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Pests:$errno: $error\";
}
echo \" <br />Deleting you from table PERSONALITY\"; flush();
$dfs=mysql_query(\"DELETE FROM personality WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table PERSONALITY\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Personality:$errno: $error\";
}
echo \" <br />Deleting you from table POSTS\"; flush();
$dfs=mysql_query(\"DELETE FROM posts WHERE author='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table POSTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Posts:$errno: $error\";
}
echo \" <br />Deleting you from table STATS\"; flush();
$dfs=mysql_query(\"DELETE FROM stats WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table STATS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Stats:$errno: $error\";
}
echo \" <br />Deleting you from table THREADS\"; flush();
$dfs=mysql_query(\"DELETE FROM threads WHERE thread_auth='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table THREADS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Threads:$errno: $error\";
}
echo \" <br />Deleting you from table TOPS\"; flush();
$dfs=mysql_query(\"DELETE FROM tops WHERE memuid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table TOPS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Tops:$errno: $error\";
}
echo \" <br />Deleting you from table VOTES\"; flush();
$dfs=mysql_query(\"DELETE FROM votes WHERE voteeuid='$uid'\", $db); // votes on
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table VOTES\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Votes:$errno: $error\";
}
$dfs=mysql_query(\"DELETE FROM votes WHERE voteruid='$uid'\", $db); // votes made this time period
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table VOTES\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
echo \"<br />Votes:$errno: $error\";
}
echo '</p>';
if(!($delerr)){ # stats,bio,interests,personality,tops did not result in an error (may be expanded to more)
echo \" <br />Deleting you from table USERS\";
$dfs=mysql_query(\"DELETE FROM users WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Deletion complete.</p>\n$errs\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Users:$errno: $error</p>\n$errs\";
}
}else{ // something is wrong
echo \" <br />Deletion encountered errors. uid=$uid username=$un\";
echo \" <br />$errs</p>\";
}
}
// make the page
echo <<<END
$result
<h2>NOTICE: THE FOLLOWING OPTIONS <strong>CANNOT</strong> BE UNDONE</h2>
<script language=\"javascript\" type=\"text/javascript\">
function doubleCheck(){
var what=document.misc.act.value;
if(what==\"reset\"){
return confirm(\"Are you sure you want to reset your score?\");
}else if(what==\"delete\"){
return confirm(\"Are you sure you want to delete your account? (This cannot be undone)\");
}else{
return false;
}
}
</script>
<form action=\"{$_SERVER['PHP_SELF']}\" name=\"misc\" method=\"POST\" onSubmit=\"return doubleCheck();\">
<input id=\"fn\" type=\"hidden\" name=\"fn\" value=\"misc\" />
$tsnw
<tbody>
<tr>
<td class=\"center\">
<select id=\"act\" name=\"act\" size=\"1\">
<option value=\"\">Choose an Option</option>
<option value=\"reset\">Reset Your Score</option>
<option value=\"delete\">Delete Your Profile</option>
</select>
</td>
</tr>
<tr>
<td class=\"center\"><input type=\"submit\" value=\"Let's Do It!\" /></td>
</tr>
</tbody>
</table>
</form>
END;
}
}
?>
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
m3rajk posted this at 20:02 — 21st March 2004.
They have: 461 posts
Joined: Jul 2003
anyone familliar with umask?
andy206uk posted this at 13:11 — 22nd March 2004.
He has: 1,758 posts
Joined: Jul 2002
Daft question... but is the ownership and permissions on the files ok? Try running the script as root and see if it works then.
m3rajk posted this at 01:42 — 25th March 2004.
They have: 461 posts
Joined: Jul 2003
actually checked on that from elsewhere.
permission after upload on my server: -rw-rw-rw-
permission after upload on deployment server: -rw-------
set up on my server: apache, apache, everyone
set up on deployment: nobody, nobody, everyone
that's whay i asked about umask. i think i need to change it to -rw-rw-rw-
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
m3rajk posted this at 03:07 — 25th March 2004.
They have: 461 posts
Joined: Jul 2003
umask isn't helping. seems no matter the umask setting it's still not deleting. i tested and found that whether it's -rwxrwxrwx or anything else it's still not deleted.
so i tested the $fuup and $faup which give the Full Unapproved User Pic path and Full Approved User Pic path respectively.
both give the correct paths, which measn all the file names are right. the problem would lie elsewhere. any ideas?
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 00:50 — 26th March 2004.
He has: 4,048 posts
Joined: Aug 2000
Maybe check for differences in php.ini?
m3rajk posted this at 21:42 — 26th March 2004.
They have: 461 posts
Joined: Jul 2003
i figured out umask. the problem i have now is thiat no umask works.
http://forums.devnetwork.net/viewtopic.php?t=19595
is a thread at the other foums i use. someoen suggested that it might need to have file_exists instead of is_file
but that stillleaves the question of what the umask should be?
i'm thinking the server process needs to read it, no one else. and 600 would do that nicely
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.