Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 03-14-2005, 03:52 PM
Anonymous Offline
pixelpost guru
 
Join Date: Oct 2004
Posts: 810
Setting time automatically

Currently I am
1) Uploading a lot of photos
2) Setting the time on each one manually so they appear at a rate of one a day

What I would like to do is
1) Upload a lot of photos, and have Pixelpost automatically set the datetime as (24 hours after the most recent addition) so that the 1 photo a day system will work without me manually having to change the datetime

Also, even if you set the datetime into the future, it's still currently possible to see the photos by altering the url - ie changing showimage=12 to showimage=112 will show picture 112, even if it shouldn't be appearing for two weeks. Is there any way to fix this?

Many thanks in advance.

Roddy
Reply With Quote
  #2  
Old 03-16-2005, 02:49 AM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
The posting bit is not so easy, but fixing the ability to see future posts is. Just change the line in index.php from

Code:
$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (id='".$_GET['showimage']."')");

to

$query = mysql_query("select * from ".$pixelpost_db_prefix."pixelpost where (id='".$_GET['showimage']."' and datetime<='$cdate')");
That makes sure that the datetime of the image that you are viewing is not in the future.
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
  #3  
Old 03-16-2005, 10:00 AM
Anonymous Offline
pixelpost guru
 
Join Date: Oct 2004
Posts: 810
That's great, thanks.

I've now manually set two months worth of pictures. However, I think the solution to automatically setting the time is to go into the 'add folder' file under add ons, and where it currently inserts the date, tell it instead to select the date from the latest entry, add 24hours to it, and then insert THAT date.

However, I probably won't get round to trying it for two months . . .
Reply With Quote
  #4  
Old 03-16-2005, 01:24 PM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
I tend to post in advance too, so I may get around to doing this too. It is something that annoys me, so...

You should also check your archive pages. I had to make a similar fix to the view archive by category query because I was seeing future entries in categories. I am not sure if that bug is in the default install though because I have installed the multiple categories hack.
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
  #5  
Old 03-17-2005, 03:49 AM
Rob Offline
pixelpost guru
 
Join Date: Mar 2005
Location: Burlington, Canada
Posts: 342
Send a message via ICQ to Rob Send a message via MSN to Rob
I had a bunch of photos to upload tonight, so I made the change you suggested. Here is how I did it;

Code:
<div id='content'>
    Set a date and time when you want the image to appear on your blog. Leave as is if it should be published immediately.<p />
    Year-month-day     hour-minute<br />
to

Code:
<div id='content'>
    <input type='checkbox' name='autodate' value='1' checked>Set the date to 1 day after the last posted image, or<br /><br />
    Set a date and time when you want the image to appear on your blog. Leave as is if it should be published immediately.<p />
    Year-month-day     hour-minute<br />
Then add

Code:
        if( $_POST['autodate'] == 1 ) {
            $query = mysql_query("SELECT datetime + INTERVAL 1 DAY FROM ".$pixelpost_db_prefix."pixelpost ORDER BY datetime DESC LIMIT 1");
            $row = mysql_fetch_row($query);
            if( $row ) $datetime = $row[0];
        }
right after these lines

Code:
 $datetime =
                $_POST['post_year']."-".
                $_POST['post_month']."-".
                $_POST['post_day']." ".
                $_POST['post_hour'].":".
                $_POST['post_minute'].":00";
You will now have a new checkbox right above the date time selection. If you leave it checked, it will post exactly one day after the last post.
__________________
shifted*exposure powered by PixelPost 1.4
Reply With Quote
  #6  
Old 03-17-2005, 10:21 PM
Anonymous Offline
pixelpost guru
 
Join Date: Oct 2004
Posts: 810
That looks great. I'll be using it with the copy folder add on, but it shouldn't be too hard to adapt. And thanks for the tip about the archives.

Roddy
Reply With Quote
  #7  
Old 06-12-2005, 11:57 AM
roddy Offline
forum loafer
 
Join Date: Jun 2005
Posts: 3
Ok, I finally got around to automating this.

in addons/copy_folder.php

find
// insert post in mysql
look a few lines ABOVE this for a reference to $datetime = . . .
remove that line (or more wisely comment it out)
then one line below "$filenumber++;"

add
$datetime = date("Y-m-d H:i:00", mktime(date("H"), date("i"), $filenumber*INTERVAL, date("m"), date("d"), date("Y")));

this will add a certain amount of time to the time stamp for each picture. You can set this by changing INTERVAL to the number of SECONDS you want between each picture. For example
$datetime = date("Y-m-d H:i:00", mktime(date("H"), date("i"), $filenumber*3600, date("m"), date("d"), date("Y")));
will put one hour between each pic.

Hope this is useful to someone.

Roddy
Reply With Quote
  #8  
Old 06-12-2005, 02:47 PM
nauz Offline
pending loafer
 
Join Date: Oct 2004
Location: new york
Posts: 51
Send a message via MSN to nauz
Roddy.
Looks like a great solution. I tried the add / delete lines and things got a bit screwy. Could you post the entire code?
Thanks
__________________
www.nauglevision.com/pix
Reply With Quote
  #9  
Old 08-03-2005, 01:58 PM
roddy Offline
forum loafer
 
Join Date: Jun 2005
Posts: 3
Apologies for the delay, I'm only an occassional visitor (actually came back this time to get my own code, as I overwrote it when upgrading ops: )

Here's the code you need, with the changes highlighted in red. You need to comment out one line, and insert one other. The number 52100 in the inserted line gives me a gap of around 13 hours between posts - adjust as you will.

These changes need to be made in addons/copy_folder.php

// $datetime = gmdate("YmdHis",time()+(3600 * $tz)) .$secondcount;
$secondcount++;
// prepare the file
$oldfile = $file;
$newfile = "{$datetime}_$file";
$newpath = "$upload_dir$newfile";
$file = "$folder$file";
if(copy($file,$newpath)) {
$filenumber++;
$datetime = date("Y-m-d H:i:00", mktime(date("H"), date("i"), $filenumber*52100, date("m"), date("d"), date("Y")));
// insert post in mysql - supports new multi-category table in ver 1.4
$query = "insert into ".$pixelpost_db_prefix."pixelpost(id,datetime,head line,body,image,category)
VALUES('','$datetime','$oldfile','','$newfile','$c ategory')";
$result = mysql_query($query) || die("Error: ".mysql_error());
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 02:35 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs