Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location

Ansego's Achievements


Member (2/5)



  1. um. Post the script and front page code...? or any other relative code required. One on one you would need to come up with a better way to ask your question. First understand what your question is and what you are trying to achieve and provide evidence, elements and descriptions that we could use to understand your problem more clear. This way we can help you and have a better understanding of the problem that you face. Welcome to try phpfreaks IRC chat... http://www.phpfreaks.com/page/irc-live-chat
  2. fyi your IF statement failed: Failed: if (isset($_SESSION['logged']) && $_SESSION['logged'] !== true){ Operators !== failed. Works: if (isset($_SESSION['logged']) && !$_SESSION['logged'] == true){ Works: if (isset($_SESSION['logged']) && $_SESSION['logged'] != true){
  3. Thanks, I assumed "session_id()" had something to do with the security of the session, thanks for straightening that up, was scratching my head on it for awhile. Thought encryption type "multipart/form-data" was for file uploads and "text/plain" was for debugging? All good, I'll start using "multipart/form-data" Nope, that was it, was just working out sessions to have a better grasp. Acceptable to use for a website session. Or has it got security breech all over it? Put the exit(); under the redirection headers. The GET was just for a quick msg, if someone wants to put junk in there it only echo's back ( Unless that is a breech? ). Thanks for your feed back mate, fixing the code up now.
  4. Hi guys, Have some questions about "SESSIONS". I am setting: $_SESSION['sessionID'] = session_id(); BUT not sure how to use it correctly or what for? Is code below acceptable? Any suggestions for improvements? <?php error_reporting(-1); ini_set('display_errors', 'On'); spl_autoload_register(function ($class) { include 'lib/' . $class . '.inc'; }); session_start(); // =============================================================== if (isset($_GET['msg'])){ echo $_GET['msg']; } // =============================================================== if (isset($_POST['btn_login']) && !empty($_POST['btn_login'])){ $_SESSION['logged'] = "true"; $_SESSION['sessionID'] = session_id(); session_write_close(); header( 'Location: http://localhost/work/index.php?msg=Logged in!' ) ; } // =============================================================== if (isset($_POST['btn_logout']) && !empty($_POST['btn_logout'])){ //true $_SESSION['logged'] = ""; $_SESSION['sessionID'] = ""; session_write_close(); session_destroy(); header( 'Location: http://localhost/work/index.php?msg=Logged out!' ) ; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Server Status</title> </head> <body> <?php // =============================================================== if (!$_SESSION['logged'] == true){ ?> <form action="#" method="post" enctype="application/x-www-form-urlencoded" name="user-login"> <input name="btn_login" type="submit" value="Logon" /> </form> <?php }else{ ?> <form action="#" method="post" enctype="application/x-www-form-urlencoded" name="user-login"> <input name="btn_logout" type="submit" value="Logout" /> </form> <?php } ?> </body> </html> Kind regards and thanks.
  5. Hi, mysql_real_escape_string() Warning This extension is deprecated as of PHP 5.5.0 http://www.php.net//manual/en/function.mysql-real-escape-string.php
  6. Thanks guys awesome feed back and help A+++
  7. Hi Raz3rt Nothing jumps out at me, though 4am... Could you please show us the full mail code. This is what I use in my headers: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Take over the world Reminder <totw@example.com>' . "\r\n"; Worth trying a different header. Are you also sure the SMTP/POP3 server is setup correctly?
  8. Hi guys, Thanks for replying. @neil.johnson I have tried a simple connection script, works fine. But again when multiple servers using that script run into the same trouble of waiting. The function works, just a slow process. @Psycho Option 1 sounds like the only option to do, though is there a process function for php or does it require a session? Any suggestions on a process kept alive without a user present, that would be great ( Keeping in mind I am on a Windows box... I can hear you guys spewing up! ). I understand what you mean about the get_status() function, I will implement yours. Also agree that it seems long winded to process the output in another function. Looking forward to hear what you guys suggest for live process without the human element. Thank you for the great information and feed back.
  9. Hi guys, I've tested this code on the dev and live server and is very slow to run, is there something I am missing or looped? Or just plain wrong? I do however get the results after a little time, I have 6 records in the test database for testing but this is meant to be built for 100+ servers, will just take for ever to load... PS: Welcome any constructive suggestions My thoughts: I do however have a feeling it maybe: stream_socket_client ( If so, anyway to speed it up? ) with the wait time for a response from the server. Live server I pushed this on should not have to much trouble of that though, since it is in the same rack farm as the servers that it was tested on. So far I've increased and no change: memory_limit = 256M in the php.ini file. query_cache_size=256M in the my.ini for MySQL CODE: ( WARNING BIT MESSY ) Index.php: <?php error_reporting(-1); ini_set('display_errors', 'On'); spl_autoload_register(function ($class) { include 'lib/' . $class . '.inc'; }); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> </head> <body> <?php $servers = new servers; ?> </body> </html> lib/dbcon.inc: <?php include_once 'settings.inc'; class dbcon { protected $db_Hostname = HOSTNAME; protected $db_Username = USERNAME; protected $db_Password = PASSWORD; protected $db_Database = DATABASE; protected $dbConnection; public function __construct(){ $this->set_connection(); } public function set_connection(){ $this->dbConnection=mysqli_connect($this->db_Hostname,$this->db_Username,$this->db_Password,$this->db_Database); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } } public function get_connection(){ echo "Got connection"; return $this->dbConnection; } public function close_connection(){ echo "Connection Closed..."; mysqli_close($this->dbConnection); return true; } } ?> lib/servers.inc: <?php include_once 'settings.inc'; class servers { protected $dbConnection; function __construct() { spl_autoload_register(function ($class) { include '' . $class . '.inc'; }); $dbcon = new dbcon; $this->dbConnection = $dbcon->get_connection(); $this->get_servers(); } // End Construct public function get_servers(){ $message = ''; $message = '<h3>Current Servers</h3>'; $con = $this->dbConnection; $result = mysqli_query($con,"SELECT * FROM server_status.tbl_servers;")or die("Error: ".mysqli_error($con));; while($row = mysqli_fetch_array($result)) { $message .= "" . $row['ssGameType'] . " : "; $message .= "" . $row['ssIP'] . ":" . $row['ssPort'] . " : "; $message .= " Status:" . $this->get_status($row['ssIP'],$row['ssPort']) . " : "; $message .= "Timestamp:" . $row['Timestamp'] . " : "; $message .= "Orderby:" . $row['ssOrder'] . "<br />"; } $message .= "<br />End of the \"Server List\" "; $message .= "<br />"; echo $message; //$this->dbConnection->close_connection(); // FAILED return $message; } public function get_status($ServerIP,&$ServerPort){ if(@stream_socket_client("tcp://$ServerIP:$ServerPort", $errno, $errstr, 5) !== false) { return "<strong style='color:#33CC00'>Online</strong>"; } else { return "<strong style='color:#CC0000'>Offline</strong>"; } } } // End class ?> Results: Current Servers Minecraft : xxx.xxx.xxx.xxx:25575 : Status:Online : Timestamp:2014-06-17 22:19:46 : Orderby:1 Minecraft : xxx.xxx.xxx.xxx:25576 : Status:Offline : Timestamp:2014-06-17 22:19:54 : Orderby:2 Minecraft : xxx.xxx.xxx.xxx:25577 : Status:Offline : Timestamp:2014-06-17 22:20:00 : Orderby:3 Minecraft : xxx.xxx.xxx.xxx:25578 : Status:Offline : Timestamp:2014-06-17 22:20:06 : Orderby:4 Minecraft : xxx.xxx.xxx.xxx:25579 : Status:Offline : Timestamp:2014-06-17 22:20:13 : Orderby:5 Minecraft : xxx.xxx.xxx.xxx:25580 : Status:Offline : Timestamp:2014-06-17 22:20:20 : Orderby:6 End of the "Server List" Advance thanks for any help guys.
  10. I agree with @requinix, Might want to post the function code that handles the output. May have something like: strtolower($str); in there... ( REF: http://www.php.net//manual/en/function.strtolower.php ) If not maybe try another browser as @ginerjm suggested.
  11. @Jacques1 - These suggestions are amazing and sooo much appreciated mate, I've copied them down and are on my desktop for reference. Seriously thank you for the feed back, great bunch of guys on this forum, thank you, ps. Hope you don't mind I will send you a pm to pick your brains some. Re Ansego.
  12. lol @jarvis mac_gyver and Ch0cu3r suggestion is to redirect off that page for the result as it does not change it there and then. I had similar problems with sessions too and had to redirect it. I think there is a rule that this is meant to be at the top of the page but I've used it with in the page: header( 'Location: index.php' ) ; for redirection. Maybe try: $cookie_name = 'defaultLanguage'; if (isset($_GET["language"]) && !empty($_GET["language"])){ $cookie_value = $_GET["language"]; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day header( 'Location: index.php' ); // Redirect to a page }else{ $cookie_value = 'English'; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day header( 'Location: index.php' ); // Redirect to a page } If this does not work hopefully these guru's can shed some more light. But least this will have a redirection, just hope the logic is right. Good luck ;-)
  13. Sorry bit like blind leading blind, I just got over my head ache with sessions. Did not see anything check if $_COOKIE["defaultLanguage"] pre existed. In regards to @ ginerjm Manual: http://www.php.net/manual/en/function.setcookie.php @ ginerjm: You talking about example #1 OR Path, Domain, Secure and httponly? Example #1: <?php $value = 'something from somewhere'; setcookie("TestCookie", $value); setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */ setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1); ?> Test Example: <?php // Print an individual cookie echo $_COOKIE["TestCookie"]; echo $HTTP_COOKIE_VARS["TestCookie"]; // Another way to debug/test is to view all cookies print_r($_COOKIE); ?>
  14. Hi Jarvis, I am still new with cookies / sessions and all so this may not work, but could you try this: $cookie_name = 'defaultLanguage'; if (empty($cookie_value)){ $cookie_value = 'English'; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day }else{ $cookie_value = $_GET["language"]; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 day }
  15. Disregards Ch0cu3r on the job.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.