I may need to update my code

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ScroogeMcDuck
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Apr 24, 2014 8:12 am

I may need to update my code

Postby ScroogeMcDuck » Thu Apr 24, 2014 12:23 pm

Edit, read my next post. A server migration caused my problem, but I still need help :) The next post explains everything.
Last edited by ScroogeMcDuck on Fri Apr 25, 2014 9:28 pm, edited 1 time in total.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: I may need to update my code

Postby seandisanti » Fri Apr 25, 2014 6:17 pm

are you receiving any errors? permission denied on the file for example

ScroogeMcDuck
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Apr 24, 2014 8:12 am

Re: I may need to update my code

Postby ScroogeMcDuck » Fri Apr 25, 2014 9:27 pm

Hi, no errors, however here's my update. It turns out my account was migrated to another server, that's why it wasn't working, but it all works now. However I still need help. Please read on :)

Here's how my system works: One script writes a txt file to a specific folder (with permissions 755). It also sends it as an e-mail. When the e-card is viewed, the other script tells the e-card to get info from the text file.

In php 5.3 I enable Register_Globals in the php.ini, however in php 5.4, I added the following script to both my own scripts to make it work (emulated Register_Globals):

Code: Select all

register_globals( 'NGPCFRES' );

function register_global_array( $sg ) {
    Static $superGlobals    = array(
        'e' => '_ENV'       ,
        'g' => '_GET'       ,
        'p' => '_POST'      ,
        'c' => '_COOKIE'    ,
        'r' => '_REQUEST'   ,
        's' => '_SERVER'    ,
        'f' => '_FILES'     ,
        'n' => '_SESSION'
    );
    Global ${$superGlobals[$sg]};
    foreach( ${$superGlobals[$sg]} as $key => $val ) {
        $GLOBALS[$key]  = $val;
    }
}
function register_globals( $order = 'gpc' ) {
    $_SERVER;       //See Note Below
    $_ENV;
    $_REQUEST;
    $order  = str_split( strtolower( $order ) );
    array_map( 'register_global_array' , $order );
}


So things are working in the meantime, however I'd like to totally go off the Register_Globals if possible. That's where I'll need help. I will attach two txt files to this post, they are the two scripts that make everything work.

scripts.rar
Ecard Scripts
(2.26 KiB) Downloaded 19 times

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: I may need to update my code

Postby seandisanti » Fri Apr 25, 2014 9:51 pm

depending on server configuration, you should have access to the relevant superglobals. Don't use $_REQUEST though, use specific $_GET or $_POST


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests