summaryrefslogtreecommitdiffstats
path: root/utils/1kaCron/class.CronJobs.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--utils/1kaCron/class.CronJobs.php91
1 files changed, 74 insertions, 17 deletions
diff --git a/utils/1kaCron/class.CronJobs.php b/utils/1kaCron/class.CronJobs.php
index 4ae6444..8d00b5b 100644
--- a/utils/1kaCron/class.CronJobs.php
+++ b/utils/1kaCron/class.CronJobs.php
@@ -21,38 +21,78 @@ class CronJobs {
*/
public function executeAction($action = '') {
- // Izvedemo ustrezno akcijo
- if(method_exists('CronJobs', $action) && $action != '')
- $this->$action();
- else
- echo 'Method '.$action.' does not exist!';
+ // Cronjobe logiramo
+ $SL = new SurveyLog();
+
+ try{
+ $SL->addMessage(SurveyLog::INFO, "CRONJOB - ".$action);
+
+ // Izvedemo ustrezno akcijo
+ if(method_exists('CronJobs', $action) && $action != '')
+ $this->$action();
+ else
+ throw new Exception('Method '.$action.' does not exist!');
+ }
+ catch (Exception $e) {
+ $SL->addMessage(SurveyLog::INFO, "CRONJOB 3am - NAPAKA ".$action." - ".$e->getMessage());
+ }
+
+ $SL->write();
}
- // Brisanje pobrisanih anket (anekte, ki so bile pobrisane pred vec kot 1 mesecem)
- private function surveyDeleteFromDB(){
+ // Brisanje pobrisanih anket (anekte, ki so bile pobrisane pred vec kot 3 meseci - prej je bilo samo 1 mesec)
+ private function deleteSurveyFromDB(){
- // Loop po pobrisanih anketah, ki so bile nazadnje urejane vec kot 1 mesec nazaj
- $sql = sisplet_query("SELECT * FROM srv_anketa WHERE active='-1' AND edit_time < NOW() - INTERVAL 1 MONTH");
+ // Loop po pobrisanih anketah, ki so bile nazadnje urejane vec kot 3 mesec nazaj
+ $sql = sisplet_query("SELECT * FROM srv_anketa WHERE active='-1' AND edit_time < NOW() - INTERVAL 3 MONTH");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
- $s = new SurveyAdmin();
-
while ($row = mysqli_fetch_array($sql)) {
- $s->anketa_delete_from_db($row['id']);
+ SurveyAdmin::anketa_delete_from_db($row['id']);
}
}
+
+ // Brisanje pobrisanih vprasanj (vprasanja, ki so bila pobrisana vec kot 3 mesece nazaj)
+ private function deleteVprasanjeFromDB(){
+ // Loop po pobrisanih vprasanjih, ki so bila pobrisana vec kot 3 mesece nazaj
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka_deleted WHERE delete_time < NOW() - INTERVAL 3 MONTH");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row = mysqli_fetch_array($sql)) {
+ VprasanjeDeleted::permanentDeleteVprasanje($row['spr_id']);
+ }
+ }
- // Brisanje pobrisanih podatkov anket (podatki, ki so bili pobrisani pred vec kot 3 meseci)
- private function userDeleteFromDB(){
+ // Brisanje pobrisanih responsov anket (podatki, ki so bili pobrisani pred vec kot 3 meseci)
+ private function deleteResponseFromDB(){
$sql = sisplet_query("DELETE FROM srv_user WHERE deleted='1' AND time_edit < NOW() - INTERVAL 3 MONTH");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
}
-
+
+ // Brisanje neustreznih reposnov botov
+ private function deleteResponseBotFromDB(){
+
+ // Loop po nekativnih anketah, ki so bile deaktivirane vec kot 1 mesec nazaj
+ $sql = sisplet_query("SELECT id FROM srv_anketa WHERE id>0 AND active='0' AND edit_time < NOW() - INTERVAL 1 MONTH");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row = mysqli_fetch_array($sql)) {
+
+ // Brisemo response botov
+ $sql2 = sisplet_query("DELETE FROM srv_user
+ WHERE ank_id='".$row['id']."'
+ AND (last_status='-1' OR last_status='3')
+ AND (useragent LIKE '%bot%' OR useragent LIKE '%crawler%' OR useragent LIKE '%spider%')
+ ");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ }
+ }
+
// Brisanje podatkov za "ping test" (pingdom) anketo (da ne polni baze brez potrebe)
- private function userPingdomDeleteFromDB(){
+ private function deleteResponsePingdomFromDB(){
global $mysql_database_name;
global $site_domain;
@@ -91,6 +131,23 @@ class CronJobs {
}
}
}
+
+ // Brisanje emailov pri dostopu z emailom za mju (starejse od 7 dni) - instalacija gov-ankete.sis
+ private function deleteEmailAccessEmails(){
+
+ // Loop po vseh anketah, ki so bile deaktivirane 7+ dni nazaj
+ $sql = sisplet_query("SELECT a.id
+ FROM srv_activity a, srv_email_access ea
+ WHERE ea.ank_id=a.sid
+ AND a.expire < DATE_SUB(NOW(), INTERVAL 7 DAY);
+ GROUP BY a.id
+ ");
+ while($row = mysqli_fetch_array($sql)){
+
+ // Pobrisemo kode in emaile za anketo
+ SurveyEmailAccess::deleteSurveyEmailsAndCodes($row['id']);
+ }
+ }
// Kesiranje grafov
@@ -158,7 +215,6 @@ class CronJobs {
};
- $SL->addMessage(SurveyLog::INFO, "Klic masovnega generiranja - start");
$SL->addMessage(SurveyLog::INFO, $sql);
if (count($ids) > 0) {
@@ -176,6 +232,7 @@ class CronJobs {
}
$SL->addMessage(SurveyLog::INFO, "Klic masovnega generiranja - stop");
+ $SL->addMessage(SurveyLog::INFO, "- - - - - - - - - - - - - - - - -");
$SL->write();
ob_flush();