PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > Mod Submissions

Reply
 
Thread Tools
Old 03-12-2004, 03:04 PM   #1
Konstantine
Green Mole
 
Join Date: Mar 2004
Location: Russia
Posts: 21
Fixing spider.php, protecting from locking site after timeout or users stop

I found, that if your PHP has time out (for example 30 secs) and spider have no time to complete indexing, your site will be locked and you'll have to go back to admin and unlock it. It's not good, so next code fix it.

Add this code into spider.php file at the begining (from 12 line, after comments, for example):

PHP Code:
function Unlock()
{
  global $site_id, $id_connect, $run_mode, $mode;

  // unlock site if not normal terminate
if(connection_status())
{
  mysql_query('UPDATE '.PHPDIG_DB_PREFIX.'sites SET locked=0 WHERE site_id='.$site_id,$id_connect);
  print "<br />Site was unlocked<br />";

  if ($run_mode == 'http')
  { ?>
<hr />
<a href="index.php" >[<?php phpdigPrnMsg('back'?>]</a> <?php phpdigPrnMsg('to_admin'?>.
<?php
    
if (isset($mode) && isset($site_id) && $mode == 'small') {
      print 
'<br /><a href="update_frame.php?site_id='.$site_id.'" >['.phpdigMsg('back').']</a> '.phpdigMsg('to_update').'.';
    }
  } else {
      print 
$br;
  }
}

return;
}

register_shutdown_function("Unlock");
Hope, it will be in next versions and will help you!!!
Konstantine is offline   Reply With Quote
Old 03-12-2004, 09:00 PM   #2
Konstantine
Green Mole
 
Join Date: Mar 2004
Location: Russia
Posts: 21
little changes for correct work from command line

PHP Code:
function Unlock()
{
  global $site_id, $id_connect, $run_mode, $mode, $br;

  // unlock site if not normal terminate
if(connection_status())
{
  mysql_query('UPDATE '.PHPDIG_DB_PREFIX.'sites SET locked=0 WHERE site_id='.$site_id,$id_connect);
  print $br."Site was unlocked".$br;

  if ($run_mode == 'http')
  { ?>
<hr />
<a href="index.php" >[<?php phpdigPrnMsg('back'?>]</a> <?php phpdigPrnMsg('to_admin'?>.
<?php
    
if (isset($mode) && isset($site_id) && $mode == 'small') {
      print 
'<br /><a href="update_frame.php?site_id='.$site_id.'" >['.phpdigMsg('back').']</a> '.phpdigMsg('to_update').'.';
    }
  } else {
      print 
$br;
  }
}

return;
}

register_shutdown_function("Unlock");

Last edited by Konstantine; 03-12-2004 at 09:04 PM.
Konstantine is offline   Reply With Quote
Old 03-13-2004, 09:37 AM   #3
Konstantine
Green Mole
 
Join Date: Mar 2004
Location: Russia
Posts: 21
making auto-refresh for indexing with timeout

If we change index.php file, method of posting from POST to GET

PHP Code:
<form class="grey" action="spider.php" method="get" 
And changing function Unlock (see above) to that code:

PHP Code:
function Unlock()
{
  global $site_id, $id_connect, $run_mode, $mode, $br;

  // unlock site if not normal terminate
if(connection_status())
{
  // clean the tempspider table
  $query = "DELETE FROM ".PHPDIG_DB_PREFIX."tempspider WHERE site_id=$site_id AND (error = 1 OR indexed = 1)";
  mysql_query($query,$id_connect);
  mysql_query('UPDATE '.PHPDIG_DB_PREFIX.'sites SET locked=0 WHERE site_id='.$site_id,$id_connect);
  print $br."Site was unlocked".$br;

  if ($run_mode == 'http')
  { ?>
<hr />
<a href="index.php" >[<?php phpdigPrnMsg('back'?>]</a> <?php phpdigPrnMsg('to_admin'?>.
<?php
    
if (isset($mode) && isset($site_id) && $mode == 'small') {
      print 
'<br /><a href="update_frame.php?site_id='.$site_id.'" >['.phpdigMsg('back').']</a> '.phpdigMsg('to_update').'.';
    }

    print <<< HTML
<script>
<!--
window.location.reload();
//-->
</script>
HTML;
  } else {
      print 
$br;
  }

}

return;
}
Have a nice day!
Konstantine is offline   Reply With Quote
Old 04-09-2004, 12:37 PM   #4
miccheng
Green Mole
 
Join Date: Apr 2004
Location: Singapore
Posts: 1
Was this implemented for version 1.8?

I have problems with indexing one of my client's website. I have no problems spidering on my own server. Have installed this script for my installation of PHPdig. Will see if it solves the porblem.

Thanks.
miccheng is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I make the spider stop and start on a dime? dewed How-to Forum 0 11-25-2005 11:54 AM
Spider Timeout after editing source PHPfranky Troubleshooting 1 11-18-2005 02:31 AM
How To stop spider by shell command ? noel How-to Forum 4 11-03-2005 01:06 PM
Stop spidering site after using an amount of bandwidth Grefix How-to Forum 1 01-14-2004 10:45 AM
users permission webhostau Script Installation 3 12-14-2003 04:13 PM


All times are GMT -8. The time now is 01:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.