PDA

View Full Version : [RELEASE vb1.1.4 and others?]Mass Move Users!


Xenon
05 Mar 2001, 18:55
Hi!
Some Days ago, I post a request on such a Hack, but noone want to do so, so I write it myself :)
I hope there are persons out which could need it :)

This Hack ist written and testet on 1.1.4, i don't know if it works on other Versions!

Ok:
Put in your user.php in the admin-path:

// ###################### Start move by Xenon ##############
if ($action=="move") {

echo ("Move Users Version 2.0 by Xenon");
echo doformheader("user","domove");
echo "<table border=0>";
echo makeinputcode("Users to move at once:","perpage","1000");
echo "<br>";
echo makechoosercode("Move Users to:","newusergroupid","usergroup",2);
echo makeyesnocode("Update Usertitles","updatetitle",1);


echo "<tr><td colspan=2><br>Move users where:</td></tr>\n";

echo makeinputcode("User Name contains","ausername");
if ($pwdincp!=0) {
echo makeinputcode("and password contains","apassword");
}
echo makechoosercode("and usergroup is","usergroupid","usergroup",-1,"Any");
echo makeinputcode("and email contains","aemail");
echo makeinputcode("and parent's email contains","parentemail");
echo makeinputcode("and is coppa user (yes, no, blank for don't mind)","coppauser");
echo makeinputcode("and homepage contains","homepage");
echo makeinputcode("and ICQ Number contains","icq");
echo makeinputcode("and AIM Handle contains","aim");
echo makeinputcode("and Yahoo Messenger Handle contains","yahoo");
echo makeinputcode("and Biography contains","biography");
echo makeinputcode("and Signature contains","signature");
echo makeinputcode("and User Title contains","usertitle");
echo makeinputcode("and Join Date is after<br>(Format yyyy-mm-dd, leave blank for today)","joindateafter");
echo makeinputcode("and Join Date is before<br>(Format yyyy-mm-dd, leave blank for today)","joindatebefore");
echo makeinputcode("and Last Visit is after<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)","lastvisitafter");
echo makeinputcode("and Last Visit is before<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)","lastvisitbefore");
echo makeinputcode("and Last Post is after<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)","lastpostafter");
echo makeinputcode("and Last Post is before<br>(Format yyyy-mm-dd hh:mm:ss, leave blank for today)","lastpostbefore");
echo makeinputcode("and Number of Posts is greater than","postslower");
echo makeinputcode("and Number of Posts is less than","postsupper");

echo doformfooter();


}

// ###################### Start domove by Xenon ##############
if ($action=="domove") {

if (isset($perpage)==0 or $perpage=="") {
$perpage=1000;
}
if (isset($startat)==0 or $startat=="") {
$startat=0;
}
$finishat=$startat+$perpage;

echo "<p>User ids:</p>";

if ($condition=="") {

$condition="1=1";
if ($ausername!="") {
$condition.=" AND INSTR(username,'".addslashes($ausername)."')>0";
}
if ($apassword!="") {
$condition.=" AND INSTR(password,'".addslashes($apassword)."')>0";
}
if ($usergroupid!=-1 and $usergroupid!="") {
$condition.=" AND usergroupid=$usergroupid";
}
if ($aemail!="") {
$condition.=" AND INSTR(email,'".addslashes($aemail)."')>0";
}
if ($parentemail!="") {
$condition.=" AND INSTR(parentemail,'".addslashes($parentemail)."')>0";
}
$coppauser=strtolower($coppauser);
if ($coppauser=="yes") {
$condition.=" AND coppauser=1";
}
if ($coppauser=="no") {
$condition.=" AND coppauser=0";
}
if ($homepage!="") {
$condition.=" AND INSTR(homepage,'".addslashes($homepage)."')>0";
}
if ($icq!="") {
$condition.=" AND INSTR(icq,'".addslashes($icq)."')>0";
}
if ($aim!="") {
$condition.=" AND INSTR(aim,'".addslashes($aim)."')>0";
}
if ($yahoo!="") {
$condition.=" AND INSTR(yahoo,'".addslashes($yahoo)."')>0";
}
if ($biography!="") {
$condition.=" AND INSTR(biography,'".addslashes($biography)."')>0";
}
if ($signature!="") {
$condition.=" AND INSTR(signature,'".addslashes($signature)."')>0";
}
if ($usertitle!="") {
$condition.=" AND INSTR(usertitle,'".addslashes($usertitle)."')>0";
}
if ($joindateafter!="") {
$condition.=" AND joindate>UNIX_TIMESTAMP('".addslashes($joindateafter)."')";
}
if ($joindatebefore!="") {
$condition.=" AND joindate<UNIX_TIMESTAMP('".addslashes($joindatebefore)."')";
}
if ($lastvisitafter!="") {
$condition.=" AND lastvisit>UNIX_TIMESTAMP('".addslashes($lastvisitafter)."')";
}
if ($lastvisitbefore!="") {
$condition.=" AND lastvisit<UNIX_TIMESTAMP('".addslashes($lastvisitbefore)."')";
}
if ($lastpostafter!="") {
$condition.=" AND lastpost>UNIX_TIMESTAMP('".addslashes($lastpostafter)."')";
}
if ($lastpostbefore!="") {
$condition.=" AND lastpost<UNIX_TIMESTAMP('".addslashes($lastpostbefore)."')";
}
if ($postslower!="") {
$condition.=" AND posts>$postslower";
}
if ($postsupper!="") {
$condition.=" AND posts<$postsupper";
}
}


$users=$DB_site->query("SELECT userid,usertitle,usergroupid,customtitle,posts FROM user WHERE $condition AND userid>=$startat AND userid<$finishat ORDER BY userid DESC");
while ($user=$DB_site->fetch_array($users)) {

$userid=$user[userid];

// check that not removing last admin
$countadmin=$DB_site->query_first("SELECT COUNT(userid) AS users FROM user,usergroup WHERE user.usergroupid=usergroup.usergroupid AND usergroup.cancontrolpanel=1 AND user.userid<>$userid");
$getperms=$DB_site->query_first("SELECT cancontrolpanel FROM usergroup WHERE usergroupid=$usergroupid");
if ($countadmin[users]==0 and $getperms[cancontrolpanel]!=1) {
echo "<p>You are about to edit the last user with control panel access so that they do not have control panel access. This would lock you out of the control panel, so you cannot proceed.</p></body></html>";
exit;
}

// Change Group
$DB_site->query("UPDATE user SET usergroupid=$newusergroupid WHERE userid=$userid");

// Update Titles
if ($updatetitle==1) {

if ($user[customtitle]==0) {
$usergroup=$DB_site->query_first("SELECT usertitle FROM usergroup WHERE usergroupid=$newusergroupid");
if ($usergroup[usertitle]=="") {
$gettitle=$DB_site->query_first("SELECT title FROM usertitle WHERE minposts<=$user[posts] ORDER BY minposts DESC LIMIT 1");
$usertitle=$gettitle[title];
} else {
$usertitle=$usergroup[usertitle];
}

$sql="usertitle='".addslashes($usertitle)."'";
$DB_site->query("UPDATE user SET $sql WHERE userid=$userid");
}


}


echo "$user[userid]<br>\n";
flush();

}

if ($checkmore=$DB_site->query_first("SELECT userid FROM user WHERE $condition AND userid>=$finishat")) {

echo doformheader("user","domove");
echo makehiddencode("ausername",$ausername);
echo makehiddencode("apassword",$apassword);
echo makehiddencode("usergroupid",$usergroupid);
echo makehiddencode("newusergroupid",$newusergroupid);
echo makehiddencode("updatetitle",$updatetitle);
echo makehiddencode("aemail",$aemail);
echo makehiddencode("parentemail",$parentemail);
echo makehiddencode("coppauser",$coppauser);
echo makehiddencode("homepage",$homepage);
echo makehiddencode("icq",$icq);
echo makehiddencode("aim",$aim);
echo makehiddencode("yahoo",$yahoo);
echo makehiddencode("biography",$biography);
echo makehiddencode("signature",$signature);
echo makehiddencode("usertitle",$usertitle);
echo makehiddencode("joindateafter",$joindateafter);
echo makehiddencode("joindatebefore",$joindatebefore);
echo makehiddencode("lastvisitafter",$lastvisitafter);
echo makehiddencode("lastvisitbefore",$lastvisitbefore);
echo makehiddencode("lastpostafter",$lastpostafter);
echo makehiddencode("lastpostbefore",$lastpostbefore);
echo makehiddencode("postslower",$postslower);
echo makehiddencode("postsupper",$postupper);
echo makehiddencode("from",$from);
echo makehiddencode("subject",$subject);
echo makehiddencode("message",$message);
echo makehiddencode("startat",$finishat);
echo makehiddencode("perpage",$perpage);

echo "<input type=submit value=\"Do Next Page\">";

} else {
echo "<p>All done!</p>";
}

}


And in your Index.php in th usersection:
<a href="user.php?action=move">Move users</a><br>



Hope you enjoy it :)

Xenon

05 Mar 2001, 20:31
not bad. i've been meaning to get me one of these.