Esempio n. 1
0
 public function get_images()
 {
     $all_img = array();
     foreach ($this->html->find('img') as $obj) {
         $src = $obj->src;
         $src = ConvertRelativeToAbsoluteURL(ExtractURL($GLOBALS['root_url']), $src);
         array_push($all_img, $src);
     }
     return $all_img;
 }
Esempio n. 2
0
 public function ExtractForms($baseurl, $data)
 {
     $result = array();
     if ($this->html === false) {
         $this->html = new simple_html_dom();
     }
     $this->html->load($data);
     $html5rows = $this->html->find("input[form],textarea[form],select[form],button[form],datalist[id]");
     $rows = $this->html->find("form");
     foreach ($rows as $row) {
         $info = array();
         if (isset($row->id)) {
             $info["id"] = trim($row->id);
         }
         if (isset($row->name)) {
             $info["name"] = (string) $row->name;
         }
         $info["action"] = isset($row->action) ? ConvertRelativeToAbsoluteURL($baseurl, (string) $row->action) : $baseurl;
         $info["method"] = isset($row->method) && strtolower(trim($row->method)) == "post" ? "post" : "get";
         if ($info["method"] == "post") {
             $info["enctype"] = isset($row->enctype) ? strtolower($row->enctype) : "application/x-www-form-urlencoded";
         }
         if (isset($row->{"accept-charset"})) {
             $info["accept-charset"] = (string) $row->{"accept-charset"};
         }
         $fields = array();
         $rows2 = $row->find("input,textarea,select,button");
         foreach ($rows2 as $row2) {
             if (!isset($row2->form)) {
                 $this->ExtractFieldFromDOM($fields, $row2);
             }
         }
         // Handle HTML5.
         if (isset($info["id"]) && $info["id"] != "") {
             foreach ($html5rows as $row2) {
                 if (strpos(" " . $info["id"] . " ", " " . $row2->form . " ") !== false) {
                     $this->ExtractFieldFromDOM($fields, $row2);
                 }
             }
         }
         $form = new WebBrowserForm();
         $form->info = $info;
         $form->fields = $fields;
         $result[] = $form;
     }
     return $result;
 }
    DownloadFailed("Error retrieving URL.  " . $result["error"]);
} else {
    if ($result["response"]["code"] != 200) {
        DownloadFailed("Error retrieving URL.  Server returned:  " . $result["response"]["code"] . " " . $result["response"]["meaning"]);
    }
}
$baseurl = $result["url"];
$html->load($result["body"]);
$rows = $html->find("a[href]");
foreach ($rows as $row) {
    if (preg_match('/^\\/downloads\\/releases\\/php-(5\\.5\\.\\d+)-Win32-VC11-x86.zip$/', $row->href, $matches)) {
        echo "Found:  " . $row->href . "\n";
        echo "Latest version:  " . $matches[1] . "\n";
        echo "Currently installed:  " . (isset($installed["php"]) ? $installed["php"] : "Not installed") . "\n";
        if (!isset($installed["php"]) || $matches[1] != $installed["php"]) {
            DownloadAndExtract("php", ConvertRelativeToAbsoluteURL($baseurl, $row->href));
            $extractpath = dirname(FindExtractedFile($stagingpath, "php.exe")) . "/";
            @copy($installpath . "vc_redist/msvcr110.dll", $extractpath . "bin/msvcr110.dll");
            echo "Copying staging files to final location...\n";
            CopyDirectory($extractpath, $installpath . "php");
            echo "Cleaning up...\n";
            ResetStagingArea($stagingpath);
            $installed["php"] = $matches[1];
            SaveInstalledData();
            echo "PHP binaries updated to " . $matches[1] . ".\n\n";
        }
        break;
    }
}
ResetStagingArea($stagingpath);
rmdir($stagingpath);