<?php $script_array = array('tcp_server.php', 'db_server.php'); // $script_name = 'tcp_server.php'; function serch($script_name) { unset($output); exec('ps ax| grep ' . $script_name, $output, $retval); //var_dump($output); foreach ($output as $process_id => $prosess) { //var_dump($prosess); if (strpos($prosess, '/www/' . $script_name)) { $pid = explode(' ', trim($prosess)); return $pid[0]; } } return false; } foreach ($script_array as $script_names) { $process_id = serch($script_names); if ($process_id === false) { //echo 'start'; pclose(popen('php /www/' . $script_names . '&', 'r')); mail('*****@*****.**', 'Process started!', 'Process started ' . $script_names . '!', 'From: mail@mail.com'); } }
<?php if ($con = mysqli_connect('localhost', 'root')) { // echo "success!"; } else { echo "wrong!"; } if (mysqli_select_db($con, 'pmxg')) { // echo "open pmxg successfully!"; } else { echo "failed to open pmxg!"; } if ($_SERVER["REQUEST_METHOD"] == "GET") { serch(); } if ($_SERVER["REQUEST_METHOD"] == "POST") { create(); } function serch() { $con = mysqli_connect('localhost', 'root'); mysqli_select_db($con, 'pmxg'); $name = $_GET["name"]; $query = mysqli_query($con, 'SELECT * FROM score ORDER BY score DESC LIMIT 10'); for ($i = 0; $i < 10; $i++) { $row = mysqli_fetch_array($query); echo $row[1] . " Got " . $row[0] . " At " . $row[2]; echo "/"; } mysqli_close($con); }