include("../includes/common.htm");
//$msg="Unable to change profile category at this time";
if (($fid) && ($status=='save')) {
if ($job==2) { $sid="dbid"; } else { $sid="id"; }
$oldsid=$sid;
$qry="select * from $table[$job] where $sid='$fid'";
$rec=SelectQry($qry);
if ($category!='') {
$newpage=$mypage;
$dupcheck="select * from $table[$category] where PageName='$newpage'";
if ($debug) print "$dupcheck
";
$duprec=SelectQry($dupcheck);
$dupcount=1;
while (count($duprec)>0) {
$dupcount++;
$newpage=$newpage . $dupcount;
$dupcheck="select * from $table[$category] where PageName='$newpage'";
$duprec=SelectQry($dupcheck);
}
if ($newpage!="") {
/* insert new category */
$insert="insert into $table[$category] (PageName,Password,Name,Firstname,Lastname,email,rec_email,country,city,state,avatar) values ('$newpage','".$rec[0]['Password']."','".$rec[0]['Name']."','".$rec[0]['Firstname']."','".$rec[0]['Lastname']."','".$rec[0]['email']."','".$rec[0]['rec_email']."','".$rec[0]['country']."','".$rec[0]['city']."','".$rec[0]['state']."','".$rec[0]['avatar']."')";
if ($debug) print "$insert
";
if (!$debug) $insertrec = mysql_query("$insert") or $error="Unable to update record (1), contact admin.
";
if ($admin) print mysql_error() . "
";
}
if ($error=="") {
if ($category==2) { $sid="dbid"; } else { $sid="id"; }
$newqry="select $sid,PageName from $table[$category] where PageName='$newpage'";
if ($debug) print "$newqry
";
$newrec=SelectQry($newqry);
if ($admin) print mysql_error() . "
";
$newid=$newrec[0][$sid];
$newjob=$category;
if ($debug) $newid="newid";
/* only update if newid exist */
if (($newid!='') && ($newjob!='')) {
if ($debug) { print "newid: $newid newjob:$newjob
"; }
/* remove from previous category */
$delcategory="delete from $table[$job] where $oldsid='$fid'";
if ($debug) print "$delcategory
";
if (!$debug) $delrec = mysql_query("$delcategory") or $msg.="Unable to update record (2a), contact admin.
";
if ($admin) print mysql_error() . "
";
if (($job==1) || ($job==2) || ($job==3)) {
$delclient="delete from $client_table[$job] where pid='$fid'";
if ($debug) print "$delclient
";
if (!$debug) $delrec = mysql_query("$delclient") or $msg.="Unable to update record (2d), contact admin.
";
if ($admin) print mysql_error() . "
";
}
$updateschedule="update lerage_schedule set pid='$newid',pjob='$newjob' where pid='$fid' and pjob='$job'";
if ($debug) print "$updateschedule
";
if (!$debug) $updateschedulerec = mysql_query("$updateschedule") or $msg.="Unable to update record (2b), contact admin.
";
if ($admin) print mysql_error() . "
";
$updateemail="update lerage_email set pid='$newid' where pid='$fid' and ToMail='$email'";
if ($debug) print "$updateemail
";
if (!$debug) $updateemailrec = mysql_query("$updateemail") or $msg.="Unable to update record (2c), contact admin.
";
if ($admin) print mysql_error() . "
";
$updatenetwork="update lerage_network set pid='$newid',pjob='$newjob' where pid='$fid' and pjob='$job'";
if ($debug) print "$updatenetwork
";
if (!$debug) $updatenetworkrec = mysql_query("$updatenetwork") or $msg.="Unable to update record (2c), contact admin.
";
if ($admin) print mysql_error() . "
";
$updatenetwork="update lerage_network set subscribe_id='$newid',subscribe_job='$newjob' where subscribe_id='$fid' and subscribe_job='$job'";
if ($debug) print "$updatenetwork
";
if (!$debug) $updatenetworkrec = mysql_query("$updatenetwork") or $msg.="Unable to update record (2c), contact admin.
";
if ($admin) print mysql_error() . "
";
/* update video */
$updatevideo="update lerage_video set pid='$newid',pjob='$newjob' where pid='$fid' and pjob='$job'";
if ($debug) print "$updatevideo
";
if (!$debug) $updatevideorec = mysql_query("$updatevideo") or $msg.="Unable to update record (2e), contact admin.
";
if ($admin) print mysql_error() . "
";
/* move directory */
if ($rec[0]['PageName']!='') {
$olddir=$jobdir[$job] . $rec[0]['PageName'];
$newdir=$jobdir[$category] . $newpage;
if ($debug) { print "moving ($olddir) into ($newdir)
"; }
move_lerage_directory($olddir,$newdir,$debug);
}
/* update image record */
$imgqry="select * from $phototable[$job] where pid='$fid'";
$imgrec=SelectQry($imgqry);
$imgmoved=0; $photo_error=0;
for($i=0;$i"; }
if (!$debug) $updateimgrec = mysql_query("$updateimg") or $photo_error++;
if ($updateimgrec=='') $imgmoved++;
}
if ($debug) print "total image: " . count($imgrec) . "
total image moved: $imgmoved
";
if ($photo_error>0) { $msg.="unable to update all your images, you may have to re-upload some of the images
"; }
$delimg="delete from $phototable[$job] where pid='$fid'";
if ($debug) print "
$delimg
";
if (!$debug) $delimgrec = mysql_query("$delimg") or $msg.="Unable to update record (2f), contact admin.
";
if ($admin) print mysql_error() . "
";
if ($error=="") $msg="Profile category successfully changed.
Please logout and re-login into your new profile.";
}
}
} else { $error="Please select a category"; }
}
function move_lerage_directory($olddir,$newdir,$debug) {
//print "debug: $debug
"; return;
// print "old dir:$olddir
new dir:$newdir
";
if ($debug=="") {
if (!is_dir($newdir)) {
$oldumask = umask(0);
mkdir($newdir, 0777);
umask($oldumask);
}
}
if (is_dir($olddir)) {
$file = dir($olddir);
while (false !== $entry = $file->read()) {
if ($entry == "." || $entry == "..") { continue; }
//if ($dest !== "$source/$entry") {
if ($debug=="") copy("$olddir/$entry", "$newdir/$entry");
if ($debug=="") chmod("$newdir/$entry", 0777);
if ($debug=="") unlink("$olddir/$entry");
//if ($debug!="") print "source:$olddir/$entry
destination:$newdir/$entry
";
//}
}
//$olddir->close();
if ($debug=="") rmdir($olddir);
}
return;
}
?>
if ($msg!='') { print "$msg"; } ?>
if ($error!='') { print "$error"; } ?>