All pastes #1239432 Raw Edit

Unnamed

public text v1 · immutable
#1239432 ·published 2008-10-29 08:17 UTC
rendered paste body
<?php

//###debug-start### top of the page

//add $source to CRON_STAT.PHP as well!!! then upload it!!!

//run here gotomyjob.com:8443 => domains gotomyjob.com, first local database, phpmyadmin=> INSERT INTO `prio` ( `id` , `source1` , `priority` ) VALUES (NULL , 'XXXXXXputHere$source', '0');

$_GET['bx']=1;//1 means no DB insert

$testmode=1;//stop looping at 5th result

$local_debug=0;//0 means open website location, 1 means read data file from local server

//###debug-end###



include "func.php";

$counter=1;



$source="jobbuilding.be";

$company="Job Building";



$today=getdate();

$month=$today['mon'];

$mday=$today['mday'];

$year=$today['year'];

$hours= "00";

$minutes="00";

$seconds="00";

$today=$year.'-'.$month.'-'.$mday.' '.$hours.':'.$minutes.':'.$seconds;

$date=$today;



$link_base="https://www.jobbuilding.be/";

echo "<a href=\"".$link_base."\" target=\"_blank\"><b style=\"color: #00000f\">".$link_base."</b></a><br />"."\n";



$industry_arr['1.'] = "Ontwikkeling &amp; Expansie";

$industry_arr['2.'] = "Beheer &amp; Management";

$industry_arr['3.'] = "Deskundigen";

$industry_arr['4.'] = "Bouw &amp; Techniek";

$industry_arr['5.'] = "Verhuur &amp; Verkoop";

$industry_arr['6.'] = "Financieel &amp; Verzekeringen";

$industry_arr['7.'] = "Ontwerp &amp; Creatief";

$industry_arr['8.'] = "Juridisch";

$industry_arr['9.'] = "Nevenfuncties";

$industry_arr['10.'] = "Administratief";

$industry_arr['11.'] = "Consultancy";

$industry_arr['12.'] = "Franchising &amp; Filiaalhouders";

$industry_arr['13.'] = "Directie &amp; Topmanagement";

$industry_arr['14.'] = "Overheidsdiensten";

$industry_arr['374.'] = "Opleiding &amp; Onderzoek";

$industry_arr['381.'] = "Andere functies";




$snoopy=new Snoopy;

$snoopy->agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$snoopy->referer="http://www.google.com/";

$snoopy->rawheaders["Pragma"]="no-cache";

$snoopy->maxredirs=2;

$snoopy->offsiteok=false;

$snoopy->expandlinks=false;

$snoopy->passcookies=true;

$snoopy->set_submit_normal();

$snoopy->setcookies();



if(!sizeof($industry_arr)) $industry_arr=array('');

