added image for first node and modified mkdirectory script
[mirrors/Kyberia-bloodline.git] / cron / rssparse.php
1 #!/usr/local/bin/php
2 <?php
3 /*
4 * Script that restores number of K for all users.
5 * Called once a day.
6 */
7
8
9 // Use relative address of config file
10 // Change this, if you move you cron directory.
11 $dir=substr(__FILE__, 0, strrpos(__FILE__, '/'));
12 require($dir.'/../wwwroot/config/config.inc');
13
14 //connecting to database and creating universal $db object
15 require(INCLUDE_DIR.'/log.inc');
16 require(INCLUDE_DIR.'/database.inc');
17 require(INCLUDE_DIR.'/nodes.inc');
18
19 // include lastRSS library
20 include INCLUDE_DIR.'/lastRSS.php';
21
22
23 $db=new CLASS_DATABASE();
24
25 $set=$db->query("select nodes.*,node_content.*,nodes.node_id as node_id from nodes left join node_content on nodes.node_id=node_content.node_id where node_type='28' and nodes.node_id>100");
26
27 // create lastRSS object
28 $rss = new lastRSS;
29
30 // setup transparent cache
31 $rss->cache_dir = './cache';
32 $rss->cache_time = 3600; // one hour
33
34 // XXX WTF
35 while ($set->next()) {
36 // load some RSS file
37 if (!preg_match("/http:(.*)/",$set->getString('node_content'))) {
38 $rs = $rss->get("http://kyberia.sk/scripts/google2rss.php?num=25&q=".$set->getString('node_content'));
39 }
40 else {
41 /*
42 ob_start();
43 readfile($set->getString('node_content'));
44 $data=ob_get_contents();
45 ob_end_clean();
46 */
47 $rs=$rss->get($set->getString('node_content'));
48
49 }
50
51
52 foreach ($rs['items'] as $item) {
53 $q="select node_id from nodes where node_name='".addslashes($item['title'])."'";
54 $itemset=$db->query($q);
55 if (!$itemset->getNumRows()) {
56 /*
57 $q="insert into nodes set
58 node_name='".addslashes($item['title'])."',
59 node_parent='".$set->getString('node_parent')."',
60 node_thread_vector='".$set->getString('node_thread_vector').";".$set->getString('node_parent')."',
61 node_system_access='".$set->getString('node_system_access')."',
62 node_external_access='".$set->getString('node_external_access')."',external_link='".addslashes($item['link'])."',
63 node_type=13,node_creator='".$set->getString('node_id')."',node_created=NOW()";
64 $db->query($q);
65 $id=$db->getLastInsertId();
66 $text=$item['description'];
67 */
68 //$text.="<br><br><iframe width='666' height='230' src='".$item['link']."'>";
69 $text=AddSlashes($item['description']);
70 $params['node_content']=$text;
71 $params['node_name']=addslashes($item['title']);
72 $params['node_parent']=$set->getString('node_parent');
73 $params['node_creator']=$set->getString('node_id');
74 nodes:addNode($params);
75
76 }
77 }
78 }
79
80
81
82
83 ?>
This page took 1.109533 seconds and 4 git commands to generate.