Exemplo n.º 1
0
function fileDeleteDir($remoteDir)
{
    $errorMess = true;
    $remoteDir = $remoteDir;
    $readDir = $remoteDir;
    if (is_dir($readDir)) {
        $filesArray = array();
        $filesArray = fileReadDirContents($readDir);
        // do recursive delete if dir contains files //
        foreach ($filesArray as $name) {
            if (is_dir($readDir . '/' . $name)) {
                fileDeleteDir($remoteDir . '/' . $name);
            } elseif (file_exists($readDir . '/' . $name)) {
                if (!unlink($remoteDir . '/' . $name)) {
                    throw new Exception(MSG00058);
                    $errorMess = false;
                }
            }
        }
        // remove dir //
        if (rmdir($readDir)) {
            $errorMess = false;
        } else {
            $errorMess = true;
        }
    } else {
        $errorMess = true;
    }
    return $errorMess;
}
Exemplo n.º 2
0
function createWebsite($siteid)
{
    $db = Database::obtain();
    $sql = "SELECT * FROM " . TABLE_WEBSITES . "\n\t\t\t\t\tWHERE `id` =" . $siteid . "";
    $websitedata = $db->query_first($sql);
    $template_id = $websitedata['website_template'];
    $sql = "SELECT * FROM " . TABLE_TEMPLATES . "\n\t\t\t\t\tWHERE `id` =" . $template_id . "";
    $template = $db->query_first($sql);
    $website_template = $template['name'];
    $website_folder = 'content/' . $siteid;
    $template_dir = 'templates/' . $website_template . '/';
    fileDeleteDir($website_folder);
    createDir($website_folder);
    createWebsiteCopyTheme($template_dir, $website_folder);
    $menu = getMenu($siteid);
    foreach ($menu as $id => $page) {
        if ($id == '0') {
            $filename = 'index.html';
        } else {
            $filename = strtolower(underscoreAdd($page['title'])) . '.html';
        }
        $pageid = $page['pageid'];
        $contents = generatePage($siteid, $pageid);
        fileSave($website_folder . '/' . $filename, $contents);
    }
}