From: niekt0 Date: Wed, 27 Oct 2010 22:27:30 +0000 (+0200) Subject: Cron scripts fixup & added isset to database.inc X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=a3be90c67dddac260c8267cf61ccd0a6b758cb35;p=mirrors%2FKyberia-bloodline.git Cron scripts fixup & added isset to database.inc --- diff --git a/cron/citizen.php b/cron/citizen.php index 68ffd76..e0a1413 100755 --- a/cron/citizen.php +++ b/cron/citizen.php @@ -1,21 +1,35 @@ #!/usr/bin/php query("select * from node_access where node_id='1961061' and node_permission='execute'"); +$set=$db->query("select * from node_access where + node_id='1961061' and node_permission='execute'"); $citizens=$set->getNumRows(); -$set2=$db->query("select k,node_id,node_creator,login from nodes left join users on nodes.node_creator=users.user_id where node_name='request for citizenship'"); +$set2=$db->query("select k,node_id,node_creator,login from nodes + left join users on nodes.node_creator=users.user_id where + node_name='request for citizenship'"); echo "TOTAL $citizens citizens \n"; @@ -25,8 +39,10 @@ while ($set2->next()) { $login=$set2->getString('login'); $citizen=$set2->getString('node_creator'); echo "citizen $citizen - $login has $votes needs ".floor(log($citizens,"1.42"))." \n"; + if (($citizens<66 && $votes>=floor($citizens/6)) || ($citizens>=66 && $votes>floor(log($citizens,"1.42")))) { + $params['node_parent']=$request_id; $params['node_creator']=UBIK_ID; $params['node_content']="request of user $login approved by $votes citizens"; @@ -34,24 +50,43 @@ while ($set2->next()) { //print_r($params); echo $votes.$citizen."\n"; nodes::addNode($params); - $t1=$db->query("select * from node_access where node_id='1961061' and user_id='$citizen' and node_permission='execute'"); - if (!$t1->getNumRows()) $db->query("insert into node_access set node_id='1961061',user_id='$citizen',node_permission='execute'"); - $t1=$db->query("select * from node_access where node_id='1061495' and user_id='$citizen' and node_permission='execute'"); - if (!$t1->getNumRows()) - $db->query("insert into node_access set node_id='1061495',user_id='$citizen',node_permission='execute'"); - $t1=$db->query("select * from node_access where node_id='1961070' and user_id='$citizen' and node_permission='execute'"); - if (!$t1->getNumRows()) - $db->query("insert into node_access set node_id='1961070',user_id='$citizen',node_permission='execute'"); - $db->query("update nodes set node_name='approved citizenship request' where node_id='$request_id'"); + $t1=$db->query("select * from node_access where + node_id='1961061' and + user_id='$citizen' + and node_permission='execute'"); + if (!$t1->getNumRows()) { + $db->query("insert into node_access set + node_id='1961061', + user_id='$citizen', + node_permission='execute'"); + } + $t1=$db->query("select * from node_access where + node_id='1061495' and + user_id='$citizen' and + node_permission='execute'"); + if (!$t1->getNumRows()) { + $db->query("insert into node_access set + node_id='1061495', + user_id='$citizen', + node_permission='execute'"); + } + $t1=$db->query("select * from node_access where + node_id='1961070' and + user_id='$citizen' and + node_permission='execute'"); + if (!$t1->getNumRows()) { + $db->query("insert into node_access set + node_id='1961070', + user_id='$citizen', + node_permission='execute'"); + } + $db->query("update nodes set node_name='approved citizenship request' + where node_id='$request_id'"); $params['mail_to']=$citizen; $params['mail_text']="you have become a citizen"; ubik::ubikMail($params); - } } - - - ?> diff --git a/cron/delete_rss.php b/cron/delete_rss.php index beac001..86a841a 100755 --- a/cron/delete_rss.php +++ b/cron/delete_rss.php @@ -2,9 +2,9 @@ query("select node_id from nodes where node_type='13'"); @@ -23,4 +23,4 @@ while ($set->next()) { -?> \ No newline at end of file +?> diff --git a/cron/k.php b/cron/k.php index 17c8560..8239910 100755 --- a/cron/k.php +++ b/cron/k.php @@ -11,9 +11,9 @@ $dir=substr(__FILE__, 0, strrpos(__FILE__, '/')); require($dir.'/../wwwroot/config/config.inc'); -require('../config/config.inc'); require(INCLUDE_DIR.'/database.inc'); require(INCLUDE_DIR.'/senate.inc'); +require(INCLUDE_DIR.'/log.inc'); $db = new CLASS_DATABASE(); $db->query('update users set user_k = '. DAILY_K); diff --git a/cron/logoutidle.php b/cron/logoutidle.php index a477b8a..c9fd763 100755 --- a/cron/logoutidle.php +++ b/cron/logoutidle.php @@ -1,12 +1,20 @@ #!/usr/bin/php query("update users set user_action=NULL,user_action_id=NULL,user_location_vector=NULL where unix_timestamp()-3600>unix_timestamp(last_action)"); ?> diff --git a/cron/ps.php b/cron/ps.php index d4cbf3c..5136017 100755 --- a/cron/ps.php +++ b/cron/ps.php @@ -1,5 +1,12 @@ #!/usr/local/bin/php 2228983, "function"=>"update_template", @@ -17,12 +24,16 @@ function update_template($params) { chown(OWN_TEMPLATE_DIR.$node_id.".tpl","www"); } -require('../config/config.inc'); +// Use relative address of config file +// Change this, if you move you cron directory. +$dir=substr(__FILE__, 0, strrpos(__FILE__, '/')); +require($dir.'/../wwwroot/config/config.inc'); + //connecting to database and creating universal $db object -require(SYSTEM_ROOT.'/inc/log.inc'); -require(SYSTEM_ROOT.'/inc/database.inc'); -require(SYSTEM_ROOT.'/inc/nodes.inc'); -require(SYSTEM_ROOT.'/inc/senate.inc'); +require(INCLUDE_DIR.'/log.inc'); +require(INCLUDE_DIR.'/database.inc'); +require(INCLUDE_DIR.'/nodes.inc'); +require(INCLUDE_DIR.'/senate.inc'); $db=new CLASS_DATABASE(); foreach ($requests as $request) { @@ -35,4 +46,4 @@ foreach ($requests as $request) { } -?> \ No newline at end of file +?> diff --git a/cron/register.php b/cron/register.php index 8238168..38bf9ea 100755 --- a/cron/register.php +++ b/cron/register.php @@ -1,12 +1,22 @@ #!/usr/local/bin/php =".REGISTRATION_VOTES; + k,node_id,node_creator,login from nodes + left join users on nodes.node_creator=users.user_id + where node_name like '".REGISTER_TEXT."%' + and node_parent=".REGISTRATION_REQUEST_NODE." + and k >=".REGISTRATION_VOTES; $set=$db->query($q); @@ -30,13 +40,16 @@ while ($set->next()) { $db->update($q); $login=$set->getString('login'); echo $login." registered\n"; - $db->update("update nodes set template_id=7,external_link='db://users',node_name='$login' where node_id=".$set->getString('node_id')); + $db->update("update nodes set + template_id=7, + external_link='db://users', + node_name='$login' + where node_id=".$set->getString('node_id')); $mail=$set->getString('email'); mail($mail,"kyberia gate is opened","Vitaj v kyberii"); //VHODNE POSLAT ZACIATOCNIKOVI POSTU // ubik::ubikMail($params); - } -?> \ No newline at end of file +?> diff --git a/cron/rssparse.php b/cron/rssparse.php index 4769c16..0302000 100755 --- a/cron/rssparse.php +++ b/cron/rssparse.php @@ -1,17 +1,29 @@ #!/usr/local/bin/php 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"); -// include lastRSS library -include '../inc/lastRSS.php'; - // create lastRSS object $rss = new lastRSS; @@ -19,8 +31,9 @@ $rss = new lastRSS; $rss->cache_dir = './cache'; $rss->cache_time = 3600; // one hour +// XXX WTF while ($set->next()) { -// load some RSS file +// load some RSS file if (!preg_match("/http:(.*)/",$set->getString('node_content'))) { $rs = $rss->get("http://kyberia.sk/scripts/google2rss.php?num=25&q=".$set->getString('node_content')); } @@ -67,4 +80,4 @@ node_type=13,node_creator='".$set->getString('node_id')."',node_created=NOW()"; -?> \ No newline at end of file +?> diff --git a/cron/search_update.php b/cron/search_update.php index c337e20..fecaeb3 100755 --- a/cron/search_update.php +++ b/cron/search_update.php @@ -1,8 +1,17 @@ #!/usr/bin/php query('insert into node_content select node_id,node_content from nodes where ( DATE_SUB(CURDATE(),INTERVAL 2 DAY) < node_created OR DATE_SUB(CURDATE(),INTERVAL 2 DAY) < node_updated) ON DUPLICATE KEY UPDATE node_content.node_content = nodes.node_content;'); diff --git a/cron/swish_generator.php b/cron/swish_generator.php index ed69812..d28f266 100755 --- a/cron/swish_generator.php +++ b/cron/swish_generator.php @@ -1,16 +1,28 @@ #!/usr/local/bin/php query("select nodes.*,node_content from nodes left join node_content on node_content.node_id=nodes.node_id where node_system_access='public' and date(node_created)<=current_date()-interval 1 day and (nodes.k>0 or nodes.node_views>0)"); +$set=$db->query("select nodes.*,node_content from nodes + left join node_content on node_content.node_id=nodes.node_id + where node_system_access='public' and + date(node_created)<=current_date()-interval 1 day and + (nodes.k>0 or nodes.node_views>0)"); while ($set->next()) { $node_id=$set->getString('node_id'); $node_content=$set->getString('node_content'); diff --git a/cron/templates.php b/cron/templates.php index d7fa82e..47e10ee 100755 --- a/cron/templates.php +++ b/cron/templates.php @@ -1,13 +1,25 @@ #!/usr/local/bin/php 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='14'"); +$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='14'"); while ($set->next()) { $node_content=$set->getString('node_content'); @@ -18,8 +30,4 @@ while ($set->next()) { chown(OWN_TEMPLATE_DIR.$template_id.".tpl","www"); } - - - - -?> \ No newline at end of file +?> diff --git a/wwwroot/inc/database.inc b/wwwroot/inc/database.inc index 815f03f..e20b5fa 100644 --- a/wwwroot/inc/database.inc +++ b/wwwroot/inc/database.inc @@ -63,26 +63,13 @@ function closeMysql() { function query($sql) { -// if (preg_match("/^select/i",$sql) && (rand(0,1000)>MASTER2SLAVE) && $this->Master) { -// every select query goes to onyx + opraveny regexp, aby matchoval vnorene selecty (br) -/* if (preg_match('/^\(?select/i',$sql) && $this->Master) { - $this->_linkId = false; - $this->connect(SLAVE_HOST,SLAVE_USER,SLAVE_PASS,SLAVE_DATABASE); - $this->Master = false; - - } - - elseif (!preg_match("/^select/i",$sql) && !$this->Master) { -*/ $this->_linkId = false; - $this->connect(DB_HOST,DB_USER,DB_PASS,DB_DATABASE); - $this->Master = true; -// } + $this->_linkId = false; + $this->connect(DB_HOST,DB_USER,DB_PASS,DB_DATABASE); + $this->Master = true; $this->_queryId = mysql_query($sql,$this->_linkId); - if ($_SESSION['debugging']) { - if ($this->Master) echo "Master::"; - else echo "Slave::"; + if (isset($_SESSION['debugging'])) { echo $sql; global $timer_start; echo "
".SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7);