2011-08-25 56 views
0

我正在爲客戶開發DLE autoposter。我寫了這個代碼:DataLife引擎自動發佈

function postit($url, $postdata ="", $header = false, $follow = 0, $headers = "") { 
    global $cookie; 
    $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_VERBOSE, '1'); 
     curl_setopt($ch, CURLOPT_COOKIESESSION, 1); 
     curl_setopt($ch, CURLOPT_REFERER, "http://www.downgiga.com/addnews.html"); 
     if($header == true) { 
      curl_setopt($ch, CURLOPT_HEADER, 1); 
     } 
     if($headers != "") { 
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

     } 
     curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd() . '/' . $cookie); 
     curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd() . '/' . $cookie); 
     $log = fopen(getcwd() . '/' . 'log.txt', 'w+'); 
     curl_setopt($ch, CURLOPT_STDERR, $log); 
     if($follow <> 0) { 
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
     } 
     if($postdata <> "") { 
      curl_setopt($ch, CURLOPT_POST, 1); 
      curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 
     } 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)"); 
    $source_code = curl_exec($ch); 
    curl_close($ch); 
    return $source_code; 
} 

$cookie = "cookies"; 
//login 
$post['login_name'] = "joker"; 
$post['login_password'] = "123123"; 
$post['login'] = "submit"; 
$page = postit("http://www.downgiga.com/addnews.html", $post); 
unset($post); 
$secpattern = '/<input type="hidden" name="([a-z]*)" value="([a-z0-9]*)" \/><\/form>/';// some security 
preg_match($secpattern, $page, $match);// some security 
if($match) $post[$match[1]] = $match[2];// some security 
$post['title'] = "test"; 
$post['catlist'] = '2'; 
$post['short_story'] = "short test"; 
$post['full_story'] = "full test"; 
$post['tags'] = "full,test"; 
$post['add'] = "Submit"; 
$post['mod'] = "addnews"; 
$post['nview'] = "Preview"; 
$post['allow_comm'] = true; 
$post['allow_main'] = false; 
$post['approve'] = true; 
$post['allow_rating'] = true; 
$headers = array('Content-Type: application/x-www-form-urlencoded'); 
echo postit("http://www.downgiga.com/addnews.html", $post, false, 0, $headers); 

,這讓我這個錯誤

ANTISPAM: User ID not valid 

好,這裏是捲曲日誌和HTTP報頭從谷歌瀏覽器上的成功後提取。

捲曲登錄

* About to connect() to www.downgiga.com port 80 (#0) 
* Trying 109.232.224.104... * connected 
* Connected to www.downgiga.com (109.232.224.104) port 80 (#0) 
> POST /addnews.html HTTP/1.1 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729) 
Host: www.downgiga.com 
Accept: */* 
Referer: http://www.downgiga.com/addnews.html 
Cookie: dle_password=4297f44b13955235245b2497399d7a93; dle_user_id=108; dle_newpm=0 
Content-Length: 1386 
Content-Type: multipart/form-data; boundary=----------------------------993bf2bec865 

< HTTP/1.1 200 OK 
< Date: Thu, 25 Aug 2011 23:49:10 GMT 
< Server: Apache/2.2.17 (EL) 
< X-Powered-By: PHP/5.2.17 
< Expires: Thu, 19 Nov 1981 08:52:00 GMT 
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
< Pragma: no-cache 
* Added cookie PHPSESSID="42104e9342c70e8db167f417f6484a2d" for domain www.downgiga.com, path /, expire 0 
< Set-Cookie: PHPSESSID=42104e9342c70e8db167f417f6484a2d; path=/ 
* Replaced cookie dle_newpm="0" for domain downgiga.com, path /, expire 1345852151 
< Set-Cookie: dle_newpm=0; expires=Fri, 24-Aug-2012 23:49:11 GMT; path=/; domain=.downgiga.com; httponly 
< Connection: close 
< Transfer-Encoding: chunked 
< Content-Type: text/html; charset=UTF-8 
< 
* Closing connection #0 

谷歌瀏覽器的HTTP報頭從谷歌瀏覽器也

title:test2 
short_story:<p>test :)</p> 
full_story:<p>testing headers :)</p> 
tags:test header 
allow_comm:1 
approve:1 
allow_rating:1 
add:Submit 
mod:addnews 
uxfpekxs:92006af0832447ad34fdaa8328ac788b 
採取

POST /addnews.html HTTP/1.1 
Host: www.downgiga.com 
Connection: keep-alive 
Content-Length: 223 
Cache-Control: max-age=0 
Origin: http://www.downgiga.com 
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.861.0 Safari/535.2 
Content-Type: application/x-www-form-urlencoded 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Referer: http://www.downgiga.com/addnews.html 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,ar;q=0.2 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 
Cookie: PHPSESSID=99de9359543b04cc43fb887fc64f7ff9; selected_language=English; dle_user_id=108; dle_password=4297f44b13955235245b2497399d7a93; dle_newpm=0 

和後數據10

發佈數據中的最後一行是關於安全性的內容,並且每次都會更改。 此外,我試圖從捲曲把手刪除自定義標題,什麼都沒有改變:(

回答

1

嘗試禁用DLE管理CP垃圾郵件過濾器因爲此選項一直虛假無效,特別是在任何使用服務器緩存的服務器上。

1

發送POST請求http://www.downgiga.com/admin.php?mod=addnews&action=addnews,不要忘了包括 user_hash

+0

我試圖將發佈的數據發送到http://www.downgiga.com/admin.php?mod=addnews&action=addnews和http: //www.downgiga.com/admin.php(作爲原始形式),但它的行爲就像我沒有發送數據,而捲曲日誌顯示內容lenght = 359,這使我確信p發送了所有數據 –