Exemplo n.º 1
0
 public function Display()
 {
     global $db;
     $rss_writer_object = new rss_writer_class();
     $rss_writer_object->specification = '1.0';
     $rss_writer_object->about = BASE_URL . 'rss.xml';
     $rss_writer_object->rssnamespaces['dc'] = 'http://purl.org/dc/elements/1.1/';
     $properties = array();
     if ($this->mCategoryId == 'all') {
         $properties['description'] = 'Latest jobs';
     } else {
         $properties['description'] = 'Latest jobs for ' . ucwords($this->mCategoryName);
     }
     $properties['link'] = BASE_URL;
     $properties['title'] = SITE_NAME;
     $properties['dc:date'] = date('d-m-Y');
     $rss_writer_object->addchannel($properties);
     $count = 0;
     $jobb = new Job();
     if ($this->mCategoryId == 'all') {
         $jobs = $jobb->GetJobs(0, 0, 0, 0, 0, true);
     } else {
         $jobs = $jobb->GetJobs(0, $this->mCategoryId, 0, 0, 0, true);
     }
     foreach ($jobs as $job) {
         $count++;
         if ($count > 10) {
             break;
         }
         $properties = array();
         $properties['description'] = '<strong>Location:</strong> ' . $job['location'] . '<br />';
         if ($job['url'] != '' && $job['url'] != 'http://') {
             $properties['description'] .= '<strong>URL:</strong> <a href="' . $job['url'] . '">' . $job['url'] . '</a><br /><br />';
         }
         $properties['description'] .= '<strong>Description:</strong><br />' . $job['description'] . '<br /><br />';
         $properties['description'] .= '<a href="' . BASE_URL . URL_JOB . '/' . $job['id'] . '/' . $job['url_title'] . '/' . '">Apply to this job</a><br />';
         $properties['link'] = BASE_URL . URL_JOB . '/' . $job['id'] . '/' . $job['url_title'] . '/';
         $type = '[' . $job['type_name'] . ']';
         $properties['title'] = $type . ' ' . $job['title'] . ' at ' . $job['company'];
         $properties['dc:date'] = $job['mysql_date'];
         $rss_writer_object->additem($properties);
     }
     if (empty($jobs)) {
         $properties = array();
         $properties['description'] = ' ';
         $properties['description'] .= ' ';
         $properties['link'] = ' ';
         $properties['title'] = ' ';
         $properties['dc:date'] = ' ';
         $rss_writer_object->additem($properties);
     }
     if ($rss_writer_object->writerss($output)) {
         header('Content-Type: text/xml; charset="utf-8"');
         header('Content-Length: ' . strval(strlen($output)));
         echo $output;
     } else {
         //header('Content-Type: text/plain');
         //echo ('Error: '.$rss_writer_object->error);
     }
 }
