Exemplo n.º 1
0
function grab_setup($url)
{
    $html = file_get_html($url);
    foreach ($html->find('ul[id=product_list] li') as $product) {
        // Obtinc el cost
        $costE = $product->find('div[class=content_price] span[class=price]');
        $cost = str_replace(',', '.', str_replace(' €', '', str_replace('.', '', $costE[0]->plaintext)));
        //Obtinc el titol i la url del producte
        foreach ($product->find('a[class=product_img_link]') as $productDescr) {
            $title = $productDescr->title;
            $srclink = $productDescr->href;
        }
        // PartNo
        $iname = explode('/', $srclink);
        $part = explode('-', $iname[count($iname) - 1]);
        $partNo = $part[0] . '-SETUP';
        // Obtinc la imatge
        foreach ($product->find('img') as $img) {
            $iname = explode('/', $img->src);
            $fname = $iname[count($iname) - 1];
            grab_image($img->src, '../images/' . $fname);
        }
        // Trec l'IVA (21%)
        $cost = $cost * 100 / 121;
        if (!empty($title) and $cost) {
            $cos = '<a href="' . $srclink . '" alt="' . $title . '" title="' . $title . '"><img src="/files/catalog/' . $fname . '" width=124 height=124 align="right"></a>';
            echo "{$partNo}|{$title}|{$cos}|21|{$cost}\n";
        }
    }
}
Exemplo n.º 2
0
function grab_landatel($url)
{
    $html = file_get_html($url);
    foreach ($html->find('table[class=productListing] tr') as $product) {
        // Obtinc el titol, el partno i el cost
        $i = 0;
        $productsTDs = $product->find('td');
        foreach ($productsTDs as $productTD) {
            if ($productTD->class == 'productListing-heading') {
                continue;
            }
            $productTD->find('s', 0)->innertext = '';
            $str = str_replace('&nbsp;', '', $productTD->plaintext);
            switch ($i) {
                case 2:
                    $title = $str;
                    break;
                case 3:
                    $partNo = $str;
                    break;
                case 4:
                    $cost = explode(' - ', str_replace('EUR', '', str_replace(',', '', $str)));
                    if (empty($cost[1])) {
                        $cost[1] = $cost[0];
                    }
                    break;
            }
            $i++;
        }
        // Obtinc la referència a la pagina del producte
        foreach ($product->find('a') as $link) {
            $srclink = $link->href;
        }
        // Obtinc la imatge
        foreach ($product->find('img[width=120]') as $img) {
            $iname = explode('/', $img->src);
            grab_image('http://landashop.com/catalog/images/' . $iname[1], '../images/' . $iname[1]);
        }
        if (!empty($title)) {
            $cos = '<a href="' . $srclink . '" alt="' . $title . '"><img src="/files/catalog/' . $iname[1] . '" width=120 height=120 align="right"></a>';
            echo "{$partNo}|{$title}|{$cos}|21|{$cost['1']}\n";
        }
    }
}
Exemplo n.º 3
0
function wp_ajax_hotlink_img_callback()
{
    $url = $_GET['url'];
    if (preg_match('/^https?:\\/\\//', $url)) {
        //        $result = (file_get_contents($url));
        //        exit($result);
        exit(grab_image($url));
    }
}
Exemplo n.º 4
0
if (file_exists("../appSettings.inc.php")) {
    include_once '../appSettings.inc.php';
    include_once '../JsonSettings.class.php';
}
function grab_image($url)
{
    //   header('Content-type: image/jpeg');
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $conf_file = "camera/camera";
    if (file_exists(DIR . $conf_file . ".json")) {
        $credentials_json = new JsonSettings($conf_file);
        if ($credentials_json->settings) {
            //var_dump($credentials_json);
            if (property_exists($credentials_json->settings, "c")) {
                $userpassword = $credentials_json->settings->c;
            }
        }
    }
    if (isset($userpassword)) {
        curl_setopt($ch, CURLOPT_USERPWD, $userpassword);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    }
    $raw = curl_exec($ch);
    echo $raw;
    //echo curl_error($ch);
    curl_close($ch);
}
grab_image($camurl);
Exemplo n.º 5
0
 function get_thumbnail($url)
 {
     $this->load->library('upload');
     $url_original = $url;
     if (parse_url($url)) {
         $url = $this->addhttp($url);
         $url = parse_url($url);
         switch ($url['host']) {
             case 'www.youtube.com':
                 parse_str($url['query'], $data);
                 $video = $data['v'];
                 $video_data = get_json("https://www.googleapis.com/youtube/v3/videos?id={$video}&part=snippet&key=AIzaSyBRa_48GW6LpDcB8VlQxrt5alf-4-GTThQ");
                 $thumbnail = $video_data->items[0]->snippet->thumbnails->high->url;
                 break;
             case 'youtu.be':
                 $video = str_replace('/', '', $url['path']);
                 $json = get_json("https://www.googleapis.com/youtube/v3/videos?id={$video}&part=snippet&key=AIzaSyBRa_48GW6LpDcB8VlQxrt5alf-4-GTThQ");
                 $video_data = json_decode($json);
                 $thumbnail = $video_data->items[0]->snippet->thumbnails->high->url;
                 break;
             case 'www.dailymotion.com':
                 $path = explode('/', $url['path']);
                 $video = $path[2];
                 $thumbnail = "http://www.dailymotion.com/thumbnail/video/{$video}";
                 break;
             case 'vimeo.com':
                 $path = explode('/', $url['path']);
                 $video = end($path);
                 $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/{$video}.php"));
                 $thumbnail = $hash[0]['thumbnail_large'];
                 break;
             case 'www.mmpro.de':
                 $this->load->library('simple_html_dom');
                 $html = file_get_html($url_original);
                 foreach ($html->find('link[rel=canonical]') as $element) {
                     $canonical_url = $element->href;
                 }
                 $canonical_url = $this->addhttp($canonical_url);
                 $canonical_url = parse_url($canonical_url);
                 parse_str($canonical_url['query'], $data);
                 $video_id = $data['videoId'];
                 $json_output = get_json("http://www.mmpro.de/cache/videolist.json", true);
                 foreach ($json_output as $object) {
                     foreach ($object as $video) {
                         $video_to_display = $video;
                         foreach ($video["video"] as $video_data) {
                             $video_uri = $video_data['uri'];
                             if ($video_data['uri'] == $video_id) {
                                 break 3;
                             }
                         }
                     }
                 }
                 if (isset($video_to_display['mcf'])) {
                     $thumbnail = "http://www.mcfootage.com/imagereplace.php?width=900&height=600&kunde=archive&file=" . $video_to_display['picture'];
                 } else {
                     $json_output = get_json("http://www.admiralcloud.com/player/json/" . $video_uri);
                     $thumbnail = $json_output->movies[0]->jpg;
                 }
                 break;
             case 'www.tvbvideo.de':
                 $CI =& get_instance();
                 $CI->load->library('simple_html_dom');
                 $html = file_get_html($url_original);
                 $r = html_entity_decode($html->find('#export_website_code', 0)->innertext());
                 $r_html = str_get_html($r);
                 preg_match('(http://api.kewego.com/video/getHTML5Thumbnail.+\\"\\))', $r_html, $thumbnail);
                 $thumbnail = substr($thumbnail[0], 0, -2);
                 $thumbnail = $this->get_final_url($thumbnail);
                 break;
             default:
                 echo "Je ne connais pas ce site web... Veuillez vérifier le lien.";
                 break;
         }
         if (isset($thumbnail) && $thumbnail != "assets/img/nopic.jpg") {
             //UPLOAD THUMBNAILS
             $filename = 'import_' . slug($_POST['title']) . '.jpg';
             grab_image($thumbnail, $this->photos_path . $filename);
             $data['filename'] = $filename;
             if (autoCrop($data)) {
                 create_thumbnail($data);
                 create_header($data);
                 unlink($this->photos_path . $filename);
             }
             return $filename;
         } else {
             if ($thumbnail == "assets/img/nopic.jpg") {
                 return "nopic.jpg";
             } else {
                 return false;
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 6
0
     @($t->{$prop} = $tem->{$prop});
 }
 $m->GlobalID = $t->ManufacturerID;
 $m->getManufacturerByGlobalID();
 $t->ManufacturerID = $m->ManufacturerID;
 // Snag the images
 if ($t->FrontPictureFile != "") {
     $tmpname = explode(".", basename($t->FrontPictureFile), 2);
     $frontname = $picturedir . $tmpname[1];
     grab_image($t->FrontPictureFile, $frontname);
     $t->FrontPictureFile = $tmpname[1];
 }
 if ($t->RearPictureFile != "") {
     $tmpname = explode(".", basename($t->RearPictureFile), 2);
     $rearname = $picturedir . $tmpname[1];
     grab_image($t->RearPictureFile, $rearname);
     $t->RearPictureFile = $tmpname[1];
 }
 // TemplateID from the repo is GlobalID for us
 $t->GlobalID = $tem->TemplateID;
 // Check the status of the Config globals for behavior
 // Specifically, if KeepLocal is set, then once a template has been downloaded, set the flag
 if ($config->ParameterArray["KeepLocal"] == "enabled") {
     $t->KeepLocal = true;
 } else {
     $t->KeepLocal = false;
 }
 // Resolve the TemplateID so that we can make the rest of the tables match
 $st = $dbh->prepare("select TemplateID, KeepLocal, count(*) as Total from fac_DeviceTemplate where GlobalID=:TemplateID or (ManufacturerID=:ManufacturerID and ucase(Model)=ucase(:Model))");
 $st->execute(array(":TemplateID" => $t->GlobalID, ":ManufacturerID" => $man->ManufacturerID, ":Model" => $t->Model));
 $row = $st->fetch();
Exemplo n.º 7
0
 if ($prevs == '1') {
     die($tempData['temp_data_real']);
 }
 $controller = cntData("SELECT ID FROM " . db_table_pref . "templates WHERE OID=" . set_org_id . " AND temp_id='" . mysql_prep($tempData['temp_id']) . "'");
 if ($controller == 0) {
     $temp_name = $tempData['name'];
     $temp_contents = $tempData['temp_data'];
     $temp_type = $tempData['temp_type'];
     $isSystem = $tempData['isSystem'];
     $temp_id = $tempData['temp_id'];
     $temp_prev = $tempData['image'];
     # Try to upload preview image
     $path_parts = pathinfo($temp_prev);
     $newName = rand(1000, 99999) . '_' . $path_parts['basename'];
     $saveto = set_org_resource . DIRECTORY_SEPARATOR . $newName;
     if (grab_image($temp_prev, $saveto)) {
         $temp_prev = set_org_resource_url . '/' . $newName;
     } else {
         $temp_prev = NULL;
     }
     $addTemp = $myconn->prepare("INSERT INTO \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . db_table_pref . "templates \n\t\t\t\t\t\t\t\t\t\t\t\t   SET \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOID=" . set_org_id . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUID=" . LETHE_AUTH_ID . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttemp_name=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttemp_contents=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttemp_prev=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttemp_type=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tisSystem=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttemp_id=?\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t") or die(mysqli_error($myconn));
     $addTemp->bind_param('ssssis', $temp_name, $temp_contents, $temp_prev, $temp_type, $isSystem, $temp_id);
     if ($addTemp->execute()) {
         echo '<span class="text-success glyphicon glyphicon-ok"></span>';
     } else {
         echo '<span class="text-danger glyphicon glyphicon-remove"></span>';
     }
     $addTemp->close();
 } else {
     echo '<span class="text-danger glyphicon glyphicon-remove"></span>';
 }