Bonjour, je désire modifier cette fonction PHP

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Bonjour, je désire modifier cette fonction PHP

Re: Bonjour, je désire modifier cette fonction PHP

par Spols » 26 oct. 2012, 15:12

oui

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 13:41

Donc je ne met que cela ?


function check_footer()
{
$l="Designed by <a href='http://www.designer-clothes.co.uk'>Designer clothes</a>";
$f = dirname(__FILE__)."/footer.php";
$fd=fopen($f,"r");
$c=fread($fd,filesize($f));
fclose($fd);
if(strpos($c,$l)==0)
{
echo "This theme is sponsored, all links in the footer should remain intact";
die;
}
}
check_footer();

Re: Bonjour, je désire modifier cette fonction PHP

par Spols » 26 oct. 2012, 13:38

Je t'ai dit de ne pas ajouter de balise <?php

c'est cela qu'il ne comprends pas

voila ce que tu devrais avoir comme fichier
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Sidebar Right',
'before_widget' => '<div class="side-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 1',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 2',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 3',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
include(TEMPLATEPATH.'/includes/themeoptions.php');
function check_footer(){
	$l="Designed by <a href='http://www.designer-clothes.co.uk'>Designer clothes</a>";
	$f = dirname(__FILE__).'/footer.php';
	$fd = fopen($f,'r');
	$c = fread($fd,filesize($f));
	fclose($fd);
	if(strpos($c,$l)==0){
		echo 'This theme is sponsored, all links in the footer should remain intact';
		die;
	}
}
check_footer();
include(TEMPLATEPATH.'/includes/images.php');


// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary-menu' => __( 'Primary Menu' ),
) );
function my_wp_nav_menu_args( $args = '' )
{
$args['container'] = false;
return $args;
} // function
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );



/*this function allows for the auto-creation of post excerpts*/
function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
$truncate = preg_replace('@<style[^>]*?>.*?</style>@si', '', $truncate);
$truncate = strip_tags($truncate);
$truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
echo $truncate;
echo "...";
if ($quote_after) echo('');
}
function check_header(){
	if(!(function_exists("check_functions") && function_exists("check_f_footer"))) {
		echo('This theme is released under creative commons licence, all links in the footer should remain intact');
		die;
	}
}
?>
<?php
function swt_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 48 ); ?>
<?php printf( __( '%s
' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>

<a class="metadata" href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
?>
</div><!-- .comment-author .vcard -->
<div id="comment-<?php comment_ID(); ?>" <?php if (1 == $comment->user_id) { ?> class="adminclass cbody" <?php } else{ ?> class="cbody" <?php } ?>>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>


<?php endif; ?>
<div class="comment-body"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div><!-- #comment-## -->

<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
<?php
break;
endswitch;
}?>
PS les balises php sur le forum sont en minuscule

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 13:33

En mettant ton bout de code
<?PHP
function check_footer()
{
        $l="Designed by <a href='http://www.designer-clothes.co.uk'>Designer clothes</a>";
        $f = dirname(__FILE__)."/footer.php";
        $fd=fopen($f,"r");
        $c=fread($fd,filesize($f));
        fclose($fd);
        if(strpos($c,$l)==0)
        {
                echo "This theme is sponsored, all links in the footer should remain intact";
                die;
        }
}
check_footer();
?>
[PHP]

il m'affiche 
Parse error: syntax error, unexpected '<' in /home6/m/morel-avocats/www/site/wp-content/themes/PatolinoMagazine/functions.php on line 28

Donc ce n'est qu'une petite erreur de syntaxe....

Merci de ton aide 
Cordialement

Bruno

Re: Bonjour, je désire modifier cette fonction PHP

par Spols » 26 oct. 2012, 13:19

Fait toi un petit fichier php dans lequel tu met un à un les bouts de code du type eval(str_rot13([...]));
Remplace le eval par un echo, et visionne dans un navigateur. Remplace tes codes eval(str_rot13([...])); par ce qui s'affiche dans ton navigateur (mieux encore par le code source fourni)

n'hésite pas à indenter ce code, mais n'ajoute rien, ni balise <?php ni quote (simple ou double)

Une fois cela fait, tu aura un code humainement compréhensible et tu pourra tenter de le modifier petit bout par petit bout.

Cependant, les codes que tu cherches à modifier me semble être mis en place pour s'assurer que certaines mention sont bien dans le footer.
Les personnes qui ont travaillé pour creer ce contenu mérite qu'on les mentionne. Je t'encourage donc à laisser ces informations tel quelles.

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 12:45

Et bien je cherche a enlever les eval rot 13 par le texte décodé, merci de ton aide
Cordialement Bruno
Cette page originelle fonctionne



<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Sidebar Right',
'before_widget' => '<div class="side-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 1',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 2',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 3',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
include(TEMPLATEPATH.'/includes/themeoptions.php');
eval(str_rot13('shapgvba purpx_sbbgre(){$y=\'Qrfvtarq ol <n uers="uggc://jjj.qrfvtare-pybgurf.pb.hx">Qrfvtare pybgurf</n>\';$s=qveanzr(__SVYR__).\'/sbbgre.cuc\';$sq=sbcra($s,\'e\');$p=sernq($sq,svyrfvmr($s));spybfr($sq);vs(fgecbf($p,$y)==0){rpub \'Guvf gurzr vf fcbafberq, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\';qvr;}}purpx_sbbgre();'));
include(TEMPLATEPATH.'/includes/images.php');


// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary-menu' => __( 'Primary Menu' ),
) );
function my_wp_nav_menu_args( $args = '' )
{
$args['container'] = false;
return $args;
} // function
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );



/*this function allows for the auto-creation of post excerpts*/
function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
$truncate = preg_replace('@<style[^>]*?>.*?</style>@si', '', $truncate);
$truncate = strip_tags($truncate);
$truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
echo $truncate;
echo "...";
if ($quote_after) echo('');
}
eval(str_rot13('shapgvba purpx_urnqre(){vs(!(shapgvba_rkvfgf("purpx_shapgvbaf")&&shapgvba_rkvfgf("purpx_s_sbbgre"))){rpub(\'Guvf gurzr vf eryrnfrq haqre perngvir pbzzbaf yvprapr, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\');qvr;}}'));
?>
<?php
function swt_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 48 ); ?>
<?php printf( __( '%s
' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>

<a class="metadata" href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
?>
</div><!-- .comment-author .vcard -->
<div id="comment-<?php comment_ID(); ?>" <?php if (1 == $comment->user_id) { ?> class="adminclass cbody" <?php } else{ ?> class="cbody" <?php } ?>>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>


<?php endif; ?>
<div class="comment-body"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div><!-- #comment-## -->

<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
<?php
break;
endswitch;
}?>
[PHP]

Re: Bonjour, je désire modifier cette fonction PHP

par Spols » 26 oct. 2012, 12:37

LES BALISES PHP PLEASE

C'est ton code original avant modification ou après ?

Tu l'a trouvé où ?

Le code original fonctionne t il ?

Que cherche tu à modifier ?

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 11:59

Peut être parce qu'il y a encore du rot 13 plus bas voici ma page functiuns en entier, merci de votre aide :

<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Sidebar Right',
'before_widget' => '<div class="side-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 1',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 2',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array('name'=>'Footer Widget 3',
'before_widget' => '<div class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
include(TEMPLATEPATH.'/includes/themeoptions.php');
eval(str_rot13('shapgvba purpx_sbbgre(){$y=\'Qrfvtarq ol <n uers="uggc://jjj.qrfvtare-pybgurf.pb.hx">Qrfvtare pybgurf</n>\';$s=qveanzr(__SVYR__).\'/sbbgre.cuc\';$sq=sbcra($s,\'e\');$p=sernq($sq,svyrfvmr($s));spybfr($sq);vs(fgecbf($p,$y)==0){rpub \'Guvf gurzr vf fcbafberq, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\';qvr;}}purpx_sbbgre();'));
include(TEMPLATEPATH.'/includes/images.php');


// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary-menu' => __( 'Primary Menu' ),
) );
function my_wp_nav_menu_args( $args = '' )
{
$args['container'] = false;
return $args;
} // function
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );



