Location: PHPKode > scripts > Support Tickets Center > zingiri-tickets/includes/active_users.inc.php
<?php
	$prefix=$wpdb->prefix."zing_ost_";
	if (isset($wpdb->base_prefix)) $wpPrefix=$wpdb->base_prefix; else $wpPrefix=$wpdb->prefix;
	//$query="select * from `##users`,`##usermeta` where `##users`.`ID`=`##usermeta`.`user_id` and `##usermeta`.`meta_key`='wp_user_level'";
	$query="select * from `##users`";
	$query=str_replace("##",$wpPrefix,$query);
	$sql = mysql_query($query) or die(mysql_error());
	while ($row = mysql_fetch_array($sql)) {
		if (!isset($row['first_name'])) $row['first_name']='';
		if (!isset($row['last_name'])) $row['last_name']=$row['display_name'];
		if (user_can($row['ID'],'activate_plugins')) { //administrator role
			$query2="REPLACE INTO `".$prefix."staff` (`staff_id`, `group_id`, `dept_id`, `username`, `firstname`, `lastname`, `passwd`, `email`, `phone`, `phone_ext`, `mobile`, `signature`, `isactive`, `isadmin`, `isvisible`, `onvacation`, `daylight_saving`, `append_signature`, `change_passwd`, `timezone_offset`, `max_page_size`, `created`, `lastlogin`, `updated`) VALUES";
			$query2.="('".$row['ID']."', 1, 1, '".$row['user_login']."', '".$row['first_name']."', '".$row['last_name']."', '".md5($row['user_pass'])."', '".$row['user_email']."', '', '', '', '', 1, 1, 1, 0, 0, 0, 0, 0.0, 0, '".date("Y-m-d")."', NULL, '".date("Y-m-d")."')";
			$wpdb->query($query2);
			$query2=sprintf("UPDATE `".$prefix."staff` SET `passwd`='%s', `isadmin`=1, `change_passwd`=0 WHERE `username`='%s'",md5($row['user_pass']),$row['user_login']);
			$wpdb->query($query2);
			$level[$row['user_login']]=8;
		} elseif (user_can($row['ID'],'edit_pages')) { //editor role
			$query2="REPLACE INTO `".$prefix."staff` (`staff_id`, `group_id`, `dept_id`, `username`, `firstname`, `lastname`, `passwd`, `email`, `phone`, `phone_ext`, `mobile`, `signature`, `isactive`, `isadmin`, `isvisible`, `onvacation`, `daylight_saving`, `append_signature`, `change_passwd`, `timezone_offset`, `max_page_size`, `created`, `lastlogin`, `updated`) VALUES";
			$query2.="('".$row['ID']."', 1, 1, '".$row['user_login']."', '".$row['first_name']."', '".$row['last_name']."', '".md5($row['user_pass'])."', '".$row['user_email']."', '', '', '', '', 1, 0, 1, 0, 0, 0, 0, 0.0, 0, '".date("Y-m-d")."', NULL, '".date("Y-m-d")."')";
			$wpdb->query($query2);
			$query2=sprintf("UPDATE `".$prefix."staff` SET `passwd`='%s', `isadmin`=0, `change_passwd`=0 WHERE `username`='%s'",md5($row['user_pass']),$row['user_login']);
			$wpdb->query($query2);
			$level[$row['user_login']]=5;
		} else {
			$query2=sprintf("DELETE FROM `".$prefix."staff` WHERE `username`='%s'",$row['user_login']);
			$wpdb->query($query2);
			$level[$row['user_login']]=1;
		}
	}
	$query="select * from `".$wpPrefix."users`,`".$prefix."staff` where `".$wpPrefix."users`.`user_login`=`".$prefix."staff`.`username`";
	$sql = mysql_query($query) or die(mysql_error());
	while ($row = mysql_fetch_array($sql)) {
		echo $row['user_login'].' - '.$row['user_email'];
		if ($level[$row['user_login']] >= 8) echo ' - admin';
		elseif ($level[$row['user_login']] >= 5) echo ' - staff';

		if (md5($row['user_pass']) != $row['passwd']) echo '!Password not synchronised';
		echo '<br />';
	}
Return current item: Support Tickets Center