Ejemplo n.º 1
0
 public function create_onload()
 {
     /* we need the packages model to figure out which are active */
     $this->model('o_packages_model');
     /* let's load the active packages in order */
     $records = ci()->o_packages_model->active();
     $n = chr(10);
     /* our cache files starts with */
     $combined = '<?php' . $n;
     $combined .= '/*' . $n;
     $combined .= 'DO NOT MODIFY THIS FILE' . $n;
     $combined .= 'THIS FILE IS MANAGED COMPLETELY BY THE FRAMEWORK' . $n;
     $combined .= 'This file is all of the onloads in a single file to make attaching them a single action' . $n;
     $combined .= 'This file is automatically rebuild by the package manager as needed' . $n;
     $combined .= '*/' . $n;
     foreach ($records as $p) {
         $package_folder = ROOTPATH . '/' . $p->full_path;
         /* does our package have a onload.php? */
         if (file_exists($package_folder . '/support/onload.php')) {
             /* add it to the combined onload.php */
             $combined .= str_replace('<?php', '/* --> ' . $p->full_path . ' <-- */', trim(file_get_contents($package_folder . '/support/onload.php'))) . $n . $n;
         }
     }
     /* opcache flushed by atomic function if needed */
     atomic_file_put_contents($this->onload_path, $combined);
     /* chainable */
     return $this;
 }
Ejemplo n.º 2
0
 public function create_autoload()
 {
     $autoload_packages = $this->o_packages_model->active();
     $package_text = '$autoload[\'packages\'] = array(' . chr(10);
     $package_text .= chr(9) . '/* updated: ' . date('Y-m-d-H:i:s') . ' */' . chr(10);
     // 	ROOTPATH.'/packages/theme_zerotype',
     foreach ($autoload_packages as $ap) {
         /* let's make sure the packages is still there! */
         if (is_dir(ROOTPATH . $ap->full_path)) {
             $package_text .= chr(9) . 'ROOTPATH.\'' . $ap->full_path . "'," . chr(10);
         }
     }
     $package_text .= ');';
     $current_content = file_get_contents($this->autoload);
     $re = "/^\\s*\\\$autoload\\['packages']\\s*=\\s*array\\s*\\((.+?)\\);/ms";
     preg_match_all($re, $current_content, $matches);
     if (!isset($matches[0][0])) {
         show_error('Regular Expression Error: packages_config->autoload.php');
     }
     $content = str_replace($matches[0][0], $package_text, $current_content);
     /* opcache flushed if needed by atomic function */
     return atomic_file_put_contents($this->autoload, $content);
 }
Ejemplo n.º 3
0
function array_cache($filename = null, $data = null)
{
    if (is_array($data) && $filename) {
        $dir = dirname($filename);
        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }
        /* write */
        atomic_file_put_contents($filename, '<?php return ' . var_export($data, true) . ';');
    } else {
        /* read */
        return file_exists($filename) ? include $filename : false;
    }
}
        }
        sleep(1);
    }
    return mkdir($tmp_dir);
}
$tmp_dir = sys_get_temp_dir() . "/tmp-uportal-conf";
//echo "working in $tmp_dir\n";
if (!wait_previous_call_terminate($tmp_dir)) {
    exit(ini_get('safe_mode') ? 'only way to make it work is to disable safe_mode!' : (is_dir($tmp_dir) ? "race detected, failing" : "failed to create {$tmp_dir}"));
}
$tmp_tar_file = "{$tmp_dir}/t.tar";
file_put_contents($tmp_tar_file, file_get_contents('php://input'));
system("tar xC {$tmp_dir} -f {$tmp_tar_file}");
$PAGSGroupStoreConfig = "{$tmp_dir}/esup-package/custom/uPortal/uportal-impl/src/main/resources/properties/groups/PAGSGroupStoreConfig.xml";
$db_export_dir = "{$tmp_dir}/db-export";
if (!is_file($PAGSGroupStoreConfig)) {
    $err = "missing PAGSGroupStoreConfig {$PAGSGroupStoreConfig}";
} else {
    if (!is_dir($db_export_dir)) {
        $err = "missing db-export {$db_export_dir}";
    } else {
        $config_menu_content = gen($PAGSGroupStoreConfig, $db_export_dir);
    }
}
rm_rf($tmp_dir);
if (@$err) {
    exit($err);
}
$config_menu_file = dirname(__FILE__) . '/config-menu-from-uportal/config-menu.inc.php';
atomic_file_put_contents($config_menu_file, $config_menu_content);
echo "success\n";