if ($xml->errno == '0') {
        $arr = array('status' => 'success', 'info_url' => (string) $xml->info_url, 'timestamp' => (string) $xml->timestamp);
    } else {
        $arr = array('status' => 'error');
    }
    echo json_encode($arr);
    exit;
}
if ($action == "dropboxlinkstep2") {
    $timestamp = "";
    if (isset($_GET["dropboxtimestamp"])) {
        $timestamp = $_GET["dropboxtimestamp"];
    }
    if ($timestamp == "") {
        $arr = array('status' => 'error');
        echo json_encode($arr);
        exit;
    }
    $url = $config->get("crawlerws.rooturl");
    $url .= "/?action=" . $action;
    $url .= "&timestamp=" . $timestamp;
    $xmlstr = readurl($url);
    $xml = new SimpleXMLElement($xmlstr);
    if ($xml->errno == '0') {
        $arr = array('status' => 'success', 'token_key' => (string) $xml->token_key, 'token_secret' => (string) $xml->token_secret);
    } else {
        $arr = array('status' => 'error');
    }
    echo json_encode($arr);
    exit;
}
    }
    print $content;
    exit;
}
if ($action == "testcleaning") {
    if (isset($_POST["test_url_cleaning"])) {
        $page = $_POST["test_url_cleaning"];
    }
    if (isset($_POST["source_automatic_cleaning"])) {
        $cleaningMethod = $_POST["source_automatic_cleaning"];
    }
    $url = $config->get("crawlerws.rooturl");
    $url .= 'testcleaning/';
    $url .= "?page=" . urlencode($page);
    $url .= "&method=" . $cleaningMethod;
    $jsonstr = readurl($url);
    // 	if ($jsonstr==0 || $jsonstr==500) {
    // 		print ('');
    // 		exit();
    // 	}
    $arr = json_decode($jsonstr, true);
    // 	$xml = new SimpleXMLElement($xmlstr, LIBXML_NOCDATA);
    // 	if (isset($xml->errno)) {
    // 		print("err=" . $xml->errno . " " . $xml->errmsg);
    // 		exit();
    // 	}
    $content = "<html><head><title>Automatic HTML page cleaning</title>";
    $content .= "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>";
    $content .= "<link href='themes/ca/styles.css' rel='stylesheet' type='text/css' />";
    $content .= "</head><body>\n";
    $content .= "<table>\n";