








http://vase_domena/admin.php?op=AutoNewsIJVOInstall



//Vytvoříme tabulku unnuke_autopolldata


CREATE TABLE `unnuke_autopolldata` (`pollID` int(11) NOT NULL default '0', `optionText` char(50) NOT NULL default '', `optionCount` int(11) NOT NULL default '0', `voteID` int(11) NOT NULL default '0', KEY `pollID` (`pollID`)) ENGINE=MyISAM;


//Vytvoříme tabulku unnuke_autopolldesc


CREATE TABLE `unnuke_autopolldesc` (`pollID` int(11) NOT NULL auto_increment, `pollTitle` varchar(100) NOT NULL default '', `timeStamp` int(11) NOT NULL default '0', `voters` mediumint(9) NOT NULL default '0', `planguage` varchar(30) NOT NULL default '', `artid` int(10) NOT NULL default '0', `comments` int(11) default '0', PRIMARY KEY (`pollID`), KEY `pollID` (`pollID`)) ENGINE=MyISAM;


//Do tabulky unnuke_autonews přidáme slopec pollID 


ALTER TABLE `unnuke_autonews` ADD `pollID` INT(10) NOT NULL default '0';


//Do tabulky unnuke_stories přidáme slopec pollID 


ALTER TABLE `unnuke_stories` ADD `anid` INT(10) NOT NULL default '0';


function automated_news() {

if ($day < 10) {
$day = "0".$day;
}

/*if ($day < 10) {
$day = "0".$day;
}*/ /* IJVo */

if ($month < 10) {
$month = "0".$month;
}

/*if ($month < 10) {
$month = "0".$month;
}*/ /* IJVo */

$doUltramode = false;

$datetimeakt = (((($year * 100 + $month) * 100 + $day) * 100 + $hour) * 100 + $min); /* IJVo */

if (($date[1] <= $year) AND ($date[2] <= $month) AND ($date[3] <= $day)) {
if (($date[4] < $hour) AND ($date[5] >= $min) OR ($date[4] <= $hour) AND ($date[5] <= $min)) {

/*if (($date[1] <= $year) AND ($date[2] <= $month) AND ($date[3] <= $day)) {*/ /* IJVo */
/*if (($date[4] < $hour) AND ($date[5] >= $min) OR ($date[4] <= $hour) AND ($date[5] <= $min)) {*/ /* IJVo */
$datetime = (((($date[1] * 100 + $date[2]) * 100 + $date[3]) * 100 + $date[4]) * 100 + $date[5]); /* IJVo */
if ($datetime <= $datetimeakt) { /* IJVo */

$aid2 = $row2['aid'];

$anid2 = $row2['anid']; /* IJVo */

$associated2 = $row2['associated'];

$pollID2 = $row2['pollID']; /* IJVo */

$nresult = $db->sql_query("SELECT COUNT(*) AS numrows FROM ".UN_TABLENAME_STORIES." WHERE title='".$title."' ".$querylang2);

/*$nresult = $db->sql_query("SELECT COUNT(*) AS numrows FROM ".UN_TABLENAME_STORIES." WHERE title='".$title."' ".$querylang2);*/
$nresult = $db->sql_query("SELECT COUNT(*) AS numrows FROM ".UN_TABLENAME_STORIES." WHERE anid='".$anid."'' ".$querylang2);
/* IJVo Tato uprava testuje hodnotu indexu anid ze souboru UN_TABLENAME_AUTONEWS a tím zajistí aby větu současně nepřidali dva uživatelé současným spuštěním funkce automated_news(). Tím že se neestuje pole title, je zároveň umožněno naplánovat článek s titulkem, který již existuje. */ 



if ($num == 0) {
$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTONEWS." WHERE anid='".$anid."'");
$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid2."', '".$aid2."', '".$title."', '".$time2."', '".$hometext."', '".$bodytext."', '0', '0', '".$topic2."', '".$informant2."', '".$notes."', '".$ihome2."', '".$alanguage2."', '".$acomm2."', '0', '0', '0', '0', '0', '".$associated2."')");
$doUltramode = true;
}
}
$db->sql_freeresult($result2);
}




