maar3amt
Jul 31st 2008, 9:55 am
Hi ppl.
I have a problem with my script because when i run get_content.php after i see double entries into mysql db.
I want this script get a new xml entries but not double old ones!
Can someone check my script and try find error please?
Thank you.
<?php session_start();
ini_set("max_execution_time",0);
require_once('init.php');
require_once("includes/config.php");
require_once("function.php");
//get all XML links...
$catid = $_GET['catid'];
$resultLink = get_all_Links($catid);
global $catidglobal;
$catidglobal = $catid;
foreach ($resultLink as $key => $value)
{
//echo "Key: $key; Value: $value<br>\n";
$feid = 0;
$curr_url = $value;
$getfeedid_qry = "select id from ".$prefix."feeds where url='".trim($curr_url)."' AND DATE_FORMAT(timestamp,'%Y-%m-%d-%h:%i') < DATE_FORMAT(subdate(now(), interval 1 MINUTE),'%Y-%m-%d-%h:%i')";
$getfeedid_res = mysql_query($getfeedid_qry);
$getfeedid_num = mysql_num_rows($getfeedid_res);
if($getfeedid_num>0)
{
while($getfeedid_row = mysql_fetch_assoc($getfeedid_res))
{
$getfeedid_arr[$feid] = $getfeedid_row['id'];
$feid++;
}
$getfeedid_str = @implode(",",$getfeedid_arr);
$delqry1 = "delete from ".$prefix."feeds where id IN (".$getfeedid_str.");";
@mysql_query($delqry1);
$delqry2 = "delete from ".$prefix."feeds_select where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry2);
$delqry3 = "delete from ".$prefix."items where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry3);
$delqry4 = "delete from ".$prefix."items_select where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry4);
}
ob_start();
{
$url = $value;
if(!empty($url))
{
RF_FeedSelect::_subscribe($url, $public);
}
$rss_result_html = ob_get_contents();
ob_clean();
if(!empty($opml))
{
if(!$content_array = file($opml))
{
echo "Cannot open $opml<br>";
//return false;
}
else
{
$content = implode("", $content_array);
$feeds = ref_opml_to_array($content);
foreach($feeds as $feed)
{
RF_FeedSelect::_subscribe($feed, $public);
echo '<hr size="1">';
flush();
}//for...
}//else...
}//if...
$opml_result_html = ob_get_contents();
ob_clean();
if($_FILES['opml_file']['tmp_name'])
{
if(!$content_array = file($_FILES['opml_file']['tmp_name']))
{
echo "Cannot open uploaded file<br>";
//return false;
}
else
{
$content = implode("", $content_array);
$feeds = ref_opml_to_array($content);
foreach($feeds as $feed)
{
RF_FeedSelect::_subscribe($feed, $public);
echo '<hr size="1">';
flush();
}//for ...
}//else ...
}//if ...
$file_result_html = ob_get_contents();
ob_clean();
}
ob_end_clean();
//update parse flag to ='1'
$sqlupdate ="update ".$prefix."xmllinks set isparsed='1' where link='$url'";
mysql_query($sqlupdate);
}//end of main foreach loop...
?>
<script language="JavaScript">
parent.window.location.href="done.php";
</script>
I have a problem with my script because when i run get_content.php after i see double entries into mysql db.
I want this script get a new xml entries but not double old ones!
Can someone check my script and try find error please?
Thank you.
<?php session_start();
ini_set("max_execution_time",0);
require_once('init.php');
require_once("includes/config.php");
require_once("function.php");
//get all XML links...
$catid = $_GET['catid'];
$resultLink = get_all_Links($catid);
global $catidglobal;
$catidglobal = $catid;
foreach ($resultLink as $key => $value)
{
//echo "Key: $key; Value: $value<br>\n";
$feid = 0;
$curr_url = $value;
$getfeedid_qry = "select id from ".$prefix."feeds where url='".trim($curr_url)."' AND DATE_FORMAT(timestamp,'%Y-%m-%d-%h:%i') < DATE_FORMAT(subdate(now(), interval 1 MINUTE),'%Y-%m-%d-%h:%i')";
$getfeedid_res = mysql_query($getfeedid_qry);
$getfeedid_num = mysql_num_rows($getfeedid_res);
if($getfeedid_num>0)
{
while($getfeedid_row = mysql_fetch_assoc($getfeedid_res))
{
$getfeedid_arr[$feid] = $getfeedid_row['id'];
$feid++;
}
$getfeedid_str = @implode(",",$getfeedid_arr);
$delqry1 = "delete from ".$prefix."feeds where id IN (".$getfeedid_str.");";
@mysql_query($delqry1);
$delqry2 = "delete from ".$prefix."feeds_select where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry2);
$delqry3 = "delete from ".$prefix."items where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry3);
$delqry4 = "delete from ".$prefix."items_select where feed_id IN (".$getfeedid_str.");";
@mysql_query($delqry4);
}
ob_start();
{
$url = $value;
if(!empty($url))
{
RF_FeedSelect::_subscribe($url, $public);
}
$rss_result_html = ob_get_contents();
ob_clean();
if(!empty($opml))
{
if(!$content_array = file($opml))
{
echo "Cannot open $opml<br>";
//return false;
}
else
{
$content = implode("", $content_array);
$feeds = ref_opml_to_array($content);
foreach($feeds as $feed)
{
RF_FeedSelect::_subscribe($feed, $public);
echo '<hr size="1">';
flush();
}//for...
}//else...
}//if...
$opml_result_html = ob_get_contents();
ob_clean();
if($_FILES['opml_file']['tmp_name'])
{
if(!$content_array = file($_FILES['opml_file']['tmp_name']))
{
echo "Cannot open uploaded file<br>";
//return false;
}
else
{
$content = implode("", $content_array);
$feeds = ref_opml_to_array($content);
foreach($feeds as $feed)
{
RF_FeedSelect::_subscribe($feed, $public);
echo '<hr size="1">';
flush();
}//for ...
}//else ...
}//if ...
$file_result_html = ob_get_contents();
ob_clean();
}
ob_end_clean();
//update parse flag to ='1'
$sqlupdate ="update ".$prefix."xmllinks set isparsed='1' where link='$url'";
mysql_query($sqlupdate);
}//end of main foreach loop...
?>
<script language="JavaScript">
parent.window.location.href="done.php";
</script>