PHP - Finding What Uses Register_globals And Changing It To Work Without
i have two SMTP scripts (attached) they need register_globals to be on to work without destroying one of my cookies.
how do i modify them so that they dont need register_globals? thank you, sorry for the open ended question, ask me anything to help you help me! thanks. [attachment deleted by admin] Similar TutorialsI have script that I need register_globals = On right now I have to put php.ini into root of my webpage on webhost. but that means it turn on register_globals = On for whole site. I have tried just putting php.ini into subdomain but does not work, well script does not work. I have tried to put AddHandler application/x-httpd-php5s .php into the .htaccess in subdomain but that does not work either, script stop working. I can not get script to work if php.ini is in root of webpage webhost. What I'm I doing wrong, thanks When I turn register_global is turned off (register_argc_argv is also set to off), this script won't work. How can I have register_globals turned off and make this work for me. Any help is highly appreciated. <?php $bd_me = mysql_bd_meect("localhost","db_me","pw_me"); mysql_select_db("db_me"); $query =sprintf("SELECT * FROM db WHERE unamename = '%s' AND stus = 'Banned'", mysql_real_escape_string($uname)); $query_new = mysql_query($query); if(mysql_num_rows($query_new)) { $login = "Sorry."; echo($login); } else { $result=sprintf("SELECT * FROM db WHERE unamename = '%s' AND password ='%s'", mysql_real_escape_string($uname), mysql_real_escape_string($password)); $resultf = mysql_query($result); if(mysql_num_rows ($resultf) == 0) { $login = "Failed."; echo($login); } else { $row = mysql_fetch_array($result); $uname=$row['uname']; $password=$row['password']; $login = "$uname=" . $uname . "$password=" . $password . "Successful."; echo($login); } } ?> Is there any other settings that needs to be changed in the php.ini to make this code work while register_globals is turned off? Hello All! Can anyone explain why when I run the following code <?php print_r($GLOBALS); ?> I get the following output Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET] => Array ( ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) ) which is expected since register_globals is set to off and no variables are defined, but when I add the following code. which is just to echo out a variable from the superglobal $_SERVER, the print_r($GLOBALS) now outputs all the superglobal $_SERVER variables as if echo somehow made all the variables available to the script and now $GLOBALS sees them. maybe a stupid question I don't know. For obvious reasons I can't show the output, but it's easy enough to run the code to view your systems output. <?php print_r($GLOBALS); echo "<br />"; echo "<br />"; echo $_SERVER["DOCUMENT_ROOT"]; ?> Thanks, steadythecourse Hi all, Just moving my old website to a new server and I can't turn register_globals off. The company that designed the site for me has long gone and I don't know enough about php to do this...any help would be greatly appreciated. The error I am getting when trying to access the page is [01-Feb-2011 05:37:13] PHP Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 [01-Feb-2011 05:37:14] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'newquayu_uncover'@'localhost' (using password: YES) in /home/xmasphot/public_html/www.newquayuncovered.com/music/classes/DB_class.php on line 44 I have had to change the name of the database and the access details, this has been reflected in other documents but I am guessing that this is trying to use the orignal details somehow??? <? /* Script * Date Created: 07 Jun, 2004 * Last Updated: 07 Jun, 2004 * * DB_class.php */ class DB { //connection parameters var $host = ''; var $user = ''; var $password = ''; var $database = ''; //Database connection handle var $conn = NULL; //Query result var $result = false; var $row; function DB($host,$user,$password,$database,$persistent = true) { $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; $this->perstitent = $perstitent; } function open() { //chose appropriate connect function if($this->perstitent) { $func = 'mysql_pconnect'; } else { $func = 'mysql_connect'; } //connect to mysql server $this->conn = $func($this->host,$this->user,$this->password); if(!$this->conn) { echo mysql_error(); exit; } //select the requested database if(!mysql_select_db($this->database,$this->conn)) { echo mysql_error(); exit; } return true; } function close() { return(mysql_close($this->conn)); } function error() { return(mysql_error()); } function query($sql) { /*if(!$this->result = mysql_query($sql,$this->conn)){ echo mysql_error(); exit; }*/ $this->result = mysql_query($sql,$this->conn); return $this->result; } function fetchobject($result='') { if(!$result){ $result = $this->result; } if(!$res = mysql_fetch_object($result,MYSQL_ASSOC)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function fetcharray() { if(!$res = mysql_fetch_array($this->result,MYSQL_NUM)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function fetchfield() { if(!$res = mysql_fetch_field($this->result)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function numrows($result='') { if(!$result){ $result = $this->result; } if(!$res = mysql_num_rows($result)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function affectedrows() { if(!$res = mysql_affected_rows($this->conn)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function insertid() { if(!$res = mysql_insert_id($this->conn)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function freeresult() { if(!$res = mysql_free_result($this->result)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } function fetchrow($result='') { if(!$result){ $result = $this->result; } if(!$res = mysql_fetch_row($result)){ if(mysql_error() != ""){ echo mysql_error(); exit; } } return $res; } } ?> Why won't this code work when register_globals is turned off (works fine when register_globals is on though). <?php $link = mysql_connect("localhost","un","pw"); mysql_select_db("the_db"); $username = $_POST['usernamex']; $surname = $_POST['surname']; $email = $_POST['email']; $result =sprintf("SELECT * FROM tbl WHERE username ='%s' || email = '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email)); $resultfin = mysql_query($result); if (mysql_num_rows ($resultfin) > 0){ $register = "Retry."; echo($register); } else { $go =sprintf("INSERT INTO tbl (username, email, surname) VALUES ('%s', '%s', '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email), mysql_real_escape_string($surname)); $resultg = mysql_query($go); $register = "Successful."; echo($register); } ?> Thanks, Bickey. hi guys. i am trying to set a variable to the session global variable. I've initialized the session with session_start(); at the very beginning of my website, and then i try finding if a session variable has been set like so if(isset($_SESSION['user'])) { print 'user is logged in'; } but this works in reverse. i have not set any session variables, but asking if it is set, results in an affirmative answer. so i am thinking this is because of register_globals. because i went to read about register_globals, and it says that if register_globals is turned off, i cannot use any other varibale except members of the session array. i dont know what that is yet, but a question befo in the php manual it says register_globals is deprecated, and it appears i need to enable it to set other variables as session variables besides it's associative array. if this is true, how to enable register_globals and allow other variables to be used as session variables? In the following code, Code: [Select] // Register Globals if (ini_get('register_globals')) { ini_set('session.use_cookies', 'On'); ini_set('session.use_trans_sid', 'Off'); session_set_cookie_params(0, '/'); session_start(); $globals = array($_REQUEST, $_SESSION, $_SERVER, $_FILES); foreach ($globals as $global) { foreach(array_keys($global) as $key) { unset($$key); } } } the above destroys all globals if register_globals is on, as I understand it. However, if it does destroy all globals, can a web form continue to work? How do you allow form fields and other stuff to be used in a script even if you kill all the globals up front? Many thanks Okay I'm done with searching for answers, working on this preg_match for about 3 hours now.
I'm looking for "($0.01/$0.02 USD)" in a string. The needle might be slighty different. Possible strings that I might look for is: (€xx.xx/€xx.xx EUR) where the EUR can be changed into USD, including its signs. Hi I have a file, that is copied from other files. All other files work perfectly. But, for some reason this one is throwing back an error. I've been over it so many time, but can't see whats wrong. Error: Fatal error: Call to undefined method stdClass::save() in /home/p/o/powtest/web/public_html/admin/lib/ajax_php/add_interests.php on line 28 add_interests.php Code: [Select] <?PHP require_once("../../../includes/initialize.php"); $flag = 0; $ID = $_POST['ID']; $type = $_POST['type']; $category = $_POST['category']; $interest = $_POST['interest']; $expInt = explode("\n", $interest); $DMOD = date('Y-m-d'); $TMOD = date('H:i:s'); $check_entry = Admin_interest::if_exists(clean_input_value($category)); if($check_entry == 0){ $new_category = Admin_interest::make($ID, clean_input_value($category), clean_input_value($type), $DMOD, $TMOD); if($new_category && $new_category->save()){ $CID = $new_category->id; $flag = 1; } } foreach($expInt as $expInts){ $check_entry = Admin_interests_sub::if_exists($CID, clean_input_value($expInts)); if($check_entry == 0){ $new_interest = Admin_interests_sub::make($ID, $CID, clean_input_value($expInts), $DMOD, $TMOD); if($new_interest && $new_interest->save()){ $message = 'Thank You: Your list Has Been Saved'; }else{ $message = "Sorry, There was an error"; } } } echo $message; ?> Class: Code: [Select] <?PHP require_once(LIB_PATH.DS.'database.php'); class Admin_interests_sub { protected static $table_name="admin_interests_sub"; protected static $db_fields = array('id', 'category_id', 'interest_sub', 'dateMod', 'timeMod'); public $id; public $category_id; public $interest_sub; public $dateMod; public $timeMod; public static function make($ID, $category_id, $interest_sub, $DMOD, $TMOD){ if(!empty($interest_sub)){ $interest = new Admin_interests_sub(); $interest->id = (int)$ID; $interest->category_id = (int)$category_id; $interest->interest_sub = $interest_sub; $kw->dateMod = $DMOD; $kw->timeMod = $TMOD; return $kw; }else{ return false; } } protected function attributes(){ $attributes = array(); foreach(self::$db_fields as $field){ if(property_exists($this, $field)){ $attributes[$field] = $this->$field; } } return $attributes; } protected function sanitized_attributes(){ global $database; $clean_attributes = array(); foreach($this->attributes() as $key => $value){ $clean_attributes[$key] = $database->escape_value($value); } return $clean_attributes; } public function save(){ return !empty($this->id) ? $this->update() : $this->create(); } public function create(){ global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)){ $this->id = $database->insert_id(); return true; }else{ return false; } } public function update(){ global $database; $attributes = $this->sanitized_attributes(); $attribute_pairs = array(); foreach($attributes as $key => $value){ $attribute_pairs[] = "{$key}='{$value}'"; } $sql = "UPDATE ".self::$table_name." SET "; $sql .= join(", ", $attribute_pairs); $sql .= " WHERE id=".$database->escape_value($this->id); $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } public function delete(){ global $database; $sql = "DELETE FROM ".self::$table_name." "; $sql .= "WHERE id=".$database->escape_value($this->id); $sql .= " LIMIT 1"; $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } } ?> Any help finding this bug will be a big help. Thanks hi there all i need the code that adds the url to a page like in the new forums cheers.
you get a image of that website and the url of the page
can anyone help please
thank you
like if i type www,google.com <<< you get a image and link automaticly..
Edited by php-real-degree, 15 September 2014 - 05:07 PM. Im trying to find the time between the last database entry and the current time and then echo it so it says something like '2 minutes ago'. I tried doing: $last_post_gap = strtotime('NOW') - strtotime($topic_info->topic_last_post_time); $last_post_gap = date('i', strtotime($last_post_gap)); $last_post = date('F j, Y', strtotime($topic_info->topic_last_post_time)); if ($last_post <= '- 1 DAY') { $last_post = 'Yesterday at '.date("g:i a", strtotime($topic_info->topic_last_post_time)); } if ($last_post <= '- 1 MINUTE') { $last_post = 'Less Than 1 Minute Ago'; } else { $last_post = $last_post_gap.' Minutes Ago'; } but that just displays 0 minutes ago regardless of the time. Is there anything im missing? Hello. I think I have a little unique and difficult to solve problem that I really need to post here. I, as a counter-strike portal administrator, am running some CS servers. With automatical script, the server uploads demos (videos of gameplay) on FTP in this format: 101229154428.dem and so on. The number is a date in this format: year, month, day, hours, minutes, seconds => for the example it's 29th December 2010, 15h, 44m and 28s. Then I have a "report" page. The important part on it is that, there is a date in unix timestamp in each row like 1336837680 (29th december 2010, 15h, 47m, 00s). And now what I need: Find a demo that corresponds to the unix timestamp. If there is a timestamp 1336837680, it should find 101229154428.dem. You know what I mean, there is not one demofile, there are plenty. Just find the demo, that contains a record of the time used in timestamp. Pretty difficult, isn't it? I would love to see if anybody came up with anything. Best regards! Howdy Colleagues,
I was wondering whether you know ways/websites/channels/magic owls to how to help find a job in USA as a programmer as in for relocating there while the company pays for the Visa and the travel expenses?
My land-lord's son found a job as a programmer in Texas and the company was generous and kind enough to pay his travelling expenses, as well for his wife and kid.
I have an account in Monster & Indeed and I send CVs very often, but no luck so far.
And I want to go there to work and live, not like some people to rely on welfare, I have worked my whole life.
Thank you!
BR,
Stefany
Hi , I'm new on this forum so don't judge too hard.. But I have a few questions. I am recently new to PHP as this is my first computer language I've learnt besides HTML. My first question is, what's the difference between !== and !=, and is it more secure to use !== when comparing two fields such as passwords? I've different things and this has confused me.. And my second question is, I have this piece of code Code: [Select] /* option error checking */ $field = "option"; // Use field name for option /* Check if the option picked is from the list of options to choose from*/ if($suboption !== "option1" || $suboption !== "option2" || $suboption !== "option3" || $suboption !== "option4" || $suboption !== "option5" || $suboption !== "option6" || $suboption !== "option7"){ $form->setError($field, "* Unexpected error with option"); } I'm guessing in the long run, this will slow down my script.. is there an easier way of checking without using || $suboption !== and is it okay if I've used !==? Like I said I'm new to this so please don't flame.. I've done some research but I can't seem to find some accurate answer. Thank you, ZT //calculate age $birthdate = "1978-04-26"; //birth date... actually being obtained from a database $today = date("Y-m-d H:i:s"); // The exact date $age = date_diff($str_birthday, $today); echo $age; I'd like a simple code to echo the age of someone with the mysql database information that's in their record. This doesn't work. I have no idea why. Nothing seems to work that I've found on the net. Please help. Thanks. User submits 1 or more refrerences via a form. On the action page I want to check if any id's on the page match any values submitted in $_POST. Code: [Select] $Ref = $_POST['Ref']; $source = file_get_contents( 'E:/wamp/www/Project/File.php' ); $document = new DOMDocument; $document->validateOnParse = true; $document->LoadHTML($source); for($i=0; $i<count($Ref); $i++) { $ID = $document->getElementById('$Ref[$i]'); } I have a table on the source page with the same id as a reference contained in $Ref, but getElementById is not seeing/recognsing it. No idea why not. What I want to be able to do is this: If I have a list of values in my database: 1 13 26 15 12 4 I do a query of this database and sort it asc so it looks like this: 1 4 12 13 15 26 I want to know how I can use php and/or sql query to find these values based off of "position" in the list. If I wanted the 3rd value in the list, that value would be 12. If i wanted the 2nd value in the list it would be 4. How would I go about doing this? Thank you in advance. I am trying to find the URL to a directory TWO levels above the script level (if you know what I mean). For example.. the script sits at Code: [Select] http://www.domain.com/TestArea2/members/index.php BUT I need to find the path to Code: [Select] http://www.domain.com/TestArea2/ the nearest I get is... $domain = $_SERVER['HTTP_HOST']; $domain .= $_SERVER['REQUEST_URI']; echo $domain; // outputs www.domain.com/TestArea2/members/index.php Is there a simple method to do this or have I got to split the string and work backwards? Many thanks My query is not finding the last recieptnum entry, it is finding the number 9 everytime for some odd reason. Im trying to incrementally increase this each time a reciept is created. $getreceiptnum = mysql_query("SELECT receiptnum FROM accounting WHERE agency = '$agency' ORDER BY receiptnum DESC LIMIT 1") or die(mysql_error()); $recieptarray = mysql_fetch_array($getreceiptnum); $recieptnum = $recieptarray['receiptnum']; echo $recieptnum; I run MAMP and would like to know where I can find and view the data stored in my Sessions? Any ideas? Thanks, Debbie |