From 45f726b537eb7ee177148309478c82ca8ba6708b Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Fri, 18 Nov 2016 11:43:27 +0100 Subject: [PATCH] =?UTF-8?q?Modifie=20le=20chemin=20d'acc=C3=A8s=20=C3=A0?= =?UTF-8?q?=20la=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/blogs/includes/blogs_last_post.php | 352 ++++++++++----------- 1 file changed, 176 insertions(+), 176 deletions(-) diff --git a/modules/blogs/includes/blogs_last_post.php b/modules/blogs/includes/blogs_last_post.php index e037a8b..f30923e 100644 --- a/modules/blogs/includes/blogs_last_post.php +++ b/modules/blogs/includes/blogs_last_post.php @@ -1,177 +1,177 @@ - 0, // penelope - 1 => 12, //explosm - 2 => 0, // margaux -); - -private $nomImages = array( - 0 => 'PenelopeBagieu', - 1 => 'CyanideAndHapiness', - 2 => 'MargauxMotin', -); - -public $link = array( - 0 => 'http://www.penelope-jolicoeur.com/', - 1 => 'http://www.explosm.net/comics/', - 2 => 'http://margauxmotin.typepad.fr/', -);*/ -private $link = array(); - - -function getResult() -{ - return $this->_result; -} - -public function getLinks(){ - if($linksXML = @simplexml_load_file('../db/blog_links.xml')){ - foreach($linksXML->link as $individualLink){ - $this->link[] = array('name'=>$individualLink->name, 'url'=>$individualLink->url, 'number'=>$individualLink->number); - } - return $this->link; - } - else - return []; -} - -function getTitles() -{ - $xhtml = ""; - try{ - foreach($this->exec() as $result) - { - $xhtml .= $this->getTitle($result); - $xhtml .= '
'; - } - }catch(Exception $e) - { - $xhtml .= $this->error(); - } - return $xhtml; - -} - -function getTitle($result = null, $url = null) -{ - if(isset($result)) - { - preg_match( "/

