<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html">jobberBase Community - XML import in to Jobberbase MySql database tool</title>
	<link rel="self" href="/forum/rewrite.php"/>
	<updated>2011-04-21T07:49:08Z</updated>
	<generator>FluxBB</generator>
	<id>http://www.jobberbase.com/forum/topic161-xml-import-in-to-jobberbase-mysql-database-tool.html</id>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post12224.html#p12224"/>
			<content type="html">Did you make any changes other than the sql file?</content>
			<author>
				<name>hobo</name>
			</author>
			<updated>2011-04-21T07:49:08Z</updated>
			<id>http://www.jobberbase.com/forum/post12224.html#p12224</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post12215.html#p12215"/>
			<content type="html">Hi ...

I have the feeds script installed here: http://www.atheistlist.com/jobberbase/simplefeeds_cronjob.php

It runs ok but shows no jobs listed. I have checked to make sure there are jobs listed in at least some of the categories via my rss reader. Any help is appreciated.

Thanks
Brenda</content>
			<author>
				<name>bgreen0722</name>
			</author>
			<updated>2011-04-19T19:59:28Z</updated>
			<id>http://www.jobberbase.com/forum/post12215.html#p12215</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10470.html#p10470"/>
			<content type="html">Hello guys,

I am looking for job wrapping tool, that can post/add all the new jobs from the portals everyday with a scheduler. The tool should post the openings in the database.  Pls help, its urgently needed.

Thanks
aishwinv@gmail.com</content>
			<author>
				<name>aishwin</name>
			</author>
			<updated>2010-10-11T11:40:48Z</updated>
			<id>http://www.jobberbase.com/forum/post10470.html#p10470</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10239.html#p10239"/>
			<content type="html">For jobberbase to jobberbase import code, some changes are needed to make it work on jobberbase 1.9.1. 
The changes are related to how new version deals with location fields.
To avoid extra log post, help you out and shamelesly promote some links I created a small website where you can download the jobberBase to jobberBase rss code for jobberBase version 1.6 and version 1.9.1.

Check it out: [url=http://jobfeeds.me]jobfeeds.me[/url]</content>
			<author>
				<name>hobo</name>
			</author>
			<updated>2010-09-09T18:19:17Z</updated>
			<id>http://www.jobberbase.com/forum/post10239.html#p10239</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10225.html#p10225"/>
			<content type="html">simple.

you use your admin email as the poster email and then you specify 0 on the apply online option. this way, applications will not be sent to your email but rather applicants will use the link on the job post, if they want to apply for a job.</content>
			<author>
				<name>redjumpsuit</name>
			</author>
			<updated>2010-09-08T15:44:52Z</updated>
			<id>http://www.jobberbase.com/forum/post10225.html#p10225</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10219.html#p10219"/>
			<content type="html">[quote=Mario]For those who talked about jobberbase-to-jobberbase import, how can this be possible while the company email is hidden? It&#039;s required for job applications isn&#039;t it?[/quote]

Looks like my question is quite general and not only about importing from other jobberbase sites. How do you people import jobs from feeds that dont share companies&#039; email? (like indeed&#039;s and simplyhired&#039;s)</content>
			<author>
				<name>Mario</name>
			</author>
			<updated>2010-09-08T12:01:42Z</updated>
			<id>http://www.jobberbase.com/forum/post10219.html#p10219</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10218.html#p10218"/>
			<content type="html">For those who talked about jobberbase-to-jobberbase import, how can this be possible while the company email is hidden? It&#039;s required for job applications isn&#039;t it?</content>
			<author>
				<name>Mario</name>
			</author>
			<updated>2010-09-08T11:50:03Z</updated>
			<id>http://www.jobberbase.com/forum/post10218.html#p10218</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post10214.html#p10214"/>
			<content type="html">Hello All,

Not posted on here for a long time now. 

I can provide one time backfills for your new jobboard in the UK via a simple CSV upload. As if you are just looking to kick start your site, then I can upload anything upto about 10,000 jobs in one go. This just saves the hassle of having to recode any of your site. 

I started up Jobberfeed.com but never really took it to much further. But new sites are reguarly being indexed on there to be included on the feeds. 

Problem I found with working with XML is the amount of server capacity it took up. So if you are running on a Shared Host, like JustHost, One.Com ,GoDaddy etc. Likelyhood is, at some point they will shut your site down as you have maxed out the capacity of the processor on the server (Trust me this has happened a few times, when I was developing the code that imported and distrubuted the feeds). 

How I plan on making it work, is simply providing login to Jobberfeed and on a weekly basis uploading the new CSV file on the server ready for download. 

There will be a small price for the service. 

One time back fill (download link will last 1 week) - £5
Monthly Unlimited Download (file updated weekly) - £10 a month (Paypal Subscription). 

On average the files should contain around 15,000 jobs and will be formated in a jobberbase format. Only the Category field will need to be updated. 

The service will be ready in about 2 weeks. So drop me an email or send a PM if interested. 

Cheers,

SteveSPI</content>
			<author>
				<name>SteveSPI</name>
			</author>
			<updated>2010-09-08T09:31:15Z</updated>
			<id>http://www.jobberbase.com/forum/post10214.html#p10214</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post9914.html#p9914"/>
			<content type="html">hi, in case anyone is still looking for solution for this...i now have an available add-on to backfill your jobberBase job board with feeds from Indeed.com and SimplyHired.com, which you can read about here:

http://www.redjumpsuit.net/2010/07/25/backfill-your-job-board-with-indeed-and-simplyhired/</content>
			<author>
				<name>redjumpsuit</name>
			</author>
			<updated>2010-07-25T16:06:28Z</updated>
			<id>http://www.jobberbase.com/forum/post9914.html#p9914</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post8255.html#p8255"/>
			<content type="html">It&#039;s pleasing to see that this discussion is still quite active...

I saw this listed elsewhere online (http://www.shearersoftware.com/software/web-tools/wordpress-rss-import/1.0/bootleg-import-rss.php.html) about importing XML into Wordpress...  and thought someone else might be able to adapt this for Jobberbase?

Any takers?!

Thanks,

Matt





&lt;?php
/*
RSS import for WordPress
by Andrew Shearer (awshearer@shearersoftware.com)

For current version and more info, see:
http://www.shearersoftware.com/software/web-tools/wordpress-rss-import/

This script is currently intended to be run from the command line or from the
web after it has been configured by editing variables in the first few lines
of the script.

To use it, first set the $path variable below to a path to an RSS file or
directory containing a blogBrowser archive (one folder per year, one RSS file
per month.) Then run this script from the command line (php import-rss.php).

Examples:

Import an rss.xml file in this directory:
$path = dirname(__FILE__).&#039;/rss.xml&#039;;

Import an rss.xml file with a full path specified (Mac OS X full path):
$path = &#039;/Users/testuser/Sites/mysite/rss.xml&#039;;

Import a blogBrowser archive in a folder named C:/documents/weblog,
including monthly RSS files such as weblog/2003/12.xml (Windows full path):
$path = &#039;C:/documents/weblog&#039;;

Future improvements: make this runnable from a web browser. Single RSS files
could be handled through uploads, and multi-file blogBrowser archives could be
specified by base URL.

Revision history:

2003-12-26  ashearer  Improved date conflict resolution with $kUpdatePostsAlways
                      and $kUpdatePostsIfNewer options; added $kTakeNoAction;
                      added more comments
2003-12-22  ashearer  Added blogBrowser archive support; optional mod. dates;
                      mod. date column autocreation
2003-12-21  ashearer  RSS import, initial version


*/

//$path = dirname(__FILE__).&#039;/../archivedir&#039;;
//$path = dirname(__FILE__).&#039;/rss.xml&#039;;
$path = &#039;http://www.example.com/rss.xml&#039;;

$kCreateModDateField = false;    // autocreate post_modified field?
$kSetModDateField = true;       // import post_modified field from RSS file?
$kUpdatePostsAlways = true;    // true to import RSS version even if it replaces current version
$kUpdatePostsIfNewer = false;    // if true, in case of conflict, use newer version; requires post_modified field
$kTakeNoAction = false;          // like -n flag; report actions but don&#039;t actually change DB

error_reporting(E_ALL);

class post {
    var $title;
    var $content;
    var $createDate;
    var $modDate;
    var $guid;
    var $categories;
    var $postTitle; 
}

$kExcludeCategories = array(&#039;Testing&#039; =&gt; &#039;&#039;);

$currentPost = null;
$currentText = &#039;&#039;;

function parseDateISO8601($input) {
    // returns the date in SQL (MySQL, at least)-compatible text format
    return substr($input, 0, 10) . &#039; &#039; . substr($input, 11, 8);
}

function parseDateRFC822($input) {
    // returns the date in SQL (MySQL, at least)-compatible text format
    return strftime(&#039;%Y-%m-%d %H:%I:%S&#039;, strtotime($input));
}

function startElement($parser, $name, $attrs) {
    global $currentPost, $currentText, $currentGuidAttrs;
    if ($name == &#039;item&#039;) {
        $currentPost = new post();
        $currentPost-&gt;categories = array();
    }
    elseif ($name == &#039;guid&#039;) {
        $currentGuidAttrs = $attrs;
    }
    $currentText = &#039;&#039;;
}

function endElement($parser, $name) {
    global $currentPost, $currentText;
    
    switch ($name) {
        case &#039;title&#039;: case &#039;http://www.w3.org/1999/02/22-rdf-syntax-ns# title&#039;:
            $currentPost-&gt;title = $currentText;
            break;
        
        case &#039;content:encoded&#039;: case &#039;http://purl.org/rss/1.0/modules/content/ encoded&#039;:
            $currentPost-&gt;content = $currentText;
            break;
            
        case &#039;description&#039;: case &#039;http://www.w3.org/1999/02/22-rdf-syntax-ns# description&#039;:
            // content:encoded trumps description, so only save the description
            // if there&#039;s no content already
            if (!isset($currentPost-&gt;content) || !strlen($currentPost-&gt;content)) {
                $currentPost-&gt;content = $currentText;
            }
            break;
        
        case &#039;pubDate&#039;:
            $currentPost-&gt;createDate = parseDateRFC822($currentText);
            break;
        
        case &#039;dc:date&#039;: case &#039;http://purl.org/dc/elements/1.1/ date&#039;:
            $currentPost-&gt;createDate = parseDateISO8601($currentText);
            break;
        
        case &#039;dcterms:modified&#039;: case &#039;http://purl.org/dc/terms/ modified&#039;:
            $currentPost-&gt;modDate = parseDateISO8601($currentText);
            break;
        
        case &#039;category&#039;: case &#039;dc:subject&#039;: case &#039;http://purl.org/dc/elements/1.1/ subject&#039;:
            $currentPost-&gt;categories[] = $currentText;
            break;
        
        case &#039;guid&#039;:
            if (isset($currentGuidAttrs[&#039;isPermaLink&#039;]) &amp;&amp; $currentGuidAttrs[&#039;isPermaLink&#039;] == &#039;true&#039;) {
                $currentPost-&gt;permalink = $currentText;
            }
            $currentPost-&gt;guid = $currentText;
            break;
        
        case &#039;item&#039;: case &#039;http://www.w3.org/1999/02/22-rdf-syntax-ns# item&#039;:
            processPost($currentPost);
            $currentPost = null;
            break;
    }
    
    $currentText = &#039;&#039;;
}

function characterData($parser, $data) {
    global $currentText;
    $currentText .= $data;
}



// WordPress-specific code


$post_author = &#039;admin&#039;;

require_once(&#039;../wp-config.php&#039;);
require_once(ABSPATH.WPINC.&#039;/template-functions.php&#039;);
require_once(ABSPATH.WPINC.&#039;/functions.php&#039;);
require_once(ABSPATH.WPINC.&#039;/vars.php&#039;);

if ($kCreateModDateField &amp;&amp; !$kTakeNoAction) {
    require_once(ABSPATH.&#039;/wp-admin/install-helper.php&#039;);
    $res = &#039;&#039;;
    $tablename = $tableposts;
    $ddl = &quot;ALTER TABLE $tableposts ADD COLUMN post_modified datetime&quot;;
    maybe_add_column($tablename, &#039;post_modified&#039;, $ddl);
    if (check_column($tablename, &#039;post_modified&#039;, &#039;datetime&#039;)) {
        $res .= $tablename . &#039; - ok &lt;br /&gt;&#039;.&quot;\n&quot;;
    } else {
        $res .= &#039;There was a problem with &#039; . $tablename . &#039;&lt;br /&gt;&#039;.&quot;\n&quot;;
        //++$error_count;
    }
    echo $res;
}


function processPost(&amp;$post) {
    global $kSetModDateField, $kUpdatePostsAlways, $kUpdatePostsIfNewer, $kTakeNoAction;
    
    //print_r($post);
    
    // Filter out (ignore) posts having categories that are all listed as &quot;excluded&quot;
    // If a post has no categories, or at least one non-excluded category, it is still
    // included.
    if (sizeof($post-&gt;categories)) {
        $gotIncludedCategory = false;
        foreach ($post-&gt;categories as $categoryName) {
            if (!isset($kExcludedCategories[$categoryName])) {
                $gotIncludedCategory = true;
                break;
            }
        }
        if (!$gotIncludedCategory) {
            return;
        }
    }
    
    global $post_author, $kExcludeCategories;
    global $wpdb;
    global $tableusers, $tableposts, $tablepost2cat, $tablecategories;

    $post_author_ID = $wpdb-&gt;get_var(&quot;SELECT ID FROM $tableusers WHERE user_login = &#039;$post_author&#039;&quot;);
    
    $post_content = $post-&gt;content;
    $post_content = str_replace(&#039;&lt;br&gt;&#039;, &#039;&lt;br /&gt;&#039;, $post_content); // XHTMLify &lt;br&gt; tags
    
    /* Un-word-wrap the content, because &lt;br /&gt; tags will be added at display time
    for line breaks, and RSS feeds are often already soft-wrapped. Replace \n and \r
    with spaces.
    
    However, we don&#039;t want to remove word wrapping inside &lt;pre&gt; tags. Stopping short
    of a full HTML parser, we only un-wrap those sections not inside &lt;pre&gt; tag pairs.
    (This code could be misled by things that look like &lt;pre&gt; tags wrapped in HTML comments,
    but oh well.)
    */
    /*$pos = $lastpos = 0;
    while ($lastpos !== false &amp;&amp; ($pos = strpos($post_content, &#039;&lt;pre&gt;&#039;, $lastpos)) !== false) {
        $post_content = substr($post_content, 0, $lastpos)
            . str_replace(&quot;\n&quot;, &#039; &#039;, str_replace(&quot;\r&quot;, &#039; &#039;, substr($post_content, $lastpos, $pos - $lastpos)))
            . substr($post_content, $pos);
        $lastpos = strpos($post_content, &#039;&lt;/pre&gt;&#039;, $pos);
    }
    if ($lastpos !== false) {
        $post_content = substr($post_content, 0, $lastpos)
            . str_replace(&quot;\n&quot;, &#039; &#039;, str_replace(&quot;\r&quot;, &#039; &#039;, substr($post_content, $lastpos)));
    }
    */
    
    $post_content = addslashes($post_content);
    
    #$post_content = str_replace(&quot;\r&quot;, &#039; &#039;, $post_content);
    #$post_content = str_replace(&quot;\n&quot;, &#039; &#039;, $post_content);
    $post_date = addslashes($post-&gt;createDate);
    $post_title = addslashes($post-&gt;title);
    $post_modified = $kSetModDateField ? addslashes($post-&gt;modDate) : &#039;&#039;;
    $post_name = &#039;&#039;;
    if (isset($post-&gt;permalink) &amp;&amp; strlen($post-&gt;permalink)) {
        $matches = array();
        if (preg_match(&#039;|/[0-9]{4}/[0-9]{2}/[0-9]{2}/([A-Za-z0-9_-]*)/?|&#039;, $post-&gt;permalink, $matches)) {
            $post_name = $matches[1];
            $post_name = mysql_escape_string($post_name);
        }
    }
        
    
    $categoryIDList = array();
    foreach ($post-&gt;categories as $categoryName) {
        if (isset($kExcludedCategories[$categoryName])) {
            continue;
        }
        $categoryID = $wpdb-&gt;get_var(&quot;SELECT cat_ID FROM $tablecategories WHERE cat_name = &#039;&quot;.mysql_escape_string($categoryName).&quot;&#039;&quot;);
        if (!$categoryID) {
            if ($kTakeNoAction) {
                echo &quot;Would have inserted new category &#039;$categoryName&#039;.&quot;;
                $categoryID = 0;
            }
            else {
                $categoryNiceName = sanitize_title($categoryName);
                $wpdb-&gt;query(&quot;INSERT INTO $tablecategories
                    (cat_name, category_nicename)
                  VALUES
                    (&#039;&quot;.mysql_escape_string($categoryName).&quot;&#039;,&#039;&quot;.mysql_escape_string($categoryNiceName).&quot;&#039;)&quot;);
                $categoryID = $wpdb-&gt;get_var(&quot;SELECT LAST_INSERT_ID()&quot;);
            }
        }
        else {
            // category already exists; could update its nicename here if it tended not to be correct already.
            //$wpdb-&gt;query(&quot;UPDATE $tablecategories SET category_nicename = &#039;&quot;.mysql_escape_string(sanitize_title($categoryName)).&quot;&#039; WHERE cat_ID = &quot;.intval($categoryID));
        }
        $categoryIDList[] = $categoryID;
    }
    
    
    // Quick-n-dirty check for dups:
    if ($kUpdatePostsIfNewer) {
        $dupcheck = $wpdb-&gt;get_results(&quot;SELECT ID,post_date,post_title,post_modified FROM $tableposts WHERE post_date=&#039;$post_date&#039; AND post_title=&#039;$post_title&#039; LIMIT 1&quot;,ARRAY_A);
    }
    else {
        $dupcheck = $wpdb-&gt;get_results(&quot;SELECT ID,post_date,post_title FROM $tableposts WHERE post_date=&#039;$post_date&#039; AND post_title=&#039;$post_title&#039; LIMIT 1&quot;,ARRAY_A);
    }
    if ($dupcheck[0][&#039;ID&#039;]) {
        // post already exists
        if ($kUpdatePostsAlways || ($kUpdatePostsIfNewer &amp;&amp; $kSetModDateField &amp;&amp; $dupcheck[0][&#039;post_modified&#039;] &lt; $post_modified)) {
            print &quot;&lt;br /&gt;\n\nUpdating post, ID = &#039;&quot; . $dupcheck[0][&#039;ID&#039;] . &quot;&#039;&lt;br /&gt;\n&quot;;
            print &quot;Timestamp: &quot; . $post_date . &quot;&lt;br /&gt;\n&quot;;
            print &quot;Post Title: &#039;&quot; . stripslashes($post_title) . &quot;&#039;&lt;br /&gt;\n&quot;;
            if (!$kTakeNoAction) {
                $postID = $dupcheck[0][&#039;ID&#039;];
                $result = $wpdb-&gt;query(&quot;
                UPDATE $tableposts 
                    SET post_author = &#039;$post_author_ID&#039;, post_date = &#039;$post_date&#039;, 
                    &quot;.($kSetModDateField ? &quot;post_modified = &#039;$post_modified&#039;, &quot; : &quot;&quot;).&quot;
                    post_content=&#039;$post_content&#039;,
                    post_title = &#039;$post_title&#039;, post_name = &#039;$post_name&#039; WHERE ID = &quot;.intval($postID));
                //echo &quot;DELETE FROM $tablepost2cat WHERE post_id = &quot;.intval($postID);
                $result = $wpdb-&gt;query(&quot;DELETE FROM $tablepost2cat WHERE post_id = &quot;.intval($postID));
                foreach ($categoryIDList as $categoryID) {
                    $result = $wpdb-&gt;query(&quot;
                        INSERT INTO $tablepost2cat 
                            (post_id, category_id)
                        VALUES 
                            (&quot;.intval($postID).&quot;,&quot;.intval($categoryID).&quot;)
                        &quot;);
                }
            }
        }
        else {  
            print &quot;&lt;br /&gt;\n\nSkipping duplicate post, ID = &#039;&quot; . $dupcheck[0][&#039;ID&#039;] . &quot;&#039;&lt;br /&gt;\n&quot;;
            print &quot;Timestamp: &quot; . $post_date . &quot;&lt;br /&gt;\n&quot;;
            print &quot;Post Title: &#039;&quot; . stripslashes($post_title) . &quot;&#039;&lt;br /&gt;\n&quot;;
        }
    }
    else {
        print &quot;&lt;br /&gt;\nInserting new post.&lt;br /&gt;\n&quot;;
        print &quot;Timestamp: &quot; . $post_date . &quot;&lt;br /&gt;\n&quot;;
        print &quot;Post Title: &#039;&quot; . stripslashes($post_title) . &quot;&#039;&lt;br /&gt;\n&quot;;
        if (!$kTakeNoAction) {
            $result = $wpdb-&gt;query(&quot;
            INSERT INTO $tableposts 
                (post_author,post_date,post_content,post_title,post_name,post_category&quot;.($post_modified ? &quot;,post_modified&quot; : &quot;&quot;).&quot;)
            VALUES 
                (&#039;$post_author_ID&#039;,&#039;$post_date&#039;,&#039;$post_content&#039;,&#039;$post_title&#039;,&#039;$post_name&#039;,&#039;1&#039;&quot;.($post_modified ? &quot;,&#039;$post_modified&#039;&quot; : &quot;&quot;).&quot;)
            &quot;);
            $postID = $wpdb-&gt;get_var(&quot;SELECT LAST_INSERT_ID();&quot;);
            if ($postID) {
                foreach ($categoryIDList as $categoryID) {
                    $result = $wpdb-&gt;query(&quot;
                    INSERT INTO $tablepost2cat 
                        (post_id, category_id)
                    VALUES 
                        (&quot;.intval($postID).&quot;,&quot;.intval($categoryID).&quot;)
                    &quot;);
                }
            } 
        }
    }
}

// XML parsing code
function importRSSFile($filePath) {
    if (function_exists(&#039;xml_parser_create_ns&#039;)) {
        $xml_parser = xml_parser_create_ns(&#039;iso-8859-1&#039;,&#039; &#039;);    // space sep for namespace URI
    }
    else {
        $xml_parser = xml_parser_create();
    }
    // make sure to turn off case-folding; XML 1.0 is case-sensitive
    xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
    xml_set_element_handler($xml_parser, &quot;startElement&quot;, &quot;endElement&quot;);
    xml_set_character_data_handler($xml_parser, &quot;characterData&quot;);
    if (!($fp = fopen($filePath, &quot;r&quot;))) {
        die(&quot;could not open XML input&quot;);
    }
    
    while ($data = fread($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            die(sprintf(&quot;XML error: %s at line %d&quot;,
                        xml_error_string(xml_get_error_code($xml_parser)),
                        xml_get_current_line_number($xml_parser)));
        }
    }
    xml_parser_free($xml_parser);
    fclose($fp);
}

function importBlogArchive($dirPath) {
    $startYear = 1980;
    $endYear = intval(strftime(&#039;%Y&#039;));
    for ($testYear = $startYear; $testYear &lt;= $endYear; $testYear++) {
        for ($testMonth = 1; $testMonth &lt;= 12; $testMonth++) {
            $rssFilePath = $dirPath.&#039;/&#039;.$testYear.&#039;/&#039;.($testMonth &lt; 10 ? &#039;0&#039; : &#039;&#039;).$testMonth.&#039;.xml&#039;;
            if (is_file($rssFilePath)) {
                importRSSFile($rssFilePath);
            }
        }
    }
}


if (is_dir($path)) {
    importBlogArchive($path);
}
else {
    importRSSFile($path);
}

/*echo &#039;&lt;pre&gt;&#039;;
print_r($EZSQL_ERROR);
echo &#039;&lt;/pre&gt;&#039;;
*/

?&gt;</content>
			<author>
				<name>mattcody</name>
			</author>
			<updated>2010-02-08T15:44:31Z</updated>
			<id>http://www.jobberbase.com/forum/post8255.html#p8255</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post8148.html#p8148"/>
			<content type="html">Hey all,

I thought this discussion was dead but I did something wrong with the instant e-mail notification. Anyway I&#039;ve received a possible solution for importing XML feeds in your database. The method is Shell scripting and I&#039;m now trying to make it all work with my site. 

Does anybody got any experience with this? When I&#039;ve got it all working I will notify you</content>
			<author>
				<name>chrisdegrote</name>
			</author>
			<updated>2010-01-27T22:09:53Z</updated>
			<id>http://www.jobberbase.com/forum/post8148.html#p8148</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post7551.html#p7551"/>
			<content type="html">Currently design of jobberBase is such that it does not support addons. v2.0 will probably contain the plugin system, so you will have to wait until that if you are looking for a addon for this. Until then, you will have to hack the core files to integrate RSS feeds into jobberBase.</content>
			<author>
				<name>navjotjsingh</name>
			</author>
			<updated>2009-11-15T11:31:32Z</updated>
			<id>http://www.jobberbase.com/forum/post7551.html#p7551</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post7546.html#p7546"/>
			<content type="html">I&#039;m a newbie and am looking for a job aggregator - the design of jobberbase is fantastic and would look great as an aggregator.

I believe a &#039;plugin&#039; that would allow RSS feeds to display jobs from other sources (with other features) would be useful.

Just an idea for you guys, I know you are discussing this in the thread about hacking the code but something easy to add-on is a must.</content>
			<author>
				<name>rawkinrich</name>
			</author>
			<updated>2009-11-14T21:40:59Z</updated>
			<id>http://www.jobberbase.com/forum/post7546.html#p7546</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post7514.html#p7514"/>
			<content type="html">How to get content from more than one website? You can already do this, since you can get rss feeds in correct format from any jobberbase powered website, but for sites not powered by jobberbase some parameters will be in different places. For example, you could have the location showing in feed title instead of feed content, this would prevent you from sorting these jobs by city in your jobberbase since the default code would not store this data in your database. 
The script currently gets location by looking for anything in the description field that is between the &quot;Location:&quot; and the first &quot;&lt;br /&gt;. This may not be the case for all feeds and that is why modifications are needed.
One way to work around this is to create a new table in your database, you can use same code as before, just change table name for each new feed format you wish to add, and also make new  simplefeeds_cronjob.php file that would be customized to the new feed format you wish to get, you could call it simplefeeds_cronjob2.php, simplefeeds_cronjob3.php 

What needs changing in the cron job code for getting new feed format?
For new table you need a new name so in simplefeeds_cronjob2.php replace this line:

$sql = &#039;SELECT * FROM feed_db WHERE is_active = 1&#039;;

with:

$sql = &#039;SELECT * FROM second_feed_db WHERE is_active = 1&#039;;

Where you replace the &quot;second_feed_db&quot; with the table name you assigned to the new table.

The get_string_between function can get the data you need to find in most cases.
Below is the piece of the code from simplefeeds_cronjob2.php that needs modifying.
[code]
$permalink = $item-&gt;get_permalink();
                
                        $title = addslashes(trim($item-&gt;get_title()));
                        $rssdate = $item-&gt;get_date();
                        $content = addslashes(trim($item-&gt;get_description()));
                        
                        $location = trim(strip_tags($todb-&gt;get_string_between($content, &quot;Location:&quot;, &quot;&lt;br /&gt;&quot;)));
                        $url =  $permalink;
                        $desc =  strip_tags(trim($content));
[/code]

When modification are done just setup your two cron jobs so you can get your two different feeds types.

You can see if it works by visiting your cron jobs at: 
http://example.com/simplefeeds_cronjob.php
http://example.com/simplefeeds_cronjob2.php
And then you visit your website to see if it worked.

Only problems I run into with this code is when I entered same rss feed url in the database table twice, so don&#039;t.

If something needs clarifying, or someone has a better idea on how to do this, feel free to contribute.</content>
			<author>
				<name>hobo</name>
			</author>
			<updated>2009-11-12T20:27:22Z</updated>
			<id>http://www.jobberbase.com/forum/post7514.html#p7514</id>
		</entry>
		<entry>
			<title type="html">Re: XML import in to Jobberbase MySql database tool</title>
			<link rel="alternate" href="http://www.jobberbase.com/forum/post7475.html#p7475"/>
			<content type="html">Hi Dre,
Relax,

It took some time to figure this one out for me, but it was quite simple solution.
This code is tested and works on 1.6, and it is for jobberbase to jobberbase transfer.
It is not complete or bulletproof as it could use some more improvements.
Also can grab any other feed from any website but styling and format may need adjusting. Feel free to ask any questions here if you need help.

All instructions from above are the same except the 2 php files.

1 The code below is from simplefeeds_cronjob.php that goes to root app folder change it to:
[code]
&lt;?php
/**
 * jobber job board platform
 *
 * @author     Filip C.T.E. &lt;http://www.filipcte.ro&gt; &lt;me@filipcte.ro&gt;
 * @license    You are free to edit and use this work, but it would be nice if you always referenced the original author ;)
 *             (see license.txt).
 */

	require_once &#039;config.php&#039;;
	require_once &#039;_includes/simplepie.inc&#039;;
	require_once &#039;_includes/class.FeedToDB.php&#039;;

	// select all feeds that are active
	$sql = &#039;SELECT * FROM feed_db WHERE is_active = 1&#039;;
	$result = $db-&gt;query($sql);
	while ($row = $result-&gt;fetch_assoc())
	{	
		if (isset($row[&#039;url&#039;]))
		{
			$url = $row[&#039;url&#039;];
			 
			$feed = new SimplePie();
			$todb = new FeedToDB();
			
			$data = array();
			
			$feed-&gt;set_feed_url($url);
			
			$success = $feed-&gt;init();
			
			$feed-&gt;handle_content_type();
			 
			// default starting item
			$start = 0;
			 
			// default number of items to display. 0 = all
			$length = 0; 
			 
			// if single item, set start to item number and length to 1
			/*
			if(isset($_GET[&#039;item&#039;]))
			{
					$start = $_GET[&#039;item&#039;];
					$length = 10;
			}
			*/
			 
			// set item link to script uri
			$link = $_SERVER[&#039;REQUEST_URI&#039;];
			 
			if ($success)
			{
				$type_id = $row[&#039;type_id&#039;];
				$category_id = $row[&#039;category_id&#039;];
				$company = $row[&#039;company&#039;];
				$poster_email = $row[&#039;poster_email&#039;];
				$database = $row[&#039;database&#039;];
					
				// loop through items
				foreach($feed-&gt;get_items($start,$length) as $key=&gt;$item)
				{
				 
						// set query string to item number
						$queryString = &#039;?item=&#039; . $key;
				 
						// if we&#039;re displaying a single item, set item link to itself and set query string to nothing
						if(isset($_GET[&#039;item&#039;]))
						{
								$link = $item-&gt;get_link();
								$queryString = &#039;&#039;;        
						}
				 
						// display item title and date    
						echo &#039;&lt;a href=&quot;&#039; . $item-&gt;get_permalink() . &#039;&quot;&gt;&#039; . $item-&gt;get_title() . &#039;&lt;/a&gt;&#039;;
						echo &#039; &lt;small&gt;&#039;.$item-&gt;get_date(&#039;j M Y, H:i:s O&#039;).&#039;&lt;/small&gt;&lt;br&gt;&#039;;
						echo &#039; &lt;small&gt;&#039;.$item-&gt;get_content().&#039;&lt;/small&gt;&lt;br&gt;&#039;;
						echo &#039; &lt;small&gt;&#039;.$item-&gt;get_permalink().&#039;&lt;/small&gt;&lt;br&gt;&#039;;
						echo &#039;&lt;br&gt;&#039;;
						
						$permalink = $item-&gt;get_permalink();
				
						$title = addslashes(trim($item-&gt;get_title()));
						$rssdate = $item-&gt;get_date();
						$content = addslashes(trim($item-&gt;get_description()));
						
						$location = trim(strip_tags($todb-&gt;get_string_between($content, &quot;Location:&quot;, &quot;&lt;br /&gt;&quot;)));
						$url =  $permalink;
						$desc =  strip_tags(trim($content));
						
						/*
						echo &quot;loc:&quot; .$location .&quot;&lt;br/&gt;&quot;;
						echo &quot;url:&quot; .$url .&quot;&lt;br/&gt;&quot;;
						echo &quot;desc:&quot; .$desc .&quot;&lt;br/&gt;&quot;;
						*/
						
						$data = array(&#039;database&#039; =&gt; $database, 
									&#039;type_id&#039; =&gt; $type_id, 
									&#039;category_id&#039; =&gt; $category_id, 
									&#039;title&#039; =&gt; $title, 
									&#039;description&#039; =&gt; $desc, 
									&#039;company&#039; =&gt; $company,						
									&#039;url&#039; =&gt; $url, 
									&#039;location&#039; =&gt; $location, 
									&#039;created_on&#039; =&gt; $rssdate,
									&#039;poster_email&#039; =&gt; $poster_email);
									
						$todb-&gt;save($data);			
						
				}
			}
			else
			{
			
					// Check to see if there are more than zero errors (i.e. if there are any errors at all)
					if ($feed-&gt;error())
					{
						// If so, start a &lt;div&gt; element with a classname so we can style it.
						echo &#039;&lt;div class=&quot;sp_errors&quot;&gt;&#039; . &quot;\r\n&quot;;

							// ... and display it.
							echo &#039;&lt;p&gt;&#039; . htmlspecialchars($feed-&gt;error()) . &quot;&lt;/p&gt;\r\n&quot;;

						// Close the &lt;div&gt; element we opened.
						echo &#039;&lt;/div&gt;&#039; . &quot;\r\n&quot;;
					}
			
			}
		}
		
		echo &quot;&lt;strong&gt;Feed upload for &quot;. $row[&#039;database&#039;] .&quot; - &quot;. $row[&#039;category_label&#039;] .&quot; completed.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&quot;;
	}
?&gt;
[/code]

And the class.FeedToDB.php in the _includes folder should be changed to:
[code]
&lt;?php
/**
 * jobber job board platform
 *
 * @author     RedJumpsuit &lt;myredjumpsuit@gmail.com&gt;
 * 
 * FeedToDB class handles feeding RSS/XML feed to MySQL
 * Thanks to SimplePie :)
 *
 */

class FeedToDB
{
	
	function __construct()
	{ }
	
	public function save($data)
	{
	
		global $db;
	
		// category
		
		$dbname = $data[&#039;database&#039;];
		$category_id = $data[&#039;category_id&#039;];
		
		/*
		if (!is_numeric($category_id) &amp;&amp; strstr($category_id, &quot;|&quot;))
		{
			$cats = array();
			$cats = explode(&quot;|&quot;, $category_id);
			
			$dbname = trim($cats[0]);
			$category_id = trim($cats[1]);
		}
		*/
		
		$sqldup = &#039;SELECT * FROM &#039;. $dbname.&#039;.jobs WHERE url = &quot;&#039;. trim($data[&#039;url&#039;]) .&#039;&quot;&#039;;
		$resultdup = $db-&gt;query($sqldup);
		$rowdup = $resultdup-&gt;fetch_assoc();

		if (!$rowdup)
		{
			$sqlcity = &#039;SELECT id FROM &#039;. $dbname.&#039;.cities WHERE name LIKE &quot;%&#039;. $data[&#039;location&#039;] .&#039;%&quot;&#039;;
			$resultcity = $db-&gt;query($sqlcity);
			$rowcity = $resultcity-&gt;fetch_assoc();
			
			if (is_numeric($rowcity[&#039;id&#039;]) &amp;&amp; $rowcity[&#039;id&#039;] &gt; 0)
			{
				$city_id = $rowcity[&#039;id&#039;];
				$outside_location = &#039;&#039;;
			}
			else
			{
				$city_id = -1;
				$outside_location = $data[&#039;location&#039;];
			}
		
				$sql = &#039;INSERT INTO &#039;. $dbname.&#039;.jobs (type_id, category_id, title, description, company, city_id, url, created_on, is_temp, is_active,
					views_count, auth, outside_location, poster_email, apply_online)
					VALUES (&#039; . $data[&#039;type_id&#039;] . &#039;,
						 &#039; . $category_id . &#039;,
						 &quot;&#039; . $data[&#039;title&#039;] . &#039;&quot;,
						 &quot;&#039; . $data[&#039;description&#039;] . &#039;&quot;,
						 &quot;&#039; . $data[&#039;company&#039;] . &#039;&quot;,
						 &#039; . $city_id . &#039;,
						 &quot;&#039; . $data[&#039;url&#039;] . &#039;&quot;,
						 NOW(), 0, 1, 0, &quot;&#039; . md5(uniqid() . time()) . &#039;&quot;, 
						 &quot;&#039; . $outside_location . &#039;&quot;, &quot;&#039; . $data[&#039;poster_email&#039;] . &#039;&quot;, 0)&#039;;
		
				$db-&gt;query($sql);
		}
		else
		{
			echo &quot;&lt;strong&gt;FAILED: This Job already exists! &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&quot;;
		}
	}
	
	public function get_string_between($string, $start, $end)
	{
        $string = &quot; &quot;.$string;
		
        $ini = strpos($string,$start);
		
        if ($ini == 0) return &quot;&quot;;
		
        $ini += strlen($start);   
		
        $len = strpos($string,$end,$ini) - $ini;
		
        return substr($string,$ini,$len);
		
	}

}
?&gt;
[/code]

It could possibly work on 1.8, but I did not try yet.

To see if it works, once you added the valid category number and valid rss feed to your feed_db database table visit your website at http://example.com/simplefeeds_cronjob.php
Use at own risk and thanks again to Redjumpsuit for coming up with this simple easy to edit code.</content>
			<author>
				<name>hobo</name>
			</author>
			<updated>2009-11-08T07:08:04Z</updated>
			<id>http://www.jobberbase.com/forum/post7475.html#p7475</id>
		</entry>
</feed>

