199 lines
4.9 KiB
PHP
199 lines
4.9 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\Library\cCron;
|
|
|
|
use BRSystems\Core\Library\cDb\cDb;
|
|
|
|
/**
|
|
* Cron DB Module
|
|
*
|
|
* @category Cron Module
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @since Version 2.0
|
|
*/
|
|
class cCronModule
|
|
{
|
|
public $db;
|
|
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function __construct() {
|
|
|
|
$this->db = cDb::getInstance(DB_HOST, DB_USR, DB_PWD, DB_PORT, DB_NAME);
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete cms message links
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function deleteCmsMsgLinks(){
|
|
|
|
$this->db->query("TRUNCATE TABLE temp_cms_msg_links");
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete pub message links
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function deletePubMsgLinks(){
|
|
|
|
$this->db->query("TRUNCATE TABLE temp_pub_msg_links");
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete url links
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function sysSiteCleanup(){
|
|
|
|
$this->db->query("TRUNCATE TABLE temp_map_links");
|
|
$this->db->query("TRUNCATE TABLE temp_access_tokens");
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete access tokens
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function deleteOldAccessTokens(){
|
|
|
|
//$this->db->query("DELETE FROM temp_access_tokens WHERE stime < " . time());
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete access tokens
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function deleteOldUserOnlineTokens(){
|
|
|
|
$this->db->query("DELETE FROM temp_users_online WHERE o_time < " . strtotime("-2 hours"));
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to get the amount of accounts created by date
|
|
*
|
|
* @author Aivars Žukovskis <info@brsystems.lv>
|
|
* @category cCron Module
|
|
* @param array $vDates
|
|
* @return bool|int
|
|
* @version 1.1
|
|
*/
|
|
public function getAccountsCreatedByDate($vDates){
|
|
$sSql = "
|
|
SELECT COUNT(id)
|
|
FROM mod_account_to_create
|
|
WHERE a_created BETWEEN {$vDates['s']} AND {$vDates['e']}
|
|
";
|
|
$this->db->query($sSql);
|
|
return $this->db->getOne();
|
|
}
|
|
/**
|
|
* Function to get the amount of accounts activated by date
|
|
*
|
|
* Function uses accounts registration date
|
|
*
|
|
* @author Aivars Žukovskis <info@brsystems.lv>
|
|
* @category cCron Module
|
|
* @param array $vDates
|
|
* @return bool|int
|
|
* @version 1.1
|
|
*/
|
|
public function getAccountsActivatedByDate($vDates){
|
|
$sSql = "
|
|
SELECT
|
|
COUNT(cc.id)
|
|
FROM
|
|
mod_account_to_create cc
|
|
LEFT JOIN mod_users uu ON
|
|
uu.id = cc.user_link_to_id
|
|
WHERE
|
|
cc.a_created BETWEEN {$vDates['s']} AND {$vDates['e']}
|
|
AND uu.user_activated = '1'
|
|
";
|
|
$this->db->query($sSql);
|
|
return $this->db->getOne();
|
|
}
|
|
/**
|
|
* Function to get count of created bills by date
|
|
*
|
|
* @author Aivars Žukovskis <info@brsystems.lv>
|
|
* @category cCron Module
|
|
* @param array $vDates
|
|
* @return bool|int
|
|
* @version 1.1
|
|
*/
|
|
public function getReceivedInquiriesByDate($vDates){
|
|
$sSql = "
|
|
SELECT COUNT(id)
|
|
FROM mod_account_to_bills bb
|
|
WHERE bb.r_bill_created BETWEEN {$vDates['s']} AND {$vDates['e']};
|
|
";
|
|
$this->db->query($sSql);
|
|
return $this->db->getOne();
|
|
}
|
|
/**
|
|
* Function to get count of users online
|
|
*
|
|
* @author Aivars Žukovskis <info@brsystems.lv>
|
|
* @category cCron Module
|
|
* @param array $vDates
|
|
* @return bool|int
|
|
* @version 1.1
|
|
*/
|
|
public function getUsersOnlineByDate($vDates){
|
|
$sSql = "
|
|
SELECT COUNT(id)
|
|
FROM mod_users bb
|
|
WHERE bb.user_last_login BETWEEN {$vDates['s']} AND {$vDates['e']};
|
|
";
|
|
$this->db->query($sSql);
|
|
return $this->db->getOne();
|
|
}
|
|
|
|
/**
|
|
* Function to get site default language
|
|
*
|
|
* @author Aivars Žukovskis <info@brsystems.lv>
|
|
* @category cCron Module
|
|
* @return string - public side language id
|
|
*/
|
|
public function getDefaultAppLang(){
|
|
|
|
if($lang = $this->db->_querySelectOne('site_languages', array('id'), array(
|
|
'type' => 0,
|
|
'default' => 1,
|
|
'lang_blocked' => 0
|
|
))){
|
|
return $lang;
|
|
}
|
|
|
|
die('No default language marked!');
|
|
}
|
|
}
|