Ejemplo n.º 1
0
function install_PIWIK($servername)
{
    $sources = "/usr/share/piwik";
    $unix = new unix();
    $cp = $unix->find_program("cp");
    $freeweb = new freeweb($servername);
    if (!is_dir($sources)) {
        writelogs("[{$servername}] {$sources} no such directory", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    if (!is_dir($freeweb->WORKING_DIRECTORY)) {
        writelogs("[{$servername}] {$freeweb->WORKING_DIRECTORY} no such directory", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    include_once dirname(__FILE__) . "/ressources/class.piwik.inc";
    $piwik = new piwik();
    if ($piwik->checkWebsite($freeweb->WORKING_DIRECTORY)) {
        return;
    }
    writelogs("[{$servername}] copy sources...", __FUNCTION__, __FILE__, __LINE__);
    shell_exec("{$cp} -rf {$sources}/* {$freeweb->WORKING_DIRECTORY}/");
    @unlink("{$freeweb->WORKING_DIRECTORY}/config/config.ini.php");
    @mkdir('/usr/share/piwik/tmp/assets', 0777, true);
    @mkdir('/usr/share/piwik/tmp/templates_c', 0777, true);
    @mkdir('/usr/share/piwik/tmp/cache', 0777, true);
    @mkdir('/usr/share/piwik/tmp/assets', 0777, true);
    shell_exec('/bin/chmod 0777 /usr/share/piwik/tmp');
    shell_exec('/bin/chmod 0777 /usr/share/piwik/tmp/templates_c/');
    shell_exec('/bin/chmod 0777 /usr/share/piwik/tmp/cache/');
    shell_exec('/bin/chmod 0777 /usr/share/piwik/tmp/assets/');
    shell_exec('/bin/chmod a+w /usr/share/piwik/config');
    $apacheusername = $unix->APACHE_SRC_ACCOUNT();
    $apachegroup = $unix->APACHE_SRC_GROUP();
    $freeweb->chown($freeweb->WORKING_DIRECTORY);
}