本文整理汇总了PHP中remove_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP remove_directory函数的具体用法?PHP remove_directory怎么用?PHP remove_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_directory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove_directory
function remove_directory($directory, $empty = FALSE)
{
if (substr($directory, -1) == '/') {
$directory = substr($directory, 0, -1);
}
if (!file_exists($directory) || !is_dir($directory)) {
return FALSE;
} elseif (!is_readable($directory)) {
return FALSE;
} else {
$handle = opendir($directory);
while (FALSE !== ($item = readdir($handle))) {
if ($item != '.' && $item != '..') {
$path = $directory . '/' . $item;
if (is_dir($path)) {
remove_directory($path);
} else {
unlink($path);
}
}
}
closedir($handle);
if ($empty == FALSE) {
if (!rmdir($directory)) {
return FALSE;
}
}
return TRUE;
}
}
示例2: remove_directory
function remove_directory($dir)
{
if ($handle = opendir("{$dir}")) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
if (is_dir("{$dir}/{$item}")) {
remove_directory("{$dir}/{$item}");
} else {
unlink("{$dir}/{$item}");
}
}
}
closedir($handle);
rmdir($dir);
}
}
示例3: remove_directory
function remove_directory($dir)
{
if (substr($dir, -1, 1) == "/") {
$dir = substr($dir, 0, strlen($dir) - 1);
}
if ($handle = opendir("{$dir}")) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
if (is_dir("{$dir}/{$item}")) {
remove_directory("{$dir}/{$item}");
} else {
unlink("{$dir}/{$item}");
}
}
}
closedir($handle);
rmdir($dir);
}
}
示例4: remove_directory
/**
* remove_directory
* Will recursively remove directories and clean up files in each directory.
*
* @param String $directory Name of directory to clean up and clear.
*
* @return Boolean Returns false if it can't remove a directory or a file. Returns true if it all worked ok.
*/
function remove_directory($directory='')
{
$safe_mode = ini_get('safe_mode');
if (!is_dir($directory)) {
return true;
}
// need to use the '@' in case we can't open the directory
// otherwise it still throws a notice.
if (!$handle = @opendir($directory)) {
return false;
}
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$f = $directory . '/' . $file;
if (is_dir($f)) {
remove_directory($f);
continue;
}
if (is_file($f)) {
if (!unlink($f)) {
closedir($handle);
return false;
}
}
}
closedir($handle);
if ($safe_mode) {
$status = true;
} else {
$status = rmdir($directory);
}
return $status;
}
示例5: remove_directory
function remove_directory($path)
{
$dir = @opendir($path);
if ($dir === FALSE) {
return false;
}
//remove all files and subdirectories in directory
while ($file = readdir($dir)) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($path . '/' . $file)) {
remove_directory($path . '/' . $file);
} else {
@unlink($path . '/' . $file);
}
}
//remove directory
closedir($dir);
rmdir($path);
return true;
}
示例6: Delete
/**
* Delete
* Delete a template from the database
* This will also clean up after itself in case there are any attachments or images associated with the template.
*
* @param Int $templateid Templateid of the template to delete. If not passed in, it will delete 'this' template. We delete the template, then reset all class vars.
*
* @see remove_directory
*
* @return Boolean True if it deleted the template, false otherwise.
*/
function Delete($templateid=0)
{
if ($templateid == 0) {
$templateid = $this->templateid;
}
$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "templates WHERE templateid='" . $templateid. "'";
$result = $this->Db->Query($query);
if (!$result) {
list($error, $level) = $this->Db->GetError();
trigger_error($error, $level);
return false;
}
$template_dir = TEMP_DIRECTORY . '/templates/' . $templateid;
remove_directory($template_dir);
$this->templateid = 0;
$this->name = '';
$this->format = 'h';
$this->active = 0;
$this->SetBody('text', '');
$this->SetBody('html', '');
$this->ownerid = 0;
return true;
}
示例7: action
/**
* Call action (mark as fav, archive, delete, etc.)
*/
public function action($action, Url $url, $id = 0, $import = FALSE, $autoclose = FALSE, $tags = null)
{
switch ($action) {
case 'add':
$content = Tools::getPageContent($url);
$title = $content['rss']['channel']['item']['title'] != '' ? $content['rss']['channel']['item']['title'] : _('Untitled');
$body = $content['rss']['channel']['item']['description'];
// clean content from prevent xss attack
$purifier = $this->getPurifier();
$title = $purifier->purify($title);
$body = $purifier->purify($body);
//search for possible duplicate
$duplicate = NULL;
$duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId());
$last_id = $this->store->add($url->getUrl(), $title, $body, $this->user->getId());
if ($last_id) {
Tools::logm('add link ' . $url->getUrl());
if (DOWNLOAD_PICTURES) {
$content = filtre_picture($body, $url->getUrl(), $last_id);
Tools::logm('updating content article');
$this->store->updateContent($last_id, $content, $this->user->getId());
}
if ($duplicate != NULL) {
// duplicate exists, so, older entry needs to be deleted (as new entry should go to the top of list), BUT favorite mark and tags should be preserved
Tools::logm('link ' . $url->getUrl() . ' is a duplicate');
// 1) - preserve tags and favorite, then drop old entry
$this->store->reassignTags($duplicate['id'], $last_id);
if ($duplicate['is_fav']) {
$this->store->favoriteById($last_id, $this->user->getId());
}
if ($this->store->deleteById($duplicate['id'], $this->user->getId())) {
Tools::logm('previous link ' . $url->getUrl() . ' entry deleted');
}
}
$this->messages->add('s', _('the link has been added successfully'));
} else {
$this->messages->add('e', _('error during insertion : the link wasn\'t added'));
Tools::logm('error during insertion : the link wasn\'t added ' . $url->getUrl());
}
if ($autoclose == TRUE) {
Tools::redirect('?view=home');
} else {
Tools::redirect('?view=home&closewin=true');
}
break;
case 'delete':
$msg = 'delete link #' . $id;
if ($this->store->deleteById($id, $this->user->getId())) {
if (DOWNLOAD_PICTURES) {
remove_directory(ABS_PATH . $id);
}
$this->messages->add('s', _('the link has been deleted successfully'));
} else {
$this->messages->add('e', _('the link wasn\'t deleted'));
$msg = 'error : can\'t delete link #' . $id;
}
Tools::logm($msg);
Tools::redirect('?');
break;
case 'toggle_fav':
$this->store->favoriteById($id, $this->user->getId());
Tools::logm('mark as favorite link #' . $id);
if (Tools::isAjaxRequest()) {
echo 1;
exit;
} else {
Tools::redirect();
}
break;
case 'toggle_archive':
$this->store->archiveById($id, $this->user->getId());
Tools::logm('archive link #' . $id);
if (Tools::isAjaxRequest()) {
echo 1;
exit;
} else {
Tools::redirect();
}
break;
case 'archive_all':
$this->store->archiveAll($this->user->getId());
Tools::logm('archive all links');
Tools::redirect();
break;
case 'add_tag':
if (isset($_GET['search'])) {
//when we want to apply a tag to a search
$tags = array($_GET['search']);
$allentry_ids = $this->store->search($tags[0], $this->user->getId());
$entry_ids = array();
foreach ($allentry_ids as $eachentry) {
$entry_ids[] = $eachentry[0];
}
} else {
//add a tag to a single article
$tags = explode(',', $_POST['value']);
$entry_ids = array($_POST['entry_id']);
//.........这里部分代码省略.........
示例8: remove_directory
/**
* Suppression du répertoire d'images
*/
function remove_directory($directory)
{
if (is_dir($directory)) {
$files = array_diff(scandir($directory), array('.', '..'));
foreach ($files as $file) {
is_dir("{$directory}/{$file}") ? remove_directory("{$directory}/{$file}") : unlink("{$directory}/{$file}");
}
return rmdir($directory);
}
}
示例9: pre_configure_site
pre_configure_site();
if (INSTALL_SEO_URLS == 1) {
$contents = '#-MS- SEO-G Added' . "\n" . 'Options +FollowSymLinks' . "\n" . 'RewriteEngine On' . "\n" . 'RewriteBase ' . DIR_WS_HTTP_CATALOG . "\n\n" . '# Note whatever extension you use it should match the SEO-G configuration -> extension on the admin end even if its blank' . "\n" . '# Also the separators defined in the SEO-G for the various entities should be included in the rule here.' . "\n\n" . '# Rules for extensionless URLs' . "\n" . '# 1. Using a trailing slash' . "\n" . '#RewriteRule ^(.*)/$ root.php?$1&%{QUERY_STRING}' . "\n\n" . '# 2. Not using a trailing slash links with alphanumeric characters and hyphens' . "\n" . '#RewriteRule ^([a-z0-9_-]+)$ root.php?$1&%{QUERY_STRING}' . "\n\n" . '# Rules for URLs with extensions' . "\n" . '#RewriteRule ^(.*).asp$ root.php?$1.asp&%{QUERY_STRING}' . "\n" . '#RewriteRule ^(.*).(htm|html|asp|jsp|aspx)$ root.php?$1.*&%{QUERY_STRING}' . "\n\n" . '# Current Rules to support multiple extensions' . "\n" . '#RewriteRule ^([a-z0-9_-]+)$ root.php?$1&%{QUERY_STRING}' . "\n" . 'RewriteRule ^([/a-z0-9_-]+)$ root.php?$1&%{QUERY_STRING}' . "\n" . 'RewriteRule ^(.*)/$ root.php?$1&%{QUERY_STRING}' . "\n" . 'RewriteRule ^(.*).(htm|html|asp|jsp|aspx)$ root.php?$1.*&%{QUERY_STRING}' . "\n" . '#-MS- SEO-G Added EOM' . "\n";
$result = write_contents('.htaccess', $contents);
if (!$result) {
$errors_array[] = ERROR_GLOBAL_WRITE_HTACCESS;
}
$contents = '#-MS- Disable SEO-G on admin folder' . "\n" . 'Options +FollowSymLinks' . "\n" . 'RewriteEngine On' . "\n" . 'RewriteBase ' . DIR_WS_HTTP_CATALOG . 'admin/' . "\n" . 'RewriteRule ^(.*)$ $1 [L]' . "\n" . '#-MS- SEO-G Added EOM' . "\n";
chdir(DIR_FS_CATALOG . 'admin/');
$result = write_contents('.htaccess', $contents);
if (!$result) {
$errors_array[] = ERROR_GLOBAL_WRITE_HTACCESS;
}
}
chdir($current_dir);
remove_directory($current_dir);
chdir(DIR_FS_CATALOG);
break;
case 'license_agreement':
$amend = '';
if (!read_contents(FILE_LICENSE, $contents) || !read_contents(FILE_LICENSE_AMENDMENT, $amend)) {
redirect($_SERVER['SCRIPT_NAME']);
}
if (!isset($_POST['license'])) {
$error_string = ERROR_GLOBAL_LICENSE_AGREE;
redirect($_SERVER['SCRIPT_NAME'] . '?error_string=' . $error_string);
}
redirect($_SERVER['SCRIPT_NAME'] . '?action=server_detect');
break;
default:
if (!read_contents(FILE_LICENSE, $contents) || !read_contents(FILE_LICENSE_AMENDMENT, $amend)) {
示例10: remove_directory
/**
* remove_directory
* Will recursively remove directories and clean up files in each directory.
*
* @param directory Name of directory to clean up and clear.
*
* @return boolean Returns false if it can't remove a directory or a file. Returns true if it all worked ok.
*/
function remove_directory($directory = '')
{
if (!is_dir($directory)) {
return true;
}
if (!($handle = opendir($directory))) {
return false;
}
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$f = $directory . '/' . $file;
if (is_dir($f)) {
remove_directory($directory . '/' . $f);
}
if (is_file($f)) {
if (!unlink($f)) {
closedir($handle);
return false;
}
}
}
closedir($handle);
return true;
}
示例11: Delete
/**
* Delete
* Delete an autoresponder from the database. Also deletes the queue associated with it.
*
* @param Int $autoresponderid Autoresponderid of the autoresponder to delete. If not passed in, it will delete 'this' autoresponder. We delete the autoresponder, then reset all class vars.
* @param Int $userid The user doing the deleting of the autoresponder. This is so the stats api can "hide" autoresponder stats.
*
* @see Stats_API::HideStats
* @see ClearQueue
*
* @return Boolean True if it deleted the autoresponder, false otherwise.
*
*/
function Delete($autoresponderid=0, $userid=0)
{
if ($autoresponderid == 0) {
$autoresponderid = $this->autoresponderid;
}
$this->Load($autoresponderid);
$query = "DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "autoresponders WHERE autoresponderid='" . $autoresponderid. "'";
$result = $this->Db->Query($query);
if (!$result) {
list($error, $level) = $this->Db->GetError();
trigger_error($error, $level);
return false;
}
$this->ClearQueue($this->queueid, 'autoresponder');
$autoresponder_dir = TEMP_DIRECTORY . '/autoresponders/' . $autoresponderid;
remove_directory($autoresponder_dir);
$this->autoresponderid = 0;
$this->name = '';
$this->format = 'h';
$this->hoursaftersubscription = 0;
$this->queueid = 0;
$this->archive = 0;
$this->SetBody('text', '');
$this->SetBody('html', '');
$this->ownerid = 0;
$this->autorespondersize = 0;
$stats = array();
$query = "SELECT statid FROM " . SENDSTUDIO_TABLEPREFIX . "stats_autoresponders WHERE autoresponderid='" . $autoresponderid . "'";
$result = $this->Db->Query($query);
while ($row = $this->Db->Fetch($result)) {
$stats[] = $row['statid'];
}
// clean up stats
if (!class_exists('stats_api', false)) {
require_once(dirname(__FILE__) . '/stats.php');
}
$stats_api = new Stats_API();
$stats_api->HideStats($stats, 'autoresponder', $userid);
return true;
}
示例12: publish_student
//.........这里部分代码省略.........
$accUrl = site_url('login/checkProfileLogin/' . $this->encrypt->encode($_POST['siteID']));
$script = <<<'EOS'
<?PHP
session_start();
if(!isset($_SESSION) || session_id() == "") {
if(isset($_REQUEST['sessid']) && $_REQUEST['sessid']!="" ) {
list($sid, $ext) = explode('-', $_REQUEST['sessid']);
session_id($sid);
}
}
?>
EOS;
$sessionSet = <<<'EOD'
<?PHP
EOD;
$sessionSet .= ' $sess = isset($_SESSION["extids"]["' . base64_encode($siteDetails['site']->site_id) . '"])?$_SESSION["extids"]["' . base64_encode($siteDetails['site']->site_id) . '"]:"";';
$sessionSet .= <<<'EOD'
if(is_array($_SESSION) && count($_SESSION)>0 && isset($sess)) {
?>
<input type="hidden" class="myid" name="myid" value="<?PHP echo base64_encode($sess); ?>">
<?PHP
}
else {
?>
<input type="hidden" class="myid" name="myid" value="">
<?PHP
}
?>
EOD;
$pageContent = str_replace("<!-- password check url -->", '<input type="hidden" class="siteurl" name="siteurl" value="' . $valUrl . '">', $pageContent);
$pageContent = str_replace("<!-- site url -->", '<input type="hidden" class="siteaccess" name="siteaccess" value="' . $accUrl . '">', $pageContent);
$pageContent = str_replace("<!-- session -->", $script, $pageContent);
$pageContent = str_replace("<!-- password protection on-->", '<input type="hidden" class="hiddenpassword" name="haspassword" value="' . $siteDetails['site']->has_password . '">', $pageContent);
$pageContent = str_replace("<!-- session variable -->", $sessionSet, $pageContent);
$pageContent = str_replace("<!-- site id -->", '<input type="hidden" class="siteId" name="siteId" value="' . base64_encode($siteDetails['site']->site_id) . '">', $pageContent);
/* STUDENT SECTION NEEDED ENDS */
$pageContent = str_replace("<!-- site contact url div -->", '<div id="contact-url" data-content="' . site_url('login/site_contact/' . $this->encrypt->encode($_POST['siteID'])) . '"></div>', $pageContent);
$pageContent = str_replace("<!-- site counter url div -->", '<div id="counter-url" data-content="' . site_url('login/visitor_counter/' . $this->encrypt->encode($_POST['siteID'])) . '"></div>', $pageContent);
$pageContent = str_replace("<!-- site url div -->", '<div id="site-url" data-content="' . $base_url_all . '"></div>', $pageContent);
$pageContent = str_replace("<!-- page id div -->", '<div id="page-id" data-content="' . $pageMeta->pages_id . '"></div>', $pageContent);
$pageContent = str_replace("<!-- page url div -->", '<div id="page-url" data-content="' . $remote_url . '/' . $page . '.php"></div>', $pageContent);
if (!stristr($pageContent, '<link href="' . base_url('elements'))) {
$pageContent = str_replace('<link href="', '<link href="' . $base_url_all . '/', $pageContent);
}
if (stristr($pageContent, '<link href="' . $base_url_all . '/https://')) {
$pageContent = str_replace('<link href="' . $base_url_all . '/https://', '<link href="https://', $pageContent);
}
if (!stristr($pageContent, '<script src="' . $base_url_all . '/js')) {
$pageContent = str_replace('<script src="js', '<script src="' . $base_url_all . '/js', $pageContent);
}
if (stristr($pageContent, 'src="' . $base_url_all . '/https://')) {
$pageContent = str_replace('src="' . $base_url_all . '/https://', 'src="https://', $pageContent);
}
if (stristr($pageContent, '<script src="' . $base_url_all . '/http://')) {
$pageContent = str_replace('<script src="' . $base_url_all . '/http://', '<script src="http://', $pageContent);
}
if (strstr($pageContent, 'src="/elements/images')) {
$pageContent = str_replace('src="/elements/images', 'src="' . $base_url_all . '/images', $pageContent);
}
if (strstr($pageContent, 'url("/elements/images')) {
$pageContent = str_replace('url("/elements/images', 'url("' . site_url('elements/images'), $pageContent);
}
if (strstr($pageContent, 'url("/studentelements/images')) {
$pageContent = str_replace('url("/studentelements/images', 'url("' . site_url('studentelements/images'), $pageContent);
}
if (strstr($pageContent, 'src="/studentelements/images')) {
$pageContent = str_replace('src="/studentelements/images', 'src="' . $base_url_all . '/images', $pageContent);
}
if (stristr($pageContent, 'href="scripts')) {
$pageContent = str_replace('href="scripts', 'href="' . $base_url_all . '/scripts', $pageContent);
}
if (stristr($pageContent, '<script src="scripts')) {
$pageContent = str_replace('<script src="scripts', '<script src="' . $base_url_all . '/scripts', $pageContent);
}
if (stristr($pageContent, 'href="images')) {
$pageContent = str_replace('href="images', 'href="' . $base_url_all . '/images', $pageContent);
}
if (stristr($pageContent, 'src="./images')) {
$pageContent = str_replace('src="./images', 'src="' . $base_url_all . '/images', $pageContent);
}
if (stristr($pageContent, 'src="../elements/scripts')) {
$pageContent = str_replace('src="../elements/scripts', 'src="' . site_url('/elements/scripts'), $pageContent);
}
if (stristr($pageContent, 'href="./images')) {
$pageContent = str_replace('href="./images', 'href="' . $base_url_all . '/images', $pageContent);
}
write_file($absPath . '/' . $page . ".php", trim($pageContent));
// }
isset($userID) && $userID != '' ? remove_directory('./temp/' . $userID) : '';
$this->sitemodel->publish($_POST['siteID'], base_url() . $siteDetails['site']->domain);
if ($siteDetails['site']->url_option == 'freeUrl') {
$this->users_domains_model->domain_publish($_POST['siteID']);
}
//all went well
$return = array();
$return['responseCode'] = 1;
die(json_encode($return));
}
示例13: saveOds
function saveOds($obj, $file)
{
$charset = ini_get('default_charset');
ini_set('default_charset', 'UTF-8');
$tmp = get_tmp_dir();
$uid = uniqid();
mkdir($tmp . '/' . $uid);
file_put_contents($tmp . '/' . $uid . '/content.xml', $obj->array2ods());
file_put_contents($tmp . '/' . $uid . '/mimetype', 'application/vnd.oasis.opendocument.spreadsheet');
file_put_contents($tmp . '/' . $uid . '/meta.xml', $obj->getMeta('pt-BR'));
file_put_contents($tmp . '/' . $uid . '/styles.xml', $obj->getStyle());
file_put_contents($tmp . '/' . $uid . '/settings.xml', $obj->getSettings());
mkdir($tmp . '/' . $uid . '/META-INF/');
mkdir($tmp . '/' . $uid . '/Configurations2/');
mkdir($tmp . '/' . $uid . '/Configurations2/acceleator/');
mkdir($tmp . '/' . $uid . '/Configurations2/images/');
mkdir($tmp . '/' . $uid . '/Configurations2/popupmenu/');
mkdir($tmp . '/' . $uid . '/Configurations2/statusbar/');
mkdir($tmp . '/' . $uid . '/Configurations2/floater/');
mkdir($tmp . '/' . $uid . '/Configurations2/menubar/');
mkdir($tmp . '/' . $uid . '/Configurations2/progressbar/');
mkdir($tmp . '/' . $uid . '/Configurations2/toolbar/');
file_put_contents($tmp . '/' . $uid . '/META-INF/manifest.xml', $obj->getManifest());
$ziper = new zipfile();
$ziper->addFiles($tmp . '/' . $uid, array('META-INF', 'Configurations2', 'content.xml', 'meta.xml', 'mimetype', 'settings.xml', 'styles.xml'));
$ziper->output($file);
remove_directory($tmp . '/' . $uid);
ini_set('default_charset', $charset);
}
示例14: while
}
} else {
if ($op == "gallerycat_del") {
//////////////////////////////////////////// ¡Ã³Õź Form
if (CheckLevel($admin_user, $op)) {
$db->connectdb(DB_NAME, DB_USERNAME, DB_PASSWORD);
$res['gallery'] = $db->select_query("SELECT * FROM " . TB_GALLERY_CAT . " where id='" . $_GET['id'] . "' ");
$arr['gallery'] = $db->fetch($res['gallery']);
$CAT = $arr['gallery']['post_date'];
$res['cat'] = $db->select_query("SELECT * FROM " . TB_GALLERY . " WHERE category='" . $_GET['id'] . "' ");
while ($arr['cat'] = $db->fetch($res['cat'])) {
$db->del(TB_GALLERY, " category='" . $arr['gallery']['id'] . "' ");
$db->del(TB_GALLERY_COMMENT, " gallery_id='" . $arr['cat']['id'] . "' ");
}
$galdir = "images/gallery/gal_" . $CAT . "";
remove_directory($galdir);
$db->del(TB_GALLERY_CAT, " id='" . $_GET['id'] . "' ");
$db->closedb();
$ProcessOutput = "<BR><BR>";
$ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>" . _ADMIN_GALLERY_MESSAGE_DEL_CAT . "</B></FONT><BR><BR>";
$ProcessOutput .= "<A HREF=\"?name=admin&file=gallery\"><B>" . _ADMIN_GALLERY_MESSAGE_GOBACK . "</B></A>";
$ProcessOutput .= "</CENTER>";
$ProcessOutput .= "<BR><BR>";
} else {
//¡Ã³ÕäÁè¼èÒ¹
$ProcessOutput = $PermissionFalse;
}
echo $ProcessOutput;
}
}
示例15: download_template_repo
function download_template_repo(&$output, $template, $childpath = false)
{
# Creating the zip directory for the download
$zip_file = tempnam('/tmp', 'REPODL');
$zip_resource = fopen($zip_file, "w");
# Logging
$output[] = ' - Starting download of template repo "' . $template . '"<br />';
# Loading the master branch from github
$repo_url = 'https://github.com/nuQuery-Templates/' . $template . '/archive/master.zip';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $repo_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FILE, $zip_resource);
$success = curl_exec($ch);
curl_close($ch);
# Error downloading
if (!$success) {
$output[] = ' - Error downloading repo : ' . curl_error($ch) . '<br />';
return false;
} else {
# Logging
$output[] = ' - Download complete, unzipping.<br />';
# Extracting the zip
$zip = new ZipArchive();
$save_path = __DIR__ . '/_installed/';
mkdir($save_path);
if ($zip->open($zip_file) != "true") {
$output[] = ' - Unable to open the Zip File';
return false;
}
$zip->extractTo($save_path);
$zip->close();
# Removing zip
unlink($zip_file);
# Moving directories into root
if ($childpath !== false) {
move_directory($save_path . $template . '-master/', $childpath . '/');
remove_directory($save_path . $template . '-master');
} else {
rename($save_path . $template . '-master', __DIR__ . '/' . $template);
}
# Removing install directory
remove_directory($save_path);
# Logging
$output[] = ' - Install of template "' . $template . '" complete.<br />';
}
# Success
return true;
}