public function sGet($sUrl, $nSleepSeconds = null, $sCookieJarFile = '[auto]') { ODT::vDump('sGet("' . $sUrl . '", ' . $nSleepSeconds . ')'); $oInstance = isset($this) ? $this : self::$oDefault; $oCurl = curl_init(); curl_setopt($oCurl, CURLOPT_URL, $sUrl); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt($oCurl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); if ($sCookieJarFile == '[auto]') { if (!$oInstance->sCookieJarFile) { $oInstance->sCreateCookieJarFile(); } $sCookieJarFile = $oInstance->sCookieJarFile; } if ($sCookieJarFile) { curl_setopt($oCurl, CURLOPT_COOKIEJAR, $sCookieJarFile); curl_setopt($oCurl, CURLOPT_COOKIEFILE, $sCookieJarFile); } $sResponse = curl_exec($oCurl); $oInstance->iLastStatus = curl_getinfo($oCurl, CURLINFO_HTTP_CODE); curl_close($oCurl); if ($nSleepSeconds) { usleep($nSleepSeconds * 1000000); } return $sResponse; }
public static function nDateDiff($sDateA, $sDateB = 'now', $sUnit = 'seconds') { $nReturn = strtotime($sDateB) - strtotime($sDateA); $aUnitMap = array('seconds' => 1, 'minutes' => 60, 'hours' => 60 * 60, 'days' => 24 * 60 * 60, 'years' => 365 * 24 * 60 * 60); if (isset($aUnitMap[$sUnit])) { $nReturn /= $aUnitMap[$sUnit]; } ODT::vDump(array('nDateDiff', $sDateA, $sDateB, $sUnit, $nReturn)); return $nReturn; }
$bParse = isset($_REQUEST['parse']) || isset($_REQUEST['fetch_and_parse']); if (isset($_REQUEST['search_html'])) { if (isset($_REQUEST['url'])) { $aWhere = array('url' => array('%like%' => $_REQUEST['url'])); $oHtml = DirectDB::oSelectOne('ads_htmls', $aWhere, 'id , url', 'ORDER BY fetched DESC LIMIT 1'); ODT::vDump($oHtml); } } if ($bFetch) { Ad::vDeleteDuplicateUrlAds(); WgGesuchtReader::vFetch(); } if ($bParse) { $iParse = intval($_REQUEST['parse']); if ($iParse) { $oAd = WgGesuchtReader::oParseHtml($iParse); ODT::vDump($oAd); $oHtml = Ad::oGetHtml($iParse); ODT::vDump($oHtml); } else { $aHtmlIDs = Ad::aGetLatestHtmlIDs('999 days'); foreach ($aHtmlIDs as $iID) { WgGesuchtReader::oParseHtml($iID); } } } if (isset($_REQUEST['show'])) { $oHtml = Ad::oGetHtml($_REQUEST['show']); $sHtml = $oHtml->html; echo $sHtml; }
public function vLog($mInfo) { $oInstance = isset($this) && get_class($this) == __CLASS__ ? $this : self::$oDefault; if ($oInstance->sLogFile) { ODT::log($mInfo, $oInstance->sLogFile); } if ($oInstance->bLog) { ODT::dump($mInfo); } }