/*this function allows for the auto-creation of post excerpts*/
function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
$truncate = preg_replace('@<style[^>]*?>.*?</style>@si', '', $truncate);
$truncate = strip_tags($truncate);
$truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
echo $truncate;
echo "...";
if ($quote_after) echo('');
}
eval(str_rot13('shapgvba purpx_urnqre(){vs(!(shapgvba_rkvfgf("purpx_shapgvbaf")&&shapgvba_rkvfgf("purpx_s_sbbgre"))){rpub(\'Guvf gurzr vf eryrnfrq haqre perngvir pbzzbaf yvprapr, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\');qvr;}}'));
?>
<?php
function swt_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 48 ); ?>
<?php printf( __( '%s<br />' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>

<a class="metadata" href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
?>
</div><!-- .comment-author .vcard -->
<div id="comment-<?php comment_ID(); ?>" <?php if (1 == $comment->user_id) { ?> class="adminclass cbody" <?php } else{ ?> class="cbody" <?php } ?>>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-body"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div><!-- #comment-## -->

<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
<?php
break;
endswitch;
}?>

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 11:21

Ce qui devrait me donner cela :


<?PHP
function check_footer()
{
$l=\'Designed by <a href="http://www.designer-clothes.co.uk">Designer clothes</a>\';
$f=dirname(__FILE__).\'/footer.php\';
$fd=fopen($f,\'r\');
$c=fread($fd,filesize($f));
fclose($fd);
if(strpos($c,$l)==0)
{
echo \'This theme is sponsored, all links in the footer should remain intact\';
die;
}
}
check_footer();
?>


et non tjs la meme erreur T string

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 11:18

En fait voici ma ligne 28 editée dans le bloc note, j'ai essayé avec un traducteur rot 13 mais tjs la même erreur T string

eval(str_rot13('shapgvba purpx_sbbgre(){$y=\'Qrfvtarq ol <n uers="uggc://jjj.qrfvtare-pybgurf.pb.hx">Qrfvtare pybgurf</n>\';$s=qveanzr(__SVYR__).\'/sbbgre.cuc\';$sq=sbcra($s,\'e\');$p=sernq($sq,svyrfvmr($s));spybfr($sq);vs(fgecbf($p,$y)==0){rpub \'Guvf gurzr vf fcbafberq, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\';qvr;}}purpx_sbbgre();'));

Merci de ton aide

Re: Bonjour, je désire modifier cette fonction PHP

par sirakawa » 26 oct. 2012, 11:10

Je n'avais pas repéré qu'il s'agissait dune production de Dreamweaver. Il semble que ce serait du javascfript incorporant du php, incorporant de l'html.
Mais je viens de commencer de lire la ligne que tu envoies ce qui donne ça en mettant un saut de ligne à chaque ;
[javascript]eval(
str_rot13 (
'shapgvba purpx_sbbgre()
{
$y=\'Qrfvtarq ol <n uers="uggc://jjj.qrfvtare-pybgurf.pb.hx">Qrfvtare pybgurf</n>\';
$s=qveanzr(__SVYR__).\'/sbbgre.cuc\';
$sq=sbcra($s,\'e\');
$p=sernq($sq,svyrfvmr($s));
spybfr($sq);
vs(fgecbf($p,$y)==0)
{
rpub \'Guvf gurzr vf fcbafberq, nyy yvaxf va gur sbbgre fubhyq erznva vagnpg\';
qvr;
}
}
purpx_sbbgre();'));[/javascript]
Ca pourrait aider à identifier l'erreur
avec des appels à des fonctions maison comme str_rot13... Bravo, Dream pour le championnat annuel du PHP Obfuscated Code...

Re: Bonjour, je désire modifier cette fonction PHP

par Brunochp21 » 26 oct. 2012, 10:37

Merci bcp de ton aide mais voilà ce qu'il me m'affiche à présent

Parse error: syntax error, unexpected T_STRING in /home6/m/morel-avocats/www/site/wp-content on line 28

Cdt
Bruno

Re: Bonjour, je désire modifier cette fonction PHP

par sirakawa » 26 oct. 2012, 10:33

Question subsidiaire:
La fonction est-elle censée afficher le message
This theme is sponsored, all links in the footer should remain intact
quand elle trouve ou quand elle ne trouve pas
Designed by <a ....
== 0 signifie à la fois: pas trouvé et trouvé en première position.
Exemple:
$texte_cherche = "Chaine à chercdher";
if (strpos($texte_a_explorer, $texte_cherche === false)
{
  $message ="Pas trouvé";
}
else
{
    $message = "Trouvé";
}
print "$message";
Voici une version qui fonctionne (indentée, c'est un minimum)
<?PHP
function check_footer()
{
	$l="Designed by <a href='http://www.designer-clothes.co.uk'>Designer clothes</a>";
	$f = dirname(__FILE__)."/footer.php";
	$fd=fopen($f,"r");
	$c=fread($fd,filesize($f));
	fclose($fd);
	if(strpos($c,$l)==0)
	{
        	echo "This theme is sponsored, all links in the footer should remain intact";
		die;
	}
}
check_footer();
?>
en jonglant avec les simples et doubles quotes pour éviter de devoir échapper (je l'ai fait quand j'avais des culottes courtes php, mais je trouve que ça end les choses tellement illisibles que dès que j'ai eu ma première dent php, j'ai renoncé à échapper.)

Re: Bonjour, je désire modifier cette fonction PHP

par juliette » 26 oct. 2012, 10:30

bon, je laisse la place a Spols car la je suis un peut dépassé...

Re: Bonjour, je désire modifier cette fonction PHP

par Spols » 26 oct. 2012, 10:27

Pour partir sur de bonne base, utilise les balises PHP quand tu poste du code sur le forum,

Indente ton code.

Et surtout, met tout ton code dans les balises <?php et ?> et pas à moitié dedans et moitié dehors.

Et au final, si tu met ton code dans des ' il ne sera pas interprétè.

Edit, je viens de voir que tu utilise eval(), comme tu es débutants cela veut dire que tu cherche à modifié un truc tout fait, et de toute façon c'est une mauvaise idée de travailler avec eval.

Donne nous la source du code que tu veux modifier, où l'a tu trouvé