| 1 |
<?PHP |
|---|
| 2 |
error_reporting(0); |
|---|
| 3 |
|
|---|
| 4 |
$rfh=fopen("/etc/amportal.conf","r") or Die("amportal.conf did not open."); |
|---|
| 5 |
if ($rfh) { |
|---|
| 6 |
while (!feof($rfh)) { |
|---|
| 7 |
$line = fgets($rfh); |
|---|
| 8 |
if (strstr($line,"AMPDBUSER=")) { |
|---|
| 9 |
$temp=explode("=",$line); |
|---|
| 10 |
$temp[1]=trim($temp[1]); |
|---|
| 11 |
$ampdata['user'] = $temp[1]; |
|---|
| 12 |
}elseif (strstr($line,"AMPDBPASS=")) { |
|---|
| 13 |
$temp=explode("=",$line); |
|---|
| 14 |
$temp[1]=trim($temp[1]); |
|---|
| 15 |
$ampdata['pass'] = $temp[1]; |
|---|
| 16 |
|
|---|
| 17 |
} |
|---|
| 18 |
} |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
echo "Welcome\n"; |
|---|
| 22 |
|
|---|
| 23 |
include 'functions.inc'; |
|---|
| 24 |
|
|---|
| 25 |
global $endpoint, $amp_conf; |
|---|
| 26 |
|
|---|
| 27 |
$amp_conf['AMPDBUSER'] = $ampdata['user']; |
|---|
| 28 |
$amp_conf['AMPDBPASS'] = $ampdata['pass']; |
|---|
| 29 |
$amp_conf['AMPDBNAME'] = 'asterisk'; |
|---|
| 30 |
|
|---|
| 31 |
$endpoint = new endpointmanager(); |
|---|
| 32 |
|
|---|
| 33 |
$brand_up = $endpoint->brand_update_check(); |
|---|
| 34 |
|
|---|
| 35 |
$note = "<br/> <br/>NOTE: This was generated by the Endpoint Manager Module, not by FreePBX<br/> You can turn off these updates on the settings page within the Endpoint Manager Settings Page"; |
|---|
| 36 |
|
|---|
| 37 |
$sql="SELECT * from endpointman_brand_list WHERE id > 0 AND hidden = 0 AND installed = 1 ORDER BY id ASC "; |
|---|
| 38 |
$result=mysql_query($sql); |
|---|
| 39 |
$i = 0; |
|---|
| 40 |
while($row = mysql_fetch_assoc($result)) { |
|---|
| 41 |
$row_out[$i] = $row; |
|---|
| 42 |
$row_out[$i]['count'] = $i; |
|---|
| 43 |
$id = $endpoint->arraysearchrecursive($row['name'], $brand_up,'brand_name'); |
|---|
| 44 |
$id = $id[0]; |
|---|
| 45 |
if(isset($brand_up[$id]['update'])) { |
|---|
| 46 |
echo "Brand '".$brand_up[$id]['brand_name']."' has updates available\n"; |
|---|
| 47 |
echo "Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."\n"; |
|---|
| 48 |
echo "Changes: ". $brand_up[$id]['changes']."\n"; |
|---|
| 49 |
$endpoint->add_freepbx_notification("PU_".$brand_up[$id]['brand_name'], '', "Brand \'".$brand_up[$id]['brand_name']."\' has updates available", "Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."<br/>"."Changes: ". $brand_up[$id]['changes'].$note, ""); |
|---|
| 50 |
$email_message .= "Brand \'".$brand_up[$id]['brand_name']."\' has updates available \n Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."\n"."Changes: ". $brand_up[$id]['changes']."\n\n"; |
|---|
| 51 |
} |
|---|
| 52 |
if($row['installed']){ |
|---|
| 53 |
$j = 0; |
|---|
| 54 |
$sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND brand = '.$row['id'].' ORDER BY long_name ASC'; |
|---|
| 55 |
$result2=mysql_query($sql); |
|---|
| 56 |
while($row2 = mysql_fetch_assoc($result2)) { |
|---|
| 57 |
$row_out[$i]['products'][$j] = $row2; |
|---|
| 58 |
if(($temp = $endpoint->product_update_check($row2['id'])) AND ($row2['installed'] == 1)) { |
|---|
| 59 |
echo "Product '".$row2['long_name']."' has updates available\n"; |
|---|
| 60 |
echo "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n"; |
|---|
| 61 |
echo "Changes: ". $temp['data']['description']."\n"; |
|---|
| 62 |
$endpoint->add_freepbx_notification("PU_".$row2['long_name'], '', "There is a Product update for ".$row2['long_name'], "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."<br/>"."Changes: ". $temp['data']['description'].$note, ""); |
|---|
| 63 |
$email_message .= "There is a Product update for ".$row2['long_name']."\n"."Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n"."Changes: ". $temp['data']['description']."\n\n"; |
|---|
| 64 |
} |
|---|
| 65 |
if(($temp = $endpoint->firmware_update_check($row2['id'])) AND ($row['firmware_vers'] > 0)) { |
|---|
| 66 |
echo "Product '".$row2['long_name']."' has new firmware available\n"; |
|---|
| 67 |
echo "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n"; |
|---|
| 68 |
$endpoint->add_freepbx_notification("PU_".$row2['long_name'], '', "There is a firmware update for phone module ".$row2['long_name'], "Old Version: ".$row2['firmware_vers']." New Version: ".$temp['data']['version'].$note, ""); |
|---|
| 69 |
$email_message .= "There is a firmware update for phone module ".$row2['long_name']."\n Old Version: ".$row2['firmware_vers']." New Version: ".$temp['data']['version']."\n\n"; |
|---|
| 70 |
} |
|---|
| 71 |
$j++; |
|---|
| 72 |
} |
|---|
| 73 |
} |
|---|
| 74 |
$i++; |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
$email_message .= "\n\n\nNOTE: This was generated by the Endpoint Manager Module, not by FreePBX\n You can turn off these updates on the settings page within the Endpoint Manager Settings Page"; |
|---|
| 78 |
|
|---|
| 79 |
$sql = 'SELECT * FROM `admin` WHERE `variable` = CONVERT(_utf8 \'email\' USING latin1) COLLATE latin1_swedish_ci'; |
|---|
| 80 |
$result=mysql_query($sql); |
|---|
| 81 |
$row = mysql_fetch_assoc($result); |
|---|
| 82 |
|
|---|
| 83 |
$email = $row['value']; |
|---|
| 84 |
|
|---|
| 85 |
$time = time() - 25200; |
|---|
| 86 |
|
|---|
| 87 |
$sql = 'SELECT * FROM `notifications` WHERE `module` = CONVERT(_utf8 \'endpointman\' USING latin1) COLLATE latin1_swedish_ci'; |
|---|
| 88 |
$result=mysql_query($sql); |
|---|
| 89 |
while($row = mysql_fetch_assoc($result)) { |
|---|
| 90 |
if(($row['timestamp'] > $time) AND ($row['reset'] != 1)) { |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
$message = wordwrap($email_message, 70); |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
mail($email, 'Phone Updates Available', $message); |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
?> |
|---|