function import($file) { $zip = new ZipArchive(); if ($zip->open($file) === TRUE) { $zip->extractTo('../'); $zip->close(); } require '../includes/functions/latest_dir.php'; $dir = latest_dir('../modules/'); if ($this->install($dir)) { return true; } else { return false; } }
function style_import($file) { global $db; $zip = new ZipArchive(); # open the style file if ($zip->open($file) === TRUE) { $zip->extractTo('../'); $zip->close(); } # get the installed style's directory require '../includes/functions/latest_dir.php'; $dir = latest_dir('../styles/'); # fetch details.text if (file_exists("../styles/{$dir}")) { $details_file = @explode('|', read_file("../styles/{$dir}/details.text")); $style_name = $details_file[0]; $style_code = $details_file[1]; $version = $details_file[2]; $designer_name = $details_file[3]; $designer_email = $details_file[4]; } # insert style entry into the databse $css = read_file("../styles/{$dir}/css.text"); $insert = $db->insert('styles', array('style_name', 'style_code', 'version', 'designer_name', 'designer_email', 'css'), array($style_name, $style_code, $version, $designer_name, $designer_email, $css)); $get_r = $db->fetch('styles', false, false, 'id', 'DESC'); $style_id = $get_r[0]['id']; if ($insert) { # import the templates $import = $this->import(read_file("../styles/{$dir}/templates.xml"), $style_id); } if ($insert and $import) { return true; } else { return false; } }