foreach ($industry_arr as $cat_link=>$industry) {

    $already_submitted=0;

    $next_page_exists=true;



    $page_nr=1;



    while ($next_page_exists) {

        $link_base_while=$link_base."Search.aspx?&p=3.&q=&page=".($page_nr-1);

        echo "<a href=\"".$link_base_while."\" target=\"_blank\"><b style=\"color: #00000f\">".$link_base_while."</b></a>".($industry ? "\n"."<br /><span style=\"color: #800080;font-weight: bold\"><u>".$industry."</u> Jobs</span>" : "")."<br />"."\n";



        if(!$local_debug) {

            $snoopy->fetch($link_base_while);

            $htmlsource=$snoopy->results;

        } else {

            //$htmlsource = getSource ('http://computer4.server.intranet/clients/other/gotomyjob.com/cron/_tmp/www.nationalevacaturebank.nl_vacatures.html');

        }



        if (!eregi('type="button" name="Laatste"',$htmlsource)) {

            $next_page_exists=false;

        }



        echo $htmlsource;exit;

        ExtractAndDelete($htmlsource,'Volgende pagina','<');

        do {

            echo "<hr />";



            /* $date_extracted = ExtractAndDelete($htmlsource,'<br>','<');

            if($link!="-1" && $date_extracted!="-1") {

                $date_exploded=explode("/",trim($date_extracted));

                $date=$date_exploded[2]."-".(strlen($date_exploded[1])==1?"0":"").$date_exploded[1]."-".(strlen($date_exploded[0])==1?"0":"").$date_exploded[0];

                if (strtotime($date) <= strtotime(date('Y-m-d', mktime(date('H'),0,0,date('m'),date('d')-$delete_days,date('Y'))))) {

                    echo "<br /><span style=\"color:#ff0000\">Expired Jobs</span><br />";

                    continue;

                }

            } // */



            $link=ExtractAndDelete($htmlsource,'="ab" href=\'','\'');

            $title=ExtractAndDelete($htmlsource,'>','<');

            $title=preg_replace("/^\((.*)\)/","",$title);

            $city=ucwords(strtolower(ExtractAndDelete($htmlsource,'<td class="" style="" onMouseOut="" onClick="" onMouseOver="" colspan="1">','<')));



            $link=$link_base.$link;

            echo "<b style=\"color: #0000ff\">Details Page: <a href=\"".$link."\" target=\"_blank\">".$link."</a></b><br />"."\n";



            //$industry

            $occupation=$title;



            if(substr($link,-2)=="-1")

                $link="-1";

            if($link!="-1") { //*

                $snoopy->fetch($link);

                $htmlsource1=$snoopy->results;

                ExtractAndDelete($htmlsource1,'Functieomschrijving','</tr>');

                $description=RemoveAllTrash(ExtractAndDelete($htmlsource1,'<tr class="">','</tr>'));

                // */

            }



            $thetime="fulltime";

            $hhh=strtolower($htmlsource1);

            if(strpos($hhh,"tijdelijk")>0)$thetime="parttime";

            else

            if(strpos($hhh,"parttime")>0)$thetime="parttime";

            else

            if(strpos($hhh,"part time")>0)$thetime="parttime";



            if(strcmp($link,"-1")!=0){

                //$link=$link_base.$link;

                echo "\n"."<br>--".$counter++."--";

                $already_submitted+=AddToDatabase($title,$link,$description,$city,$date,$source,$occupation,$industry,$company,$thetime,$thelogo);

            }

            if($already_submitted>=3) {

                echo "\n"."<br /><span style=\"color: #ff0000;font-weight: bold;\">Found 3 entries already submitted in the database. Exiting ...</span><br />"."\n";

                break 2;

            }



        //###debug-start### after the last AddToDatabase, but ouside the condition

        if(strcmp($link,"-1")!=0) {

            if($title=="-1" | $title=="")

                $bad_title[$link_base.$industry_link]++;

            if($description=="-1" | $description=="")

                $bad_description[$link_base.$industry_link]++;

            if($city=="-1" | $city=="")

                $bad_city[$link_base.$industry_link]++;

            if($occupation=="-1" | $occupation=="")

                $bad_occupation[$link_base.$industry_link]++;

            if($industry=="-1" | $industry=="")

                $bad_industry[$link_base.$industry_link]++;

            if($company=="-1" | $company=="")

                $bad_company[$link_base.$industry_link]++;



            if ($testmode && (($counter>5 && $testmode==1) | ($counter>$testmode && $testmode!=1))) {

                echo "\n"."<br />Stopped at ".($counter)." job. Exiting...";

                cron_debug_check_errors();

                exit;

            }

        } else {

            $bad_link[$link_base.$industry_link]++;

        }

        //###debug-end###



            ob_flush();

            flush();

            if(substr($link,-2)=="-1")

                echo "\n"."<br /><span style=\"color:#ff0000;font-weight:bold;\">--- BAD LINK ---------------------------------------------------------------------------</span><br />"."\n";

        } while (strcmp($link,"-1"));

        echo "<span style=\"color:blue;font-weight: bold;\">############################################################################<br />"."\n"."End of Page: ".($page_nr)."\n"."<br />############################################################################</span><br />"."\n";

        $page_nr+=1;

    }

}



echo "\n"."<br />------------------------------------------"."\n"."<br />Finishing the process!!!<br />"."\n";



//###debug-start### bottom of page

function cron_debug_check_errors() {

    global $bad_link, $bad_title, $bad_description, $bad_city, $bad_occupation, $bad_industry, $bad_company;

    echo "\n"."<br />Debug messages: <br />"."\n";

    if(sizeof($bad_link)) {

        foreach ($bad_link as $key=>$value) {

            echo "\n"."<br />Bad links: Error in URL: <b>".$key."</b> - nr. of bad links: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_title)) {

        foreach ($bad_title as $key=>$value) {

            echo "\n"."<br />Bad titles: Error in URL: <b>".$key."</b> - nr. of bad titles: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_description)) {

        foreach ($bad_description as $key=>$value) {

            echo "\n"."<br />Bad descriptions: Error in URL: <b>".$key."</b> - nr. of bad descriptions: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_city)) {

        foreach ($bad_city as $key=>$value) {

            echo "\n"."<br />Bad cities:Error in URL: <b>".$key."</b> - nr. of bad cities: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_occupation)) {

        foreach ($bad_occupation as $key=>$value) {

            echo "\n"."<br />Bad occupations: Error in URL: <b>".$key."</b> - nr. of bad occupations: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_industry)) {

        foreach ($bad_industry as $key=>$value) {

            echo "\n"."<br />Bad industries: Error in URL: <b>".$key."</b> - nr. of bad industries: <b>".$value."</b>";

        }

    }

    if(sizeof($bad_company)) {

        foreach ($bad_company as $key=>$value) {

            echo "\n"."<br />Bad companies: Error in URL: <b>".$key."</b> - nr. of bad companies: <b>".$value."</b>";

        }

    }

}

echo "\n\n"."<br /><br />";

cron_debug_check_errors();



/* // generate the necessary code for this cron file: select the code below then press CTRL+[-] then use it

print("\n------------------------------------------------------------------------------------------------------------------------")

local job_site=''

for m in editor:match("[$]source[ ]*=[ ]*.*", SCFIND_REGEXP) do

                job_site=string.gsub(m.text,"(.*)=\"(.*)\"(.*)","%2")

           end



print("INSERT INTO `prio` ( `id` , `source1` , `priority` ) VALUES (NULL , '"..job_site.."', '0');")

print("-> upload cron_bx_xxx.php file");

print("add to CRON_STAT.PHP : $job_sites['"..job_site.."']=\""..job_site.."\";");

print("11 23 * * * /usr/bin/php /var/www/vhosts/gotomyjob.com/httpdocs/"..filename().." >/dev/null");

print("------------------------------------------------------------------------------------------------------------------------")

*/



//###debug-end###

?>