Please I Need all your Help!!!

Discussion in 'PHP' started by GeelongTECH, Dec 4, 2010.

  1. #1
    Hello,
    I have a config.php page located @ /home/account1/public_html/includes/config.php.

    config.php:
    
    <?php
    $page_break = ' - ';
    $page_slogan = 'Slogan';
    
    ?>
    
    PHP:
    I need a php code that will make admin.php witch is password protected to change $page_break & $page_slogan?

    Thanks,
     
    GeelongTECH, Dec 4, 2010 IP
  2. Putnam11

    Putnam11 Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What exactly are you trying to do? You could just simply change the $page_slogan manually by accessing it via FTP or your file manager, and why use a page_break? HTML has <hr> that you can set the length, or you could just simple type '-' on your web page.
     
    Putnam11, Dec 4, 2010 IP
  3. GeelongTECH

    GeelongTECH Peon

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the page the needs all the information use's
    <?php
    $page_title = 'Home';
    include 'includes/config.php';
    ?>
    Content
    <?php
    include 'includes/footer.php';
    ?>
    PHP:
    in config.php the title tag looks like
    <title><?php echo $page_title; ?><?php echo $page_break; ?><?php echo $page_slogan; ?></title>
    HTML:
    witch would echo somthing like <title>Home - Slogan</title>

    I need so i can log in to admin.php and there i can change $page_break & $page_slogan, ect...
     
    GeelongTECH, Dec 4, 2010 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Well, you need to store these values somewhere - preferably a database. If you don't have that, you need a lot more logic.

    What you need to do is create a form that sends the data input from the form into the database. If you don't have a database to play with, this is gonna be slightly more hasslesome, although you can rewrite the config-file each time you change stuff from the form (but again, this is a bad solution, and not something you want to do)
     
    PoPSiCLe, Dec 5, 2010 IP
  5. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #5
    assuming that you submit the page_break and page_slogan via post .. you can use this code:
    
    <?php
    if(count($_POST) > 0)
    {
            $page_break = filter_input(INPUT_POST, 'page_break', FILTER_SANITIZE_STRING);
            $page_slogan = filter_input(INPUT_POST, 'page_slogan', FILTER_SANITIZE_STRING);
            $data = '<?php' . "\n";
            $data .= '$page_break = \'' . $page_break . '\';' ."\n";
            $data .= '$page_slogan = \'' . $page_slogan . '\';' ."\n";
            $data .= '?>';
    
            $fp = fopen('includes/config.php', 'w');
            fwrite($fp, $data);
            fclose($fp);
    }
    ?>
    
    Code (markup):

    Don;t forget to make includes/config.php writable by web server.
    I hope that helps
     
    drctaccess, Dec 5, 2010 IP
  6. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    we don't know how your admin.php looks like... were you want to add it... etc.
     
    w47w47, Dec 5, 2010 IP
  7. GeelongTECH

    GeelongTECH Peon

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks that worked but when if using that i posted
    <script type="text/javascript"><!--
    google_ad_client = "pub-3438406889490676";
    google_ad_slot = "9467592827";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    HTML:
    sent for $global_nav_728x90 it writes as
    <?php
    $global_nav_ad728x90 = '
    
    
    ';
    ?>
    PHP:
    and if i make it on one line like
    <script type="text/javascript">google_ad_client = "pub-3438406889490676"; google_ad_slot = "9467592827"; google_ad_width = 728; google_ad_height = 90;</script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
    HTML:
    it writes it as
    <?php
    $global_nav_ad728x90 = 'google_ad_client = &#34;pub-3438406889490676&#34;; google_ad_slot = &#34;9467592827&#34;; google_ad_width = 728; google_ad_height = 90; ';
    ?>
    HTML:
    so in case you need to see the code i'm using its:
    <?php
    if(count($_POST) > 0)
    {
            $global_nav_ad728x90 = filter_input(INPUT_POST, '$global_nav_ad728x90', FILTER_SANITIZE_STRING);
            $data = '<?php' . "\n";
            $data .= '$global_nav_ad728x90 = \'' . $global_nav_ad728x90 . '\';' ."\n";
            $data .= '?>';
    
            $fp = fopen('includes/advertisement.php', 'w');
            fwrite($fp, $data);
            fclose($fp);
    }
    ?>
    PHP:
    Thanks,
     
    GeelongTECH, Dec 5, 2010 IP
  8. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #8
    It is because of filtering the data... since you are not using it in database you can use it like this:

    
    $google = '<script type="text/javascript"><!--
    google_ad_client = "pub-3438406889490676";
    google_ad_slot = "9467592827";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';
    
    
            $data = '<?php' . "\n";
            $data .= '$global_nav_ad728x90 = \'' . $google . '\';' ."\n";
            $data .= '?>';
    
            $fp = fopen('includes/advertisement.php', 'w');
            fwrite($fp, $data);
            fclose($fp);
    
    Code (markup):
    however this is not good practice because someone can inject code into the file and then access the file through the browser
     
    drctaccess, Dec 5, 2010 IP