| Voir le sujet précédent
:: Voir le sujet suivant
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Jeu Juil 21, 2005 7:33 am Sujet du message:
[Resolu]Google news phpnuke |
|
|
|
Bonjour !
Tout d abord bravo pour le site qui est clair, précis et tres fonctionnel !
Voila j aimerais savoir comment le webmaster a fait (exactement) pour installer le GOOGLE NEWS sur ce site !
J ai essaye sur mon site mais rien a faire cela ne fonctionne pas ! J ai pourtant bien suivi les etapes mais cela ne fonctionne pas !
As tu creer un module?
Je suis un peu novice en php, et , j aimerais que tu m aides si cela est possible !
Voilou !
Dernière édition par nicolium le Jeu Aoû 04, 2005 8:40 am; édité 1 fois |
|
| Revenir en haut de page |
|
|
mumulafrite
Administrateur


Inscrit le: 01 Jan 1970
Messages: 1260
Localisation: Marseille
|
Posté le:
Jeu Juil 21, 2005 9:23 am Sujet du message:
|
|
|
|
Bonjour,
Bon promis je regarde ca car cela fait longtemps que je l'ai installé je me souvient plus du tout
Voit ce post http://www.webfolie.com/ftopict-221.html
Si c'est pas ca je te dirais _________________
 |
|
| Revenir en haut de page |
|
|
Sorcier
Modérateur


Inscrit le: 01 Jan 1970
Messages: 314
Localisation: Sur Graphizone et Webfolie
|
Posté le:
Jeu Juil 21, 2005 1:10 pm Sujet du message:
|
|
|
|
un de plus qui va pas recevoir ces sous :P  _________________
 |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Jeu Juil 21, 2005 7:22 pm Sujet du message:
|
|
|
|
oki !
J ai regardé le topic mais les zip sont corrompus !
J ai exactement les memes erreurs ! |
|
| Revenir en haut de page |
|
|
mumulafrite
Administrateur


Inscrit le: 01 Jan 1970
Messages: 1260
Localisation: Marseille
|
Posté le:
Jeu Juil 21, 2005 10:25 pm Sujet du message:
|
|
|
|
Bon alors reprenons, jai téléchargé le bloc et as tu bien suivis l'install:
Citation: 1.) Unzip googlenews.zip to your PHPNuke root directory, or unzip it
locally and copy the contents there.
2.) Run the googlenews.sql file on your database like so:
# mysql -u <user> -p <pass> <dbname> < googlenews.sql
or use your favorite sql client to the same effect.
3.) In blocks/Google-blockcode.php select your country on line 12
4.) Go to your site's admin.php and click "Google News" to configure your
blocks, then click on "Blocks" in admin.php and add them to your site.
5.) (by ckforum)
Create the dir cache named "cache" form root dir with 777 atribute !
Ensuite remplace le fichier Google-blockcode.php par ceci:
<?php
/****************************************/
/* Google News block code by CPHDesign */
/* Copyright 2004 CPHDesign.com */
/****************************************/
/********************************************************
Just a little contribution with this good idea
from CPHDesign by ckforum from http://www.ckforum.com
last update : 21/08/2004 01:09
mod release : ckforum_03
- the modifications @ 16/03/2004 02:08 are :
- create a little class for create block content
- create the blocks news cache
- define a method to get the content of file
because not the same method with php under 4.3 version
- info next time update cache for admin
- somes cosmetics
- correct slq file header
For the cache dir you need to set it with 777 attribute !
just see below for special setting (country news, dir cache, etc...)
********************************************************/
if (eregi("Google-blockcode.php", $_SERVER['PHP_SELF'])) {
Header("Location:../index.php");
die();
}
//global $act_but;
class NewBlock
{
var $blockname ='';
var $rebuild ='';
var $CACHE_FILE ='';
function NewBlock()
{
$this->blockname = '' ;
}
function CreatecontentBlock()
{
return $this->getGoogleNews() ;
}
function getGoogleNews() {
$blockname=$this->blockname;
// Main fonction
global $prefix,$db,$admin,$act_but;
/***********************Settings !*****************************************************************/
// country code is here for now, will move to DB
$country='fr/fr'; // Country Codes
// en/au = Austrailia
// en/ca = Canada
// fr/fr = France
// de/de = Deutschland
// en/in = India
// it/it = Italia
// en/nz = New Zealand
// es/es = Espana
// en/uk = UK
// en/us = USA
$cachegnews_dir ="cache"; // Cache dir from root without "/" at the end
$time_expir_cache = 43200 ; // 86400 = 1 day
$url_google_news = "http://news.google.com/news"; // Url google news without "/" at the end
// over original size change the value or add "//" if you want to keep the original image's size
// $img_over_size = "height=\"60\" width=\"65\"";
// Only cosmetic shadows picture delete if u don't whant it (only for IE)
$ombrepic = " onload=this.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction=135,strength=5)'";
/*************************End settings ************************************************************/
// load this block's setting from DB (set by admin/modules/googlenews.php)
$result = $db->sql_query("SELECT category,itemnum,blurb,pic from ".$prefix."_googlenews where blockname='$blockname'", $dbi);
list($category,$itemnum,$blurb,$pic) = $db->sql_fetchrow($result, $dbi);
// default category for now, should also be in DB
if (!$category) $category = 'world';
$CACHE_FILE = "$cachegnews_dir/block-G_news_".$category."_".$this->blockname.".cache";
$CACHE_EXPIRED = $time_expir_cache;
// Check the cache file to see if it's up to date
$rebuild = 1;
if (file_exists($CACHE_FILE)) {
$stat = stat($CACHE_FILE);
$mtime = $stat[9];
if (time() - $mtime < $CACHE_EXPIRED) {
$rebuild = 0;
}
}
if ($rebuild) {
// we call and parse the file from the url google news
$news = $this->Getnewsformgoogle($country,$category,$url_google_news,$CACHE_FILE);
} else {
// we call the file from cache !
$news = $this->methodget($CACHE_FILE) ;
}
// the fields in each story to be matched, in order of () matches in regex
$fields = array('piclink','picid1','picsrc','picw','pich','picsource','link','picid2','title','source','timeago','story');
// now for the actual matching
if ($news) { // add for no fatal error !
// last modification 21/08/2004 01:10
preg_match_all(
'|<a href="([^ ]+)" id=([^ ]+)><img src=([^ ]+) width=(\d+) height=(\d+) alt="" border=1><br><font size=-2>([^<]+)</font></a></td><td valign=top><a href="([^"]+)" id=([^ ]+)><b>([^<]+)<\/b><\/a><br><font size=-1><font color=#6f6f6f><b>([^&]+) ;;-<\/font> <nobr>([^<]+)</nobr></b></font><br><font size=-1>([^<]+)|',
$news, $matches, PREG_SET_ORDER);
// now we assign our matches to the $stories array
foreach ($matches as $match) {
$count = 1; $story = array();
foreach ($fields as $field) {
$story[$field] = $match[$count]; $count++;
}
$story[link] =
urldecode(
preg_replace('/^\/url\?ntc=[^\&]+\&q=/', '', $story[link])
);
$story[picsrc] = '' . $story[picsrc];
$stories[] = $story;
}
// build $content from $stories array
$content = '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
if ($stories) { // check if $stories is not empty
foreach ($stories as $story) {
$items++;
// if $blurb of text then left justify, otherwise center
$checktimeago= explode (" ", $story[timeago]);
$checktimeagob=ereg_replace("[^0-9]","",$checktimeago[0]);
$addhour = "today's news";
if ($checktimeagob>0){ $cktimeago="$story[timeago]"; } else {$cktimeago="$addhour, cached since : ".$this->calcul_hours(time()-($mtime))."";}
if ($blurb) {
$img = $pic ? "<img src='$story[picsrc]' align='left' border=0 $ombrepic $img_over_size title=\"$story[title]\">"
: "";
$content .= "<tr><td><br><a href='$story[link]' target='_blank'>$img<b>$story[title]</b></a><br><span class='content'>$story[source], <i>$cktimeago</i> </span><br>$story[story]<br></td></tr>";
} else {
$img = $pic ? "<img src='$story[picsrc]' border=0 $ombrepic $img_over_size title=\"$story[title]\">" : "";
$content .= "<tr><td align='center'><a href='$story[link]' target='_blank'>$img<br><b>$story[title]</b></a><br><span class='tiny'>$story[source], $cktimeago</span><br></td></tr>";
}
// stop at max items, do all if set to 0
if ($items == $itemnum) break;
} // fin de foreach
} else {
$content .= "No news with picture here! \n";
}
if (is_admin($admin)) $infomaj = "<center><p>Last Upd : ".$this->formatdate($mtime,$format = 'd M Y @ H:i')."<b> Next Upd</b> : ".$this->formatdate(($mtime+$CACHE_EXPIRED),$format = 'd M Y @ H:i')." is in : ".$this->calcul_hours(($mtime + $CACHE_EXPIRED) - time())."</center> ".$this->delete_cache_conf($blockname,$cachegnews_dir,$category,$act_but);
$content .= '</table><hr><div align="right">Google <a href="'.$url_google_news.'/'.$country.'/'.$category.'.html" target="_blank">'.$category.'</a></div> '.$infomaj.'';
} // end if $news !
return $content;
}
function delete_cache_conf($whatblockname,$cachegnews_dir,$category,$act_but) {
// Delete all cache block selected !
$DIR_DEL = "$cachegnews_dir/";
$FILESTODEL = "block-G_news_*_".$this->blockname.".cache";
if (!$act_but or $act_but!=$whatblockname) {
$cretefrm_del = "<center><br> ";
$cretefrm_del .= "<form name=\"del_conf_$whatblockname\" method=\"post\" action=\"index.php\" >";
$cretefrm_del .= "<input type=\"submit\" name=\"but_del\" Value=\"Reload Cache\" Onclick=\"if (confirm('Êtes-vous sûr de vouloir supprimer le cache du $whatblockname')){this.form.act_but.value='$whatblockname'; return true;}else {this.form.act_but.value='$whatblockname';return false;}\">";
$cretefrm_del .= "<br><input type=\"hidden\" name=\"act_but\" id=\"act_but\" Value=\"$act_but\">";
$cretefrm_del .= "</form>";
$cretefrm_del .= "this action will delete all $whatblockname's cache";
$cretefrm_del .= "</center>";
} elseif ($act_but and $act_but==$whatblockname) {
$this->unlink_wc($DIR_DEL, $FILESTODEL);
$cretefrm_del .= "<br> Cache delete !";
header("location:index.php");
}
return $cretefrm_del;
}
function Getnewsformgoogle($country,$category,$url_google_news,$CACHE_FILE) {
$thefile="$url_google_news/$country/$category.html";
$news = $this->methodget($thefile);
// we save result to a cache file
$news_cache_ok = $this->saveCache($news,$CACHE_FILE);
return $news_cache_ok;
}
function saveCache($news,$CACHE_FILE) {
// Save content from url file to cache file and return content
$get_news = $news;
if ($fd = fopen($CACHE_FILE, "w")) {
fwrite($fd, "$get_news");
fclose($fd);
}
$news_save_ok=$get_news;
return $news_save_ok;
}
function readCache($CACHE_FILE) {
// Just read the cache file and return content!
if ($fd = fopen($CACHE_FILE, "r")) {
fclose($fd);
return $CACHE_FILE;
}
}
function methodget($thefile) {
// try to force "allow_url_fopen" if the function is not disabled by host admin
$check_allow_url_fopen =ini_get("allow_url_fopen");
if (!$check_allow_url_fopen) {
ini_set("allow_url_fopen","1");
$check_allow_url_fopen = ini_get("allow_url_fopen");
}
// to prevent
if ($check_allow_url_fopen==1) {
// do get the content of file
// define the method to get content file (php version check) and return the content
$phpver_gnews= phpversion();
if ($phpver_gnews < '4.3') {
$fd = fopen ($thefile, "r");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
$contnews .= $buffer;
}
fclose ($fd);
} else {
$contnews = file_get_contents($thefile);
}
return $contnews;
} else {
echo "Sorry ! get external url is not enable ! uninstall the google news block ! ";
$contnews="";
return $contnews;
// or could be die(); here
}
} // end function
function formatdate($date,$format = 'l d F Y @ H:i')
//$date=formatdate(time(), "votre chaine de formatage"); // applique un formatage perso
//
//ou
//
//$date=formatdate(time()); // applique le formatage par defaut
{
for ( $n = 0; $n <= strlen($format); $n++ )
{
switch($format[$n])
{
case ' ':
$dateformat .= ' ';
break;
case 'l': // jour format complet
$in = array('|Monday|', '|Tuesday|', '|Wednesday|',
'|Thursday|', '|Friday|', '|Saturday|',
'|Sunday|');
$out = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi',
'Vendredi', 'Samedi', 'Dimanche' );
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'D': // jour format 3
$in = array('|Mon|', '|Tue|', '|Wed|', '|Thu|', '|Fri|',
'|Sat|', '|Sun|');
$out = array('Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'F': // mois format complet
$in = array('|January|', '|February|', '|March|', '|April|',
'|May|', '|June|', '|July|', '|August|',
'|September|', '|October|', '|November|',
'|December|' );
$out = array('Janvier', 'Février', 'Mars', 'Avril', 'Mai',
'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre',
'Novembre', 'Décembre');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'M': // mois format 3
$in = array('|Jan|', '|Feb|', '|Mar|', '|Apr|', '|May|',
'|Jun|', '|Jul|', '|Aug|', '|Sep|', '|Oct|', '|Nov|',
'|Dec|');
$out = array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jui', 'Jui',
'Aoû', 'Sep', 'Oct','Nov', 'Déc');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
default :
$dateformat .= date($format[$n],$date);
break;
}
}
return $dateformat;
}
function calcul_hours($temps)
{
//combien d'heures ?
$hours = floor($temps / 3600);
//combien de minutes ?
$min = floor(($temps - ($hours * 3600)) / 60);
if ($min < 10)
$min = "0".$min;
//combien de secondes
$sec = $temps - ($hours * 3600) - ($min * 60);
if ($sec < 10)
$sec = "0".$sec;
return $hours." h ".$min." m ".$sec." s ";
}
function unlink_wc($dir, $pattern){
if ($dh = opendir($dir)) {
//List and put into an array all files
while (false !== ($file = readdir($dh))){
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($dh);
//Split file name and extenssion
if(strpos($pattern,".")) {
$baseexp=substr($pattern,0,strpos($pattern,"."));
$typeexp=substr($pattern,strpos($pattern,".")+1,strlen($pattern));
}else{
$baseexp=$pattern;
$typeexp="";
}
//Escape all regexp Characters
$baseexp=preg_quote($baseexp);
$typeexp=preg_quote($typeexp);
// Allow ? and *
$baseexp=str_replace(array("\*","\?"), array(".*","."), $baseexp);
$typeexp=str_replace(array("\*","\?"), array(".*","."), $typeexp);
//Search for pattern match
$i=0;
foreach($files as $file) {
$filename=basename($file);
if(strpos($filename,".")) {
$base=substr($filename,0,strpos($filename,"."));
$type=substr($filename,strpos($filename,".")+1,strlen($filename));
}else{
$base=$filename;
$type="";
}
if(preg_match("/^".$baseexp."$/i",$base) && preg_match("/^".$typeexp."$/i",$type)) {
$matches[$i]=$file;
$i++;
}
}
while(list($idx,$val) = each($matches)){
if (substr($dir,-1) == "/"){
unlink($dir.$val);
}else{
unlink($dir."/".$val);
}
}
}
}
} // Fin de class
?>
Si cela ne marche pas donne nous une adresse pour que je vois ca ou donne nous le message d'erreur _________________
 |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Ven Juil 22, 2005 8:44 am Sujet du message:
|
|
|
|
J ai essayé mais cela ne marche toujours pas!
Peut etre parce que c est en page d accueil , j ai vu que tu avais fait ca sur une autre page ! Je te passe mon adresse ouebi
a++ |
|
| Revenir en haut de page |
|
|
mumulafrite
Administrateur


Inscrit le: 01 Jan 1970
Messages: 1260
Localisation: Marseille
|
Posté le:
Ven Juil 22, 2005 12:21 pm Sujet du message:
|
|
|
|
tu as bien mis un dossier cache sur le root de ton site en ayant bien mis le chmod en 777
Bizzare que ca marche pas j'ai pas le souvenir d'avoir eu des problemes _________________
 |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Ven Juil 22, 2005 12:21 pm Sujet du message:
|
|
|
|
oui |
|
| Revenir en haut de page |
|
|
mumulafrite
Administrateur


Inscrit le: 01 Jan 1970
Messages: 1260
Localisation: Marseille
|
Posté le:
Ven Juil 22, 2005 12:28 pm Sujet du message:
|
|
|
|
Et si tu mets des news sans images cela marche toujours pas?
Tu as reloader le cache? _________________
 |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Ven Juil 22, 2005 12:31 pm Sujet du message:
|
|
|
|
c fait mais cela ne marche toujours pas |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Mar Aoû 02, 2005 3:44 pm Sujet du message:
|
|
|
|
« nicolium » a écrit: c fait mais cela ne marche toujours pas
Bonjour !
Je viens d installer platinium et j ai encore réessayé de l installer mais c est tjrs pareil ! Cela ne marche pas !
En fait ca n apparait qu en bloc ! Est ce que cela devrait créer un module parceque cela ne le fait pas !
Jsuis perdu la ! J ai cherche partout et rien a faire !
a l aide svp
Citation: Google Block1
No news with picture here!
--------------------------------------------------------------------------------
Google world
Last Upd : 02 Aoû 2005 @ 15:37 Next Upd : 03 Aoû 2005 @ 03:37 is in : 11 h 48 m 25 s
this action will delete all Block1's cache |
|
| Revenir en haut de page |
|
|
mumulafrite
Administrateur


Inscrit le: 01 Jan 1970
Messages: 1260
Localisation: Marseille
|
Posté le:
Mer Aoû 03, 2005 7:19 pm Sujet du message:
|
|
|
|
Bon alors deja, google news ne fonctionne qu'en bloc pour la version téléchargeable, mais apres pourquoi cela ne fonctionne pas c'est bizzare, jai ete sur sur le forum de nuke europe et je vois que le systeme marche quand le patch de ckforum est mis ( suivre ce lien) ensuite pour avoir la version sur module allez sur le forum du même site. Par contre je sais pas si cela fonctionne sous nuke platinium je n'ai jamais tester ce CMS _________________
 |
|
| Revenir en haut de page |
|
|
nicolium
Nouveau


Inscrit le: 01 Jan 1970
Messages: 7
|
Posté le:
Jeu Aoû 04, 2005 8:39 am Sujet du message:
|
|
|
|
salut !
Merci je semble qu on est sur la bonne voie maintenant !
Donc tout s affiche correctement !
Le google block c est celui ci
<?php
/****************************************/
/* Google News block code by CPHDesign */
/* Copyright 2004 CPHDesign.com */
/****************************************/
/********************************************************
Just a little contribution with this good idea
from CPHDesign by ckforum from http://www.ckforum.com
last update : 09/01/2005 12:42
mod release : ckforum_03
- the modifications @ 16/03/2004 02:08 are :
- create a little class for create block content
- create the blocks news cache
- define a method to get the content of file
because not the same method with php under 4.3 version
- info next time update cache for admin
- somes cosmetics
- correct slq file header
For the cache dir you need to set it with 777 attribute !
just see below for special setting (country news, dir cache, etc...)
********************************************************/
if (eregi("Google-blockcode.php", $_SERVER['PHP_SELF'])) {
Header("Location:../index.php");
die();
}
//global $act_but;
class NewBlock
{
var $blockname ='';
var $rebuild ='';
var $CACHE_FILE ='';
function NewBlock()
{
$this->blockname = '' ;
}
function CreatecontentBlock()
{
return $this->getGoogleNews() ;
}
function getGoogleNews() {
$blockname=$this->blockname;
// Main fonction
global $prefix,$db,$admin,$act_but;
/***********************Settings !*****************************************************************/
// country code is here for now, will move to DB
$country='fr/fr'; // Country Codes
// en/au = Austrailia
// en/ca = Canada
// fr/fr = France
// de/de = Deutschland
// en/in = India
// it/it = Italia
// en/nz = New Zealand
// es/es = Espana
// en/uk = UK
// en/us = USA
$cachegnews_dir ="cache"; // Cache dir from root without "/" at the end
$time_expir_cache = 43200 ; // 86400 = 1 day
$url_google_news = "http://news.google.com/news"; // Url google news without "/" at the end
// over original size change the value or add "//" if you want to keep the original image's size
// $img_over_size = "height=\"60\" width=\"65\"";
// Only cosmetic shadows picture delete if u don't whant it (only for IE)
$ombrepic = " onload=this.style.filter='progid:DXImageTransform.Microsoft.Shadow(color=#000000,direction=135,strength=5)'";
/*************************End settings ************************************************************/
// load this block's setting from DB (set by admin/modules/googlenews.php)
$result = $db->sql_query("SELECT category,itemnum,blurb,pic from ".$prefix."_googlenews where blockname='$blockname'");
list($category,$itemnum,$blurb,$pic) = $db->sql_fetchrow($result);
// default category for now, should also be in DB
if (!$category) $category = 'world';
$CACHE_FILE = "$cachegnews_dir/block-G_news_".$category."_".$this->blockname.".cache";
$CACHE_EXPIRED = $time_expir_cache;
// Check the cache file to see if it's up to date
$rebuild = 1;
if (file_exists($CACHE_FILE)) {
$stat = stat($CACHE_FILE);
$mtime = $stat[9];
if (time() - $mtime < $CACHE_EXPIRED) {
$rebuild = 0;
}
}
if ($rebuild) {
// we call and parse the file from the url google news
$news = $this->Getnewsformgoogle($country,$category,$url_google_news,$CACHE_FILE);
} else {
// we call the file from cache !
$news = $this->methodget($CACHE_FILE) ;
}
// the fields in each story to be matched, in order of () matches in regex
$fields = array('piclink','picid1','picsrc','picw','pich','picsource','link','picid2','title','source','timeago','story');
// now for the actual matching
if ($news) { // add for no fatal error !
// last modification 21/08/2004 01:10
preg_match_all(
'|<a href="([^ ]+)" id=([^ ]+)><img src=([^ ]+) width=(\d+) height=(\d+) alt="" border=1><br><font size=-2>([^<]+)</font></a></td><td valign=top><a href="([^"]+)" id=([^ ]+)><b>([^<]+)<\/b><\/a><br><font size=-1><font color=#6f6f6f><b>([^&]+) -<\/font> <nobr>([^<]+)</nobr></b></font><br><font size=-1>([^<]+)|',
$news, $matches, PREG_SET_ORDER);
// now we assign our matches to the $stories array
foreach ($matches as $match) {
$count = 1; $story = array();
foreach ($fields as $field) {
$story[$field] = $match[$count]; $count++;
}
$story[link] =
urldecode(
preg_replace('/^\/url\?ntc=[^\&]+\&q=/', '', $story[link])
);
$story[picsrc] = '' . $story[picsrc];
$stories[] = $story;
}
// build $content from $stories array
$content = '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
if ($stories) { // check if $stories is not empty
foreach ($stories as $story) {
$items++;
// if $blurb of text then left justify, otherwise center
$checktimeago= explode (" ", $story[timeago]);
$checktimeagob=ereg_replace("[^0-9]","",$checktimeago[0]);
$addhour = "today's news";
if ($checktimeagob>0){ $cktimeago="$story[timeago]"; } else {$cktimeago="$addhour, cached since : ".$this->calcul_hours(time()-($mtime))."";}
if ($blurb) {
$img = $pic ? "<img src='$story[picsrc]' align='left' border=0 $ombrepic $img_over_size title=\"$story[title]\">"
: "";
$content .= "<tr><td><br><a href='$story[link]' target='_blank'>$img<b>$story[title]</b></a><br><span class='content'>$story[source], <i>$cktimeago</i> </span><br>$story[story]<br></td></tr>";
} else {
$img = $pic ? "<img src='$story[picsrc]' border=0 $ombrepic $img_over_size title=\"$story[title]\">" : "";
$content .= "<tr><td align='center'><a href='$story[link]' target='_blank'>$img<br><b>$story[title]</b></a><br><span class='tiny'>$story[source], $cktimeago</span><br></td></tr>";
}
// stop at max items, do all if set to 0
if ($items == $itemnum) break;
} // fin de foreach
} else {
$content .= "No news with picture here! \n";
}
if (is_admin($admin)) $infomaj = "<center><p>Last Upd : ".$this->formatdate($mtime,$format = 'd M Y @ H:i')."<b> Next Upd</b> : ".$this->formatdate(($mtime+$CACHE_EXPIRED),$format = 'd M Y @ H:i')." is in : ".$this->calcul_hours(($mtime + $CACHE_EXPIRED) - time())."</center> ".$this->delete_cache_conf($blockname,$cachegnews_dir,$category,$act_but);
$content .= '</table><hr><div align="right">Google <a href="'.$url_google_news.'/'.$country.'/'.$category.'.html" target="_blank">'.$category.'</a></div> '.$infomaj.'';
} // end if $news !
return $content;
}
function delete_cache_conf($whatblockname,$cachegnews_dir,$category,$act_but) {
// Delete all cache block selected !
$DIR_DEL = "$cachegnews_dir/";
$FILESTODEL = "block-G_news_*_".$this->blockname.".cache";
if (!$act_but or $act_but!=$whatblockname) {
$cretefrm_del = "<center><br> ";
$cretefrm_del .= "<form name=\"del_conf_$whatblockname\" method=\"post\" action=\"index.php\" >";
$cretefrm_del .= "<input type=\"submit\" name=\"but_del\" Value=\"Reload Cache\" Onclick=\"if (confirm('Êtes-vous sûr de vouloir supprimer le cache du $whatblockname')){this.form.act_but.value='$whatblockname'; return true;}else {this.form.act_but.value='$whatblockname';return false;}\">";
$cretefrm_del .= "<br><input type=\"hidden\" name=\"act_but\" id=\"act_but\" Value=\"$act_but\">";
$cretefrm_del .= "</form>";
$cretefrm_del .= "this action will delete all $whatblockname's cache";
$cretefrm_del .= "</center>";
} elseif ($act_but and $act_but==$whatblockname) {
$this->unlink_wc($DIR_DEL, $FILESTODEL);
$cretefrm_del .= "<br> Cache delete !";
header("location:index.php");
}
return $cretefrm_del;
}
function Getnewsformgoogle($country,$category,$url_google_news,$CACHE_FILE) {
$thefile="$url_google_news/$country/$category.html";
$news = $this->methodget($thefile);
// we save result to a cache file
$news_cache_ok = $this->saveCache($news,$CACHE_FILE);
return $news_cache_ok;
}
function saveCache($news,$CACHE_FILE) {
// Save content from url file to cache file and return content
$get_news = $news;
if ($fd = fopen($CACHE_FILE, "w")) {
fwrite($fd, "$get_news");
fclose($fd);
}
$news_save_ok=$get_news;
return $news_save_ok;
}
function readCache($CACHE_FILE) {
// Just read the cache file and return content!
if ($fd = fopen($CACHE_FILE, "r")) {
fclose($fd);
return $CACHE_FILE;
}
}
function methodget($thefile) {
// try to force "allow_url_fopen" if the function is not disabled by host admin
$check_allow_url_fopen =ini_get("allow_url_fopen");
if (!$check_allow_url_fopen) {
ini_set("allow_url_fopen","1");
$check_allow_url_fopen = ini_get("allow_url_fopen");
}
// to prevent
if ($check_allow_url_fopen==1) {
// do get the content of file
// define the method to get content file (php version check) and return the content
$phpver_gnews= phpversion();
if ($phpver_gnews < '4.3') {
$fd = fopen ($thefile, "r");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
$contnews .= $buffer;
}
fclose ($fd);
} else {
$contnews = file_get_contents($thefile);
}
return $contnews;
} else {
echo "Sorry ! get external url is not enable ! uninstall the google news block ! ";
$contnews="";
return $contnews;
// or could be die(); here
}
} // end function
function formatdate($date,$format = 'l d F Y @ H:i')
//$date=formatdate(time(), "votre chaine de formatage"); // applique un formatage perso
//
//ou
//
//$date=formatdate(time()); // applique le formatage par defaut
{
for ( $n = 0; $n <= strlen($format); $n++ )
{
switch($format[$n])
{
case ' ':
$dateformat .= ' ';
break;
case 'l': // jour format complet
$in = array('|Monday|', '|Tuesday|', '|Wednesday|',
'|Thursday|', '|Friday|', '|Saturday|',
'|Sunday|');
$out = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi',
'Vendredi', 'Samedi', 'Dimanche' );
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'D': // jour format 3
$in = array('|Mon|', '|Tue|', '|Wed|', '|Thu|', '|Fri|',
'|Sat|', '|Sun|');
$out = array('Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'F': // mois format complet
$in = array('|January|', '|February|', '|March|', '|April|',
'|May|', '|June|', '|July|', '|August|',
'|September|', '|October|', '|November|',
'|December|' );
$out = array('Janvier', 'Février', 'Mars', 'Avril', 'Mai',
'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre',
'Novembre', 'Décembre');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
case 'M': // mois format 3
$in = array('|Jan|', '|Feb|', '|Mar|', '|Apr|', '|May|',
'|Jun|', '|Jul|', '|Aug|', '|Sep|', '|Oct|', '|Nov|',
'|Dec|');
$out = array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jui', 'Jui',
'Aoû', 'Sep', 'Oct','Nov', 'Déc');
$dateformat .= preg_replace($in,$out,date($format[$n],$date));
break;
default :
$dateformat .= date($format[$n],$date);
break;
}
}
return $dateformat;
}
function calcul_hours($temps)
{
//combien d'heures ?
$hours = floor($temps / 3600);
//combien de minutes ?
$min = floor(($temps - ($hours * 3600)) / 60);
if ($min < 10)
$min = "0".$min;
//combien de secondes
$sec = $temps - ($hours * 3600) - ($min * 60);
if ($sec < 10)
$sec = "0".$sec;
return $hours." h ".$min." m ".$sec." s ";
}
function unlink_wc($dir, $pattern){
if ($dh = opendir($dir)) {
//List and put into an array all files
while (false !== ($file = readdir($dh))){
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($dh);
//Split file name and extenssion
if(strpos($pattern,".")) {
$baseexp=substr($pattern,0,strpos($pattern,"."));
$typeexp=substr($pattern,strpos($pattern,".")+1,strlen($pattern));
}else{
$baseexp=$pattern;
$typeexp="";
}
//Escape all regexp Characters
$baseexp=preg_quote($baseexp);
$typeexp=preg_quote($typeexp);
// Allow ? and *
$baseexp=str_replace(array("\*","\?"), array(".*","."), $baseexp);
$typeexp=str_replace(array("\*","\?"), array(".*","."), $typeexp);
//Search for pattern match
$i=0;
foreach($files as $file) {
$filename=basename($file);
if(strpos($filename,".")) {
$base=substr($filename,0,strpos($filename,"."));
$type=substr($filename,strpos($filename,".")+1,strlen($filename));
}else{
$base=$filename;
$type="";
}
if(preg_match("/^".$baseexp."$/i",$base) && preg_match("/^".$typeexp."$/i",$type)) {
$matches[$i]=$file;
$i++;
}
}
while(list($idx,$val) = each($matches)){
if (substr($dir,-1) == "/"){
unlink($dir.$val);
}else{
unlink($dir."/".$val);
}
}
}
}
} // Fin de class
?>
Il me reste 2 ptits trucs à régler !
- J ai toujours cela en bas des blocs et j aimerais bien l effacer
Citation: Last Upd : 04 Aoû 2005 @ 08:06 Next Upd : 04 Aoû 2005 @ 20:06 is in : 11 h 28 m 16 s
this action will delete all Block2's cache
- Il ne s affichent qu en 1ere page et j aimerais bien créer comme toi un lien vers une autre page ! Je ne sais pas trop comment faire !
En tout cas merci de ton aide mumu !  |
|
| Revenir en haut de page |
|
|
|
|
|
Vous ne pouvez pas poster de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas voter dans les sondages de ce forum
|
|