(.*)<\/h3>/i", $result, $match ); - - if(isset($match[1])) - return utf8_decode(strip_tags($match[1])); - else{ - preg_match( "/(.*)<\/title>/i", $result, $title ); - if(isset($title[1])) - return $title[1]; - else - return 'Erreur : pas de titre de blog trouv�.'; - } - - } - //TODO en fonction de l'url et non du resultat du cURL -} - -function getPost() -{ - -} - -function createThumbnail($result, $title = 0) -{ - if(isset($result)) - { - - preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); - - /*$ret = file_put_contents('match.txt', var_export($match,true), FILE_APPEND); - if ($ret === false) - { - echo 'erreur'; - }*/ - $number = $this->link[$title]['number']; - $title = $this->link[$title]['name']; - if(isset($match[1][(int)$number])) - { - $source = @imagecreatefromjpeg($match[1][(int)$number]); - if($source == false) - $source = @imagecreatefrompng($match[1][(int)$number]); - - $wSource = @imagesx($source); - $hSource = @imagesy($source); - - $destination = imagecreatetruecolor(50, 50); - @imagecopyresampled($destination, $source, 0, 0, 0, 0, 50, 50, $wSource, $hSource); - @imagepng($destination, 'images/blogs/'.$title.'.png'); - return 'images/blogs/'.$title.'.png'; - } - - } -} - -function getImages($notFromGetImage = false) -{ - if($notFromGetImage){ - //TODO stuff - }else{ - $xhtml = ""; - $i = 0; - try{ - foreach($this->exec() as $result) - { - $xhtml .= '<img src="'.$this->createThumbnail($result, $i).'" />'; - $xhtml .= '<br/>'; - $i++; - } - }catch(Exception $e) - { - $xhtml .= $this->error(); - } - return $xhtml; - } -} - -function getAllImagesToChoose($result,$notFromGetImage = false) -{ - if($notFromGetImage){ - //TODO stuff - }else{ - preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); - $nbImages = count($match[1]); - $xhtml = 'Liste d\'images : <br/>'; - - for($i = 0; $i<$nbImages; $i++){ - $xhtml .= '<img src="'.$match[1][$i].'" id="n-'.$i.'" class="choose"/><br/>'; - } - return $xhtml; - } -} - -function getEverything() -{ - $temps_debut = microtime(true); - $xhtml = ""; - $i = 0; - try{ - foreach($this->exec() as $result) - { - $xhtml .= '<a href="'.$this->link[$i]['url'].'" target="_blank" class="blogLinks"><img src="'.$this->createThumbnail($result, $i).'" />  '.utf8_encode($this->getTitle($result))."</a>"; - $xhtml .= '<br/>'; - $i++; - } - }catch(Exception $e) - { - $xhtml .= $this->error(); - } - $temps_fin = microtime(true); - $xhtml .= 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4).'s'; - return $xhtml; -} - - +<?php +require('CURL.php'); +class Blogs_last_post extends CURL{ + +private $_result; + +/*private $listeImages = array( + 0 => 0, // penelope + 1 => 12, //explosm + 2 => 0, // margaux +); + +private $nomImages = array( + 0 => 'PenelopeBagieu', + 1 => 'CyanideAndHapiness', + 2 => 'MargauxMotin', +); + +public $link = array( + 0 => 'http://www.penelope-jolicoeur.com/', + 1 => 'http://www.explosm.net/comics/', + 2 => 'http://margauxmotin.typepad.fr/', +);*/ +private $link = array(); + + +function getResult() +{ + return $this->_result; +} + +public function getLinks(){ + if($linksXML = @simplexml_load_file($this->pathToModule.'db/blog_links.xml')){ + foreach($linksXML->link as $individualLink){ + $this->link[] = array('name'=>$individualLink->name, 'url'=>$individualLink->url, 'number'=>$individualLink->number); + } + return $this->link; + } + else + return []; +} + +function getTitles() +{ + $xhtml = ""; + try{ + foreach($this->exec() as $result) + { + $xhtml .= $this->getTitle($result); + $xhtml .= '<br/>'; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + return $xhtml; + +} + +function getTitle($result = null, $url = null) +{ + if(isset($result)) + { + preg_match( "/<h3 class=\"entry-header\">(.*)<\/h3>/i", $result, $match ); + + if(isset($match[1])) + return utf8_decode(strip_tags($match[1])); + else{ + preg_match( "/<title>(.*)<\/title>/i", $result, $title ); + if(isset($title[1])) + return $title[1]; + else + return 'Erreur : pas de titre de blog trouvé.'; + } + + } + //TODO en fonction de l'url et non du resultat du cURL +} + +function getPost() +{ + +} + +function createThumbnail($result, $title = 0) +{ + if(isset($result)) + { + + preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); + + /*$ret = file_put_contents('match.txt', var_export($match,true), FILE_APPEND); + if ($ret === false) + { + echo 'erreur'; + }*/ + $number = $this->link[$title]['number']; + $title = $this->link[$title]['name']; + if(isset($match[1][(int)$number])) + { + $source = @imagecreatefromjpeg($match[1][(int)$number]); + if($source == false) + $source = @imagecreatefrompng($match[1][(int)$number]); + + $wSource = @imagesx($source); + $hSource = @imagesy($source); + + $destination = imagecreatetruecolor(50, 50); + @imagecopyresampled($destination, $source, 0, 0, 0, 0, 50, 50, $wSource, $hSource); + @imagepng($destination, 'images/blogs/'.$title.'.png'); + return 'images/blogs/'.$title.'.png'; + } + + } +} + +function getImages($notFromGetImage = false) +{ + if($notFromGetImage){ + //TODO stuff + }else{ + $xhtml = ""; + $i = 0; + try{ + foreach($this->exec() as $result) + { + $xhtml .= '<img src="'.$this->createThumbnail($result, $i).'" />'; + $xhtml .= '<br/>'; + $i++; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + return $xhtml; + } +} + +function getAllImagesToChoose($result,$notFromGetImage = false) +{ + if($notFromGetImage){ + //TODO stuff + }else{ + preg_match_all( "#<img[^>]+src=['|\"](.*?)['|\"][^>]*>#i", $result, $match ); + $nbImages = count($match[1]); + $xhtml = 'Liste d\'images : <br/>'; + + for($i = 0; $i<$nbImages; $i++){ + $xhtml .= '<img src="'.$match[1][$i].'" id="n-'.$i.'" class="choose"/><br/>'; + } + return $xhtml; + } +} + +function getEverything() +{ + $temps_debut = microtime(true); + $xhtml = ""; + $i = 0; + try{ + foreach($this->exec() as $result) + { + $xhtml .= '<a href="'.$this->link[$i]['url'].'" target="_blank" class="blogLinks"><img src="'.$this->createThumbnail($result, $i).'" />  '.utf8_encode($this->getTitle($result))."</a>"; + $xhtml .= '<br/>'; + $i++; + } + }catch(Exception $e) + { + $xhtml .= $this->error(); + } + $temps_fin = microtime(true); + $xhtml .= 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4).'s'; + return $xhtml; +} + + } \ No newline at end of file