CC-1724:phone-home-statistics
Rebase from devel into this branch
This commit is contained in:
parent
11b601308e
commit
cf654f1a45
18 changed files with 656 additions and 193 deletions
|
@ -119,6 +119,12 @@ class Playlist {
|
|||
$sql = 'DELETE FROM '.$CC_CONFIG["playListTable"];
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public static function getPlaylistCount(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the file from all playlists.
|
||||
|
|
|
@ -221,6 +221,14 @@ class Application_Model_Preference
|
|||
return Application_Model_Preference::GetValue("support_feedback");
|
||||
}
|
||||
|
||||
public static function SetPublicise($publicise){
|
||||
Application_Model_Preference::SetValue("publicise", $publicise);
|
||||
}
|
||||
|
||||
public static function GetPublicise(){
|
||||
return Application_Model_Preference::GetValue("publicise");
|
||||
}
|
||||
|
||||
public static function SetRegistered($registered){
|
||||
Application_Model_Preference::SetValue("registered", $registered);
|
||||
}
|
||||
|
@ -229,14 +237,101 @@ class Application_Model_Preference
|
|||
return Application_Model_Preference::GetValue("registered");
|
||||
}
|
||||
|
||||
public static function GetSystemInfo(){
|
||||
$output;
|
||||
exec('airtime-check-system', $output);
|
||||
$out = implode("\n", preg_replace('/\s+/', ' ', $output));
|
||||
|
||||
// Sever API
|
||||
$out .= php_sapi_name();
|
||||
public static function SetStationCountry($country){
|
||||
Application_Model_Preference::SetValue("country", $country);
|
||||
}
|
||||
|
||||
public static function GetStationCountry(){
|
||||
return Application_Model_Preference::GetValue("country");
|
||||
}
|
||||
|
||||
public static function SetStationCity($city){
|
||||
Application_Model_Preference::SetValue("city", $city);
|
||||
}
|
||||
|
||||
public static function GetStationCity(){
|
||||
return Application_Model_Preference::GetValue("city");
|
||||
}
|
||||
|
||||
public static function SetStationDescription($description){
|
||||
Application_Model_Preference::SetValue("description", $description);
|
||||
}
|
||||
|
||||
public static function GetStationDescription(){
|
||||
return Application_Model_Preference::GetValue("description");
|
||||
}
|
||||
|
||||
public static function SetStationLogo($imagePath){
|
||||
if(!empty($imagePath)){
|
||||
$image = file_get_contents($imagePath);
|
||||
$image = base64_encode($image);
|
||||
Application_Model_Preference::SetValue("logoImage", $image);
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetStationLogo(){
|
||||
return Application_Model_Preference::GetValue("logoImage");
|
||||
}
|
||||
|
||||
public static function GetUniqueId(){
|
||||
return Application_Model_Preference::GetValue("uniqueId");
|
||||
}
|
||||
|
||||
public static function GetCountryList(){
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM cc_country";
|
||||
$res = $CC_DBC->GetAll($sql);
|
||||
$out = array();
|
||||
foreach($res as $r){
|
||||
$out[$r["iso_code"]] = $r["name"];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function GetSystemInfo(){
|
||||
exec('/usr/bin/airtime-check-system', $output);
|
||||
|
||||
$output = preg_replace('/\s+/', ' ', $output);
|
||||
|
||||
$systemInfoArray = array();
|
||||
foreach( $output as $key => &$out){
|
||||
$info = explode('=', $out);
|
||||
if(isset($info[1])){
|
||||
$key = str_replace(' ', '_', $info[0]);
|
||||
$key = strtoupper($key);
|
||||
$systemInfoArray[$key] = $info[1];
|
||||
}
|
||||
}
|
||||
|
||||
$outputArray = array();
|
||||
|
||||
$outputArray['STATION_NAME'] = Application_Model_Preference::GetStationName();
|
||||
$outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite();
|
||||
$outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry();
|
||||
$outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity();
|
||||
$outputArrat['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription();
|
||||
//$outputArray['Version'] = $systemInfoArray['AIRTIME_VERSION'];
|
||||
$outputArray['WEB_SERVER'] = php_sapi_name();
|
||||
//$outputArray['OS Info'] = $systemInfoArray['OS'];
|
||||
$outputArray['NUM_OF_USERS'] = User::getUserCount();
|
||||
$outputArray['NUM_OF_SONGS'] = StoredFile::getFileCount();
|
||||
$outputArray['NUM_OF_PLAYLISTS'] = Playlist::getPlaylistCount();
|
||||
$outputArray['NUM_OF_SCHEDULED_PLAYLIST'] = Schedule::getSchduledPlaylistCount();
|
||||
$outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId();
|
||||
|
||||
$outputArray = array_merge($outputArray, $systemInfoArray);
|
||||
|
||||
$outputString = "\n";
|
||||
foreach($outputArray as $key => $out){
|
||||
$outputString .= $key.' : '.$out."\n";
|
||||
}
|
||||
|
||||
return $outputString;
|
||||
}
|
||||
|
||||
public static function SetRemindMeDate($now){
|
||||
$weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y"));
|
||||
Application_Model_Preference::SetValue('remindme', $weekAfter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -527,6 +527,12 @@ class Schedule {
|
|||
$retVal = $CC_DBC->query($sql);
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
public static function getSchduledPlaylistCount(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,6 +88,13 @@ class StoredFile {
|
|||
}
|
||||
}
|
||||
|
||||
public static function getFileCount()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]." WHERE state='ready'";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple metadata values using database columns as indexes.
|
||||
*
|
||||
|
|
|
@ -188,6 +188,33 @@ class User {
|
|||
|
||||
return $CC_DBC->GetAll($sql);
|
||||
}
|
||||
|
||||
public static function getUserCount($type=NULL){
|
||||
global $CC_DBC;
|
||||
|
||||
$sql;
|
||||
|
||||
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
|
||||
|
||||
if(!isset($type)){
|
||||
$sql = $sql_gen;
|
||||
}
|
||||
else{
|
||||
if(is_array($type)) {
|
||||
for($i=0; $i<count($type); $i++) {
|
||||
$type[$i] = "type = '{$type[$i]}'";
|
||||
}
|
||||
$sql_type = join(" OR ", $type);
|
||||
}
|
||||
else {
|
||||
$sql_type = "type = {$type}";
|
||||
}
|
||||
|
||||
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
||||
}
|
||||
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
public static function getHosts($search=NULL) {
|
||||
return User::getUsers(array('H'), $search);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue