示例#1
0
function testCookieUrl($url, $loginSets)
{
    if (!function_exists('curl_init')) {
        echo '<div class="error"><p>cURL extension is not enable, can not use Cookie</p></div>';
        return;
    }
    if ($loginSets['mode'] == 1) {
        $cookie_jar = get_cookie_jar_ap($loginSets['url'], $loginSets['para']);
        //echo 'file:'.$cookie_jar;
        $result = curl_get_contents_ap($url, 0, null, 0, 30, null, $cookie_jar);
        unlink($cookie_jar);
    } else {
        //$loginSets['mode']==2
        $cookie = $loginSets['cookie'];
        $result = curl_get_contents_ap($url, 0, null, 0, 30, $cookie);
    }
    $dom = str_get_html_ap($result);
    $fcs = $dom->find('script');
    foreach ($fcs as $fc) {
        $fc->outertext = '';
    }
    $result = $dom->save();
    $dom->clear();
    unset($dom);
    $file = dirname(__FILE__) . '/test_cookie_temp.html';
    $fileUrl = plugins_url('/test_cookie_temp.html', __FILE__);
    file_put_contents($file, $result);
    echo '<div id="message" class="updated fade"><p>' . __('The Cookie test result, if Cookie set right you can see the contents that need to login', 'wp-autopost') . '</p></div>';
    echo '<div style="border-width:2px;border-style:solid;border-color:#dfdfdf; margin-bottom:20px;">';
    echo '<iframe src="' . $fileUrl . '"  width="100%" height="600" frameborder="0"  ></iframe></div>';
}
 function createTextNode($value)
 {
     return @end(str_get_html_ap($value)->nodes);
 }