Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -381,10 +381,15 @@ class _Application extends \IPS\Node\Model
|
||||
{
|
||||
$versionsJson = static::getRootPath( $appKey ) . "/applications/{$appKey}/data/versions.json";
|
||||
|
||||
$_versions = $human ? array_values( json_decode( file_get_contents( $versionsJson ), TRUE ) ) : array_keys( json_decode( file_get_contents( $versionsJson ), TRUE ) );
|
||||
if ( file_exists( $versionsJson ) and $versionsJson = $_versions )
|
||||
if( file_exists( $versionsJson ) and $content = json_decode( file_get_contents( $versionsJson ), TRUE ) )
|
||||
{
|
||||
return array_pop( $versionsJson );
|
||||
$_versions = $human ? array_values( $content ) : array_keys( $content );
|
||||
|
||||
/* Set the variable so that we return the newest version */
|
||||
if ( $versionsJson = $_versions )
|
||||
{
|
||||
return array_pop( $versionsJson );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -526,94 +531,6 @@ class _Application extends \IPS\Node\Model
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* MD5 check (returns path to files which do not match)
|
||||
*
|
||||
* @param int|NULL $version Version to check against
|
||||
* @return array
|
||||
* @throws \IPS\Http\Request\Exception
|
||||
*/
|
||||
public static function md5Check( $version = NULL )
|
||||
{
|
||||
/* For Community in the Cloud customers we cannot do this because they have encoded files
|
||||
and the encoder produces different output each time it runs, so every Cloud customer
|
||||
has different files, even for the same version */
|
||||
$key = \IPS\IPS::licenseKey();
|
||||
if ( \IPS\CIC OR $key['cloud'] )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/* For everyone else, get the correct md5 sums for each file... */
|
||||
$url = \IPS\Http\Url::ips( 'md5' );
|
||||
if ( $version !== NULL )
|
||||
{
|
||||
$url = $url->setQueryString( 'version', $version );
|
||||
}
|
||||
$correctMd5s = $url->request()->get()->decodeJson();
|
||||
|
||||
/* And return whichever ones don't match */
|
||||
$return = array();
|
||||
foreach ( $correctMd5s as $file => $md5Hash )
|
||||
{
|
||||
/* Fix the admin directory */
|
||||
$file = preg_replace( '/^\/admin\//', '/' . \IPS\CP_DIRECTORY . '/', $file );
|
||||
|
||||
/* If this is an application directory but the application doesn't exist or has been disabled then we shouldn't check it */
|
||||
preg_match( '/^\/applications\/(.+?)\//', $file, $matches );
|
||||
if ( $matches )
|
||||
{
|
||||
if( \in_array( $matches[1], \IPS\IPS::$ipsApps ) AND !static::appIsEnabled( $matches[1] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore init.php (which always changes on build) and conf_global.dist.php (which doesn't exist after install) */
|
||||
if ( \in_array( $file, array( '/init.php', '/conf_global.dist.php' ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the file doesn't exist at all, flag it */
|
||||
if ( !file_exists( \IPS\ROOT_PATH . $file ) )
|
||||
{
|
||||
$return[] = \IPS\ROOT_PATH . $file;
|
||||
}
|
||||
/* Otherwise, compare the md5 hashes... */
|
||||
else
|
||||
{
|
||||
/* Get the contents. If you can't get the contents, it may be that the file permissions are set wrong. Try to fix. */
|
||||
$fileContents = @file_get_contents( \IPS\ROOT_PATH . $file );
|
||||
if ( !$fileContents )
|
||||
{
|
||||
@chmod( \IPS\ROOT_PATH . $file, \IPS\FILE_PERMISSION_NO_WRITE );
|
||||
}
|
||||
|
||||
/* If we got the file contents... */
|
||||
if ( $fileContents )
|
||||
{
|
||||
/* Strip whitespace since FTP in ASCII mode will change the whitespace characters */
|
||||
$fileContents = preg_replace( '#\s#', '', utf8_decode( file_get_contents( \IPS\ROOT_PATH . $file ) ) );
|
||||
|
||||
/* Compare */
|
||||
if ( md5( $fileContents ) != $md5Hash )
|
||||
{
|
||||
$return[] = \IPS\ROOT_PATH . $file;
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, flag it */
|
||||
else
|
||||
{
|
||||
$return[] = \IPS\ROOT_PATH . $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
@@ -632,7 +549,7 @@ class _Application extends \IPS\Node\Model
|
||||
/**
|
||||
* @brief [ActiveRecord] Database ID Fields
|
||||
*/
|
||||
protected static $databaseIdFields = array( 'app_id', 'app_marketplace_id' );
|
||||
protected static $databaseIdFields = array( 'app_id' );
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
@@ -1035,7 +952,7 @@ EOF;
|
||||
$buttons['export'] = array(
|
||||
'icon' => 'download',
|
||||
'title' => 'download',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=applications&appKey={$this->_id}&do=customDownload")
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=applications&appKey={$this->_id}&do=downloadMafia")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1839,7 +1756,8 @@ EOF;
|
||||
{
|
||||
if( file_exists( $this->getApplicationPath() . "/data/tasks.json" ) )
|
||||
{
|
||||
foreach ( json_decode( file_get_contents( $this->getApplicationPath() . "/data/tasks.json" ), TRUE ) as $key => $frequency )
|
||||
$taskJson = json_decode( file_get_contents( $this->getApplicationPath() . "/data/tasks.json" ), TRUE );
|
||||
foreach ( $taskJson as $key => $frequency )
|
||||
{
|
||||
\IPS\Db::i()->replace( 'core_tasks', array(
|
||||
'app' => $this->directory,
|
||||
@@ -1848,6 +1766,9 @@ EOF;
|
||||
'next_run' => \IPS\DateTime::create()->add( new \DateInterval( $frequency ) )->getTimestamp()
|
||||
) );
|
||||
}
|
||||
|
||||
/* Delete any tasks that are no longer present */
|
||||
\IPS\Db::i()->delete( 'core_tasks', [ [ 'app=?', $this->directory ], [ \IPS\Db::i()->in( '`key`', array_keys( $taskJson ), true ) ] ] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1867,7 +1788,7 @@ EOF;
|
||||
/* Only check for Amazon when installing an app via the Admin CP on Community in the Cloud. The CiC Installer will handle brand new installs. */
|
||||
if ( \IPS\CIC AND !$newInstall )
|
||||
{
|
||||
$fileSystem = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'method=?', 'Amazon' ), 'id ASC' )->first();
|
||||
$fileSystem = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'method=?', 'Cloud' ), 'id ASC' )->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4745,6 +4666,7 @@ EOF;
|
||||
\IPS\Db::i()->delete( 'core_acp_notifications', array( 'app=?', $this->directory ) );
|
||||
\IPS\Db::i()->delete( 'core_solved_index', array( 'app=?', $this->directory ) );
|
||||
\IPS\Db::i()->delete( 'core_notifications', array( 'notification_app=?', $this->directory ) );
|
||||
\IPS\Db::i()->delete( 'core_javascript', array( 'javascript_app=?', $this->directory ) );
|
||||
|
||||
$rulesToDelete = iterator_to_array( \IPS\Db::i()->select( 'id', 'core_achievements_rules', [ "action LIKE CONCAT( ?, '_%' )", $this->directory ] ) );
|
||||
\IPS\Db::i()->delete( 'core_achievements_rules', \IPS\Db::i()->in( 'id', $rulesToDelete ) );
|
||||
|
||||
Reference in new issue
Block a user