Commit | Line | Data |
---|---|---|
b42b2bf9 H |
1 | #!/usr/bin/php |
2 | <?php | |
a3be90c6 | 3 | /* |
4 | * Script that XXX | |
5 | * Called XXX | |
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__, '/')); | |
ccb9c667 | 12 | require_once($dir.'/../wwwroot/config/config.inc'); |
a3be90c6 | 13 | |
14 | ||
b42b2bf9 | 15 | //connecting to database and creating universal $db object |
ccb9c667 | 16 | require_once(INCLUDE_DIR.'/log.inc'); |
17 | require_once(INCLUDE_DIR.'/database.inc'); | |
18 | require_once(INCLUDE_DIR.'/nodes.inc'); | |
19 | require_once(INCLUDE_DIR.'/permissions.inc'); | |
20 | require_once(INCLUDE_DIR.'/ubik.inc'); | |
b42b2bf9 H |
21 | |
22 | $_SESSION['user_id']=UBIK_ID; | |
23 | ||
24 | $db=new CLASS_DATABASE(); | |
25 | ||
a3be90c6 | 26 | $set=$db->query("select * from node_access where |
27 | node_id='1961061' and node_permission='execute'"); | |
b42b2bf9 H |
28 | $citizens=$set->getNumRows(); |
29 | ||
a3be90c6 | 30 | $set2=$db->query("select k,node_id,node_creator,login from nodes |
31 | left join users on nodes.node_creator=users.user_id where | |
32 | node_name='request for citizenship'"); | |
b42b2bf9 H |
33 | |
34 | echo "TOTAL $citizens citizens \n"; | |
35 | ||
36 | while ($set2->next()) { | |
37 | $request_id=$set2->getString('node_id'); | |
38 | $votes=$set2->getString('k'); | |
39 | $login=$set2->getString('login'); | |
40 | $citizen=$set2->getString('node_creator'); | |
41 | echo "citizen $citizen - $login has $votes needs ".floor(log($citizens,"1.42"))." \n"; | |
a3be90c6 | 42 | |
b42b2bf9 H |
43 | if (($citizens<66 && $votes>=floor($citizens/6)) || |
44 | ($citizens>=66 && $votes>floor(log($citizens,"1.42")))) { | |
a3be90c6 | 45 | |
b42b2bf9 H |
46 | $params['node_parent']=$request_id; |
47 | $params['node_creator']=UBIK_ID; | |
48 | $params['node_content']="request of user $login approved by $votes citizens"; | |
49 | $params['node_name']="citizen $citizen approved"; | |
50 | //print_r($params); | |
51 | echo $votes.$citizen."\n"; | |
52 | nodes::addNode($params); | |
a3be90c6 | 53 | $t1=$db->query("select * from node_access where |
54 | node_id='1961061' and | |
55 | user_id='$citizen' | |
56 | and node_permission='execute'"); | |
57 | if (!$t1->getNumRows()) { | |
58 | $db->query("insert into node_access set | |
59 | node_id='1961061', | |
60 | user_id='$citizen', | |
61 | node_permission='execute'"); | |
62 | } | |
63 | $t1=$db->query("select * from node_access where | |
64 | node_id='1061495' and | |
65 | user_id='$citizen' and | |
66 | node_permission='execute'"); | |
67 | if (!$t1->getNumRows()) { | |
68 | $db->query("insert into node_access set | |
69 | node_id='1061495', | |
70 | user_id='$citizen', | |
71 | node_permission='execute'"); | |
72 | } | |
73 | $t1=$db->query("select * from node_access where | |
74 | node_id='1961070' and | |
75 | user_id='$citizen' and | |
76 | node_permission='execute'"); | |
77 | if (!$t1->getNumRows()) { | |
78 | $db->query("insert into node_access set | |
79 | node_id='1961070', | |
80 | user_id='$citizen', | |
81 | node_permission='execute'"); | |
82 | } | |
83 | $db->query("update nodes set node_name='approved citizenship request' | |
84 | where node_id='$request_id'"); | |
b42b2bf9 H |
85 | $params['mail_to']=$citizen; |
86 | $params['mail_text']="you have become a citizen"; | |
87 | ||
88 | ubik::ubikMail($params); | |
b42b2bf9 H |
89 | } |
90 | } | |
91 | ||
b42b2bf9 | 92 | ?> |