[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: ViewRss.class.php 199 2007-01-17 18:17:11Z matthieu_ $ 11 12 require_once INCLUDE_PATH."/core/include/ViewModule.class.php"; 13 require_once INCLUDE_PATH."/core/include/PmvConfig.class.php"; 14 require_once INCLUDE_PATH."/libs/Cache/Lite.php"; 15 require_once INCLUDE_PATH."/core/views/ViewVisitsRss.class.php"; 16 require_once INCLUDE_PATH."/libs/Xml/Serializer.php"; 17 18 class ViewRss extends ViewModule 19 { 20 function ViewRss( ) 21 { 22 parent::ViewModule( '' ); 23 } 24 25 function showAll() 26 { 27 28 $idSite = getRequestVar('site', -1, 'int'); 29 if ($idSite == -1) { 30 $allSiteArchive = DataModel::getSites(); 31 } 32 else { 33 $allSiteArchive[] = new Site ($idSite); 34 } 35 36 $uniqCacheId = (DataModel::getSitesSignature() . date("Y-m-d") . serialize($_GET)) . '.rss'; 37 38 // Set a few options 39 $options = array( 40 'cacheDir' => DIR_CACHE_RSS, 41 'lifeTime' => CACHE_RSS_LIFETIME 42 ); 43 44 45 // Create a Cache_Lite object 46 $Cache_Lite = new Cache_Lite($options); 47 48 if(time() % 500 === 0) 49 { 50 $Cache_Lite->clean(); 51 } 52 53 // Test if thereis a valide cache for this id 54 if (SMARTY_DEBUG 55 || (!$allData = $Cache_Lite->get($uniqCacheId)) 56 ) 57 { 58 59 $dataTmp = $this->data; 60 61 $o_config =& PmvConfig::getInstance(); 62 63 $allItems = array(); 64 65 foreach($allSiteArchive as $id => $infoSite) 66 { 67 $allArchives = $dataTmp->getLastArchives(NB_DAYS_FOR_RSS_ITEMS, 0, DATE_NORMAL, $infoSite); 68 69 $i = 0; 70 foreach($allArchives as $date => $o_archive) 71 { 72 //var_dump($date); 73 $this->request->setDate( $o_archive->date->get() ); 74 $this->request->setModuleName( 'view_visits_rss' ); 75 76 $o_mod = new ViewVisitsRss($infoSite); 77 $o_mod->init($this->request, $this->tpl, $o_archive); 78 79 //var_dump($o_mod->data->archive->date->get()); 80 $rssContent = $o_mod->showAll( true ); 81 82 $dateRss = date("r", time() - 100 * $i++ - 10 * $id); 83 $item['pubDate'] = $dateRss; 84 85 $url = PHPMV_URL . "/?site=".$infoSite->getId()."&mod=view_visits&date=".$o_archive->date->get(); 86 $item['guid'] = $url;//"http://www.phpmyvisites.us/".md5($dateRss); 87 $item['link'] = $url; 88 89 $item['title'] = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $date)); 90 91 $rssContent = $item['title'] . $rssContent; 92 $item['author'] = "phpmyvisites@gmail.com (phpMyVisites)"; 93 $item['date_ts'] = time() - 10 * $id ; 94 $item['description'] = $rssContent; 95 $item['date_ts'] = $o_archive->date->getTimestamp(); 96 97 $allItems[] = $item; 98 $urls[] = $url; 99 } 100 } 101 $GLOBALS['sorting_index'] = 'date_ts'; 102 uasort($allItems, "sortingDataInfo"); 103 104 $channel['title'] = "phpMyVisites stats by RSS"; 105 $channel['link'] = "http://www.phpmyvisites.us"; 106 $channel['description'] = "Enjoy phpmyvisites power ! :)"; 107 $channel['pubDate'] = date("r"); 108 $channel['generator'] = "phpMyVisites"; 109 $channel['language'] = $GLOBALS['lang']['lang_iso']; 110 $channel['lastBuildDate'] = date("r"); 111 112 foreach($allItems as $chan) 113 { 114 unset($chan['date_ts']); 115 $channel[] = $chan; 116 } 117 $rss = array('channel' => $channel); 118 119 120 // An array of serializer options 121 $serializer_options = array ( 122 'addDecl' => TRUE, 123 'encoding' => 'UTF-8', 124 'indent' => ' ', 125 'rootName' => 'rss', 126 'defaultTagName' => 'item', 127 'rootAttributes' => array ( 'version' => '2.0'), 128 ); 129 130 $Serializer = &new XML_Serializer($serializer_options); 131 // Serialize the data structure 132 133 $Serializer->setOption("keyAttribute", "rdf:about"); 134 135 $status = $Serializer->serialize($rss); 136 137 $allData = $Serializer->getSerializedData(); 138 139 $Cache_Lite->save($allData); 140 141 } 142 143 $this->displayRss($allData); 144 } 145 146 function displayRss(&$data) 147 { 148 // Display the XML document 149 header('Content-type: text/xml'); 150 print($data); 151 exit; 152 } 153 } 154 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |