Exemplo n.º 1
1
function test($serviceId)
{
    $tableau = Connexion::query('select url,port,texte,trl from services where id=\'' . $serviceId . '\'');
    $url = $tableau[0][0];
    $port = $tableau[0][1];
    $texte = $tableau[0][2];
    $ping = ping($url, $port, $texte, $tableau[0][3]);
    $date = date('Y-m-d');
    $heure = date('H:i:s');
    $trl = $ping[2];
    $etat = $ping[0] == true ? 1 : 0;
    $codeHttp = strlen($ping[1]) != 3 ? '500' : $ping[1];
    Connexion::exec('insert into tests (service_id,date,heure,trl,etat,codeHttp) values (\'' . $serviceId . '\',\'' . $date . '\',\'' . $heure . '\',\'' . $trl . '\',\'' . $etat . '\',\'' . $codeHttp . '\')');
    if ($ping[0] == false or $trl * 1000 > $tableau[0][3] or $codeHttp != '200') {
        $res = false;
    } else {
        $res = true;
        validation($serviceId, $date, $heure);
    }
    if ($res == false) {
        notif($serviceId, $date, $heure);
        erreur($serviceId, $date, $heure);
    }
    return $res;
}
Exemplo n.º 2
0
function update_geraete()
{
    //UPDATE geraete SET zeitEin = $timestamp WHERE id = 1"
    $defaultIP = "0.0.0.0";
    //$sqlbefehl = "SELECT id,ip,zeitEin FROM `devices` WHERE ip NOT like '" . $defaultIP . "'";
    $sqlbefehl = "SELECT id,ip,zeitEin,zeitHeute FROM `devices` WHERE ip NOT like '" . $defaultIP . "' AND ip NOT like ''";
    //SELECT id,ip,zeitEin FROM `devices` WHERE ip NOT like '0.0.0.0' AND ip NOT like ''
    $sql = query($sqlbefehl);
    //var_dump($sql);
    while ($row = fetch($sql)) {
        //var_dump($row);
        $result = ping($row['ip']);
        //var_dump($result);
        if ($result) {
            if ($row['zeitEin'] == "0") {
                $sql1 = query("UPDATE devices SET zeitEin = '" . time() . "' WHERE id = '" . $row['id'] . "'");
                // update Zeit Ein heute
            }
        } else {
            if ($row['zeitEin'] != "0") {
                $zeitHeute = time() - $row['zeitEin'];
                var_dump($zeitHeute);
                $sql2 = query("UPDATE devices SET zeitHeute = '" . $zeitHeute . "' WHERE id = '" . $row['id'] . "'");
                $sql1 = query("UPDATE devices SET zeitEin = '0' WHERE id = '" . $row['id'] . "'");
                //update Zeit Ein heute
            }
        }
    }
}
Exemplo n.º 3
0
 private function editOrSave($action)
 {
     if (!POST("title")) {
         return getAlert("You need to write a title");
     } elseif (!POST("description")) {
         return getAlert("You need to write a description");
     } elseif (!ping(POST("URL"))) {
         return getAlert("Invalid URL");
     } elseif (FILES("image", "name") === "" and $action === "save") {
         return getAlert("Selected image");
     } elseif (FILES("preview1", "name") === "" and $action === "save") {
         return getAlert("Selected preview");
     } elseif (FILES("preview2", "name") === "" and $action === "save") {
         return getAlert("Selected preview");
     }
     if (FILES("image", "name") !== "") {
         $upload = $this->upload("image");
         if ($upload) {
             $this->image = $upload;
         } else {
             return $this->error;
         }
     } else {
         if ($action === "edit") {
             $this->image = "";
         }
     }
     if (FILES("preview1", "name") !== "") {
         $upload = $this->upload("preview1");
         if ($upload) {
             $this->preview1 = $upload;
         } else {
             return $this->error;
         }
     } else {
         if ($action === "edit") {
             $this->preview1 = "";
         }
     }
     if (FILES("preview2", "name") !== "") {
         $upload = $this->upload("preview2");
         if ($upload) {
             $this->preview2 = $upload;
         } else {
             return $this->error;
         }
     } else {
         if ($action === "edit") {
             $this->preview2 = "";
         }
     }
     $this->ID = POST("ID_Work");
     $this->title = POST("title", "decode", "escape");
     $this->nice = nice($this->title);
     $this->description = POST("description");
     $this->URL = POST("URL");
     $this->state = POST("state");
 }
Exemplo n.º 4
0
 public function proccess($data = NULL, $validations = FALSE)
 {
     if (is_array($validations)) {
         foreach ($validations as $field => $validation) {
             if ($validation === "required") {
                 if (!POST($field)) {
                     $field = $this->rename($field);
                     return array("error" => getAlert("{$field} is required"));
                 }
             } elseif ($validation === "email?") {
                 if (!isEmail(POST($field))) {
                     return array("error" => getAlert("{$field} is not a valid email"));
                 }
             } elseif ($validation === "injection?") {
                 if (isInjection(POST($field))) {
                     return array("error" => getAlert("SQL/HTML injection attempt blocked"));
                 }
             } elseif ($validation === "spam?") {
                 if (isSPAM(POST($field))) {
                     return array("error" => getAlert("SPAM prohibited"));
                 }
             } elseif ($validation === "vulgar?") {
                 if (isVulgar(POST($field))) {
                     return array("error" => getAlert("Your {$field} is very vulgar"));
                 }
             } elseif ($validation === "ping") {
                 if (!ping(POST($field))) {
                     return array("error" => getAlert("Invalid URL"));
                 }
             } elseif (is_string($validation) and substr($validation, 0, 6) === "length") {
                 $count = (int) substr($validation, 7, 8);
                 $count = $count > 0 ? $count : 6;
                 if (strlen(POST($field)) < $count) {
                     return array("error" => getAlert("{$field} must have at least {$count} characters"));
                 }
             } elseif (isset($field["exists"]) and isset($this->table) and POST("save")) {
                 if (is_array($validation)) {
                     $exists = $this->Db->findBy($validation);
                     if ($exists) {
                         return array("error" => getAlert("The record already exists"));
                     }
                 }
             }
         }
     }
     if (is_null($data)) {
         $data = array();
     }
     $POST = POST(TRUE);
     foreach ($POST as $field => $value) {
         if (!in_array($field, $this->ignore)) {
             if (!isset($data[$this->rename($field)])) {
                 $data[$this->rename($field)] = decode(filter($value, "escape"));
             }
         }
     }
     return $data;
 }
Exemplo n.º 5
0
function getTypeC()
{
    global $_GET;
    if (!$_GET["ECOMM"]) {
        if (ping() == "logout") {
            header('Content-type: application/json');
            echo '{"die":"ok"}';
            exit(0);
        }
        return "ERP";
    } else {
        return "ECOMMERCE";
    }
}
Exemplo n.º 6
0
<?php

// starting point for tests to devices
// future: icinga, mtr, jitter etc....
if (!empty($_GET['ip'])) {
    $ip = $_GET['ip'];
    $pingReply = ping($ip);
    if ($pingReply) {
        $reply = "up";
    } else {
        $reply = "down";
    }
} else {
    $ip = null;
}
echo $reply;
// functions to play with
function ping($host)
{
    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
    return $rval === 0;
}
Exemplo n.º 7
0
 public function saveComments()
 {
     $this->ID_Application = POST("ID_Application");
     $this->ID_Record = POST("ID_Record");
     $this->comment = POST("comment", "clean", FALSE);
     $this->email = POST("email");
     $this->website = POST("website");
     $this->name = SESSION("ZanUser") ? NULL : POST("name");
     $this->username = SESSION("ZanUser") ? SESSION("ZanUser") : NULL;
     $this->ID_User = SESSION("ZanUserID") ? (int) SESSION("ZanUserID") : 0;
     $this->state = "Active";
     $this->date1 = now(4);
     $this->date2 = now(2);
     $this->year = date("Y");
     $this->month = date("m");
     $this->day = date("d");
     $this->URL = POST("URL");
     if ($this->ID_Application === "3") {
         if ($this->comment === NULL) {
             return getAlert("Empty Comment");
         }
         if (isSPAM($this->comment) === TRUE) {
             return getAlert("STOP, SPAM");
         }
         if (isVulgar($this->comment) === TRUE) {
             return getAlert("STOP, The Comment is Vulgar");
         }
         if (isInjection($this->comment) === TRUE) {
             return getAlert("STOP, Injection");
         } else {
             cleanHTML($this->comment);
         }
         if ($this->ID_User > 0) {
             $this->Db->table($this->table);
             $repost = $this->Db->findBySQL("Comment = '{$this->comment}' AND Year = '{$this->year}' AND Month = '{$this->month}' AND Day = '{$this->day}' AND Name = '{$this->name}'");
             if (is_array($repost)) {
                 return getAlert("This Comment has been posted yet");
             }
             $fields = "ID_User, Username, Comment, Start_Date, Text_Date, Year, Month, Day, State";
             $values = "'{$this->ID_User}', '{$this->username}', '{$this->comment}', '{$this->date1}', '{$this->date2}', '{$this->year}', '{$this->month}', '{$this->day}', '{$this->state}'";
             $this->Db->table($this->table, $fields);
             $this->Db->values($values);
             $this->insertID1 = $this->Db->save();
             $fields = "ID_Application, ID_Comment";
             $values = "'3', '{$this->insertID1}'";
             $this->Db->table("comments2applications", $fields);
             $this->Db->values($values);
             $this->insertID2 = $this->Db->save();
             $fields = "ID_Comment2Application, ID_Record";
             $values = "'{$this->insertID2}', '{$this->ID_Record}'";
             $this->Db->table("comments2records", $fields);
             $this->Db->values($values);
             $this->insertID3 = $this->Db->save();
         } else {
             $this->Db->table($this->table);
             $repost = $this->Db->findBySQL("ID_User = '******' AND Comment = '{$this->comment}' AND Year = '{$this->year}' AND Month = '{$this->month}' AND Day = '{$this->day}'");
             if (is_array($repost)) {
                 return getAlert("This Comment has been posted yet");
             }
             if ($this->name === NULL) {
                 return getAlert("Empty Name");
             }
             if (isVulgar($this->name) === TRUE) {
                 return getAlert("STOP, Vulgar Name");
             }
             if (isInjection($this->name) === TRUE) {
                 return getAlert("STOP, Injection");
             } else {
                 cleanHTML($this->comment);
             }
             if ($this->email === NULL) {
                 return getAlert("Empty Email");
             }
             if (isEmail($this->email) === FALSE) {
                 return getAlert("Invalid Email");
             }
             if (isset($this->website) and ping($this->website) === FALSE) {
                 if (isInjection($this->website) === TRUE) {
                     return getAlert("STOP, Injection");
                 } else {
                     cleanHTML($this->website);
                 }
                 return getAlert("Invalid Website");
             }
             $fields = "ID_User, Comment, Start_Date, Text_Date, Year, Month, Day, Name, Email, Website, State";
             $values = "'{$this->ID_User}', '{$this->comment}', '{$this->date1}', '{$this->date2}', '{$this->year}', '{$this->month}', '{$this->day}', '{$this->name}', '{$this->email}', '{$this->website}', '{$this->state}'";
             $this->Db->table($this->table, $fields);
             $this->Db->values($values);
             $this->insertID1 = $this->Db->save();
             $fields = "ID_Application, ID_Comment";
             $values = "'3', '{$this->insertID1}'";
             $this->Db->table("comments2applications", $fields);
             $this->Db->values($values);
             $this->insertID2 = $this->Db->save();
             $fields = "ID_Comment2Application, ID_Record";
             $values = "'{$this->insertID2}', '{$this->ID_Record}'";
             $this->Db->table("comments2records", $fields);
             $this->Db->values($values);
             $this->insertID3 = $this->Db->save();
         }
         if ($this->insertID1 === "rollback" or $this->insertID2 === "rollback" or $this->insertID3 === "rollback") {
             $this->Db->rollBack();
             return getAlert("Insert error");
         } else {
             $this->Db->commit();
             return getAlert("The comment has been saved correctly", "success");
         }
     }
 }
Exemplo n.º 8
0
<html>
<head>
	<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
	<div class="container">
		<div class="transbox">
			<!-- center the server status on page-->
			<!-- <div id="h1"> -->
			<p>
				<?php 
function ping($host, $port, $timeout)
{
    $tB = microtime(true);
    $fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
    if (!$fP) {
        return "Server Status:<div id='h2'>Offline</div> @Ping:" . "N/A";
    }
    $tA = microtime(true);
    return "Server Status<div id='h1'>Online</div> @Ping: " . round(($tA - $tB) * 1000, 0) . " ms";
}
//Echoing it will display the ping if the host is up, if not it'll say "server down".
echo @ping("swaggify.me", 4000, 10);
?>
			</p>
			<!-- </div> -->
		</div>
	</div>
</body>
</html>
Exemplo n.º 9
0
include_once dirname(__FILE__) . '/ressources/class.templates.inc';
include_once dirname(__FILE__) . '/ressources/class.blackboxes.inc';
include_once dirname(__FILE__) . '/ressources/class.mysql.squid.builder.php';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/ressources/class.mysql.inc';
ini_set('display_errors', 1);
ini_set('html_errors', 0);
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
}
if ($argv[1] == "--ping") {
    ping($argv[2]);
    exit;
}
function ping($hostid)
{
    $mefile = basename(__FILE__);
    $GLOBALS["CLASS_UNIX"] = new unix();
    $GLOBALS["CLASS_UNIX"]->events("{$mefile}:: blackboxes({$hostid})", "/var/log/stats-appliance.log");
    $black = new blackboxes($hostid);
    $ssluri = $black->ssluri . "/nodes.listener.php";
    $nossluri = $black->sslnouri . "/nodes.listener.php";
    if ($GLOBALS["VERBOSE"]) {
        echo "Try {$ssluri}\n";
    }
    $GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
    $curl = new ccurl($ssluri);
Exemplo n.º 10
0
                ping($array);
                break;
            case 3:
                check_racer($array);
                break;
            case 4:
                clear_all($array);
                break;
            case 5:
                all_plus($array);
                break;
            case 6:
                all_red($array);
                break;
            case 7:
                all_yellow($array);
                break;
            case 8:
                all_green($array);
                break;
            default:
                echo "f**k off";
        }
    } else {
        if ($array['type'] == 2) {
            ping($array);
        } else {
            echo "error";
        }
    }
}
Exemplo n.º 11
0
 /**
 * Title
 *
 * Description
 *
 * @access public
 */
 function checkAllHosts($limit = 1000)
 {
     // ping hosts
     $pings = SQLSelect("SELECT * FROM pinghosts WHERE CHECK_NEXT<=NOW() ORDER BY CHECK_NEXT LIMIT " . $limit);
     $total = count($pings);
     for ($i = 0; $i < $total; $i++) {
         $host = $pings[$i];
         echo "Checking " . $host['HOSTNAME'] . "\n";
         $online_interval = $host['ONLINE_INTERVAL'];
         if (!$online_interval) {
             $online_interval = 60;
         }
         $offline_interval = $host['OFFLINE_INTERVAL'];
         if (!$offline_interval) {
             $offline_interval = $online_interval;
         }
         if ($host['STATUS'] == '1') {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         } else {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $offline_interval);
         }
         SQLUpdate('pinghosts', $host);
         $online = 0;
         // checking
         if (!$host['TYPE']) {
             //ping host
             $online = ping(processTitle($host['HOSTNAME']));
         } else {
             //web host
             $online = getURL(processTitle($host['HOSTNAME']), 0);
             SaveFile("./cached/host_" . $host['ID'] . '.html', $online);
             if ($host['SEARCH_WORD'] != '' && !is_integer(strpos($online, $host['SEARCH_WORD']))) {
                 $online = 0;
             }
             if ($online) {
                 $online = 1;
             }
         }
         if ($online) {
             $new_status = 1;
         } else {
             $new_status = 2;
         }
         $old_status = $host['STATUS'];
         if ($host['COUNTER_REQUIRED']) {
             $old_status_expected = $host['STATUS_EXPECTED'];
             $host['STATUS_EXPECTED'] = $new_status;
             if ($old_status_expected != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT'] = 0;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter reset (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             } elseif ($host['STATUS'] != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT']++;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter increased to ' . $host['COUNTER_CURRENT'] . ' (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             }
             if ($host['COUNTER_CURRENT'] >= $host['COUNTER_REQUIRED']) {
                 $host['STATUS'] = $host['STATUS_EXPECTED'];
                 $host['COUNTER_CURRENT'] = 0;
             } else {
                 $interval = min($online_interval, $offline_interval, 20);
                 $online_interval = $interval;
                 $offline_interval = $interval;
             }
         } else {
             $host['STATUS'] = $new_status;
             $host['STATUS_EXPECTED'] = $host['STATUS'];
             $host['COUNTER_CURRENT'] = 0;
         }
         $host['CHECK_LATEST'] = date('Y-m-d H:i:s');
         if ($host['LINKED_OBJECT'] != '' && $host['LINKED_PROPERTY'] != '') {
             setGlobal($host['LINKED_OBJECT'] . '.' . $host['LINKED_PROPERTY'], $host['STATUS']);
         }
         if ($host['STATUS'] == '1') {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $online_interval);
         } else {
             $host['CHECK_NEXT'] = date('Y-m-d H:i:s', time() + $offline_interval);
         }
         if ($old_status != $host['STATUS']) {
             if ($host['STATUS'] == 2) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is offline' . "\n";
             } elseif ($host['STATUS'] == 1) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is online' . "\n";
             }
             $tmp = explode("\n", $host['LOG']);
             $total = count($tmp);
             if ($total > 50) {
                 $tmp = array_slice($tmp, 0, 50);
                 $host['LOG'] = implode("\n", $tmp);
             }
         }
         SQLUpdate('pinghosts', $host);
         if ($old_status != $host['STATUS'] && $old_status != 0) {
             // do some status change actions
             $run_script_id = 0;
             $run_code = '';
             if ($old_status == 2 && $host['STATUS'] == 1) {
                 // got online
                 if ($host['SCRIPT_ID_ONLINE']) {
                     $run_script_id = $host['SCRIPT_ID_ONLINE'];
                 } elseif ($host['CODE_ONLINE']) {
                     $run_code = $host['CODE_ONLINE'];
                 }
             } elseif ($old_status == 1 && $host['STATUS'] == 2) {
                 // got offline
                 if ($host['SCRIPT_ID_OFFLINE']) {
                     $run_script_id = $host['SCRIPT_ID_OFFLINE'];
                 } elseif ($host['CODE_OFFLINE']) {
                     $run_code = $host['CODE_OFFLINE'];
                 }
             }
             if ($run_script_id) {
                 //run script
                 runScript($run_script_id);
             } elseif ($run_code) {
                 //run code
                 try {
                     $code = $run_code;
                     $success = eval($code);
                     if ($success === false) {
                         DebMes("Error in hosts online code: " . $code);
                         registerError('ping_hosts', "Error in hosts online code: " . $code);
                     }
                 } catch (Exception $e) {
                     DebMes('Error: exception ' . get_class($e) . ', ' . $e->getMessage() . '.');
                     registerError('ping_hosts', get_class($e) . ', ' . $e->getMessage());
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
/**
* Title
*
* Description
*
* @access public
*/
 function checkAllHosts($limit=1000) {

  // ping hosts
  $pings=SQLSelect("SELECT * FROM pinghosts WHERE CHECK_NEXT<=NOW() ORDER BY CHECK_NEXT LIMIT ".$limit);
  $total=count($pings);
  for($i=0;$i<$total;$i++) {
   $host=$pings[$i];
   echo "Checking ".$host['HOSTNAME']."\n";
   $online_interval=$host['ONLINE_INTERVAL'];
   if (!$online_interval) {
    $online_interval=60;
   }
   $offline_interval=$host['OFFLINE_INTERVAL'];
   if (!$offline_interval) {
    $offline_interval=$online_interval;
   }

   if ($host['STATUS']=='1') {
    $host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$online_interval);
   } else {
    $host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$offline_interval);
   }
   SQLUpdate('pinghosts', $host);

   $online=0;
   // checking
   if (!$host['TYPE']) {
    //ping host
    $online=ping($host['HOSTNAME']);
   } else {
    //web host
    $online=file_get_contents($host['HOSTNAME']);
    SaveFile("./cached/host_".$host['ID'].'.html', $online);
    if ($host['SEARCH_WORD']!='' && !is_integer(strpos($online, $host['SEARCH_WORD']))) {
     $online=0;
    }
    if ($online) {
     $online=1;
    }
   }

   $old_status=$host['STATUS'];
   if ($online) {
    $new_status=1;
   } else {
    $new_status=2;
   }

   $host['CHECK_LATEST']=date('Y-m-d H:i:s');
   $host['STATUS']=$new_status;

   if ($host['STATUS']=='1') {
    $host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$online_interval);
   } else {
    $host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$offline_interval);
   }

   if ($old_status!=$new_status) {
    if ($new_status==2) {
     $host['LOG']=date('Y-m-d H:i:s').' Host is offline'."\n".$host['LOG'];
    } elseif ($new_status==1) {
     $host['LOG']=date('Y-m-d H:i:s').' Host is online'."\n".$host['LOG'];
    }
   }

   SQLUpdate('pinghosts', $host);

   if ($old_status!=$new_status && $old_status!=0) {
    // do some status change actions
    $run_script_id=0;
    $run_code='';
    if ($old_status==2 && $new_status==1) {
     // got online
     if ($host['SCRIPT_ID_ONLINE']) {
      $run_script_id=$host['SCRIPT_ID_ONLINE'];
     } elseif ($host['CODE_ONLINE']) {
      $run_code=$host['CODE_ONLINE'];
     }
    } elseif ($old_status==1 && $new_status==2) {
     // got offline
     if ($host['SCRIPT_ID_OFFLINE']) {
      $run_script_id=$host['SCRIPT_ID_OFFLINE'];
     } elseif ($host['CODE_OFFLINE']) {
      $run_code=$host['CODE_OFFLINE'];
     }
    }

    if ($run_script_id) {
     //run script
     runScript($run_script_id);
    } elseif ($run_code) {
     //run code
     eval($run_code);
    }

   }
   

  } 


 }
Exemplo n.º 13
0
$message = $data['message']['text'];
if ($userName != "") {
    if (substr($message, 0, 1) == "/") {
        if (true) {
            // For user check
            $cmd = str_replace('@' . BOT_NAME, '', $message);
            $message = strtolower($message);
            logging($cmd);
            $cmd = split(' ', $cmd);
            switch ($cmd[0]) {
                case "/ping":
                    if (intval($chatID) < 0) {
                        break;
                    }
                    if (count($cmd) == 2) {
                        ping($cmd[1]);
                    } else {
                        error(4);
                    }
                    break;
                    /*case "/ping6":
                      if(count($cmd) == 2){
                          ping6($cmd[1]); 
                      }else{
                          error(4);
                      }
                      break;*/
                /*case "/ping6":
                  if(count($cmd) == 2){
                      ping6($cmd[1]); 
                  }else{
Exemplo n.º 14
0
    die($url);
}
if (isset($_GET["multiseed"])) {
    $toplant = (int) $_GET["multiseed"] + 2;
    // 2 extras just in case
    if ($_GET["multiseed"] > 4) {
        die("7:TOOHIGH");
    }
    $db = mysql_connect($dbhost, $dbuname, $dbpasswd);
    mysql_select_db($dbname, $db);
    $query = sprintf("SELECT url FROM trackers WHERE alive = 1 ORDER BY rand() LIMIT %s", quote_smart($toplant));
    // 2 more just in case
    $result = mysql_query($query);
    $urls = array();
    while ($row = mysql_fetch_row($result)) {
        if (ping($row[0])) {
            $urls[] = $row[0];
        }
        if (count($urls) == (int) $_GET["multiseed"]) {
            break;
        }
    }
    mysql_close($db);
    if (count($urls) != (int) $_GET["multiseed"]) {
        die("5:FALSE");
    }
    // or else
    $bdata = "l";
    foreach ($urls as $one) {
        $bdata .= strlen($one) . ":" . $one;
    }
Exemplo n.º 15
0
    die("Corrupted Tracker Data");
}
$number = count($data);
if ($number != 0) {
    $counter = 0;
    foreach ($data as $tracker) {
        $counter += "1";
        $tracker = urldecode($tracker);
        // might be neccessary
        if (ping($tracker) === FALSE) {
            $number -= "1";
            echo "{$counter}.  ";
            echo $tracker;
            print "         NO VALID RESPONSE RECEIVED";
            echo "<br>";
        } elseif (ping($tracker) === TRUE) {
            echo "{$counter}.  ";
            echo $tracker;
            print "         ALIVE";
            echo "<br>";
        }
    }
    echo "<BR>";
    if ($number === count($data)) {
        echo "<B>SYSTEM FULLY ACTIVE</B>";
    } elseif ($number == 1) {
        echo "{$number} supertracker alive";
    } else {
        echo "{$number} supertrackers alive";
    }
} else {
Exemplo n.º 16
0
 public function process($data = null, $validations = false)
 {
     if (is_array($validations)) {
         foreach ($validations as $field => $validation) {
             if ($validation === "required") {
                 if (!POST($field)) {
                     $field = $this->rename($field);
                     return array("error" => getAlert(__("{$field} is required")));
                 }
             } elseif ($validation === "name?") {
                 if (!isName(POST($field))) {
                     return array("error" => getAlert(__("{$field} is not a valid name")));
                 }
             } elseif ($validation === "email?") {
                 if (!isEmail(POST($field))) {
                     return array("error" => getAlert(__("{$field} is not a valid email")));
                 }
             } elseif ($validation === "captcha?") {
                 if (!POST("captcha_token") or !POST("captcha_type")) {
                     return array("error" => getAlert(__(POST("captcha_type") === "aritmethic" ? "Please enter your answer again" : "Please type the characters you see in the picture")));
                 } elseif (POST("captcha_type") === "aritmethic") {
                     if (SESSION("ZanCaptcha" . POST("captcha_token")) != POST($field)) {
                         return array("error" => getAlert(__("Your answer was incorrect")));
                     }
                 } else {
                     if (SESSION("ZanCaptcha" . POST("captcha_token")) !== POST($field)) {
                         return array("error" => getAlert(__("The characters did not match the picture")));
                     }
                 }
             } elseif ($validation === "injection?") {
                 if (isInjection(POST($field))) {
                     return array("error" => getAlert(__("SQL/HTML injection attempt blocked")));
                 }
             } elseif ($validation === "spam?") {
                 if (isSPAM(POST($field))) {
                     return array("error" => getAlert(__("SPAM prohibited")));
                 }
             } elseif ($validation === "vulgar?") {
                 if (isVulgar(POST($field))) {
                     return array("error" => getAlert(__("Your {$field} is very vulgar")));
                 }
             } elseif ($validation === "ping") {
                 if (!ping(POST($field))) {
                     return array("error" => getAlert(__("Invalid URL")));
                 }
             } elseif (is_string($validation) and substr($validation, 0, 6) === "length") {
                 $count = (int) substr($validation, 7, 8);
                 $count = $count > 0 ? $count : 6;
                 if (strlen(POST($field)) < $count) {
                     return array("error" => getAlert(__("{$field}") . " " . __("must have at least") . " {$count} " . __("characters")));
                 }
             } elseif (isset($field["exists"]) and isset($this->table)) {
                 if (is_array($validation)) {
                     if (isset($validation["or"]) and count($validation) > 2) {
                         unset($validation["or"]);
                         $fields = array_keys($validation);
                         for ($i = 0; $i <= count($fields) - 1; $i++) {
                             $exists = $this->Db->findBy($fields[$i], $validation[$fields[$i]]);
                             if ($exists) {
                                 return array("error" => getAlert(__("The " . strtolower($fields[$i]) . " already exists")));
                             }
                         }
                     } else {
                         $field = array_keys($validation);
                         $exists = $this->Db->findBy($field[0], $validation[$field[0]]);
                         if ($exists) {
                             return array("error" => getAlert(__("The " . strtolower($field[0]) . " already exists")));
                         }
                     }
                 }
             }
         }
     }
     if (is_null($data)) {
         $data = array();
     }
     $POST = POST(true);
     foreach ($POST as $field => $value) {
         if (!in_array($field, $this->ignore)) {
             if (!isset($data[$this->rename($field)])) {
                 $data[$this->rename($field)] = decode(filter($value, "escape"));
             }
         }
     }
     return $data;
 }
Exemplo n.º 17
0
<?php

//imports the ping function.
require_once 'ping.php';
//turns of the error reporting, as there WILL be an error whenever the socket is not able to connect.
error_reporting(0);
ini_set('display_errors', 0);
$ip = $_POST["ip"];
$port = $_POST["port"];
$name = $_POST["name"];
$section = $_POST["section"];
$timeout = $_POST["timeout"];
if (!$timeout) {
    $timeout = 2;
}
//sends the ping request through the ping(host, port, ttl) function.
$ping = ping($ip, $port, $timeout);
//checks if the ping was successfull or failed.
if ($ping != false) {
    $response = array('name' => $name, 'section' => $section, 'ip' => $ip, 'status' => 'Online', 'ms' => $ping);
} else {
    $response = array('name' => $name, 'section' => $section, 'ip' => $ip, 'status' => 'Offline');
}
//encodes the values in to a json object.
$jobj = json_encode($response);
//echoes the object.
echo $jobj;
Exemplo n.º 18
0
        if ($c == "\n") {
            // && ($c == "\r") //May be later on oher systems
            return $t;
        } else {
            $t = $t . $c;
        }
    }
    return $t;
}
//READLINE END
//Code
//echo (ping ("192.168.2.1"));
$fp = fopen("hosts.txt", "r+");
//host list file (hosts separated by newline, ends with two empty lines)
$fhost = "EMPTY";
while ($fhost != "") {
    $ping = "";
    $fhost = trim(readline($fp));
    if ($fhost != "") {
        echo "HOST: " . $fhost;
        try {
            $ping = ping($fhost);
        } catch (string $err) {
        }
        if ($ping != "" && $ping > "0") {
            echo " - UP PING: " . $ping . " sec.\n";
        } else {
            echo " - TIMED OUT\n";
        }
    }
}
Exemplo n.º 19
0
function sabSpeedAdjuster()
{
    global $sabnzbd_ip;
    global $sabnzbd_port;
    global $sabnzbd_api;
    global $sabnabdSpeedLimitMax;
    global $sabnzbdSpeedLimitMin;
    // Set how high ping we want to hit before throttling
    global $ping_throttle;
    // Check the current ping
    $avgPing = ping();
    // Get SABnzbd XML
    $sabnzbdXML = simplexml_load_file('http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=queue&start=START&limit=LIMIT&output=xml&apikey=' . $sabnzbd_api);
    // Get current SAB speed limit
    $sabSpeedLimitCurrent = $sabnzbdXML->speedlimit;
    // Check to see if SAB is downloading
    if ($sabnzbdXML->status == 'Downloading') {
        // If it is downloading and ping is over X value, slow it down
        if ($avgPing > $ping_throttle) {
            if ($sabSpeedLimitCurrent > $sabnzbdSpeedLimitMin) {
                // Reduce speed by 256KBps
                echo 'Ping is over ' . $ping_throttle;
                echo '<br>';
                echo 'Slowing down SAB';
                $sabSpeedLimitSet = $sabSpeedLimitCurrent - 256;
                shell_exec('curl "http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=config&name=speedlimit&value=' . $sabSpeedLimitSet . '&apikey=' . $sabnzbd_api . '"');
            } else {
                echo 'Ping is over ' . $ping_throttle . ' but SAB cannot slow down anymore';
            }
        } elseif ($avgPing . 9 < $ping_throttle) {
            if ($sabSpeedLimitCurrent < $sabnabdSpeedLimitMax) {
                // Increase speed by 256KBps
                echo 'SAB is downloading and ping is ' . ($avgPing . 9) . '  so increasing download speed.';
                $sabSpeedLimitSet = $sabSpeedLimitCurrent + 256;
                shell_exec('curl "http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=config&name=speedlimit&value=' . $sabSpeedLimitSet . '&apikey=' . $sabnzbd_api . '"');
            } else {
                echo 'SAB is downloading. Ping is low enough but we are at global download speed limit.';
            }
        } else {
            echo 'SAB is downloading. Ping is ok but not low enough to speed up SAB.';
        }
    } else {
        // do nothing,
        echo 'SAB is not downloading.';
    }
}
Exemplo n.º 20
0
<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, accept');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
require_once __DIR__ . '/classes/connexion.php';
require_once __DIR__ . '/classes/checkAPI.php';
require_once __DIR__ . '/classes/Sync.php';
$page_level = 0;
if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) {
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            if (isset($_REQUEST['ping'])) {
                echo json_encode(ping($_REQUEST['ping']));
            } else {
                echo json_encode(get());
            }
            break;
        case 'POST':
            echo add($_REQUEST);
            break;
        case 'PUT':
            update($_REQUEST);
            break;
        case 'DELETE':
            delete($_REQUEST);
            break;
    }
} else {
    http_response_code(403);
}
Exemplo n.º 21
0
<!DOCTYPE html>
<?php 
Ini_Set('display_errors', true);
include "functions.php";
?>
<html lang="en">
	<script>
		// Enable bootstrap tooltips
		$(function ()
		        { $("[rel=tooltip]").tooltip();
		        });
	</script>
<?php 
echo ping();
Exemplo n.º 22
0
            echo "{\n\"address\":\"" . $ligne["address"] . "\",\n\"type\":\"" . $ligne["type"] . "\",\n\"state\":\"" . $ligne["state"] . "\",\n\"groupe\":\"" . $ligne["groupe"] . "\"\n}";
        }
        echo "]\n";
        break;
    case "ping":
        if ($address != "*") {
            ping($address);
            exit(0);
        }
        Emma_connection();
        $sql = mysql_query("SELECT * FROM log ORDER BY address");
        $precedent = "";
        while ($ligne = mysql_fetch_array($sql)) {
            if ($ligne["address"] != $precedent) {
                $precedent = $ligne["address"];
                if (ping($ligne["address"])) {
                    $tmp = mysql_query("SELECT * FROM network WHERE address='" . $ligne["address"] . "'");
                    $tmp = mysql_fetch_array($tmp);
                    if ($tmp) {
                        mysql_query("UPDATE network SET state='Connected' WHERE id='{$tmp['address']}'");
                    } else {
                        mysql_query("INSERT INTO network (address, type, state, groupe)\n\t\t\t\t\t\t\tVALUES('" . $ligne["address"] . "','','Connected','')");
                    }
                } else {
                    mysql_query("DELETE FROM network WHERE address='" . $ligne["address"] . "'");
                }
            }
        }
        break;
    default:
}
Exemplo n.º 23
0
<?php

/* our simple php ping function */
function ping($host)
{
    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
    return $rval === 0;
}
/* check if the host is up
   $host can also be an ip address */
$host = '10.4.12.16';
$up = ping($host);
/* optionally display either a red or green image to signify the server status */
echo $up ? 'up' : 'down';
Exemplo n.º 24
0
/**
 * Vérifie que la page est bien accessible par l'utilisateur
 *
 * @global string 
 * @return boolean TRUE si la page est accessible, FALSE sinon
 * @see tentative_intrusion()
 */
function checkAccess()
{
    global $gepiPath;
    global $mysqli;
    if (!preg_match("/mon_compte.php/", $_SERVER['SCRIPT_NAME'])) {
        if (isset($_SESSION['statut']) && $_SESSION['statut'] != "administrateur" && getSettingAOui('MailValideRequis' . ucfirst($_SESSION['statut']))) {
            $debug_test_mail = "n";
            if ($debug_test_mail == "y") {
                $f = fopen("/tmp/debug_check_mail.txt", "a+");
                fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): depuis " . $_SERVER['SCRIPT_NAME'] . "\n");
                fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Avant le test check_mail().\n");
                fclose($f);
            }
            $ping_host = getSettingValue('ping_host');
            if ($ping_host == "") {
                //$ping_host="www.google.fr";
                $ping_host = "173.194.40.183";
            }
            $redir_saisie_mail_requise = "n";
            //if((!isset($_SESSION['email']))||(!check_mail($_SESSION['email']))) {
            if (!isset($_SESSION['email'])) {
                $redir_saisie_mail_requise = "y";
                if ($debug_test_mail == "y") {
                    $f = fopen("/tmp/debug_check_mail.txt", "a+");
                    fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " \$_SESSION['email'] est vide.\n");
                    fclose($f);
                }
            } elseif (getSettingAOui('MailValideRequisCheckDNS') && ping($ping_host, 80, 3) != "down") {
                if ($debug_test_mail == "y") {
                    $f = fopen("/tmp/debug_check_mail.txt", "a+");
                    fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Avant le test checkdnsrr...\n");
                    fclose($f);
                }
                if (!check_mail($_SESSION['email'], 'checkdnsrr', 'y')) {
                    $redir_saisie_mail_requise = "y";
                    if ($debug_test_mail == "y") {
                        $f = fopen("/tmp/debug_check_mail.txt", "a+");
                        fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Le test checkdnsrr a échoué.\n");
                        fclose($f);
                    }
                }
            } elseif (!check_mail($_SESSION['email'])) {
                if ($debug_test_mail == "y") {
                    $f = fopen("/tmp/debug_check_mail.txt", "a+");
                    fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Le check_mail() a échoué.\n");
                    fclose($f);
                }
                $redir_saisie_mail_requise = "y";
            }
            if ($redir_saisie_mail_requise == "y") {
                if ($debug_test_mail == "y") {
                    $f = fopen("/tmp/debug_check_mail.txt", "a+");
                    if (!isset($_SESSION['email'])) {
                        fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Après le test check_mail() qui n'a pas été effectué : \$_SESSION['email'] n'est pas initialisé.\n");
                    } else {
                        fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Après le test check_mail() qui a échoué sur '" . $_SESSION['email'] . "'.\n");
                    }
                    fclose($f);
                }
                header("Location: {$gepiPath}/utilisateurs/mon_compte.php?saisie_mail_requise=yes");
                //getSettingValue('sso_url_portail')
                die;
            }
        }
    }
    $url = parse_url($_SERVER['SCRIPT_NAME']);
    if (mb_substr($url['path'], 0, mb_strlen($gepiPath)) != $gepiPath) {
        tentative_intrusion(2, "Tentative d'accès avec modification sauvage de gepiPath");
        return FALSE;
    } else {
        if ($_SESSION["statut"] == 'autre') {
            $sql = "SELECT autorisation\n\t\t\t\t\tFROM droits_speciaux\n\t\t\t\t\tWHERE nom_fichier = '" . mb_substr($url['path'], mb_strlen($gepiPath)) . "'\n\t\t\t\t\tAND id_statut = '" . $_SESSION['statut_special_id'] . "'\n\t\t\t\t\tAND autorisation='V'";
        } else {
            $sql = "SELECT " . $_SESSION['statut'] . " AS autorisation\n\t\t\t\t\tFROM droits\n\t\t\t\t\tWHERE id = '" . mb_substr($url['path'], mb_strlen($gepiPath)) . "'\n\t\t\t\t\tAND " . $_SESSION['statut'] . "='V';";
        }
        $resultat = mysqli_query($mysqli, $sql);
        $nb_lignes = $resultat->num_rows;
        $resultat->close();
        if ($nb_lignes > 0) {
            return TRUE;
        } else {
            tentative_intrusion(1, "Tentative d'accès à un fichier sans avoir les droits nécessaires");
            return FALSE;
        }
    }
}
Exemplo n.º 25
0
     handle_abort_batch($r);
     break;
 case 'abort_jobs':
     handle_abort_jobs($r);
     break;
 case 'create_batch':
     create_batch($r);
     break;
 case 'estimate_batch':
     estimate_batch($r);
     break;
 case 'get_templates':
     get_templates($r);
     break;
 case 'ping':
     ping($r);
     break;
 case 'query_batch':
     query_batch($r);
     break;
 case 'query_batch2':
     query_batch2($r);
     break;
 case 'query_batches':
     query_batches($r);
     break;
 case 'query_job':
     query_job($r);
     break;
 case 'query_completed_job':
     query_completed_job($r);
<?php

include "../conectar.php";
$start = $_REQUEST['start'];
$limit = $_REQUEST['limit'];
$sql = "SELECT nome, ip FROM hosts LIMIT {$start},  {$limit}";
//consulta sql
$query = mysql_query($sql) or die(mysql_error());
//faz um looping e cria um array com os campos da consulta
$hosts = array();
while ($host = mysql_fetch_assoc($query)) {
    $hosts[] = $host;
}
/* our simple php ping function */
function ping($host)
{
    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
    return $rval === 0;
}
$ping = array();
foreach ($hosts as $key) {
    $ping[] = $arr = array("nome" => $key['nome'], "ip" => $key['ip'], "result" => ping($key['ip']));
}
/* optionally display either a red or green image to signify the server status */
//$resultado = $up ? 'up' : 'down';
//$resultado2 = $up2 ? 'up' : 'down';
//encoda para formato JSON
echo json_encode(array("success" => mysql_errno() == 0, "ping" => $ping));
Exemplo n.º 27
0
    $castling = $req_mess["castling"];
    $sql = "INSERT INTO {$name} (x, y, lx, ly, piece, owner, castling) VALUES ('{$x}', '{$y}', '{$lx}', '{$ly}', '{$piece}', '{$owner}', '{$castling}')";
    $_SESSION["turn"] = false;
    $query = @mysql_query($sql, $dbc) or die(mysql_error());
}
switch ($req_type) {
    case "change_want_side":
        global $dbc;
        $name = "chess_users_" . $_SESSION["name"];
        $id = $_SESSION["id"];
        $req = "UPDATE {$name} SET want_side = '{$req_mess}' WHERE id = '{$id}'";
        $query = mysql_query($req, $dbc) or die(mysql_error());
        die("want_side changed");
        break;
    case "ping":
        ping();
        die("pinged");
        break;
    case "disconnect":
        delete_session($_SESSION["name"]);
        die("disconnected");
        break;
    case "new_session":
        $_SESSION["name"] = $req_mess["name"];
        $_SESSION["id"] = rand(100000, 999999);
        $_SESSION["enemy_connected"] = false;
        $_SESSION["turn"] = false;
        switch (check_session($_SESSION["name"])) {
            case "no_session":
                register_session($req_mess["name"]);
                fill_users_file($_SESSION["id"], false, $req_mess["want_side"]);
Exemplo n.º 28
0
	echo "<script>$('jsmenu').style.display='inline';</script>";
	htmlfooter();
	}
} elseif($action == 'all_logout') {//退出登陆
	setcookie('toolpassword', '', -86400 * 365);
	errorpage("<h6>您已成功退出,欢迎下次使用.强烈建议您在不使用时删除此文件.</h6>");
} elseif($action == 'all_config') {
	htmlheader();
	echo '<h4>修改配置文件助手</h4>';
	echo "<div class=\"specialdiv\">操作提示:<ul id=\"ping\">
		<li>修改后提交程序会自动修改配置文件中的各项配置,修改前请保证配置文件可写权限。</li>
		</ul></div>";
	if($submit) {
		all_doconfig_modify($whereis);
	}
	ping($whereis);
	all_doconfig_output($whereis);	
	htmlfooter();
} elseif($action == 'phpinfo') {
	echo phpinfo(13);exit;
} elseif($action == 'datago') {
	htmlheader();
	!$tableno && $tableno = 0;
	!$do && $do = 'create';
	!$start && $start = 0;
	$limit = 2000;
	echo '<h4>数据库编码转换</h4>';
	echo "<div class=\"specialdiv\">操作提示:<ul>
		<li><font color=red>转换后请自行修改配置文件中的数据库前缀、页面编码、数据库编码</font></li>
		<li>详细转换教程:<a href='http://www.discuz.net/thread-1460873-1-1.html'><font color=red>使用Tools转换数据库编码教程</font></a></li>
		<li>如果数据库过大,可能需要过多时间</li>
Exemplo n.º 29
0
 public function editProfile()
 {
     if (POST("edit")) {
         if (POST("website")) {
             if (POST("website") !== "http://") {
                 if (!ping(POST("website"))) {
                     $alert = getAlert("Invalid URL");
                 }
             } else {
                 $website = "";
             }
         }
         $ID = POST("ID_User");
         if (isset($alert)) {
             $website = "";
         } else {
             if (POST("website") !== "http://") {
                 $website = POST("website", "decode", "escape");
             }
         }
         $name = POST("name", "decode", "escape");
         $gender = POST("gender", "decode", "escape");
         $birthday = POST("birthday", "decode", "escape");
         $company = POST("company", "decode", "escape");
         $country = POST("country", "decode", "escape");
         $district = POST("district", "decode", "escape");
         $town = POST("town", "decode", "escape");
         $twitter = POST("twitter", "decode", "escape");
         $facebook = POST("facebook", "decode", "escape");
         $linkedin = POST("linkedin", "decode", "escape");
         $google = POST("google", "decode", "escape");
         $phone = POST("telephone", "decode", "escape");
         $sign = POST("sign", "decode", FALSE);
         if (!POST("userTwitter")) {
             $actualAvatar = $this->Db->find($ID, $this->table);
             if (FILES("file", "name") !== "") {
                 $this->Files = $this->core("Files");
                 $this->Files->filename = FILES("file", "name");
                 $this->Files->fileType = FILES("file", "type");
                 $this->Files->fileSize = FILES("file", "size");
                 $this->Files->fileError = FILES("file", "error");
                 $this->Files->fileTmp = FILES("file", "tmp_name");
                 $dir = "www/lib/files/images/users/";
                 if (!file_exists($dir)) {
                     mkdir($dir, 0777);
                 }
                 if ($actualAvatar[0]["Avatar"] !== "") {
                     @unlink($actualAvatar[0]["Avatar"]);
                 }
                 $upload = $this->Files->upload($dir);
                 if ($upload["upload"]) {
                     $this->Images = $this->core("Images");
                     $avatar = $this->Images->getResize("mini", $dir, $upload["filename"], _minOriginal, _maxOriginal);
                     @unlink($dir . $upload["filename"]);
                 } else {
                     $alert2 = getAlert($upload["message"]);
                 }
             } else {
                 $avatar = "";
             }
             if (isset($alert2)) {
                 $avatar = "";
             }
         } else {
             $avatar = "";
         }
         if ($avatar === "") {
             $this->Db->update($this->table, array("Website" => $website, "Sign" => $sign), $ID);
             if ($update) {
                 $data[0] = $this->Db->find($ID, $this->table);
             } else {
                 return FALSE;
             }
         } else {
             $this->Db->update($this->table, array("Website" => $website, "Sign" => $sign, "Avatar" => $avatar), $ID);
             if ($update) {
                 $data[0] = $this->Db->find($ID, $this->table);
             } else {
                 return FALSE;
             }
         }
         $userInfo = $this->Db->findBySQL("ID_User = '******'", "users_information");
         $ID2 = $userinfo[0]["ID_User"];
         $data = array("Name" => $name, "Phone" => $phone, "Company" => $company, "Gender" => $gender, "Birthday" => $birthday, "Country" => $country, "District" => $district, "Town" => $town, "Facebook" => $facebook, "Twitter" => $twitter, "Linkedin" => $linkedin, "Google" => $google);
         $update = $this->Db->update("users_information", $data, $ID2);
         if ($update) {
             $data[1] = $this->Db->find($ID2, "users_information");
         } else {
             return FALSE;
         }
         if ($data) {
             $success = TRUE;
             if (isset($alert)) {
                 $data[2][] = $alert;
                 $success = FALSE;
             }
             if (isset($alert2)) {
                 $data[2][] = $alert2;
                 $success = FALSE;
             }
             if ($success === TRUE) {
                 $data[2][0] = getAlert("Your profile has been edited correctly", "success");
             }
             return $data;
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
Exemplo n.º 30
-17
function statusping($host)
{
    $pingtime = 0;
    $avgpingtime = 0;
    $packetloss = 0;
    for ($i = 1; $i <= 10; $i++) {
        $pingtime = ping($host, 2);
        if ($pingtime == FALSE) {
            $packetloss++;
        } else {
            $avgpingtime += $pingtime;
        }
    }
    if ($packetloss == 10) {
        $avgpingtime = 0;
    } else {
        $avgpingtime = round($avgpingtime / (10 - $packetloss) * 1000);
    }
    if ($packetloss > 5) {
        $status = 40002;
    } else {
        if ($packetloss > 2 || $avgpingtime > 1000) {
            $status = 40001;
        } else {
            $status = 40000;
        }
    }
    $packetloss *= 10;
    return array($status, $avgpingtime, $packetloss);
}