PDA

View Full Version : I need a script which ...



jack-bristol
11-08-2009, 12:22 AM
I love EastEnders and so would like a script which saves the webcam images from the ee site every 2 minutes. I no nothing about PHP and would be over the moon if someone could make this for me. I plan on adding the script as a cron in cPanel after. This is what I want the script to do.

Save 3 images from 3 different locations every 2 minutes. Locations are ...

http://www.bbc.co.uk/eastenders/images/live/cam1.jpg
http://www.bbc.co.uk/eastenders/images/live/cam2.jpg
http://www.bbc.co.uk/eastenders/images/live/cam3.jpg

And then if possible save it in the following format from the current scripts directory ...

/albertsquare/{date e.g. 110809}_{time e.g. 1604}.jpg (This is the location for cam1

/georgestreet/{date e.g. 110809}_{time e.g. 1604}.jpg (This is the location for cam2)

/turpinroad/{date e.g. 110809}_{time e.g. 1604}.jpg (This is the location for cam3)

Thanks again,

Jack :-)

Chippiewill
11-08-2009, 08:18 AM
So basically you want it to grab the image

http://www.bbc.co.uk/eastenders/images/live/cam1.jpg

and

http://www.bbc.co.uk/eastenders/images/live/cam2.jpg

and

http://www.bbc.co.uk/eastenders/images/live/cam3.jpg

And then save it as a timecode basically under a folder

jack-bristol
11-08-2009, 08:37 AM
So basically you want it to grab the image

http://www.bbc.co.uk/eastenders/images/live/cam1.jpg

and

http://www.bbc.co.uk/eastenders/images/live/cam2.jpg

and

http://www.bbc.co.uk/eastenders/images/live/cam3.jpg

And then save it as a timecode basically under a folder

Yes please! Can this be done?

BoyBetterKnow
11-08-2009, 09:36 AM
Yeh, I'm not doing it for free but it'd just be createjpegfrom or w/e in PHP GD. Or it's probably possible to just simple copy it.

I've never copied cross URL so I don't know if you can use copy();

Chippiewill
11-08-2009, 11:21 PM
Just download it to a location and then copy it (Timecoded) to the folder :)

http://php.about.com/od/advancedphp/ss/php_read_file.htm

For info on downloading the file

Dentafrice
12-08-2009, 05:42 PM
Setup a cron job for every 2 minutes, create the three folders.. and make sure you chmod them.



<?php
//
// save_image.php
// Eastenders - Image Save
//
// Created by Caleb Mingle on 2009-08-12.
// Copyright 2009 MacDowell Diesel Performance. All rights reserved.
//

/* Grabs the images */
$image = array();
$image[1] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam1.jpg");
$image[2] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam2.jpg");
$image[3] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam3.jpg");

/* Sets up the folder locations */
$location = array();
$location[1] = 'albertsquare';
$location[2] = 'georgestreet';
$location[3] = 'turpinroad';

$filename = date('dmy_gi') . '.jpg'; // file name for the images.

$counter = 1; // counter for the location.


foreach($image as $key => $value) {
$image = imagecreatefromstring($value); // creates image from data.
imagejpeg($image, "{$location[$counter]}/{$filename}"); // saves image in location.

$counter++; // increments counter.
}

jack-bristol
12-08-2009, 07:41 PM
Setup a cron job for every 2 minutes, create the three folders.. and make sure you chmod them.



<?php
//
// save_image.php
// Eastenders - Image Save
//
// Created by Caleb Mingle on 2009-08-12.
// Copyright 2009 MacDowell Diesel Performance. All rights reserved.
//

/* Grabs the images */
$image = array();
$image[1] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam1.jpg");
$image[2] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam2.jpg");
$image[3] = file_get_contents("http://www.bbc.co.uk/eastenders/images/live/cam3.jpg");

/* Sets up the folder locations */
$location = array();
$location[1] = 'albertsquare';
$location[2] = 'georgestreet';
$location[3] = 'turpinroad';

$filename = date('dmy_gi') . '.jpg'; // file name for the images.

$counter = 1; // counter for the location.


foreach($image as $key => $value) {
$image = imagecreatefromstring($value); // creates image from data.
imagejpeg($image, "{$location[$counter]}/{$filename}"); // saves image in location.

$counter++; // increments counter.
}


Thanks, I owe you +rep, need to spread more around first.

BoyBetterKnow
12-08-2009, 08:33 PM
Thanks, I owe you +rep, need to spread more around first.

I repped him for you :P

Want to hide these adverts? Register an account for free!