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