Jump to content

void_set

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by void_set

  1. Hello how can i modify this script to search in all subdirectories to get only one new directory? THX! This little script only search in current $path for newest directory but i also need to search in all subdirectories <?php function getNewestDir($path) { $working_dir = getcwd(); chdir($path); ## chdir to requested dir $ret_val = false; if ($p = opendir($path) ) { while (false !== ($file = readdir($p))) { if ($file{0} != '.' && is_dir($file)) { $list[] = date('YmdHis', filemtime($path.'/'.$file)).$path.'/'.$file; } } rsort($list); $ret_val = $list[0]; } chdir($working_dir); ## chdir back to script's dir return $ret_val; } ?>
  2. So basically this will opens a port at 3053 and i want to log those IP which connects to that port into port.txt, but it wont log, can you help me why ? <?php $ip = $_SERVER['REMOTE_ADDR']; // port number $port = 3053; // open the socket $socket = socket_create_listen($port); if ($socket === false) die("Error"); while (true) { // accept a request $client = socket_accept($socket); while (true) { $buf = socket_read($client, 2048); if ($buf == "") break; echo $buf; $fp = fopen("port.txt", 'a+'); fwrite($fp, "".$ip."\n"); fclose($fp); } socket_close($client); } socket_close($socket);
×
×
  • 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.