IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Recuperation d'un text area puis decomposition et test


Sujet :

Langage PHP

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Par défaut Recuperation d'un text area puis decomposition et test
    Bonjour,

    J'essaye de faire un script qui va permettre d'avoir les liens finaux qui sont redirigé par linkbuck jusqu'à une profondeur de 2 redirections.

    en gros mon internaute met des liens linckbuck dans le texarea( un par ligne), il clique sur ok et magie tout les liens finaux apparaissent .

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    <?php
    if(!$_POST['submit'])
    {
    	?>
    <form action="" method="post">
    <textarea name="link" cols="80" rows="40"></textarea>
    <input name="submit" type="submit" value="Go" />
    </form>
    <?php 
    }
    else
    {
    		$host = $_POST['link'];
    		$host = explode("\n",$host);
     
    		foreach($host as $n => $hostatester)
    		}
    		if(!preg_match('#^http://[0-9a-z]+.[a-z]+.com/?(url/)?(http://)?(.*)?$#',$hostatester))
    				{
    					echo '<font color="red">Lien incorect</font><br/>';
    				}
    				else
    				{
    							$fp = fopen($hostatester,"r");		
    							while (!feof($fp))
    								{
    									$buffer .= fgets($fp);
    								}
    								fclose($fp);
    							$link = explode("linkDestUrl",$buffer);
    							$linke = strpos($link[1],';');
    							$link = substr($link[1],4,$linke-5);
    							//test si le lien obtenu n'est plus un lien linbuck
    							if(preg_match('#^http://[0-9a-z]+.[a-z]+.com/?$#',$link,$match))
    							{
    								$fp2 = fopen($link,"r");		
    							while (!feof($fp2))
    								{
    									$buffer2 .= fgets($fp2);
    								}
    								fclose($fp2);
    							$link2 = explode("linkDestUrl",$buffer2);
    							$linke2 = strpos($link2[1],';');
    							$link = substr($link2[1],4,$linke2-5);
     
    							}
    				echo $link."<br/>";
    				}
    		}
    }
    ?>
    edit :
    Le script marche si j'enlève la boucle et que je rentre qu'une seul url
    donc mon problème est comment récupérer chaque ligne de mon textarea et de tester chaque ligne avec ce script

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Par défaut
    Voila ou j'en suis,
    La boucle se fait mais j'obtient le même resultat($link) pour tout les liens
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    <?php
    if(!$_POST['submit'])
    {
    	?>
    <form action="" method="post">
    <textarea name="link" cols="80" rows="40"></textarea>
    <input name="submit" type="submit" value="Go" />
    </form>
    <?php 
    }
    else
    {
    		$host = $_POST['link'];
    		$host = str_replace("\r\n", "\n", $host);
    		$host = explode("\n",$host);
     
     
    foreach($host as $n => $hostatester)
    {
    //TEST DU LIEN ENTRE DANS LE POST		
    if(!preg_match('#^http://[0-9a-z]+.linkbucks.com|baberepublic.com|blahetc.com|linkgalleries.net|inkseer.net|picturesetc.net|placepictures.com|qvvo.com|realfiles.net|seriousfiles.com|seriousurls.com|thatsprime.com|thesefiles.com|thesegalleries.com|thosegalleries.com|tinybucks.net|uberpicz.com|ubervidz.com|ubucks.net|ugalleries.net|urlpulse.net|viraldatabase.com|youfap.com|zxxo.net.com/?(url/)?(http://)?(.*)?$#',$hostatester))
    				{
    					echo '<font color="red">Lien incorect</font><br/>';
    				}
    				else
    				{	
    				 //DEEP = 1
    							$fp = fopen($hostatester,"r");	
    							while (!feof($fp))
    								{
    									$buffer .= fgets($fp);
    								}
    								fclose($fp);
     
     
    							ereg("linkDestUrl",$buffer,$match);//TEST SI IL SAGIT DUNE INTERMISSION 
    							ereg('<frame id="frame2" frameborder="0" noresize="1" src="',$buffer,$match2);//TEST SI IL SAGIT DUNE TOPBANNERS
    								if($match != false)
    									 {
    							$link = explode("linkDestUrl",$buffer);	
    							$linke = strpos($link[1],';');
    							$link = substr($link[1],4,$linke-5);
    									 }
    								elseif($match2 != false)
    									 {
    							$link = explode('<frame id="frame2" frameborder="0" noresize="1" src="',$buffer);
    							$linke = strpos($link[1],'"');
    							$link = substr($link[1],0,$linke);
    									 }
    //DEEP = 2	
     
    							if(preg_match('#^http://[0-9a-z]+.linkbucks.com|baberepublic.com|blahetc.com|linkgalleries.net|inkseer.net|picturesetc.net|placepictures.com|qvvo.com|realfiles.net|seriousfiles.com|seriousurls.com|thatsprime.com|thesefiles.com|thesegalleries.com|thosegalleries.com|tinybucks.net|uberpicz.com|ubervidz.com|ubucks.net|ugalleries.net|urlpulse.net|viraldatabase.com|youfap.com|zxxo.net.com/?/?$#',$link))
    							{
    								$fp2 = fopen($link,"r");
    							while (!feof($fp2))
    								{
    									$buffer2 .= fgets($fp2);
    								}
    								fclose($fp2);
    							ereg("linkDestUrl",$buffer2,$match);//TEST SI IL SAGIT DUNE INTERMISSION 
    							ereg('<frame id="frame2" frameborder="0" noresize="1" src="',$buffer2,$match2);//TEST SI IL SAGIT DUNE TOPBANNERS
    								if($match != false)
    									 {
    							$link = explode("linkDestUrl",$buffer2);	
    							$linke = strpos($link[1],';');
    							$link = substr($link[1],4,$linke-5);
    									 }
    								elseif($match2 != false)
    									 {
    							$link = explode('<frame id="frame2" frameborder="0" noresize="1" src="',$buffer2);
    							$linke = strpos($link[1],'"');
    							$link = substr($link[1],0,$linke);
    									 }
    							}
    						echo $link."<br/>";
     
    					}
     
    		}
    }
    ?>

  3. #3
    Membre Expert Avatar de Fench
    Homme Profil pro
    Chercheur en informatique
    Inscrit en
    Mai 2002
    Messages
    2 353
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Groenland

    Informations professionnelles :
    Activité : Chercheur en informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 353
    Par défaut
    Salut,

    Est tu sûr que $match et $match2 contiennent des booléens ?

    Edit: 2) est tu sûr de $host = str_replace("\r\n", "\n", $host);
    c pas "\n\r" les fins de lignes ?

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Décembre 2009
    Messages : 8
    Par défaut
    Voila its works comme dirait apache

    Pour ceux que cela interesse.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    <?php
    if($_GET['what'] == linkfinder) //DEBRIDEUR LINKBUCK & LINKBEE
     {
    	if($_GET['l'] == 'list')
    	 {?>
         	<h3>LINKBUCK</h3>
            <em><b>Les redirections de type intermission, popup et topbanner sont supportées</b></em><br/><br />
            http://xxxxxx.linkbucks.com<br/>
            http://xxxxxx.baberepublic.com<br/>
            http://xxxxxx.blahetc.com<br/>
            http://xxxxxx.linkgalleries.net<br/>
            http://xxxxxx.linkseer.net<br/>
            http://xxxxxx.picturesetc.net<br/>
            http://xxxxxx.placepictures.com<br/>
            http://xxxxxx.qvvo.com<br/>
            http://xxxxxx.realfiles.net<br/>
            http://xxxxxx.seriousfiles.com<br/>
            http://xxxxxx.seriousurls.com<br/>
            http://xxxxxx.thatsprime.com<br/>
            http://xxxxxx.thesefiles.com<br/>
            http://xxxxxx.thesegalleries.com<br/>
            http://xxxxxx.thosegalleries.com<br/>
            http://xxxxxx.tinybucks.net<br/>
            http://xxxxxx.uberpicz.com<br/>
            http://xxxxxx.ubervidz.com<br/>
            http://xxxxxx.ubucks.net<br/>
            http://xxxxxx.ugalleries.net<br/>
            http://xxxxxx.urlpulse.net<br/>
            http://xxxxxx.viraldatabase.com<br/>
            http://xxxxxx.youfap.com<br/>
            http://xxxxxx.zxxo.net<br/>
            <h3>LINKBEE</h3>
            <em><b>Les redirections de type intermission et top banner sont supportées</b></em><br /><br />
            http://linkbee.com/xxxxxx
            <?php
    	 }
    if(!$_POST['submit'] && !$_GET['l'])
    {
    		?>
     
           	Support linkbee et linkbuck <a href="?page=divers&what=linkfinder&l=list">Voir la liste des urls supportées avec précission</a>.<br />
           	Profondeur de redirection illimité.<br/>
            Un lien par ligne sinon ca marche pas ( max : 20 ).<br />
            Veuillez reporter tout bug via le formulaire de contact<br />
           	<span style="color:red">AVIS : Envoyez-moi via le formulaire de contact tout les sites de redirection les plus utilisés pour que je puisse mettre en place un mutli debrideur universel</span>
    	<form action="" method="post">
    <script>
    	var nbDeLigne_ = 20;
    	var nbCharParLigne_ = 200;
    	if(navigator.appName=='Microsoft Internet Explorer') {var sautDeLigne_=13;var decalage_=-1}
    	else {var sautDeLigne_=10;var decalage_=0}
    	function fnct_textarea(p){
    		var nbDeLigne = 1;
    		var nbCharLigne = 0;
    		var texte = p.value;
    		for (var i=0; i<texte.length; i++){
    			if (texte.charCodeAt(i)==sautDeLigne_) {
    				nbDeLigne++;
    				nbCharLigne=decalage_;
    				if (nbDeLigne>nbDeLigne_) {
    					p.value = texte.substring(0,i);
    					alert('vous avez dépassé le nombre max de ligne autorisé ('+nbDeLigne_+')');
    					break;
    				}
    			}else{
    				nbCharLigne++;
    				if (nbCharLigne>nbCharParLigne_) {
    					for (var j=i; (j<texte.length)&&(texte.charCodeAt(j)!=10); j++){}
    					p.value = texte.substring(0,i) + texte.substring(j);
    					alert('vous avez dépassé le nombre max de caractère par ligne autorisé ('+nbCharParLigne_+')');
    					break;
    				}
    			}
    		}
    	}
    </script>
    	<textarea name="link" cols="80" rows="20" onKeyup="fnct_textarea(this)"></textarea>
    	<input name="submit" type="submit" value="Go" />
    	</form>
    	<?php 
    }
    	elseif(!$_GET['l'])
    	{
    		?>
            Passer votre souris sur le lien pour voir à qu'elle lien il correspondait avant le débridage et voir la profondeur de la redirection ( iteration )<br />
            Les liens non valide ne sont pas affichés<br />
            <?php
    			$host = $_POST['link'];
    			$host = str_replace("\r\n", "\n", $host);
    			$host = explode("\n",$host);
     
     
    	foreach($host as $n => $hostatester)
    	{
    								$link= '';
    								$match1 ='';
    								$match12 ='';
    								$n = '';
    								$type ='';
    	//TEST DU LIEN ENTRE DANS LE POST	
    	$regexlinkbuck  ='#^http://[0-9a-z]+.linkbucks.com|baberepublic.com|blahetc.com|linkgalleries.net|inkseer.net|picturesetc.net|placepictures.com|qvvo.com|realfiles.net|seriousfiles.com|seriousurls.com|thatsprime.com|thesefiles.com|thesegalleries.com|thosegalleries.com|tinybucks.net|uberpicz.com|ubervidz.com|ubucks.net|ugalleries.net|urlpulse.net|viraldatabase.com|youfap.com|zxxo.net.com/?(url/)?(http://)?(.*)?$#'; 
    	$regexlinkbee = '#^http://linkbee.com/.*$#';
    	$n= 1;
    	$iteration = array();
    	while($n)
    	{
    		if($n !=1)
    				 {
    					 $hostatester = $link;
    				 }
    	if(preg_match($regexlinkbuck,$hostatester)) //LINKBUCK
    					{	
    								$fp = fopen($hostatester,"r");	
    								while (!feof($fp))
    									{
    										$buffer .= fgets($fp);
    									}
    									fclose($fp);
     
     
    								preg_match('^linkDestUrl^',$buffer,$match);//TEST SI IL SAGIT DUNE INTERMISSION 
    								preg_match('^<frame id="frame2" frameborder="0" noresize="1" src="^',$buffer,$match2);//TEST SI IL SAGIT DUNE TOPBANNERS
    									if($match != false)
    										 {
     
     
    								preg_match('^linkDestUrl.=.\'(.+\..+)\'^',$buffer,$link);	
    								$link = $link[1];
    								$buffer ='';
    								$type = intermission;
    										 }
    									elseif($match2 != false)
    										 {	
     
    								preg_match('^<frame.id="frame2".frameborder="0".noresize="1".src=\"(.+)\">^',$buffer,$link);
    								$link = $link[1];
    								$buffer ='';
    								$type = topbanner;
    										 }
    										 $match ='';
    										 $match2 ='';
    					}
     
    		elseif(preg_match($regexlinkbee,$hostatester)) //LINKBEE
    					{
    							$fp =fopen($hostatester,"r");
    							while(!feof($fp))
    										{
    											$buffer .=fgets($fp);
    										}
    										fclose($fp);
    							preg_match('^<title>Linkbee redirection, please wait...</title>^',$buffer,$match); 
    								if($match == false) //top banner
    									{
    									preg_match('^<title>Linkbee:(.*)</^',$buffer,$link);
    									$link = $link[1];
    									$type = topbanner;
    									}
    								else //top intermission
    									{
    									preg_match('^<meta.http-equiv="REFRESH".content="..;.url=(.*)\">^',$buffer,$link);
    									$link = $link[1];
    									$type = intermission;
    									}
    						$match ='';			
    						$buffer ='';
    					}
    					$regex = '^http://[0-9a-z]+.linkbucks.com|baberepublic.com|blahetc.com|linkgalleries.net|inkseer.net|picturesetc.net|placepictures.com|qvvo.com|realfiles.net|seriousfiles.com|seriousurls.com|thatsprime.com|thesefiles.com|thesegalleries.com|thosegalleries.com|tinybucks.net|uberpicz.com|ubervidz.com|ubucks.net|ugalleries.net|urlpulse.net|viraldatabase.com|youfap.com|zxxo.net.com/?(url/)?(http://)?(.*)?http://linkbee.com/.*^';
    			preg_match($regex,$link,$match);
    				if($match == false)
    					{	
    						$lol = $n;
    						$n='';
     
    					}
    					else
    					{
    					$lol = $n;
    					$n++;		
    					$match ='';
    					}
     
     
     
    		  }
    		  ?>
                <a href="<?php echo $link;?>" title="<?php echo $hostatester.' | '.$type.' | iteration : '.$lol;?>" target="_blanck"><?php echo $link;?></a><br/>
    		<?php
    		  }
     
    }
    ?>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. recuperer la position x y du curseur dans une texte area
    Par nsanabi dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 26/03/2009, 12h31
  2. Recuperer la derniere ligne d'un text area
    Par bassam0205 dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 14/12/2007, 15h58
  3. Iframe, y charger 2 text-area
    Par CCyrillus dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 11/10/2005, 10h43
  4. Image avec texte à droite puis en dessous
    Par StarNab dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 16/05/2005, 17h25
  5. [HTML] problème avec un text area
    Par krfa1 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 29/10/2004, 11h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo