Marius Cramer
2013-11-14 7fe908c50c8dbc5cc05f571dbe11d66141caacd4
interface/lib/classes/aps_crawler.inc.php
@@ -27,7 +27,7 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('aps_base.inc.php');
require_once 'aps_base.inc.php';
@set_time_limit(0);
@ignore_user_abort(1);
@@ -43,10 +43,14 @@
    * @param $app the application instance (db handle + log method)
    * @param $interface_mode act in interface (true) or server mode (false)
    */
    public function __construct($app, $interface_mode = false)
    {
        parent::__construct($app, 'APS crawler: ', $interface_mode);
    }
    
    /**
     * Before the cron is executed, make sure all necessary options are set
@@ -77,12 +81,15 @@
            
            return true;
        }
        catch(Exception $e)
        {
            $app->log($this->log_prefix.'Aborting execution because '.$e->getMessage(), LOGLEVEL_ERROR);
            return false;
        }
    }
    
    /**
     * Remove a directory recursively
@@ -152,6 +159,8 @@
        return $ret;
    }
    
    /**
     * Fetch binary data from a given array
     * The data is retrieved in binary mode and 
@@ -198,6 +207,8 @@
        curl_multi_close($mh);
    }
    
    /**
     * A method to build query URLs out of a list of vendors
     *
@@ -207,8 +218,10 @@
        $array_item = str_replace(' ', '%20', $array_item);
        $array_item = str_replace('http://', '', $array_item);
        $array_item = '/'.$this->aps_version.'.atom?vendor='.$array_item.'&pageSize=100';
      return($array_item);
      return $array_item;
    }
    
    /**
     * The main method which performs the actual crawling
@@ -457,12 +470,15 @@
                ' apps from the repo. Downloaded '.$apps_updated.
                ' updates, '.$apps_downloaded.' new apps');
        }
        catch(Exception $e)
        {
            $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
            return false;
        }
    }
    
    /**
     * Read in all possible packages from the interface packages folder and 
@@ -551,6 +567,7 @@
            }
            }
        }
        catch(Exception $e)
        {
            $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
@@ -558,6 +575,8 @@
            return false;
        }
    }
   
   /**
     * Add missing package URLs to database
@@ -581,6 +600,7 @@
            }
         }
        }
        catch(Exception $e)
        {
            $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
@@ -588,5 +608,7 @@
            return false;
        }
    }
}
?>