| Kod: // LOAD LÄSER IN EN SIDA; function load($url,$options=array('method'=>'get','return_info'=>false)) { $url_parts = parse_url($url);
$url_parts['post']=$options['post'];
$info = array(//Currently only supported by curl. 'http_code' => 200 ); $response = ''; $send_header = array( 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9'
);
///////////////////////////// Curl ///////////////////////////////////// //If curl is available, use curl to get the data. if(function_exists("curl_init") and (!(isset($options['use']) and $options['use'] == 'fsocketopen'))) { //Don't user curl if it is specifically stated to user fsocketopen in the options if(isset($options['method']) and $options['method'] == 'post') { $page = $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path']; } else { $page = $url; }
$ch = curl_init($url_parts['host']);
curl_setopt($ch, CURLOPT_URL, $page); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data - not print the whole thing. curl_setopt($ch, CURLOPT_HEADER, true); //We need the headers curl_setopt($ch, CURLOPT_NOBODY, false); //The content - if true, will not download the contents if(isset($options['method']) and $options['method'] == 'post' and $url_parts['query']) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $url_parts['query']); } //Set the headers our spiders sends curl_setopt($ch, CURLOPT_USERAGENT, $send_header['User-Agent']); //The Name of the UserAgent we will be using ;) $custom_headers = array("Accept: " . $send_header['Accept'] ); if(isset($options['modified_since'])) array_push($custom_headers,"If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since']))); curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); //If ever needed... curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
if(isset($url_parts['user']) and isset($url_parts['pass'])) { $custom_headers = array("Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass'])); curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers); }
$response = curl_exec($ch); $info = curl_getinfo($ch); //Some information on the fetch curl_close($ch);
//////////////////////////////////////////// FSockOpen ////////////////////////////// } else { //If there is no curl, use fsocketopen if(isset($url_parts['query'])) { $page = $url_parts['path'] . '?' . $url_parts['query']; } else { $page = $url_parts['path']; }
$fp = fsockopen($url_parts['host'], 80, $errno, $errstr, 30);
if ($fp) { $out = '';
if(isset($options['method']) and $options['method'] == 'post' and isset($url_parts['query'])) {
$out .= "POST $page HTTP/1.1\r\n"; } else { $out .= "GET $page HTTP/1.0\r\n"; //HTTP/1.0 is much easier to handle than HTTP/1.1 }
$out .= "Host: $url_parts[host]\r\n"; $out .= "Accept: $send_header[Accept]\r\n"; $out .= "User-Agent: {$send_header['User-Agent']}\r\n";
if(isset($options['modified_since'])) $out .= "If-Modified-Since: ".gmdate('D, d M Y H:i:s \G\M\T',strtotime($options['modified_since'])) ."\r\n";
$out .= "Connection: Close\r\n";
//HTTP Basic Authorization support if(isset($url_parts['user']) and isset($url_parts['pass'])) { $out .= "Authorization: Basic ".base64_encode($url_parts['user'].':'.$url_parts['pass']) . "\r\n"; }
//If the request is post - pass the data in a special way. if(isset($options['method']) and $options['method'] == 'post') {
if(isset($options['cookie'])) { $out .= "Cookie: ". $options['cookie'] ."\r\n"; }
$out .= "Accept-Encoding: row\r\n"; $out .= "Referer: " . $url . "\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= 'Content-Length: ' . strlen($url_parts['post']) . "\r\n"; $out .= "\r\n" . $url_parts['post']; } $out .= "\r\n";
//echo $out . "<hr><hr>"; fwrite($fp, $out); while (!feof($fp)) { $response .= fgets($fp, 128); } fclose($fp); } }
//Get the headers in an associative array $headers = array();
if($info['http_code'] == 404) { $body = ""; $headers['Status'] = 404; } else { //Seperate header and content $separator_position = strpos($response,"\r\n\r\n"); $header_text = substr($response,0,$separator_position); $body = substr($response,$separator_position+4); foreach(explode("\n",$header_text) as $line) { $parts = explode(": ",$line); if(count($parts) == 2) $headers[$parts[0]] = chop($parts[1]); } }
if($options['return_info']==1) return array('headers' => $headers, 'body' => $body, 'info' => $info); return $body; }
/*****************************************************************/
function getinfo_std($d, $v) {
switch ($v) { case "email": $g=explode('<input class="post" type="text" name="email" size="35" maxlength="255" value="', $d); break;
case 'username': $g=explode('<input class="post" type="text" name="username" size="35" maxlength="40" value="', $d); break;
case 'icq': $g=explode('<input class="post" type="text" name="icq" size="10" maxlength="15" value="', $d); break;
case 'aim': $g=explode('<input class="post" type="text" name="aim" size="20" maxlength="255" value="', $d); break;
case 'msn': $g=explode('<input class="post" type="text" name="msn" size="20" maxlength="255" value="', $d); break;
case 'yim': $g=explode('<input class="post" type="text" name="yim" size="20" maxlength="255" value="', $d); break;
case 'website': $g=explode('<input class="post" type="text" name="website" size="35" maxlength="255" value="', $d); break;
case 'location': $g=explode('<input class="post" type="text" name="location" size="35" maxlength="100" value="', $d); break;
case 'occupation': $g=explode('</textarea>", $g[$i]);
$g[$i]=$v[0];
if(isset($v[0])) { $k=explode("checked", $v[0]); if(isset($k[1])) { $g['yes']=$k[0]; } }
} } $g[0]="";
if(isset($g['yes'])) { $g=explode('"' ,$g['yes']); } if(isset($g[1])) { return $g[1]; } else { return "XXX"; }
}
function getinfo_select($d, $s) { $g=explode("<select>", $d); if(isset($g[1])) { $g=explode("</select>", $g[1]); if(isset($g[0])) { $g=explode("</option>", $g[0]); for($i=0;$i<count> 0, 'method' => 'post', 'post' => 'username='.$usernamne.'&mode=edit' , 'cookie' => $c
); $result = load($url,$options); return $result ; }
function codepost($d) { $result=""; foreach($d as $k => $v) { if(isset($d[$k])) { $result .= $k . "=" . urlencode($v) . "&"; } } return substr($result, 0, strlen($result)-1); }
/*****************************************************************/ function loadpostdata($user, $url, $cocke) {
$dd = getinfo($user, $url,$cocke );
$dat['username']=getinfo_std($dd, 'username'); $dat['email']=getinfo_std($dd, 'email'); $dat['password']=""; $dat['password_confirm']=""; $dat['icq']=getinfo_std($dd, 'icq'); $dat['aim']=getinfo_std($dd, 'aim'); $dat['msn']=getinfo_std($dd, 'msn'); $dat['yim']=getinfo_std($dd, 'yim'); $dat['website']=getinfo_std($dd, 'website'); $dat['location']=getinfo_std($dd, 'location'); $dat['occupation']=getinfo_std($dd, 'occupation'); $dat['interests']=getinfo_std($dd, 'interests'); $dat['signature']=getinfo_aria($dd, 'signature');
// DENNA RADEN SKA ÄR UNIK FÖR VÅRT FORUM // $dat['alliansbehörighet']=getinfo_ally($dd);
$dat['viewemail']=getinfo_radio($dd, 'viewemail'); $dat['hideonline']=getinfo_radio($dd, 'hideonline'); $dat['notifyreply']=getinfo_radio($dd, 'notifyreply'); $dat['notifypm']=getinfo_radio($dd, 'notifypm'); $dat['popup_pm']=getinfo_radio($dd, 'popup_pm'); $dat['attachsig']=getinfo_radio($dd, 'attachsig'); $dat['allowbbcode']=getinfo_radio($dd, 'allowbbcode'); $dat['allowhtml']=getinfo_radio($dd, 'allowhtml'); $dat['allowsmilies']=getinfo_radio($dd, 'allowsmilies'); $dat['language']=getinfo_select($dd, 'language'); $dat['style']=getinfo_select($dd, 'style'); $dat['timezone']=getinfo_select($dd, 'timezone'); $dat['dateformat']=getinfo_date($dd); $dat['user_status']=getinfo_radio($dd, 'user_status');
// VAD VILL DU GÖRA? 1=AKTIVERA; 0=INAKTIVERA $dat['user_status']=1;
$dat['user_allowpm']=getinfo_radio($dd, 'user_allowpm'); $dat['user_allowavatar']=getinfo_radio($dd, 'user_allowavatar'); $dat['user_rank']=getinfo_select($dd, 'user_rank'); if($dat['user_rank']=="") { $dat['user_rank']=0; } $dat['mode']="save"; $dat['agreed']="true"; $dat['coppa']=""; $dat['id']=getinfo_id($dd); $dat['submit']="Skicka";
return codepost($dat);
}
function edituser($user) { $u="NAMN PÅ FORUM /admin/admin_users.php?sid= ID NUMER"; $c="DINNA KAOR FÖR DIG; MED DIN ADMIN SOM INLOGGADE";
$p = loadpostdata($user, $u,$c);
$options = array( 'return_info' => 0, 'method' => 'post', 'post' => $p , 'cookie' => $c
); $result = load($u ,$options);
return $result ; }
// SKRIV IN LISTA MED ANVÄNDA NAMN $user="";
$ulist=explode("\r\n", $user);
foreach($ulist as $k => $v) { if($v!="") { edituser($v); echo "Set On $v From Forum<br>"; } }
| |