| Current Path : /var/www/html/mmishra/indem/Parisarnews/ |
| Current File : /var/www/html/mmishra/indem/Parisarnews/webmasters.php |
Please furnish these information in order to host user's profile on this website. User must be assigned a specific role.
<p>
<?php
checkAdmin($webid, $user, $role);
$tbl = 'webmasters';
$roles = array('admin','webmaster','user','guest');
$rowid = $_REQUEST['rowid'];
$userid = $_REQUEST['userid'];
$passwd = $_POST['passwd'];
$fullname = htmlsafe($_POST['fullname']);
$email = htmlsafe($_POST['email']);
$contact = htmlsafe($_POST['contact']);
$profile = htmlsafe($_POST['profile']);
$roll = $_POST['roll'];
$status = $_POST['status'];
$submit = $_POST['submit'];
$statuss = array('online','offline');
switch ($submit) {
case "SAVE":
if (mysql_num_rows(mysql_query("select * from $tbl where webid='$webid' and userid='$userid'"))) {
if ($passwd) mysql_query("update $tbl set passwd=password('$passwd') where userid='$userid'");
mysql_query("update $tbl set fullname='$fullname',contact='$contact',email='$email',role='$roll',profile='$profile',status='$status'
where webid='$webid' and userid='$userid'");
} else {
mysql_query("insert into $tbl(webid,userid,passwd,fullname,contact,email,role,profile,status,datecreation)
values('$webid','$userid',password('$passwd'),'$fullname','$contact','$email','$roll','$profile','online',now())");
}
break;
case 'DELETE':
mysql_query("delete from $tbl where webid='$webid' and userid='$userid'");
break;
}
$tbl = 'webmasters';
if ($role == 'admin') {
echo "Create <a href='$PHP_SELF?conf=$conf&userid=0'>New User</a> OR
Edit Existing <select name='userid' style='width: 100px' onchange=\"document.location.href='$PHP_SELF?conf=$conf&userid='+this.value\">
<option value=''>User</option>";
$rs = mysql_query("select * from $tbl where webid='$webid' order by userid");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->userid'";
if ($userid == $o->userid) {
echo " selected";
$roll = $o->role;
}
echo ">$o->userid</option>";
}
echo "</select><br>";
$rs = mysql_query("select * from $tbl where webid='$webid' and userid='$userid'");
} else if ($role == 'webmaster') {
$rs = mysql_query("select * from $tbl where webid='$webid' and userid='$user'");
}
if ($rs) {
$o = mysql_fetch_object($rs);
$rowid = $o->rowid;
$userid = $o->userid;
$passwd = $o->passwd;
$fullname = $o->fullname;
$email = $o->email;
$roll = $o->role;
$contact = $o->contact;
$profile = $o->profile;
if (!$roll) $roll = 'guest';
echo "User Role";
foreach ($roles as $rl){
echo "<input type='radio' name='roll' value='$rl'";
if ($rl == $roll) echo " checked";
echo ">$rl ";
}
echo "<table width='95%'>
<tr><td nowrap>User ID *</td><td><input type='text' name='userid' value='$userid' size='40'";
if ($userid) echo ' readonly';
echo "></td></tr>
<tr><td nowrap>Password *</td><td><input type='password' name='passwd' value='' size='40'></td></tr>
<tr><td nowrap>Fullname *</td><td><input type='text' name='fullname' value='$fullname' size='40'></td></tr>
<tr><td nowrap>Email *</td><td><input type='text' name='email' value='$email' size='40'></td></tr>
<tr><td>Contact</td><td><input type='text' name='contact' value='$contact' size='40'></td></tr>
<tr valign='top'><td>Profile</td><td><textarea name='profile' rows='3' cols='40'>$profile</textarea></td></tr>
";
if ($userid) {
echo "<tr><td>Status</td><td><select name='status' style='width: 100px'>";
foreach ($statuss as $st) {
echo "<option value='$st'";
if ($status == $st) echo ' selected';
echo ">$st</option>";
}
echo "</select> Offline users will not be able to log into the site.</td></tr>";
}
echo "<tr><td></td><td><input type='submit' name='submit' value='SAVE' style='width: 80px'> ";
if ($userid) {
echo "<input type='submit' name='submit' value='DELETE' style='width: 80px'> ";
}
echo "</td></tr></table>";
}
?>
</p>