if ($num == 0) {
if ($pollID2 == 0) {
$haspoll = 0;
$id = 0;
if($db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid2."', '".$aid2."', '".$title."', '".$time2."', '".$hometext."', '".$bodytext."', '0', '0', '".$topic2."', '".$informant2."', '".$notes."', '".$ihome2."', '".$alanguage2."', '".$acomm2."', '0', '0', '0', '0', '0', '".$associated2."', '0')")) {
$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTONEWS." WHERE anid='".$anid."'");
$doUltramode = true;
};
} else {


/* IJVo */ /* Zacatek Preneseni ankety */
$oresult3 = $db->sql_query("SELECT * FROM ".UN_TABLENAME_AUTOPOLL_DESC." WHERE pollID='".$pollID2."'"); /* IJVo */

while ($row3 = $db->sql_fetchrow($oresult3)) {


$pollID3 = $row3['pollID'];
$pollTitle3 = $row3['pollTitle'];
$timeStamp3 = $row3['timeStamp'];
$voters3 = $row3['voters'];
$planguage3 = $row3['planguage'];
$artid3 = $row3['artid'];
$comments3 = $row3['comments'];
$haspoll = 1;
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_POLL_DESC." VALUES (NULL, '".$pollTitle3."', '".$timeStamp3."', '".$voters3."', '".$alanguage3."', '".$artid3."', '".$comments3."')")) {
return;
}


$oresult5 = $db->sql_query("SELECT pollID FROM ".UN_TABLENAME_POLL_DESC." WHERE pollTitle='".$pollTitle3."' AND timeStamp='".$timeStamp3."'");
$object = $db->sql_fetchrow($oresult5);
$db->sql_freeresult($oresult5);
$id = $object['pollID'];


$oresult4 = $db->sql_query("SELECT * FROM ".UN_TABLENAME_AUTOPOLL_DATA." WHERE pollID='".$pollID3."'");
while ($row4 = $db->sql_fetchrow($oresult4)) {
$pollID4 = $id;
$optionText4 = $row4['optionText'];
$optionCount4 = 0;
$voteID4 = $row4['voteID'];
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_POLL_DATA." (pollID, optionText, optionCount, voteID) VALUES ('".$pollID4."', '".$optionText4."', '0', '".$voteID4."')")) {
return;
}
}
$db->sql_freeresult($oresult4);
$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTOPOLL_DATA." WHERE pollID='".$pollID3."'");

if($db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid2."', '".$aid2."', '".$title."', '".$time2."', '".$hometext."', '".$bodytext."', '0', '0', '".$topic2."', '".$informant2."', '".$notes."', '".$ihome2."', '".$alanguage2."', '".$acomm2."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated2."', '".$anid2."')")) {
$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTONEWS." WHERE anid='".$anid."'");
$doUltramode = true;
};


$oresult6 = $db->sql_query("SELECT sid FROM ".UN_TABLENAME_STORIES." WHERE anid='".$anid."' ORDER BY time DESC LIMIT 0,1");
$row = $db->sql_fetchrow($oresult6);
$db->sql_freeresult($oresult6);
$artid = $row['sid'];
$db->sql_query("UPDATE ".UN_TABLENAME_POLL_DESC." SET artid='".$artid."' WHERE pollID='".$id."'");
if (!$result) {
exit();
}
}
$db->sql_freeresult($oresult3);
/*$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTOPOLL_DESC." WHERE artid='".$anid."'");*/
$db->sql_query("DELETE FROM ".UN_TABLENAME_AUTOPOLL_DESC." WHERE pollID='".$pollID2."'"); /* IJVo */


/* IJVo */ /* Konec Preneseni ankety */
}
}
}
$db->sql_freeresult($result2);
/*}*/ /* IJVo */ 


$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."')");



