Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Guest Message by DevFuse
Wklejka ogn3u89vdl4o dodana przez corel, 23.11.2013 23:32
asdasdas
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251. 252. 253. 254. 255. 256. 257. 258. 259. 260. 261. 262. 263. 264. 265. 266. 267. 268. 269. 270. 271. 272. 273. 274. 275. 276. 277. 278. 279. 280. 281. 282. 283. 284. 285. 286. 287. 288. 289. 290. 291. 292. 293. 294. 295. 296. 297. 298. 299. 300. 301. 302. 303. 304. 305. 306. 307. 308. 309. 310. 311. 312. 313. 314. 315. 316. 317. 318. 319. 320. 321. 322. 323. 324. 325. 326. 327. 328. 329. 330. 331. 332. 333. 334. 335. 336. 337. 338. 339. 340. 341. 342. 343. 344. 345. 346. 347. 348. 349. 350. 351. 352. 353. 354. 355. 356. 357. 358. 359. 360. 361. 362. 363. 364. 365. 366. 367. 368. 369. 370. 371. 372. 373. 374. 375. 376. 377.
<?php /** * Ported to PHP from * * AMXX NVault Reader for Windows By P34nut */ define("VAULT_MAGIC", 0x6E564C54); // NVault Magic ('nVLT') define("VAULT_MAJVER", 2); // Current Major Version define("VAULT_MINVER", 0); // Current Minor Version interface inVaultRead{ /** * Vault version $iMajorVer.$iMinorVer */ //public $iMinorVer, $iMajorVer; /** * Array of vault entries */ //public $Entries; /** * Open nVault file, checks format and file existing * * @param file path to file * @return true on success */ public function Open($file); /** * Optimalized full read function */ public function fullLoadEntries(); /** * Load table of keys and positions of data * After call this function $obj->Entries is array with keys as indexes * and $obj->Entries['MyNVaultKey']->iPointer contain position data in file. * * Warning: * $obj->Entries['MyKey']->Value is undefined in this step! * * $numberOfEntries = count($obj->Entries); * * @return true on success */ public function LoadEntries(); /** * Fill Value and Timestamp in one element of Entries array. * Use when want value of specific field without loading all data. * * @param entry nVault`s key, index */ public function getEntry($entry); /** * Fill Value and Timestamp in whole Entries array */ public function getAllEntries(); /** * Set keys filter for load only some group of entries * * @param callback * function cb($key){} * return 1 when want to load */ public function setKeyFilter($callback); /** * Print debug listing of entries */ public function print_r(); }; /** * BinaryReader */ class BinaryReader{ /** * File Pointer */ private $fp; public function BinaryReader($fp){ $this->fp = $fp; } public function ReadAddr(&$buffer, $size){ if($size <= 0) return false; if(($buffer = fread($this->fp, $size)) !== false) return true; return false; } public function ReadUInt32(){ $num; if(!$this->ReadAddr($num, 4)) throw new Exception("Read failed"); $res = unpack("i", $num); return $res[1]; } public function ReadInt32(){ $num; if(!$this->ReadAddr($num, 4)) throw new Exception("Read failed"); $res = unpack("I", $num); return $res[1]; } public function ReadUInt16(){ $num; if(!$this->ReadAddr($num, 2)) throw new Exception("Read failed"); $res = unpack("v", $num); return $res[1]; } public function ReadInt16(){ $num; if(!$this->ReadAddr($num, 2)) throw new Exception("Read failed"); $res = unpack("s", $num); return $res[1]; } public function ReadUInt8(){ $num; if(!$this->ReadAddr($num, 1)) throw new Exception("Read failed"); $res = unpack("C", $num); return $res[1]; } public function ReadInt8(){ $num; if(!$this->ReadAddr($num, 1)) throw new Exception("Read failed"); $res = unpack("c", $num); return $res[1]; } public function ReadChars(&$buffer, $len){ return $this->ReadAddr($buffer, $len); } }; class Vault{ public $iPointer; public $iKeyLen, $iValLen; public $Value; public $iTimestamp; public function Vault($pos, $value, $tstamp){ $this->iPointer = $pos; $this->Value = $value; $this->iTimestamp = $tstamp; } }; class nVaultRead implements inVaultRead{ /** * Name of vault file */ private $szFileName; /** * Binary reader object */ private $binread; /** * Vault version $iMajorVer.$iMinorVer */ public $iMinorVer, $iMajorVer; /** * Array of vault entries */ public $Entries; /** * Filter function */ public $callback; public function Open($file){ $this->szFileName = $file; $fp = fopen($file, "rb"); if(!$fp) return false; $br = new BinaryReader($fp); try{ if($br->ReadUInt32() != VAULT_MAGIC) return false; }catch(Exception $ex){ return false; } fclose($fp); $callback = NULL; return true; } public function fullLoadEntries(){ $fp = fopen($this->szFileName, "rb"); if(!$fp) return false; $br = new BinaryReader($fp); try{ if($br->ReadUInt32() != VAULT_MAGIC) return false; $this->iMinorVer = $br->ReadUInt8(); $this->iMajorVer = $br->ReadUInt8(); $iEntries = $br->ReadUInt32(); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } $pos = 10; fseek($fp, $pos); $this->Entries = array(); for ($i = 0; $i < $iEntries; $i++) { $szKey = ""; $vault = new Vault($pos, "", 0); try{ $vault->iTimestamp = $br->ReadInt32(); $vault->iKeyLen = $br->ReadUInt8(); $vault->iValLen = $br->ReadUInt16(); $br->ReadChars($szKey, $vault->iKeyLen); $br->ReadChars($vault->Value, $vault->iValLen); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } if(!is_callable($this->callback) || call_user_func($this->callback, $szKey)) $this->Entries[$szKey] = $vault; $pos = $pos + 11 + $vault->iKeyLen + $vault->iValLen; } fclose($fp); } public function LoadEntriesNum(){ static $num = NULL; if($num === NULL){ $fp = fopen($this->szFileName, "rb"); if(!$fp) return false; $br = new BinaryReader($fp); try{ if($br->ReadUInt32() != VAULT_MAGIC) return false; $br->ReadUInt8(); $br->ReadUInt8(); $num = $br->ReadUInt32(); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } fclose($fp); } return $num; } public function LoadEntries(){ $fp = fopen($this->szFileName, "rb"); if(!$fp) return false; $br = new BinaryReader($fp); try{ if($br->ReadUInt32() != VAULT_MAGIC) return false; $this->iMinorVer = $br->ReadUInt8(); $this->iMajorVer = $br->ReadUInt8(); $iEntries = $br->ReadUInt32(); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } $szKey = ""; $pos = 14; fseek($fp, $pos); $iPointers = array(); $this->Entries = array(); for ($i = 0; $i < $iEntries; $i++) { $szKey = ""; $iPointers[$i] = $pos-4; try{ $iKeyLen = $br->ReadUInt8(); $iValLen = $br->ReadUInt16(); $br->ReadChars($szKey, $iKeyLen); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } $this->Entries[$szKey] = new Vault($iPointers[$i], "", 0); $pos = $iPointers[$i] + 11 + $iKeyLen + $iValLen; fseek($fp, $pos); } fclose($fp); return true; } public function getEntry($entry){ $fp = fopen($this->szFileName, "rb"); if (!$fp) return 0; $vault = $this->Entries[$entry]; $iPos = $vault->iPointer; if($iPos < 0) return 0; $br = new BinaryReader($fp); fseek($fp, $iPos); try{ $vault->iTimestamp = $br->ReadInt32(); $vault->iKeyLen = $br->ReadUInt8(); $vault->iValLen = $br->ReadUInt16(); $br->ReadChars($szKey, $vault->iKeyLen); $br->ReadChars($vault->Value, $vault->iValLen); } catch(Exception $ex){ die("<h1>".$ex->getMessage()."</h1>"); } fclose($fp); return 1; } public function getAllEntries(){ foreach($this->Entries as $key=>$value){ $this->getEntry($key); } } public function print_r(){ echo "<pre>"; print_r($this->Entries); echo "</pre>"; } public function setKeyFilter($callback){ $this->callback = $callback; } public function sort(){ uasort($this->Entries, 'ByXp'); } }; function ByXP($a, $b){ $temp = $a->Value; $temp = explode("#",$temp); $xpA = intVal($temp[1]); $temp = $b->Value; $temp = explode("#",$temp); $xpB = intVal($temp[1]); if($xpA == $xpB) return 0; return ($xpA > $xpB)?-1:1; } ?>
Dodanych wklejek: 11179
Powered By (Pav32) Pastebin © 2011