Exemplo n.º 2
0
function gen_comment_feeds()
{
    global $dbtable_prefix;
    require_once _BASEPATH_ . '/includes/access_levels.inc.php';
    $short_blog_chars = 400;
    if (allow_at_level('read_blogs')) {
        // if non-members are allowed to read blogs...
        require_once _BASEPATH_ . '/includes/classes/rss_writer.class.php';
        $rss_writer_object = new rss_writer_class();
        $rss_writer_object->specification = '1.0';
        $rss_writer_object->about = _BASEURL_ . '/rss/latest-comments.xml';
        //		$rss_writer_object->rssnamespaces['dc']='http://purl.org/dc/elements/1.1/';
        $properties = array();
        $properties['description'] = 'Latest blog comments on ' . _SITENAME_;
        $properties['link'] = _BASEURL_;
        $properties['title'] = 'Latest Blog Comments';
        //		$properties['dc:date']=mktime(gmdate('H'),gmdate('i'),gmdate('s'),gmdate('m'),gmdate('d'),gmdate('Y'));
        $rss_writer_object->addchannel($properties);
        $query = "SELECT a.`comment_id`,a.`fk_user_id`,c.`alt_url` as `profile_url`,a.`_user`,a.`comment`,b.`post_id`,b.`title`,b.`alt_url` as `post_url` FROM `{$dbtable_prefix}comments_blog` a LEFT JOIN `{$dbtable_prefix}user_profiles` c ON a.`fk_user_id`=c.`fk_user_id`,`{$dbtable_prefix}blog_posts` b WHERE a.`fk_parent_id`=b.`post_id` AND a.`status`=" . STAT_APPROVED . " AND b.`is_public`=1 AND b.`status`=" . STAT_APPROVED . " ORDER BY a.`date_posted` DESC LIMIT 10";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        while ($rsrow = mysql_fetch_assoc($res)) {
            $properties = array();
            if (strlen($rsrow['comment']) < $short_blog_chars) {
                $properties['description'] = $rsrow['comment'];
            } else {
                $properties['description'] = substr($rsrow['comment'], 0, strrpos(substr($rsrow['comment'], 0, $short_blog_chars), ' '));
            }
            $properties['description'] = sanitize_and_format($properties['description'], TYPE_STRING, $GLOBALS['__field2format'][TEXT_DB2DISPLAY]);
            if (empty($rsrow['post_url'])) {
                $properties['link'] = _BASEURL_ . '/blog_post_view.php?pid=' . $rsrow['post_id'] . '#comm' . $rsrow['comment_id'];
            } else {
                $properties['link'] = $rsrow['post_url'] . '#comm' . $rsrow['comment_id'];
            }
            $rsrow['title'] = sanitize_and_format($rsrow['title'], TYPE_STRING, $GLOBALS['__field2format'][TEXT_DB2DISPLAY]);
            $properties['title'] = sprintf('%1$s on "%2$s"', $rsrow['_user'], $rsrow['title']);
            //			$properties['dc:date']=$rsrow['date_posted'];
            $rss_writer_object->additem($properties);
        }
        if ($rss_writer_object->writerss($towrite)) {
            require_once _BASEPATH_ . '/includes/classes/fileop.class.php';
            $fileop = new fileop();
            $fileop->file_put_contents(_BASEPATH_ . '/rss/latest-comments.xml', $towrite);
        } else {
            $error = true;
            $topass['message']['type'] = MESSAGE_ERROR;
            $topass['message']['text'] = $rss_writer_object->error;
        }
    }
    return true;
}
Exemplo n.º 3
0
}
/** this is a hack to convert pgsql date format to W3C date format required by RSS */
function toW3CDate($date)
{
    //2003-02-21 00:00:00+01
    //debug("date", $date);
    //$retval = substr($date, 0, 10) . 'T' . substr($date, 12) . ':00';
    //return $retval;
    return $date;
}
// calculate day to list things after that
$now = getDate();
$dayInThePast = mktime(0, 0, 0, $now['mon'], $now['mday'] - 10, $now['year']);
$fromDay = date('Y-m-d', $dayInThePast);
// prepare RSS writer
$rss_writer_object = new rss_writer_class();
$rss_writer_object->specification = "1.0";
$rss_writer_object->inputencoding = "utf-8";
$rss_writer_object->outputencoding = "utf-8";
$rss_writer_object->about = $config['rootUrl'] . "/rss.php";
// Specify the URL of an optional XSL stylesheet. This lets the document be rendered automatically in XML capable browsers.
// $rss_writer_object->stylesheet=$config['rootUrl'] . "/static/rss2html.xsl";
// When generating RSS version 1.0, you may declare additional namespaces that enable the use of
// more property tags defined by extension modules of the RSS specification.
$rss_writer_object->rssnamespaces["dc"] = "http://purl.org/dc/elements/1.1/";
$rss_writer_object->allownoitems = 1;
// do the job, fill in RSS
if ($prgId) {
    // send RSS for programme
    $db->begin();
    $prg =& $repository->getObject($prgId);
Exemplo n.º 4
0
     $input['date_posted'] = gmdate('YmdHis');
     $query = "INSERT INTO `{$dbtable_prefix}site_news` SET ";
     foreach ($site_news_default['defaults'] as $k => $v) {
         if (isset($input[$k])) {
             $query .= "`{$k}`='" . $input[$k] . "',";
         }
     }
     $query = substr($query, 0, -1);
     if (!($res = @mysql_query($query))) {
         trigger_error(mysql_error(), E_USER_ERROR);
     }
     $topass['message']['type'] = MESSAGE_INFO;
     $topass['message']['text'] = 'News added.';
 }
 require_once _BASEPATH_ . '/includes/classes/rss_writer.class.php';
 $rss_writer_object = new rss_writer_class();
 $rss_writer_object->specification = '1.0';
 $rss_writer_object->about = _BASEURL_ . '/rss/site_news.xml';
 $rss_writer_object->rssnamespaces['dc'] = 'http://purl.org/dc/elements/1.1/';
 $properties = array();
 $properties['description'] = 'Site news';
 $properties['link'] = _BASEURL_;
 $properties['title'] = 'Site news';
 $properties['dc:date'] = mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y'));
 $rss_writer_object->addchannel($properties);
 $query = "SELECT `news_title`,`news_body`,UNIX_TIMESTAMP(`date_posted`) as `date_posted` FROM `{$dbtable_prefix}site_news` ORDER BY `news_id` DESC";
 if (!($res = @mysql_query($query))) {
     trigger_error(mysql_error(), E_USER_ERROR);
 }
 while ($rsrow = mysql_fetch_assoc($res)) {
     $properties = array();
Exemplo n.º 5
0
 function &_getRssWriter()
 {
     $url = 'http://' . $_SERVER['SERVER_NAME'] . str_replace('index.php', '', $_SERVER['PHP_SELF']);
     require_once TEST_ROOT . '/lib/xml_writer_class.php';
     require_once TEST_ROOT . '/lib/rss_writer_class.php';
     $rss_writer_object = new rss_writer_class();
     $rss_writer_object->specification = "1.0";
     $rss_writer_object->about = $url . "index.php?output=xml";
     $rss_writer_object->stylesheet = $url . "rss2html.xsl";
     $rss_writer_object->rssnamespaces["dc"] = "http://purl.org/dc/elements/1.1/";
     // Channel Properties
     $properties = array();
     $properties["title"] = "Dokuwiki Unit Test Cases";
     $properties["description"] = "Dokuwiki Unit Test Cases";
     $properties["link"] = "http://wiki.splitbrain.org/";
     $properties["dc:date"] = gmdate("Y-m-d\\TH:i:sO");
     $rss_writer_object->addchannel($properties);
     // Logo like this (if we had one)
     /*
     $properties=array();
     
     $properties["link"]="http://www.phpclasses.org/";
     $properties["title"]="PHP Classes repository logo";
     $properties["description"]="Repository of components and other resources for PHP developers";
     $rss_writer_object->addimage($properties);
     */
     return $rss_writer_object;
 }