Closes #160 Add update checking for Mods for HESK
This commit is contained in:
parent
df277c915e
commit
ffcd684bb3
@ -102,15 +102,30 @@ if ( defined('HESK_DEMO') )
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><?php echo $hesklang['installation_information']; ?></div>
|
<div class="panel-heading"><?php echo $hesklang['installation_information']; ?></div>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr><td class="text-right">
|
<tr>
|
||||||
|
<td class="text-right">
|
||||||
<?php echo $hesklang['v']; ?>:
|
<?php echo $hesklang['v']; ?>:
|
||||||
</td>
|
</td>
|
||||||
<td style="padding-left: 10px">
|
<?php
|
||||||
|
$cellClass = '';
|
||||||
|
if ($hesk_settings['check_updates'])
|
||||||
|
{
|
||||||
|
$latest = hesk_checkVersion();
|
||||||
|
|
||||||
|
if ($latest === true)
|
||||||
|
{
|
||||||
|
$cellClass = 'class="success"';
|
||||||
|
} elseif ($latest != -1)
|
||||||
|
{
|
||||||
|
$cellClass = 'class="warning"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<td style="padding-left: 10px" <?php echo $cellClass; ?>>
|
||||||
<?php echo $hesk_settings['hesk_version']; ?>
|
<?php echo $hesk_settings['hesk_version']; ?>
|
||||||
<?php
|
<?php
|
||||||
if ($hesk_settings['check_updates'])
|
if ($hesk_settings['check_updates'])
|
||||||
{
|
{
|
||||||
$latest = hesk_checkVersion();
|
|
||||||
|
|
||||||
if ($latest === true)
|
if ($latest === true)
|
||||||
{
|
{
|
||||||
@ -138,13 +153,45 @@ if ( defined('HESK_DEMO') )
|
|||||||
?> - <a href="http://www.hesk.com/update.php?v=<?php echo $hesk_settings['hesk_version']; ?>" target="_blank"><?php echo $hesklang['check4updates']; ?></a><?php
|
?> - <a href="http://www.hesk.com/update.php?v=<?php echo $hesk_settings['hesk_version']; ?>" target="_blank"><?php echo $hesklang['check4updates']; ?></a><?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-right" style="padding-bottom: 5px">
|
<td class="text-right" style="padding-bottom: 5px">
|
||||||
<?php echo $hesklang['mods_for_hesk_version']; ?>:
|
<?php echo $hesklang['mods_for_hesk_version']; ?>:
|
||||||
</td>
|
</td>
|
||||||
<td style="padding-left: 10px; padding-bottom: 5px">
|
<?php
|
||||||
|
$cellClass = '';
|
||||||
|
if ($hesk_settings['check_updates'])
|
||||||
|
{
|
||||||
|
$latest = hesk_checkMfhVersion($modsForHeskVersion);
|
||||||
|
if ($latest === true)
|
||||||
|
{
|
||||||
|
$cellClass = 'class="success"';
|
||||||
|
} elseif ($latest != -1)
|
||||||
|
{
|
||||||
|
$cellClass = 'class="warning"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<td <?php echo $cellClass; ?> style="padding-left: 10px; padding-bottom: 5px">
|
||||||
<?php echo $modsForHeskVersion; ?>
|
<?php echo $modsForHeskVersion; ?>
|
||||||
|
<?php
|
||||||
|
if ($hesk_settings['check_updates'])
|
||||||
|
{
|
||||||
|
if ($latest === true)
|
||||||
|
{
|
||||||
|
echo ' - <span style="color:green">' . $hesklang['mfh_up_to_date'] . '</span>';
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
?> - <a href="http://mods-for-hesk.mkochcs.com" target="_blank" style="color:orange;font-weight:bold"><?php echo $hesklang['hnw']; ?></a>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
?> - <a href="http://mods-for-hesk.mkochcs.com?checkVersion.php?v=<?php echo $modsForHeskVersion; ?>" target="_blank"><?php echo $hesklang['check4updates']; ?></a>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td class="text-right">
|
<tr><td class="text-right">
|
||||||
@ -2481,7 +2528,6 @@ function hesk_getLatestVersion()
|
|||||||
|
|
||||||
} // END hesk_getLatestVersion()
|
} // END hesk_getLatestVersion()
|
||||||
|
|
||||||
|
|
||||||
function hesk_cacheLatestVersion($latest)
|
function hesk_cacheLatestVersion($latest)
|
||||||
{
|
{
|
||||||
global $hesk_settings;
|
global $hesk_settings;
|
||||||
@ -2492,6 +2538,77 @@ function hesk_cacheLatestVersion($latest)
|
|||||||
|
|
||||||
} // END hesk_cacheLatestVersion()
|
} // END hesk_cacheLatestVersion()
|
||||||
|
|
||||||
|
function hesk_checkMfhVersion($currentVersion)
|
||||||
|
{
|
||||||
|
if ($latest = hesk_getMfhLatestVersion() )
|
||||||
|
{
|
||||||
|
if ( strlen($latest) > 12 )
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
elseif ($latest == $currentVersion)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $latest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hesk_getMfhLatestVersion()
|
||||||
|
{
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
// Do we have a cached version file?
|
||||||
|
if ( file_exists(HESK_PATH . $hesk_settings['attach_dir'] . '/__latest-mfh.txt') )
|
||||||
|
{
|
||||||
|
if ( preg_match('/^(\d+)\|([\d.]+)+$/', @file_get_contents(HESK_PATH . $hesk_settings['attach_dir'] . '/__latest-mfh.txt'), $matches) && (time() - intval($matches[1])) < 3600 )
|
||||||
|
{
|
||||||
|
return $matches[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No cached file or older than 3600 seconds, try to get an update
|
||||||
|
$hesk_version_url = 'http://mods-for-hesk.mkochcs.com/latestversion.php';
|
||||||
|
|
||||||
|
// Try using cURL
|
||||||
|
if ( function_exists('curl_init') )
|
||||||
|
{
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $hesk_version_url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 6);
|
||||||
|
$latest = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
return hesk_cacheMfhLatestVersion($latest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try using a simple PHP function instead
|
||||||
|
if ($latest = file_get_contents($hesk_version_url) )
|
||||||
|
{
|
||||||
|
return hesk_cacheMfhLatestVersion($latest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't check automatically, will need a manual check
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hesk_cacheMfhLatestVersion($latest)
|
||||||
|
{
|
||||||
|
global $hesk_settings;
|
||||||
|
|
||||||
|
@file_put_contents(HESK_PATH . $hesk_settings['attach_dir'] . '/__latest-mfh.txt', time() . '|' . $latest);
|
||||||
|
|
||||||
|
return $latest;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function hesk_testLanguage($return_options = 0)
|
function hesk_testLanguage($return_options = 0)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,8 @@ $hesklang['_COLLATE']='utf8_unicode_ci';
|
|||||||
$hesklang['EMAIL_HR']='------ Reply above this line ------';
|
$hesklang['EMAIL_HR']='------ Reply above this line ------';
|
||||||
|
|
||||||
// ADDED OR MODIFIED IN Mods for HESK 2.1.0
|
// ADDED OR MODIFIED IN Mods for HESK 2.1.0
|
||||||
$hesklang['e_mfh_settings']='You will not be able to save your settings unless this file is writable by the script (CHMOD to 666)!';
|
$hesklang['e_mfh_settings'] = 'You will not be able to save your settings unless this file is writable by the script (CHMOD to 666)!';
|
||||||
|
$hesklang['mfh_up_to_date'] = 'Mods for HESK is up to date';
|
||||||
|
|
||||||
// ADDED OR MODIFIED IN Mods For HESK 2.0.0
|
// ADDED OR MODIFIED IN Mods For HESK 2.0.0
|
||||||
$hesklang['saved_ticket_tpl'] = 'Saved Templates';
|
$hesklang['saved_ticket_tpl'] = 'Saved Templates';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user