How to plan / content queue for future publication? Post to PHP?

I have a very simple PHP script that I use to publish interesting links that I find in a filtered list on my site, as well as in my rss feed (which feedburner then also tweets when pinging).

I wonder how difficult it would be to add a “queue” in which I could send several records at once and plan a future time / date for each of them?

Similar to what Twuffer does for Twitter or Tumblr and Wordpress for blog posts.

Is cron jobs required? Perhaps with my PHP script writing another file "drafts.txt" if it is a future post and a scheduled cron to check if there is a time / date = and then write it to other files?

I am obviously new to this - but I would appreciate any help! Thank!

Here is my current little script:

<?php 

if($_POST['Submit']) 
{ 
$category = $_POST['category']; 
$linkurl = $_POST['linkurl']; 
$linkname = $_POST['linkname']; 
$description = $_POST['description']; 
$submittername = $_POST['submittername']; 
$submitterurl = $_POST['submitterurl']; 
$postdate = $_POST['postdate'];

// Remove slashes.
$description = stripslashes($description);

//the data for list.txt
$data = "
<li class='$category'>
    <h3><a href='$linkurl' target='_blank'>$linkname</a></h3>
    <p><b>$description</b></p> 
    <p><small>Submitted by: <a href='$submitterurl' target='_blank'>$submittername</a><i> - $postdate</i></small></p>
</li>
"; 

$filename   = "list.txt";

$fp         = fopen( $filename,"r"); 
$OldData    = fread($fp, 80000); 
fclose( $fp ); 

$New = "$data$OldData";

$fp = fopen( $filename,"w"); 
if(!$fp) die("Cannot write $filename .");
fwrite($fp, $New, 800000); 
fclose( $fp ); 

//the data for rss.php
$feeddata = "
<item>
   <title>Supplement: $linkname</title>
   <link>$linkurl</link>
   <description>$description</description>
</item>
"; 

$ffilename  = "rss.txt";

$ff         = fopen( $ffilename,"r"); 
$OldfeedData    = fread($ff, 80000); 
fclose( $ff ); 

$New = "$feeddata$OldfeedData";

$ff = fopen( $ffilename,"w"); 
if(!$ff) die("Cannot write $ffilename .");
fwrite($ff, $New, 800000); 
fclose( $ff ); 


print("<h1>Success!</h1><a href='add.php'>Add Another?</a>");
}
?>
+3
source share
2 answers

Here's what I did (thanks to Alfred for thinking in the right direction):

  • I added radio buttons in my form to publish "Now" or "Later."
  • Choosing "Later" shows a datupixer that passes datetime var to my script when I would like to publish an article.
  • script, "", .txt, . "" , ( ) MySQL db.
  • cron php script , , .txt db.

!

+2

, :

cron (, ). - . !

, at


Google /cron, ( ). webhooks .

+1

Source: https://habr.com/ru/post/1778445/


All Articles