Virus scanning development using PHP

Reply

Join Date: Mar 2006
Posts: 14
Reputation: chaom79 is an unknown quantity at this point 
Solved Threads: 0
chaom79 chaom79 is offline Offline
Newbie Poster

Virus scanning development using PHP

 
0
  #1
Apr 21st, 2006
Hi guys, I've developed a virus scanning program using php. Well, it seems my program worked fine--- it can detected the infected files. The problem is how can I make the program to delete the infected files. It seems when I tried to developed the coding, it didn't work. Below is the code;

  1. <?php
  2. $path = $_SERVER['DOCUMENT_ROOT'];
  3. $debug = true;
  4. file_scan("http://localhost/", $defs, true);
  5. $extensions = Array();
  6. $extensions[] = 'htm';
  7. $extensions[] = 'html';
  8. $extensions[] = 'txt';
  9. $extensions[] = 'php';
  10. $extensions[] = 'hp4';
  11. $extensions[] = 'hp5';
  12. //$extensions[] = '.pl';
  13.  
  14.  
  15.  
  16. // CODE BEGINS here
  17.  
  18. // declare variables
  19. $report = '';
  20.  
  21. // output html headers
  22. renderhead();
  23.  
  24. // set counters
  25. $dircount = 0;
  26. $filecount = 0;
  27. $infected = 0;
  28.  
  29. // load virus defs
  30. if (!check_defs('virus.def'))
  31. trigger_error("Virus.def vulnerable to overwrite, please change permissions", E_USER_ERROR);
  32. $defs = load_defs('virus.def', $debug);
  33.  
  34. // scan specified root for specified defs
  35. file_scan($path, $defs, $debug);
  36.  
  37. // output summary
  38. echo '<h1>Scan Completed</h2>';
  39. echo '<div id=summary>';
  40. echo '<p><strong>Scanned folders:</strong> ' . $dircount . '</p>';
  41. echo '<p><strong>Scanned files:</strong> ' . $filecount . '</p>';
  42. echo '<p class=r><strong>Infected files:</strong> ' . $infected . '</p>';
  43. echo '</div>';
  44.  
  45. // output full report
  46. echo $report;
  47.  
  48.  
  49. function file_scan($folder, $defs, $debug = true) {
  50. // hunts files/folders recursively for scannable items
  51. global $dircount, $report;
  52. $dircount++;
  53. if ($debug)
  54. $report .= '<p class="d">Scanning folder ...</p>';
  55. if ($d = @dir($folder)) {
  56. while (false !== ($entry = $d->read())) {
  57. $isdir = @is_dir($folder.'/'.$entry);
  58. if (!$isdir and $entry!='.' and $entry!='..') {
  59. virus_check($folder.'/'.$entry,$defs,$debug);
  60. } elseif ($isdir and $entry!='.' and $entry!='..') {
  61. file_scan($folder.'/'.$entry,$defs,$debug);
  62. }
  63. }
  64. $d->close();
  65. }
  66. }
  67.  
  68. function virus_check($file, $defs, $debug = true) {
  69. global $filecount, $infected, $report, $extensions;
  70.  
  71. // find scannable files
  72. $scannable = 0;
  73. foreach ($extensions as $ext) {
  74. if (substr($file,-3)==$ext)
  75. $scannable = 1;
  76. }
  77.  
  78. // compare against defs
  79. if ($scannable) {
  80. // affectable formats
  81. $filecount++;
  82. $data = file($file);
  83. $data = implode('\r\n', $data);
  84. $clean = 1;
  85. foreach ($defs as $virus) {
  86. if (strpos($data, $virus[1])) {
  87. // file matches virus defs
  88. $report .= '<p class="r">Infected: ' . $file . ' (' . $virus[0] . ')</p>';
  89. $infected++;
  90. $clean = 0;
  91. }
  92. }
  93. if (($debug)&&($clean))
  94. $report .= '<p class="g">Clean: ' . $file . '</p>';
  95. }
  96. }
  97.  
  98. function load_defs($file, $debug = true) {
  99. // reads tab-delimited defs file
  100. $defs = file($file);
  101. $counter = 0;
  102. $counttop = sizeof($defs);
  103. while ($counter < $counttop) {
  104. $defs[$counter] = explode(' ', $defs[$counter]);
  105. $counter++;
  106. }
  107. if ($debug)
  108. echo '<p>Loaded ' . sizeof($defs) . ' malicious codes definitions</p>';
  109. return $defs;
  110. }
  111.  
  112. function check_defs($file) {
  113. // check for >755 perms on virus defs
  114. clearstatcache();
  115. $perms = substr(decoct(fileperms($file)),-2);
  116. if ($perms > 55)
  117. return false;
  118. else
  119. return true;
  120. }
  121.  
  122. function renderhead() {
  123. ?>
  124.  
  125. <html>
  126. <head>
  127. <title>Virus scan</title>
  128. <style type="text/css">
  129. h1 {
  130. font-family: arial;
  131. }
  132.  
  133. p {
  134. font-family: arial;
  135. padding: 0;
  136. margin: 0;
  137. font-size: 10px;
  138. }
  139.  
  140. .g {
  141. color: #009900;
  142. }
  143.  
  144. .r {
  145. color: #990000;
  146. font-weight: bold;
  147. }
  148.  
  149. .d {
  150. color: #ccc;
  151. }
  152.  
  153. #summary {
  154. border: #333 solid 1px;
  155. background: #f0efca;
  156. padding: 10px;
  157. margin: 10px;
  158. }
  159.  
  160. #summary p {
  161. font-size: 12px;
  162. }
  163. </style>
  164. </head>
  165.  
  166. <body>
  167. <?php
  168. }
  169. ?>
  170. <p class="d">&nbsp;</p>
  171. </body>
  172. </html>

So guys can you helped enhance my coding? I mean the program can delete the infected files. Thanks in advanced.
Last edited by cscgal; Sep 9th, 2008 at 11:49 am. Reason: Fixed code tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 14
Reputation: chaom79 is an unknown quantity at this point 
Solved Threads: 0
chaom79 chaom79 is offline Offline
Newbie Poster

Re: Virus scanning development using PHP

 
0
  #2
Apr 22nd, 2006
plz guys can you help me??
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 6
Reputation: sndpbohra is an unknown quantity at this point 
Solved Threads: 0
sndpbohra sndpbohra is offline Offline
Newbie Poster

Re: Virus scanning development using PHP

 
0
  #3
Sep 9th, 2008
Hi, Actually i have a chat system, i want to add your virus scanner when user upload file during chat. can you tell me how i can integrate it. below i send my code in which i want to add virus scan testing
  1. <?
  2. //include_once("./virus.php");
  3. if (empty($current_user->id)) {
  4. die();
  5. }
  6.  
  7. $_window_title.=' '.PCPIN_WINDOW_TITLE_SEPARATOR.' '.$l->g('upload_file');
  8.  
  9. _pcpin_loadClass('message'); $msg=new PCPIN_Message($session);
  10.  
  11. if (empty($profile_user_id) || $current_user->is_admin!=='y') {
  12. $profile_user_id=$current_user->id;
  13. }
  14.  
  15. if (!isset($f_target) || !is_scalar($f_target)) {
  16. $f_target='/dev/null';
  17. }
  18. // Validate uploaded file
  19. if (isset($f_submitted)) {
  20. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  21. } else {
  22. $upload_status=null;
  23. }
  24. $binaryfile_id=0;
  25. $width=0;
  26. $height=0;
  27. $filename='';
  28.  
  29. if (!empty($f_data) && is_array($f_data) && isset($f_data['error']) && isset($f_data['tmp_name']) && isset($f_data['size'])) {
  30. $filename=$f_data['name'];
  31.  
  32. /*$file=$filename;
  33. $scan=file_scan($file, $defs, $debug = true);
  34. */
  35. $upload_status=array('code'=>10, 'message'=>$l->g('error'));
  36. if ($f_data['error']==UPLOAD_ERR_NO_FILE || $f_data['error']==UPLOAD_ERR_OK && empty($f_data['size'])) {
  37. // No file was uploaded or file is empty
  38. $upload_status=array('code'=>-1, 'message'=>$l->g('file_upload_error'));
  39. } elseif ($f_data['error']!=UPLOAD_ERR_OK) {
  40. // File upload error
  41. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  42. } /*elseif ($scan==0){
  43.   //virus scan check.
  44. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  45. exit();
  46. }*/ else {
  47.  
  48. switch ($f_target) {
  49.  
  50. case 'avatar': // New Avatar
  51. // Check avatars number limit
  52. _pcpin_loadClass('avatar'); $avatar=new PCPIN_Avatar($session);
  53. $avatar->_db_getList('COUNT', 'user_id = '.$profile_user_id);
  54. if ($avatar->_db_list_count>=$session->_conf_all['avatars_max_count']) {
  55. // Limit reached
  56. $upload_status=array('code'=>10, 'message'=>str_replace('[NUMBER]', $session->_conf_all['avatars_max_count'], $l->g('avatars_limit_reached')));
  57. } else {
  58. // Check image data
  59. $img_data=null;
  60. switch (PCPIN_Image::checkImage($img_data,
  61. $f_data['tmp_name'],
  62. $session->_conf_all['avatar_image_types'],
  63. $session->_conf_all['avatar_max_width'],
  64. $session->_conf_all['avatar_max_height'],
  65. $session->_conf_all['avatar_max_filesize'],
  66. false)) {
  67.  
  68. case PCPIN_IMAGE_CHECK_OK: // Image OK
  69. $upload_status=array('code'=>0, 'message'=>$l->g('avatar_uploaded'));
  70. break;
  71.  
  72. case PCPIN_IMAGE_CHECK_ERROR_FILE: // File does not exists / not readable
  73. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  74. break;
  75.  
  76. case PCPIN_IMAGE_CHECK_ERROR_MIME: // MIME not allowed
  77. case PCPIN_IMAGE_CHECK_ERROR_NOT_IMAGE: // File is not an image or has incompatible format
  78. $upload_status=array('code'=>200, 'message'=>$l->g('image_type_not_allowed'));
  79. break;
  80.  
  81. case PCPIN_IMAGE_CHECK_ERROR_WIDTH: // Image width larger than allowed
  82. case PCPIN_IMAGE_CHECK_ERROR_HEIGHT: // Image height larger than allowed
  83. $upload_status=array('code'=>300, 'message'=>str_replace('[WIDTH]', $session->_conf_all['avatar_max_width'], str_replace('[HEIGHT]', $session->_conf_all['avatar_max_height'], $l->g('image_too_large'))));
  84. break;
  85.  
  86. case PCPIN_IMAGE_CHECK_ERROR_FILESIZE: // Image file size larger than allowed
  87. $upload_status=array('code'=>400, 'message'=>str_replace('[SIZE]', $session->_conf_all['avatar_max_filesize'], $l->g('file_too_large')));
  88. break;
  89.  
  90. }
  91. }
  92. if ($upload_status['code']===0) {
  93. // Image OK
  94. $width=$img_data['width'];
  95. $height=$img_data['height'];
  96. _pcpin_loadClass('binaryfile'); $binaryfile=new PCPIN_BinaryFile($session);
  97. if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $img_data['mime'], $width, $height, 'log')) {
  98. if (!empty($binaryfile->id)) {
  99. $binaryfile_id=$binaryfile->id;
  100. $avatar->addAvatar($binaryfile->id, $profile_user_id);
  101. }
  102. }
  103. $msg->addMessage(1010, 'n', 0, '', $session->_s_room_id, 0, $profile_user_id);
  104. }
  105. break;
  106.  
  107. case 'avatar_gallery_image': // New Avatar for Gallery
  108. if ($current_user->is_admin!=='y') {
  109. break;
  110. }
  111. // Check image data
  112. $img_data=null;
  113. switch (PCPIN_Image::checkImage($img_data,
  114. $f_data['tmp_name'],
  115. $session->_conf_all['avatar_image_types'],
  116. $session->_conf_all['avatar_max_width'],
  117. $session->_conf_all['avatar_max_height'],
  118. $session->_conf_all['avatar_max_filesize'],
  119. false)) {
  120.  
  121. case PCPIN_IMAGE_CHECK_OK: // Image OK
  122. $upload_status=array('code'=>0, 'message'=>$l->g('avatar_uploaded'));
  123. break;
  124.  
  125. case PCPIN_IMAGE_CHECK_ERROR_FILE: // File does not exists / not readable
  126. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  127. break;
  128.  
  129. case PCPIN_IMAGE_CHECK_ERROR_MIME: // MIME not allowed
  130. case PCPIN_IMAGE_CHECK_ERROR_NOT_IMAGE: // File is not an image or has incompatible format
  131. $upload_status=array('code'=>200, 'message'=>$l->g('image_type_not_allowed'));
  132. break;
  133.  
  134. case PCPIN_IMAGE_CHECK_ERROR_WIDTH: // Image width larger than allowed
  135. case PCPIN_IMAGE_CHECK_ERROR_HEIGHT: // Image height larger than allowed
  136. $upload_status=array('code'=>300, 'message'=>str_replace('[WIDTH]', $session->_conf_all['avatar_max_width'], str_replace('[HEIGHT]', $session->_conf_all['avatar_max_height'], $l->g('image_too_large'))));
  137. break;
  138.  
  139. case PCPIN_IMAGE_CHECK_ERROR_FILESIZE: // Image file size larger than allowed
  140. $upload_status=array('code'=>400, 'message'=>str_replace('[SIZE]', $session->_conf_all['avatar_max_filesize'], $l->g('file_too_large')));
  141. break;
  142.  
  143. }
  144. if ($upload_status['code']===0) {
  145. // Image OK
  146. $width=$img_data['width'];
  147. $height=$img_data['height'];
  148. _pcpin_loadClass('binaryfile'); $binaryfile=new PCPIN_BinaryFile($session);
  149. if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $img_data['mime'], $width, $height, '')) {
  150. $binaryfile_id=$binaryfile->id;
  151. if (!empty($binaryfile->id)) {
  152. _pcpin_loadClass('tmpdata'); $tmpdata=new PCPIN_TmpData($session);
  153. $tmpdata->_db_deleteRowMultiCond(array('user_id'=>$current_user->id, 'type'=>4));
  154. $tmpdata->addRecord(4, $current_user->id, $binaryfile_id, $filename);
  155. }
  156. }
  157. }
  158. break;
  159.  
  160. case 'language_file': // Language file
  161. if ($current_user->is_admin!=='y') {
  162. break;
  163. }
  164. $language_id=0;
  165. $l2=new PCPIN_Language($session);
  166. $import_status=$l2->importLanguage(file_get_contents($f_data['tmp_name']), $language_id);
  167. unset($l2);
  168. if ($import_status==0 && $language_id>0) {
  169. // Language imported
  170. $l->_db_getList('name,local_name', 'id = '.$language_id, 1);
  171. $upload_status=array('code'=>0, 'message'=>str_replace('[NAME]', $l->_db_list[0]['name'].' ('.$l->_db_list[0]['local_name'].')', $l->g('language_import_success')));
  172. $l->_db_freeList();
  173. } else {
  174. // Invalid language file
  175. switch ($import_status) {
  176.  
  177. case 10 :
  178. default :
  179. $upload_status=array('code'=>1000, 'message'=>$l->g('invalid_language_file'));
  180. break;
  181.  
  182. case 100 :
  183. $l->_db_getList('name', 'id = '.$language_id, 1);
  184. $upload_status=array('code'=>1000, 'message'=>str_replace('[NAME]', $l->_db_list[0]['name'], $l->g('language_already_exists')));
  185. $l->_db_freeList();
  186. break;
  187.  
  188. }
  189. }
  190. break;
  191.  
  192. case 'msg_attachment': // Message attachment
  193. $msg_attachments_limit=$session->_conf_all['msg_attachments_limit'];
  194. if (empty($session->_s_room_id)) {
  195. // User is not in room
  196. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  197. } elseif (!file_exists($f_data['tmp_name']) || !is_file($f_data['tmp_name']) || !is_readable($f_data['tmp_name'])) {
  198. // File upload error
  199. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  200. } elseif (filesize($f_data['tmp_name'])>$session->_conf_all['msg_attachments_maxsize']*1024) {
  201. // File too large
  202. $upload_status=array('code'=>400, 'message'=>str_replace('[SIZE]', $session->_conf_all['msg_attachments_maxsize']*1024, $l->g('file_too_large')));
  203. } else {
  204. // Check attachments limit
  205. _pcpin_loadClass('tmpdata'); $tmpdata=new PCPIN_TmpData($session);
  206. $tmpdata->_db_getList('COUNT', 'type = 3', 'user_id = '.$session->_s_user_id);
  207. if ($tmpdata->_db_list_count>=$msg_attachments_limit) {
  208. // Max attachments limit reached
  209. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  210. } else {
  211. $upload_status=array('code'=>0, 'message'=>'OK');
  212. }
  213. }
  214. if ($upload_status['code']===0) {
  215. // Get MIME type
  216. $mime_type=$f_data['type']; // TODO: detect real MIME type
  217. _pcpin_loadClass('binaryfile'); $binaryfile=new PCPIN_BinaryFile($session);
  218. if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $mime_type, 0, 0, 'room|'.$session->_s_room_id)) {
  219. $binaryfile_id=$binaryfile->id;
  220. if (!empty($binaryfile->id)) {
  221. _pcpin_loadClass('tmpdata'); $tmpdata=new PCPIN_TmpData($session);
  222. $tmpdata->addRecord(3, $current_user->id, $binaryfile_id, $filename);
  223. }
  224. }
  225. }
  226. break;
  227.  
  228. case 'room_image': // New room image
  229. // Room image will be saved into tmpdata table
  230. // Check image data
  231. $img_data=null;
  232. switch (PCPIN_Image::checkImage($img_data,
  233. $f_data['tmp_name'],
  234. $session->_conf_all['room_img_image_types'],
  235. $session->_conf_all['room_img_max_width'],
  236. $session->_conf_all['room_img_max_height'],
  237. $session->_conf_all['room_img_max_filesize'],
  238. false)) {
  239.  
  240. case PCPIN_IMAGE_CHECK_OK: // Image OK
  241. $upload_status=array('code'=>0, 'message'=>'OK');
  242. break;
  243.  
  244. case PCPIN_IMAGE_CHECK_ERROR_FILE: // File does not exists / not readable
  245. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  246. break;
  247.  
  248. case PCPIN_IMAGE_CHECK_ERROR_MIME: // MIME not allowed
  249. case PCPIN_IMAGE_CHECK_ERROR_NOT_IMAGE: // File is not an image or has incompatible format
  250. $upload_status=array('code'=>200, 'message'=>$l->g('image_type_not_allowed'));
  251. break;
  252.  
  253. case PCPIN_IMAGE_CHECK_ERROR_WIDTH: // Image width larger than allowed
  254. case PCPIN_IMAGE_CHECK_ERROR_HEIGHT: // Image height larger than allowed
  255. $upload_status=array('code'=>300, 'message'=>str_replace('[WIDTH]', $session->_conf_all['room_img_max_width'], str_replace('[HEIGHT]', $session->_conf_all['room_img_max_height'], $l->g('image_too_large'))));
  256. break;
  257.  
  258. case PCPIN_IMAGE_CHECK_ERROR_FILESIZE: // Image file size larger than allowed
  259. $upload_status=array('code'=>400, 'message'=>str_replace('[SIZE]', $session->_conf_all['room_img_max_filesize'], $l->g('file_too_large')));
  260. break;
  261.  
  262. }
  263. if ($upload_status['code']===0) {
  264. // Image OK
  265. $width=$img_data['width'];
  266. $height=$img_data['height'];
  267. _pcpin_loadClass('binaryfile'); $binaryfile=new PCPIN_BinaryFile($session);
  268. if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $img_data['mime'], $width, $height, 'log')) {
  269. $binaryfile_id=$binaryfile->id;
  270. if (!empty($binaryfile->id)) {
  271. _pcpin_loadClass('tmpdata'); $tmpdata=new PCPIN_TmpData($session);
  272. $tmpdata->deleteUserRecords($current_user->id, 1);
  273. $tmpdata->addRecord(1, $current_user->id, $binaryfile_id, $filename);
  274. }
  275. }
  276. }
  277. break;
  278.  
  279. case 'smilie_image': // New smilie image
  280. if ($current_user->is_admin!=='y') {
  281. break;
  282. }
  283. // Smilie image will be saved into tmpdata table
  284. // Check image data
  285. $img_data=null;
  286. switch (PCPIN_Image::checkImage($img_data,
  287. $f_data['tmp_name'],
  288. '',
  289. 0,
  290. 0,
  291. 0,
  292. false)) {
  293.  
  294. case PCPIN_IMAGE_CHECK_OK: // Image OK
  295. $upload_status=array('code'=>0, 'message'=>'OK');
  296. break;
  297.  
  298. case PCPIN_IMAGE_CHECK_ERROR_FILE: // File does not exists / not readable
  299. $upload_status=array('code'=>100, 'message'=>$l->g('file_upload_error'));
  300. break;
  301.  
  302. case PCPIN_IMAGE_CHECK_ERROR_MIME: // MIME not allowed
  303. case PCPIN_IMAGE_CHECK_ERROR_NOT_IMAGE: // File is not an image or has incompatible format
  304. $upload_status=array('code'=>200, 'message'=>$l->g('image_type_not_allowed'));
  305. break;
  306.  
  307. }
  308. if ($upload_status['code']===0) {
  309. // Image OK
  310. $width=$img_data['width'];
  311. $height=$img_data['height'];
  312. _pcpin_loadClass('binaryfile'); $binaryfile=new PCPIN_BinaryFile($session);
  313. if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $img_data['mime'], $width, $height, '')) {
  314. $binaryfile_id=$binaryfile->id;
  315. if (!empty($binaryfile->id)) {
  316. _pcpin_loadClass('tmpdata'); $tmpdata=new PCPIN_TmpData($session);
  317. $tmpdata->_db_deleteRowMultiCond(array('user_id'=>$current_user->id, 'type'=>2));
  318. $tmpdata->addRecord(2, $current_user->id, $binaryfile_id, $filename);
  319. }
  320. }
  321. }
  322. break;
  323.  
  324. }
  325. }
  326. }
  327.  
  328. _pcpin_loadClass('pcpintpl'); $tpl=new PcpinTpl();
  329. $tpl->setBasedir('./tpl');
  330. $tpl->readTemplatesFromFile('./file_upload.tpl');
  331.  
  332. // JS files
  333. $_js_files[]='./js/file_upload.js';
  334.  
  335. if (!empty($upload_status)) {
  336. $message=str_replace('\'', '\\\'', htmlspecialchars($upload_status['message']));
  337. $message=str_replace("\n", '\\n', str_replace("\r", '\\r', $message));
  338. $_body_onload[]='parseUploadResponse('.$upload_status['code'].', \''.$message.'\', '.$binaryfile_id.', '.$width.', '.$height.', \''.str_replace('\'', '\\\'', $filename).'\')';
  339. } else {
  340. $_body_onload[]='initUploadForm(\''.$f_target.'\')';
  341. }
  342.  
  343. // Add global vars to template
  344. foreach ($global_tpl_vars as $key=>$val) {
  345. $tpl->addGlobalVar($key, htmlspecialchars($val));
  346. }
  347.  
  348. // Add language expressions to template
  349. foreach ($tpl->tpl_vars_plain as $var) {
  350. if (0===strpos($var, 'LNG_')) {
  351. $var=strtolower($var);
  352. $tpl->addGlobalVar($var, htmlspecialchars($l->g(substr($var, 4))));
  353. }
  354. }
  355.  
  356. $tpl->addVar('main', 'profile_user_id', htmlspecialchars($profile_user_id));
  357. ?>
