/** * Default constructor. * * @access public * @param string $startUrl The starting url for crawling * @param string $dbUser The database username * @param string $dbPass The database password * @param string $dbName The database name * @param string $dbHost The database host * @return void */ public function __construct($startUrl, $dbUser, $dbPass, $dbName, $dbHost) { // register the Rolling Curl callback parent::__construct('parseHtml'); // validate the url is valid HTTP or HTTPS if (strpos($startUrl, 'http://') === false && strpos($startUrl, 'https://') === false) { throw new Exception('Your starting caterpillar URL must begin with http or https.'); } // store the base url $this->startUrl = rtrim($startUrl, '/') . '/'; // store the start time $this->startTime = date('Y-m-d H:i:s'); // store the base domain $info = parse_url($startUrl); $this->domain = $info['scheme'] . '://' . $info['host']; // open mysql connection $this->db = mysql_connect($dbHost, $dbUser, $dbPass); if ($this->db === false) { throw new Exception('The caterpillar database connection could not be established'); } // use user specified database if (!mysql_select_db($dbName)) { throw new Exception('An error occurred attempting to connect to the database ' . $dbName); } }
/** * AngryCurl constructor * * @throws AngryCurlException * * @param string $callback Callback function name * @param bool $debug_log Enable/disable writing log to $debug_info var (false by default to reduce memory consumption) * * @return void */ function __construct($callback = null, $debug_log = false) { self::$debug_log = $debug_log; # writing debug self::add_debug_msg("# Building"); # checking if cURL enabled if (!function_exists('curl_init')) { throw new AngryCurlException("(!) cURL is not enabled"); } parent::__construct($callback); }
function __construct($callback = null) { $this->group_callback = $callback; parent::__construct(array(&$this, "process")); }
function __construct($callback = null) { # writing debug self::add_debug_msg("# Building"); parent::__construct($callback); }