function create_site($folder, $id) { global $backend; if (is_dir(SITES_DIR . $folder)) { echo edgimo_error('Could not create site folder: folder already exists'); return; } mkdir(SITES_DIR . $folder . '/'); mkdir(SITES_DIR . $folder . '/css/'); mkdir(SITES_DIR . $folder . '/js/'); mkdir(SITES_DIR . $folder . '/images/'); mkdir(SITES_DIR . $folder . '/files/'); $skeleton_index = file_get_contents('lib/skeleton/index.php'); $skeleton_index = str_replace('{{ACTIVITY_ID}}', $id, $skeleton_index); foreach ($backend->template_folders as $template_folder) { if ($template_folder == 'comingsoon') { continue; } $template_index = file_get_contents('lib/skeleton/template_index.php'); $template_index = str_replace('{{TEMPLATE_NAME}}', $template_folder, $template_index); $template_index = str_replace('{{ACTIVITY_ID}}', $id, $template_index); mkdir(SITES_DIR . $folder . '/' . $template_folder . '/'); $handle = fopen(SITES_DIR . $folder . '/' . $template_folder . '/index.php', 'w+'); fwrite($handle, $template_index); fclose($handle); } $handle = fopen(SITES_DIR . $folder . '/index.php', 'w+'); fwrite($handle, $skeleton_index); fclose($handle); $handle = fopen(SITES_DIR . $folder . '/cheatsheet.php', 'w+'); fwrite($handle, create_site_cheatsheet($id)); fclose($handle); $handle = fopen(SITES_DIR . $folder . '/css/style.css', 'w+'); fwrite($handle, file_get_contents('lib/skeleton/css/style.css')); fclose($handle); $handle = fopen(SITES_DIR . $folder . '/css/helpers.css', 'w+'); fwrite($handle, file_get_contents('lib/skeleton/css/helpers.css')); fclose($handle); $handle = fopen(SITES_DIR . $folder . '/js/jquery.js', 'w+'); fwrite($handle, file_get_contents('lib/skeleton/js/jquery.js')); fclose($handle); $handle = fopen(SITES_DIR . $folder . '/js/functions.js', 'w+'); fwrite($handle, file_get_contents('lib/skeleton/js/functions.js')); fclose($handle); }
$title = 'Admin Functions'; $slug = 'admin'; require_once 'lib/functions.php'; include 'header.php'; if ($user->role != 'Web Vendor') { echo edgimo_error('Access Denied'); exit; } global $mysqli; if (isset($_GET['action'])) { if ($_GET['action'] == 'cheatsheet') { $query = "SELECT activity_id, folder FROM ashp_activities"; $result = $mysqli->query($query); while ($site = $result->fetch_array(MYSQLI_ASSOC)) { $html = create_site_cheatsheet($site['activity_id']); $handle = fopen(SITES_DIR . $site['folder'] . '/cheatsheet.php', 'w'); fwrite($handle, $html); fclose($handle); } } if ($_GET['action'] == 'regenerate_headings') { $activity_id = $_GET['activity']; $activity = new Activity($activity_id); $content = $activity->get_activity_content(); $headings = $mysqli->query("SELECT field_id, heading FROM ashp_fields WHERE activity_type = 0 OR activity_type = {$activity->type_id}"); while ($vars = $headings->fetch_array(MYSQLI_ASSOC)) { $update = $mysqli->query("UPDATE ashp_activity_content SET heading='{$vars['heading']}' WHERE activity_id = {$activity_id} AND field_id = {$vars['field_id']}"); } } if (isset($_POST['action']) && $_POST['action'] == 'regenerate_all') {