CC-2950: Tell users if they are running an out-of-date version or not
- added error checking to curl call - added regex validation when storing link to latest version
This commit is contained in:
parent
eae90862b1
commit
52052bd573
2 changed files with 18 additions and 5 deletions
|
@ -530,15 +530,20 @@ class Application_Model_Preference
|
||||||
public static function GetLatestLink(){
|
public static function GetLatestLink(){
|
||||||
$link = self::GetValue("latest_link");
|
$link = self::GetValue("latest_link");
|
||||||
if($link == null || strlen($link) == 0) {
|
if($link == null || strlen($link) == 0) {
|
||||||
return "";
|
return "http://www.sourcefabric.org/en/airtime/download/";
|
||||||
} else {
|
} else {
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLatestLink($link){
|
public static function SetLatestLink($link){
|
||||||
|
$pattern = "#^(http|https|ftp)://" .
|
||||||
|
"([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" .
|
||||||
|
"(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#";
|
||||||
|
if(preg_match($pattern, $link)) {
|
||||||
self::SetValue("latest_link", $link);
|
self::SetValue("latest_link", $link);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function SetUploadToSoundcloudOption($upload) {
|
public static function SetUploadToSoundcloudOption($upload) {
|
||||||
self::SetValue("soundcloud_upload_option", $upload);
|
self::SetValue("soundcloud_upload_option", $upload);
|
||||||
|
|
|
@ -72,6 +72,8 @@ if(Application_Model_Preference::GetSupportFeedback() == '1'){
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataArray);
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
|
|
||||||
|
curl_close($ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get latest version from stat server and store to db
|
// Get latest version from stat server and store to db
|
||||||
|
@ -82,12 +84,18 @@ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
$resultArray = explode("\n", $result);
|
|
||||||
|
|
||||||
|
if(curl_errno($ch)) {
|
||||||
|
echo "curl error: " . curl_error($ch) . "\n";
|
||||||
|
} else {
|
||||||
|
$resultArray = explode("\n", $result);
|
||||||
Application_Model_Preference::SetLatestVersion($resultArray[0]);
|
Application_Model_Preference::SetLatestVersion($resultArray[0]);
|
||||||
Application_Model_Preference::SetLatestLink($resultArray[1]);
|
Application_Model_Preference::SetLatestLink($resultArray[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curl_close($ch);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the user is running this PHP script with root
|
* Ensures that the user is running this PHP script with root
|
||||||
* permissions. If not running with root permissions, causes the
|
* permissions. If not running with root permissions, causes the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue