Jump to content

Issam

Members
  • Posts

    15
  • Joined

  • Last visited

Issam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Suppose that in a coffee shop we are three connected to the same router and sharing the same public ip, so our local network is the following : User1 : Ch0cu3r User2 : Russia User3 : Issam As far as i know, the only identifier used by php to physically identify a machine is ny its public ip address (before doing session stuff..). So when Russia connects to phpfreaks and authenticate while Issam and Ch0cu3r are not yet authenticated, so the server receive a request with its public ip, the packet that the server receive will also contain the local ip of the machine in the local network to be able to distinguish it from other requests coming from the same public ip. And here the question that come to ask, how to grab the local ip from the packet and use it especially using php ? or the http protocol interdict extracting local ip addresses ?
  2. Thanks, but how the server recognize that particular user from the other while both have the same public ip address ? how cookie can identify which one of them ?
  3. Hi, is two people or more sitting on the same local network and sharing the same public ip address will have the same session if they browse all of them into the same website or same php script that create session ?
  4. Hi, i know i need a vps for that, i have one but i would like to check if it work on shared or no. Thanks for giving me the right commands, just please explain to me what does uptime return ? for me this is the output : uptime command: 04:03:03 up 9 days, 5:28, 4 users, load average: 0.34, 0.44, 0.56 free command: Mem: 2941848 2811196 130652 172904 234948 1104000 -/+ buffers/cache: 1472248 1469600 Swap: 1028092 16668 1011424 How to extract the valuable information i need from the output using php ? i need to extract cpu load, current memory usage and total memory available. Thank you
  5. Hi again, the command is : $res = shell_exec('ps aux --sort -rss'); Now, how to extract total memory usage and total cpu usage from the result ? Thank you
  6. Hi, sys_getloadavg doesn't return any array when i run it from my shared hosting account, even if it is not disabled but works when test it on localhost. So how to get that info using a different approach ? Thanks.
  7. Okay, i have a function that uses a garbage collector and may consume lot of resources, so i would like to run it and at same time catch the event of resources overload. More like that: try { use_my_garbage_func(); } catch($ServerOverload) { // 1. Terminate or free resources // 2. Die or kill the script } So what i need is how to figure if there is a server overload, it can be database, cpu or memory and the script should finish even if it is not itself which is causing the overload, because someone will ask me why don't you optimize your function so for that reason. Thank you
  8. Hi; I would like to sleep the script using sleep function or even usleep while the system is in overload condition. do { $is_memory_overload = check_memory_overload(); $is_cpu_overload = check_cpu_overload(); $is_database_overloaded = check_database_overload(); sleep(1); } while($is_memory_overload || $is_cpu_overload || $is_database_overloaded); The idea is fairly simple, do nothing while there is an overload which can be from cpu or memory or database. Thank you
  9. Hi to all; Is there any way, a function for example in php to add to my script in order to guess if the running script is facing a cpu overload or a memory overload or a slow processing speed ? Thanks
  10. Hi, again I would like to make an installer that check if it is a vps or a shared not for my own but for people using the script. Some instructions and configuration have to be specific to shared hosting while an other specification for a vps or even a dedicated server, even if dedicated servers are too few. Regards
  11. Hi, I would like to ask if someone knows a trick to know if the script is running on a shared hosting or a vps or a dedicated server. Regards
  12. Hi hansford; Does the function time() is independent no matter what timezone the server is using and no matter which time the server is running on right ? Thanks
  13. Hi; I would like to get the current timestamp but the question is that i want to get the real time which is the machine bios time that can't change by the server administrator and not the server time which can be modified to any value. Thanks
  14. Hi jcbones, there is some cases in witch an htaccess rules can't coincide with each other or my knowledge isn't capable to find an htaccess solution to it. Here is an example for possible htaccess scenario : I have two .htaccess portions that i want to add both of them into one .htaccess file, the first portion can't be modified and its content is this one : RewriteCond %{REQUEST_FILENAME} \.php$ RewriteCond %{REQUEST_FILENAME} !/index[23]?\.php$ RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^([^/]+/)*([^/.]+\.)+php$ - [F] The second portion is this one, but the flags can be modified to resolve this issue of course : RewriteRule (.*) /var/www/html/script.php [L,QSA] Now here is the problem, if i add the first portion before the second, the .htaccess will deny access to script.php because the first portion deny access to any filename different than index.php Now, if i add the second portion before the first portion, the first portion won't be read by the server because the second portion will redirect to script.php giving no chance to read the rest of the file and apply any other rule. So that is the cause that make me think to convert it to php code to resolve this kind of situations. Regards
  15. Hi; I would like to make a php script read the commands in the htaccess file and apply those commands to itself. Here is an example : htaccess commands : RewriteEngine On RewriteCond %{QUERY_STRING} badword RewriteRule .* - [F] The meaning : Deny any request in witch the query string contain the word badword The translation into php code : if( strpos($_SERVER['QUERY_STRING'], 'badword') !== false ) { header('HTTP/1.1 500 Internal Server Error'); exit(0); } Now this example is simple, but how to translate more complex htaccess commands with multiple RewriteCond and complex regular expressions into php commands like the one i did ? or better is there any php script that read an entire htaccess file and apply the rule it read on it ? Thank you
×
×
  • 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.