Paul C wrote:This sounds like what I need
BUT not so sure about Cron - sounds serious. I dont mind dabbling at tech stuff but I have my limitations
What does it entail and how easy would it be to send me the php scripts
cheers
Paul
Hey Paul, let's see if we can get you moving in the right direction.
The two scripts I use are as follows and have the comments also as to what the script does
The first one is for copying and re-naming the image in the middle of the day, Day.jpg
I call this one 'picrename.php'
Code: Select all
<?php
if($_GET['password']!="password")//change this "password" to something else like H2O+Dirt=Mud
{
die("I'd like to really chew your ass out for running this script, but we'll just end it here");
}
else
{
$file = '/site/public_html/cam/image.jpg'; //file script is looking for
$day = date('D');//declaring $day as the new name for the image by using date function and short three letter name for that day. ex Wed, Thu, Mon etc.
copy($file, '/site/public_html/cam/'.$day.'.jpg');//make a copy and rename the copy to the day of the week
//used for testing, comment out when you are happy //
echo " image.jpg was succesfully renamed to $day.jpg ";
}
?>
Copy/paste that code into a text editor and name it what you want, like I said mine is 'picrename.php'
The second is to copy the Video.mp4 and change it to Day.mp4
I call this one 'vidrename.php'
Code: Select all
<?php
if($_GET['password']!="password")//change this "password" to something else like H2O+Dirt=Mud
{
die("I'd like to really chew your ass out for running this script, but we'll just end it here");
}
else
{
$file = '/site/public_html/cam/Video.mp4';//file script is looking for
$vid = date('D');//declaring $vid as the new name for the video by using date function and short three letter name for that day. ex Wed, Thu, Mon etc.
copy($file, '/site/public_html/cam/'.$vid.'.mp4');//make a copy and rename the copy to the day of the week
//used for testing, comment out when you are happy //
echo " Video.mp4 was succesfully renamed to $vid.mp4 ";
}
?>
Copy/paste that code into a text editor and name it what you want, like I said mine is 'vidrename.php'
All of my images and videos are loaded and stored in the directory 'cam'. I'm not sure where you are storing them, but you will need the full path to the image and mp4.
You can leave the "password" the way it is while you are testing or change it now if you like. After you have changed the paths in the scripts and loaded them into the same directory as the image and the videos, then you can test them and see if they work
Use
Code: Select all
http://www.bramptonweather.co.uk/directory/picrename.php?password=yourchosenpassword
If it was successful you should be returned -image.jpg was succesfully renamed to Thu.jpg- if you run the script on a Thursday
Do the same for the vidrename.php and if it is successful, we can move on to the cron part. Don't worry, you are not destroying the image and the movie. You are just copying them first and then renaming the copy to the same directory. Then ftp into your account or otherwise verify that the script indeed made the change. You could also use
Code: Select all
http://www.bramptonweather.co.uk/directory/Thu.jpg
if you run the script on a Thursday to see if the newly named image is there
From what I can see, your host does not use cPanel for their hosting control panel but they do seem to let you have access to cron/crontab thru their panel. There are a few different ways to access cron and I have always used the 'wget' method. It's the easiest for me because there are no paths to figure out, you just use the URL to access the script thru cron.
This is exactly how my vidrename is setup in my control panel except for a different password
Code: Select all
04 21 * * * wget http://mckeanweather.com/cam/vidrename.php?password=password -O /dev/null
This part is your time settings, how often you want the script to run. My vidrename runs on the 4th minute of the 21st hour every day, month and weekday.
Code: Select all
vidrename
Minute Hour Day Month Weekday
04 21 * * *
picrename
Minute Hour Day Month Weekday
03 12 * * *
And the picrename runs on the 3rd minute of the 12th hour, every day, month and weekday
Don't concentrate on making cron run until we have the scripts doing their jobs
See what you can figure out with what I've given ya and we'll work out the little tweeks that are probably going to be necessary.
Brad