Last edited by cscgal; Sep 9th, 2008 at 7:42 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Virus scanning development using PHP

 
0
  #4
Sep 9th, 2008
Hi,

In PHP if you want to delete a file you can use the unlink function.
  1. $file = 'path_to/test_file.txt';
  2. unlink( $file );
Of course there might be permission issues with certain system files ???

Hope it helps
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 6
Reputation: sndpbohra is an unknown quantity at this point 
Solved Threads: 0
sndpbohra sndpbohra is offline Offline
Newbie Poster

Re: Virus scanning development using PHP

 
0
  #5
Sep 10th, 2008
Originally Posted by langsor View Post
Hi,

In PHP if you want to delete a file you can use the unlink function.
  1. $file = 'path_to/test_file.txt';
  2. unlink( $file );
Of course there might be permission issues with certain system files ???

Hope it helps
actually sir, I used your code for virus scanning but i don't have any defination filewhich mentioned in your code. So can you send me that file . my email id is <EMAIL SNIPPED>

thanks in advance.
Last edited by peter_budo; Sep 10th, 2008 at 3:33 pm. Reason: Keep It On The Site - No emails in the post!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Virus scanning development using PHP

 
0
  #6
Sep 10th, 2008
Originally Posted by sndpbohra View Post
actually sir, I used your code for virus scanning but i don't have any defination filewhich mentioned in your code. So can you send me that file . my email id is <EMAIL SNIPPED>

thanks in advance.
I did not write the PHP Virus scan, that would be this guy: chaom79

I'm just trying to help if I can, but would be very interested in how well it works and what kind of virus activity it detects and handles ???
Last edited by peter_budo; Sep 10th, 2008 at 3:34 pm. Reason: Removing email from qouted text
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 6
Reputation: sndpbohra is an unknown quantity at this point 
Solved Threads: 0
sndpbohra sndpbohra is offline Offline
Newbie Poster

Re: Virus scanning development using PHP

 
0
  #7
Sep 10th, 2008
Originally Posted by langsor View Post
I did not write the PHP Virus scan, that would be this guy: chaom79

I'm just trying to help if I can, but would be very interested in how well it works and what kind of virus activity it detects and handles ???
this code is work if you have a virus defination file with it and dynamically pass the folder name which you want to scan at running time.

Thats why i am asking if someone have virus defination file then plz post here so we can check the code is working or not.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC