模拟登陆织梦,版本5.7,已经去掉后台验证码,不知道为啥一直登陆不上(提示登陆成功却又跳回登陆地址)
<?php
$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://localhost/dedecms/dede/login.php';
$post_fields = 'gotopage=%2Fdedecms%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=123456&sm1=';$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
$url='http://localhost/dedecms/dede/article_add.php?channelid=1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
?>
登陆成功后要跳转到 http://localhost/dedecms/dede/article_add.php?channelid=1
<?php
$cookie_file = tempnam('./temp','cookie');
$login_url = 'http://localhost/dedecms/dede/login.php';
$post_fields = 'gotopage=%2Fdedecms%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=123456&sm1=';$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
$url='http://localhost/dedecms/dede/article_add.php?channelid=1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
?>
登陆成功后要跳转到 http://localhost/dedecms/dede/article_add.php?channelid=1
google一下即可。
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
之前,我是一起写的。
[code]
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
[/code]
function getHtml($url,$tmpFile,$postData)
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpFile);
if($postData!=NULL)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
$content=curl_exec($ch);
curl_close($ch);
return $content;
}
?>
{
header("location:login.php?gotopage=".urlencode($dedeNowurl));
exit();
}
这里调处来,登入成功应该要给你个uid,你看看 在哪了搞下
同样不行,提示
DedeCMS 提示信息!对不起,你没有权限执行此操作!点击此返回上一页>>