Vous êtes 38.107.191.101(Login)

overcrowded / Action Png

carte des liens de la page courante ActionPng Sources

Action Png

<?php
/*
genere une image PNG du reseau de la page courante
*/
$im_w 700//largeur image
$im_h 300//hauteur image

$n 0// nombre de pages liées à la page courante
$p = array();

//page courante
$id $this->getPageTag();
$p[$id]['n'] = $id;         // nom de la page
$p[$id]['c'] = 'cur';       // classe css
$p[$id]['w'] = 10;          // largeur de zone par defaut


//Backlinks
if ($pagesFrom $this->LoadPagesLinkingTo($this->getPageTag()))
{    
    foreach (
$pagesFrom as $pageFrom)
    {
        
$id $pageFrom["tag"];
        if(
$id != $this->getPageTag())// exclusion des liens de la page vers elle même
        
{
            if(!
is_array($p[$id])) // si le neud n'est pas deja enregistré
            
{
                
$p[$id]['n'] = $id;
                
$p[$id]['c'] = 'in';
                
$p[$id]['w'] = 10;
                
$n++; // incremente le nombre de noeuds
            
}
            
// le noeud existe deja ou pas : on incremente la taille du rectangle
            
$p[$id]['w']++;
            
$p[$this->getPageTag()]['w']++;
        }
    }
}
//Liens sortants
$query "select to_tag as tag from ".$this->config["table_prefix"]."links where from_tag = '".mysql_escape_string($this->getPageTag())."' order by tag";
if (
$pagesTo $this->LoadAll($query))
{
    foreach (
$pagesTo as $pageTo)
    {
        
$id $pageTo["tag"];
        if(
$id != $this->getPageTag()) //exclusion des liens de la page vers elle même
        
{
            if(!
is_array($p[$id])) // si le neud n'est pas deja enregistré
            
{
                
$p[$id]['n'] = $pageTo["tag"];
                
$p[$id]['c'] = 'out';
                
$p[$id]['w'] = 10;
                
$n++;
            }
            else
            {
                
$p[$id]['c'] = 'inout'// lien entrant et sortant
            
}
            
$p[$id]['w']++;
            
$p[$this->getPageTag()]['w']++;
        }
    }
}



// attribution de coordonnées aléatoires
while(list($k,$v) = each($p))
{
    
$p[$k]['x'] = rand(0$im_w-100);
    
$p[$k]['y'] = rand(0$im_h-20);
}

$center true;
if(
$center) {
    
$p[$this->getPageTag()]['x'] = $im_w 2;
    
$p[$this->getPageTag()]['y'] = $im_h 2;
}


// coordonnées du centre du rectangle de la page courante
//$p[$this->getPageTag()]['w'] = $n;
$cur_w $p[$this->getPageTag()]['w'];
$cur_x $p[$this->getPageTag()]['x'];
$cur_y $p[$this->getPageTag()]['y'];
$x1 = ($cur_w/2) + $cur_x;
$y1 = ($cur_w/2) + $cur_y;


$html_map "<map name=\"curmap\">\n"//map HTML

if($this->GetParameter("src")) {
    
$imbase$this->GetParameter("src");
}

$im imagecreatetruecolor($im_w$im_h);
$im2 imagecreatetruecolor($im_w$im_h);
//imageantialias ($im, 'on' );
//imageantialias ($im2, 'on' );

