inserito sistema di redirect per vecchie notizie indicizzate

This commit is contained in:
Riccardo Di Dato
2016-04-19 12:31:05 +02:00
parent a82dfff95e
commit 46aaf34659
2 changed files with 27 additions and 12 deletions
+6 -12
View File
@@ -11,7 +11,6 @@ $pdo = new PDO("mysql:host=localhost;dbname=fdn_old","root","root",array(PDO::MY
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$count = 0;
// $statement = $pdo->query("select * from notizia order by id desc limit $count,100");
$statement = $pdo->query("select * from notizia order by id desc limit $count,100");
$dati = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
@@ -25,24 +24,19 @@ while (is_array($dati) && sizeof($dati)>0){
$notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("titolo"=>htmlspecialchars_decode($ele->mainTitle)));
}
if (is_null($notizia)){
var_dump($ele);
}
if (!is_null($notizia)){
// $notizia->oldId = $ele->id;
$notizia->oldId = intval($ele->id);
// GlobalVariables::get("dao")->save($notizia);
GlobalVariables::get("dao")->save($notizia);
}
else {
echo $ele->id."\n";
echo "Failed id ". $ele->id."\n";
}
}
$dati = array();
// $count+=100;
// $statement = $pdo->query("select * from notizia order by id desc limit $count,100");
// $dati = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
$count+=100;
$statement = $pdo->query("select * from notizia order by id desc limit $count,100");
$dati = $statement->fetchALL(PDO::FETCH_CLASS,"stdClass");
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 19/apr/2016
*/
require_once(dirname(__FILE__)."/load.php");
if (array_key_exists("id", $_GET)){
$id = intval($_GET["id"]);
$notizia = $notizia = GlobalVariables::get("dao")->getFirst("NotiziaModel",array("oldId"=>$id));
if (!is_null($notizia)){
GUIHandler::redirect("articolo.php?id=".$notizia->id);
}
else {
echo "asd";
}
}
?>