/* IJVo PlanClanku */ 
/*$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."')");*/
if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
$haspoll = 1;
$timeStamp = time();
$pollTitle = FixQuotes($pollTitle);
$pollTitle = addslashes(stripslashes(check_html($pollTitle, "nohtml")));
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_AUTOPOLL_DESC." VALUES (NULL, '".$pollTitle."', '".$timeStamp."', '0', '".$alanguage."', '0', '0')")) {
return;
}
$ores = $db->sql_query("SELECT pollID FROM ".UN_TABLENAME_AUTOPOLL_DESC." WHERE pollTitle='".$pollTitle."'");
$object = $db->sql_fetchrow($ores);
$db->sql_freeresult($ores);
$id = $object['pollID'];
for($i = 1; $i <= sizeof($optionText); $i++) {
if($optionText[$i] != "") {
$optionText[$i] = FixQuotes($optionText[$i]);
$optionText[$i] = addslashes(stripslashes(check_html($optionText[$i], "nohtml")));
}
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_AUTOPOLL_DATA." (pollID, optionText, optionCount, voteID) VALUES ('".$id."', '".$optionText[$i]."', '0', '".$i."')")) {
return;
}
}
$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."', '".$id."')");
} else {
$haspoll = 0;
$id = 0;
$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."', '0')");
} 


$result = $db->sql_query("SELECT anid FROM ".UN_TABLENAME_AUTONEWS." WHERE title='".$subject."' ORDER BY time DESC LIMIT 0,1");
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$artid = $row['anid'];
$db->sql_query("UPDATE ".UN_TABLENAME_AUTOPOLL_DESC." SET artid='".$artid."' WHERE pollID='".$id."'");
/* IJVo PlanClanku */


$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."')");

/* IJVo PlanClanku */
/*$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."')");*/
$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."', '0')");
/* IJVo PlanClanku */

$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."')");



/* IJVo PlanClanku */
/*$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."')");*/
if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
$haspoll = 1;
$timeStamp = time();
$pollTitle = FixQuotes($pollTitle);
$pollTitle = addslashes(stripslashes(check_html($pollTitle, "nohtml")));
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_AUTOPOLL_DESC." VALUES (NULL, '".$pollTitle."', '".$timeStamp."', '0', '".$alanguage."', '0', '0')")) {
return;
}
$oresult = $db->sql_query("SELECT pollID FROM ".UN_TABLENAME_AUTOPOLL_DESC." WHERE pollTitle='".$pollTitle."'");
$object = $db->sql_fetchrow($oresult);
$db->sql_freeresult($oresult);
$id = $object['pollID'];
for($i = 1; $i <= sizeof($optionText); $i++) {
if($optionText[$i] != "") {
$optionText[$i] = FixQuotes($optionText[$i]);
$optionText[$i] = addslashes(stripslashes(check_html($optionText[$i], "nohtml")));
}
if(!$db->sql_query("INSERT INTO ".UN_TABLENAME_AUTOPOLL_DATA." (pollID, optionText, optionCount, voteID) VALUES ('".$id."', '".$optionText[$i]."', '0', '".$i."')")) {
return;
}
}
} else {
$haspoll = 0;
$id = 0;
}
$result = $db->sql_query("INSERT INTO ".UN_TABLENAME_AUTONEWS." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', '".$date."', '".$hometext."', '".$bodytext."', '".$topic."', '".$author."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$associated."', '".$id."')");
$result = $db->sql_query("SELECT anid FROM ".UN_TABLENAME_AUTONEWS." WHERE title='".$subject."' ORDER BY time DESC LIMIT 0,1");
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$artid = $row['anid'];
$db->sql_query("UPDATE ".UN_TABLENAME_POLL_DESC." SET artid='".$artid."' WHERE pollID='".$id."'");
/* IJVo PlanClanku */


$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$aid."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."')");

/* IJVo PlanClanku */
/*$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$aid."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."')");*/
$db->sql_query("INSERT INTO ".UN_TABLENAME_STORIES." VALUES (NULL, '".$catid."', '".$aid."', '".$subject."', now(), '".$hometext."', '".$bodytext."', '0', '0', '".$topic."', '".$aid."', '".$notes."', '".$ihome."', '".$alanguage."', '".$acomm."', '".$haspoll."', '".$id."', '0', '0', '0', '".$associated."', '0')");
/* IJVo PlanClanku */ 



Obsah fóra BLASSENweb » Rady a porady - ostatní
|
|