//generation de l'image
if (isset($imbase)) {
        if(
ereg("\.jpg"$imbase)) {
            
//$imb=imagecreatefromjpeg($imbase);
            
if(!$imf=imagecreatefromjpeg($imbase)) {
                echo 
"<h1>unable to generate image base</h1>";
            } else {
                
                list(
$ws$hs$type$attr) = getimagesize($imbase);
                echo 
"<!-- ".$ws."/".$hs." -->";
                
imagecopyresampled ($im$imf0000$im_w$im_h$ws$hs );
                
imagecopyresampled ($im2$imf0000$im_w$im_h$ws$hs );
            }
        } elseif (
ereg("\.png"$imbase)) {
            
//$imb=imagecreatefrompng($imbase);
            
if(!$imf=imagecreatefrompng($imbase)) {
                echo 
"unable to generate image base";
                
            } else {
                
                echo 
"<!-- ".$ws."/".$hs."-->";
                list(
$ws$hs$type$attr) = getimagesize($imbase);
                
imagecopyresampled ($im$imf0000$vw$vh$ws$hs );
                
imagecopyresampled ($im2$imf0000$vw$vh$ws$hs );
                
            }
        }        
    
    
$blanc imagecolorclosest($im255,255,255);
    
$grisf imagecolorclosest($im70,70,70);
    
$gris imagecolorclosest($im180,180,180);
    
$rouge imagecolorclosest($im255,0,0); 
    
$jaune imagecolorclosest($im255,119,0); 
    
$bleu imagecolorclosest($im0,0,255); 
    
} else {
    
$grisf imagecolorallocate($im70,70,70);
    
$noir imagecolorallocate($im0,0,0);
    
$blanc imagecolorallocate($im255,255,255);
    
$gris imagecolorallocate($im180,180,180);
    
$rouge imagecolorallocate($im255,0,0); 
    
$jaune imagecolorallocate($im255,119,0); 
    
$bleu imagecolorallocate($im0,0,255); 
}

//imagecolortransparent ($im , $noir );



//variables pour les identifiants des éléments
$i 0;    
$j 0;  

$subnet true;

foreach (
$p as $page)
{
    
// réseau de liens secondaires
    
if($subnet)
    {
        
$nompage $page['n'];
        if(
$nompage != $this->getPageTag()) // exclusion de la recherche de backlinks sur la page courante
        
{
            if (
$retroLiens $this->LoadPagesLinkingTo($nompage)) //backlinks
            
{
                foreach (
$retroLiens as $retroLien)
                {
                    
$id $retroLien["tag"]; //$p[$id]['n'] est donc une page qui pointe vers p[$nompage]
                    
if(is_array($p[$id]) && $p[$id]['n'] != $this->getPageTag())
                    {
                        
imageline($im,$p[$id]['x'],$p[$id]['y'],$page['x'],$page['y'],$gris);
                        
$page['w']++; //incrementation de la taille de la page liée
                        
$i++;
                    }
                }
            }
        }
    }
    
    
//ajuste les coords de ligne au centre des carrés
    
$page['cx'] =  ($page['w']/2) + $page['x'];
    
$page['cy'] =  ($page['w']/2) + $page['y'];

    
    
    
//rectangle de page en lien vers le SVG correspondant
    
if($page['c'] == 'in') {
        
$col $bleu;
    } else if(
$page['c'] == 'out') {
        
$col $jaune;
    }
    
$page['x2'] = $page['x']+$page['w'];
    
$page['y2'] = $page['y']+$page['w']; 
    
//ligne sur la page courante
    
imageline($im,$x1,$y1,$page['cx'],$page['cy'],$col);
    
imagefilledrectangle($im,$page['x'], $page['y'], $page['x2'] , $page['y2'] , $blanc );
    
imagerectangle($im,$page['x'], $page['y'], $page['x2'] , $page['y2'] , $col );
    
$html_map .= "<area shape=\"rect\" coords=\"".$page['x'].","$page['y'].","$page['x2'].",".$page['y2']." \" href=\"".$this->config["base_url"].$page['n']."\" title=\"".$page['n']."\" />\n";

    
    
//texte : nom de la page 
    
imagestring($im2$page['x2']+2$page['y'], $page['n'], $bleu);
   
    

    
$i++;
    
$j++;
}
$html_map .= "</map>\n";


if(isset(
$imf)) { 
    
imagecopymerge ($im$im2000064048040);
    
imagedestroy($imf);
}

imagepng($im'pngmaps/'.$this->getPageTag().'.png');


imagedestroy($im);
echo 
'<img src="/pngmaps/'.$this->getPageTag().'.png?r='.time().'" alt="" usemap="#curmap" border="0" />';
echo 
$html_map;
?>

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]