1
0

Write ini files to tmp folder to avoid write permissions errors

This commit is contained in:
Daniel Muller 2012-11-18 02:54:25 +08:00
parent ae3e9fbf71
commit 59780cf27a
2 changed files with 24 additions and 13 deletions

View File

@ -37,6 +37,17 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
* *
* @author brentil <forums@inner-ninja.com> * @author brentil <forums@inner-ninja.com>
*/ */
protected $gm_ini;
protected $gm_core_ini;
public function __construct() {
parent::__construct();
$this->gm_ini = realpath(VARPATH.'/tmp').'/gm.ini';
$this->gm_core_ini = realpath(VARPATH.'/tmp').'/gm_core.ini';
}
public function index() { public function index() {
//Start execution timer //Start execution timer
@ -94,8 +105,8 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
if($refreshCache == true){ if($refreshCache == true){
// Only poll GalleryModules.com once for the ini file. // Only poll GalleryModules.com once for the ini file.
$fp = fopen('gm.ini', 'w'); $fp = fopen($this->gm_ini, 'w');
$fp2 = fopen('gm_core.ini','w'); $fp2 = fopen($this->gm_core_ini,'w');
if(function_exists("curl_init")) { if(function_exists("curl_init")) {
$cp = curl_init("http://www.gallerymodules.com/gallerymodules.ini"); $cp = curl_init("http://www.gallerymodules.com/gallerymodules.ini");
curl_setopt($cp, CURLOPT_FILE, $fp); curl_setopt($cp, CURLOPT_FILE, $fp);
@ -186,10 +197,10 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
log::success("moduleupdates", t("Completed checking remote GitHub for modules updates.")); log::success("moduleupdates", t("Completed checking remote GitHub for modules updates."));
} }
if(is_file('gm.ini')) if(is_file($this->gm_ini))
unlink('gm.ini'); unlink($this->gm_ini);
if(is_file('gm_core.ini')) if(is_file($this->gm_core_ini))
unlink('gm_core.ini'); unlink($this->gm_core_ini);
$view->content->vars = $cache; $view->content->vars = $cache;
$view->content->update_time = $cache_updates['date']; $view->content->update_time = $cache_updates['date'];
@ -288,11 +299,11 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
//Check the main Gallery3 GitHub //Check the main Gallery3 GitHub
if ($file == null) { if ($file == null) {
try { try {
if(file_exists('gm_core.ini')) { if(file_exists($this->gm_core_ini)) {
$file = 1; $file = 1;
} }
if ($file != null) { if ($file != null) {
$gm_core_array = parse_ini_file('gm_core.ini',true); $gm_core_array = parse_ini_file($this->gm_core_ini,true);
$server = '(G)'; $server = '(G)';
} }
} }
@ -303,11 +314,11 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
case "GH": case "GH":
//Parse ini file from GalleryModules.com //Parse ini file from GalleryModules.com
try { try {
if(file_exists('gm.ini')) { if(file_exists($this->gm_ini)) {
$file = 1; $file = 1;
} }
if ($file != null) { if ($file != null) {
$gm_array = parse_ini_file('gm.ini',true); $gm_array = parse_ini_file($this->gm_ini,true);
$server = '(GH)'; $server = '(GH)';
} }
} }
@ -350,4 +361,4 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
return array ($version, $server); return array ($version, $server);
} }
} }

View File

@ -1,7 +1,7 @@
name = "ModuleUpdates" name = "ModuleUpdates"
description = "Compares your installed module version against the ones stored in the GitHub." description = "Compares your installed module version against the ones stored in the GitHub."
version = 11 version = 12
author_name = "brentil" author_name = "brentil"
author_url = "http://gallery.menalto.com/user/153736" author_url = "http://gallery.menalto.com/user/153736"
info_url = "http://codex.gallery2.org/Gallery3:Modules:moduleupdates" info_url = "http://codex.gallery2.org/Gallery3:Modules:moduleupdates"
discuss_url = "http://gallery.menalto.com/node/96574" discuss_url = "http://gallery.menalto.com/node/96574"