Ejemplo n.º 1
0
function get_folders($root, $subdir = null)
{
    $folders = array();
    if (!empty($subdir)) {
        $path = $root . '/' . $subdir;
    } else {
        $path = $root;
    }
    $di = new DirectoryIterator($path);
    if (!empty($di)) {
        foreach ($di as $fileinfo) {
            if (!$fileinfo->isDir() || $fileinfo->isDot()) {
                continue;
            }
            $name = $fileinfo->getFilename();
            $newsubdir = empty($subdir) ? $name : $subdir . '/' . $name;
            $folders[] = $newsubdir;
            $subdirectories = get_folders($root, $newsubdir);
            if (!empty($subdirectories)) {
                foreach ($subdirectories as $s) {
                    $folders[] = $s;
                }
            }
        }
    }
    return $folders;
}
Ejemplo n.º 2
0
function dir_tree($sPathDir, $arNotToCountOn = array(), $sDS = "/")
{
    $arTree = array();
    if (is_dir($sPathDir)) {
        $arTree[] = $sPathDir;
        //bug($sPathDir,"is dir");
        //bug($arNotToCountOn);
        if (has_dir($sPathDir, $arNotToCountOn, $sDS)) {
            //bug($sPathDir,"has folders");
            $arSubDir = get_folders($sPathDir, $arNotToCountOn, $sDS);
            //bug($arSubDir,"subdir");
            foreach ($arSubDir as $sFolderName) {
                $sPath = $sPathDir . $sDS . $sFolderName;
                //$arTree[] = dir_tree($sPath);
                foreach (dir_tree($sPath, $arNotToCountOn, $sDS) as $sPaths) {
                    $arTree[] = $sPaths;
                }
            }
        }
    }
    return $arTree;
}
Ejemplo n.º 3
0
/**
 * build_settings_formtype
 * 
 * 
 * 
 */
function build_settings_formtype($setting_data)
{
    // options for themes dropdown
    if ($setting_data['property_name'] == 'theme') {
        $theme_dir = WW_ROOT . "/ww_view/themes/";
        $themes = get_folders($theme_dir);
        $setting_data['options'] = '/' . implode(',/', $themes);
    }
    switch ($setting_data['formtype']) {
        // text
        case 'text':
        case 'custom':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $default = $setting_data['formtype'] == 'custom' ? '[custom field]' : $default;
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<input type="text"
						name="' . $setting_data['property_name'] . '" 
						id="' . $setting_data['property_name'] . '" 
						value="' . $setting_data['property_value'] . '"/>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // textarea
        // textarea
        case 'textarea':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<textarea name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" 
						cols="50" rows="3">' . $setting_data['property_value'] . '</textarea>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // select
        // select
        case 'select':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<select name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" >
							<option value="">select...</option>';
            //options for front article dropdown
            if ($setting_data['property_name'] == 'article_id') {
                $articles = get_articles_basic('', '', 'date_uploaded DESC', 25);
                foreach ($articles as $article) {
                    $selected = $article['id'] == $setting_data['property_value'] ? ' selected="selected"' : '';
                    $form_field .= '
								<option value="' . $article['id'] . '"' . $selected . '>' . $article['title'] . '</option>';
                }
            } else {
                // generic options
                $options = explode(",", $setting_data['options']);
                foreach ($options as $option) {
                    $option = trim($option);
                    $selected = $option == $setting_data['property_value'] ? ' selected="selected"' : '';
                    $form_field .= '
								<option value="' . $option . '"' . $selected . '>' . $option . '</option>';
                }
            }
            $form_field .= '
					</select>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // checkbox
            /*	
            	case 'checkbox':
            		$checked = (!empty($setting_data['property_value'])) ? ' checked="checked"' : '' ;
            		$default = (!empty($setting_data['default_value'])) ? 'yes' : 'no' ;
            		$form_field = '
            		<p>
            			<label for="'.$setting_data['property_name'].'">
            				'.str_replace('_',' ',$setting_data['property_name']).'
            			</label>
            			<span class="checkbox">
            			<input type="'.$setting_data['formtype'].'"
            				name="'.$setting_data['property_name'].'" 
            				id="'.$setting_data['property_name'].'" 
            				value="1"'.$checked.'/>
            			</span>
            			<span class="default">'.$default.'</span>
            			<span class="note">'.$setting_data['summary'].'</span>
            		</p>';
            		break;
            */
        // checkbox
        /*	
        	case 'checkbox':
        		$checked = (!empty($setting_data['property_value'])) ? ' checked="checked"' : '' ;
        		$default = (!empty($setting_data['default_value'])) ? 'yes' : 'no' ;
        		$form_field = '
        		<p>
        			<label for="'.$setting_data['property_name'].'">
        				'.str_replace('_',' ',$setting_data['property_name']).'
        			</label>
        			<span class="checkbox">
        			<input type="'.$setting_data['formtype'].'"
        				name="'.$setting_data['property_name'].'" 
        				id="'.$setting_data['property_name'].'" 
        				value="1"'.$checked.'/>
        			</span>
        			<span class="default">'.$default.'</span>
        			<span class="note">'.$setting_data['summary'].'</span>
        		</p>';
        		break;
        */
        case 'checkbox':
            $yes_selected = !empty($setting_data['property_value']) ? ' selected="selected"' : '';
            $no_selected = empty($setting_data['property_value']) ? ' selected="selected"' : '';
            $default = !empty($setting_data['default_value']) ? 'yes' : 'no';
            $opt_class = !empty($setting_data['property_value']) ? ' opt_yes' : '';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<select name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" class="select_checkbox' . $opt_class . '">
						<option value="0"' . $no_selected . '>No</option>
						<option value="1"' . $yes_selected . '>Yes</option>
					</select>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
        default:
            $form_field = '';
    }
    // end switch
    return $form_field;
}
Ejemplo n.º 4
0
if (!empty($theme_files)) {
    $list_files = '
		<ul>';
    foreach ($theme_files as $th_f) {
        $file_link = $_SERVER["PHP_SELF"] . '?page_name=editor&amp;theme=' . $edit_theme . '&amp;file=';
        $list_files .= '
			<li>
				<a href="' . $file_link . $th_f['filename'] . '">' . $th_f['filename'] . '</a> (' . $th_f['size'] . 'b)
			</li>';
    }
    $list_files .= '
		</ul>';
}
$list_themes = '';
$themes_dir = WW_ROOT . "/ww_view/themes/";
$themes = get_folders($themes_dir);
if (!empty($themes)) {
    $list_themes .= '<ul>';
    foreach ($themes as $th) {
        $theme_link = $_SERVER["PHP_SELF"] . '?page_name=editor&amp;theme=' . $th;
        $list_themes .= '
			<li>
				<a href="' . $theme_link . '">' . $th . '</a>
			</li>';
    }
    $list_themes .= '</ul>';
}
$create_file = '
	<p>Create a new css file for ' . $edit_theme . '</p>
		<form action="' . $action_url . '" method="post" name="create_file_form">
		<p><label for="new_file">File name:</label> 
Ejemplo n.º 5
0
} else {
    echo $_SERVER['HTTP_HOST'];
}
?>
</title>
			<link><?php 
echo 'http://' . $_SERVER['HTTP_HOST'] . BASE_URL . 'index.php?rss=' . str_replace(" ", "%20", $params['rss']);
?>
</link>
		</image>

	      <?php 
if ($params['rss']) {
    $albums[] = str_replace("%20", " ", $params['rss']);
} else {
    $albums = get_folders(ALBUMS_ROOT);
}
foreach ($albums as $album) {
    if (is_dir(ALBUMS_ROOT . '/' . $album)) {
        $photos = get_images(ALBUMS_ROOT . '/' . $album);
    } else {
        $photos = array();
    }
    $first = true;
    foreach ($photos as $photo) {
        $title = '<title>' . $photo . '</title>';
        $desc = '<description>&lt;p>&lt;a href="' . 'http://' . $_SERVER['HTTP_HOST'] . str_replace(" ", "%20", BASE_URL . 'albums/' . $album . '/') . $photo . '">&lt;img src="' . 'http://' . $_SERVER['HTTP_HOST'] . str_replace(" ", "%20", BASE_URL . 'albums/' . $album . '/thumb/') . $photo . '" alt="photo" title="" style="float:left; padding-right:10px; padding-bottom:10px;"/>&lt;/a>&lt;/p>&lt;br clear=all></description>';
        $link = '<link>' . 'http://' . $_SERVER['HTTP_HOST'] . str_replace(" ", "%20", BASE_URL . 'albums/' . '/' . $album) . $photo . '</link>';
        $last_modified = exif_read_data(ALBUMS_ROOT . '/' . $album . '/' . $photo);
        $last_modified = mktime(substr($last_modified['DateTimeOriginal'], 11, 2), substr($last_modified['DateTimeOriginal'], 14, 2), substr($last_modified['DateTimeOriginal'], 17, 2), substr($last_modified['DateTimeOriginal'], 5, 2), substr($last_modified['DateTimeOriginal'], 8, 2), substr($last_modified['DateTimeOriginal'], 0, 4));
        if ($last_modified < 950000000) {
Ejemplo n.º 6
0
					<input name="action" type="submit" value="delete"/>
					</span>
				</p>
			</form>
			';
}
// output aside content - into $aside_content variable
$quicklinks = '
			<ul>
				<li><a href="' . $_SERVER["PHP_SELF"] . '?page_name=files">Files</a></li>
				<li><a href="' . $_SERVER["PHP_SELF"] . '?page_name=images">Images</a></li>
				<li><a href="' . $_SERVER["PHP_SELF"] . '?page_name=attachments">Attachments</a></li>
			</ul>';
$aside_content = build_snippet('Quick Links', $quicklinks);
// attachment subfolders
$attachment_folders = get_folders(WW_ROOT . "/ww_files/attachments");
if (!empty($attachment_folders)) {
    $aside_content .= '
		<div class="snippet">
		<h6>Attachment folders</h6>
		<ul>';
    foreach ($attachment_folders as $folder) {
        $aside_content .= '
			<li>
				<a href="' . $_SERVER["PHP_SELF"] . '?page_name=attachments&amp;ext=' . $folder . '">' . $folder . '</a>
			</li>';
    }
    $aside_content .= '
		</ul>
		</div>';
}
Ejemplo n.º 7
0
				</div>
			</div>
			<div class="title_bg"> 
				<div class="title">Manage</div> 
				<div class="module_content">
					<div class="subtitle">Uninstalled Applications</div>
					<table cellspacing="0" cellpadding="0" class="table_table">
						<thead>
							<tr>
								<th>Folder Name</th>
								<th>Actions</th>
							</tr>
						</thead>
						<tbody>
<?php 
    $folders = get_folders(AC_FOLDER_APPLICATIONS);
    $no_installed = true;
    if (!empty($folders)) {
        foreach ($folders as $folder) {
            if (!in_array($folder['name'], $apps_array)) {
                $no_installed = false;
                ?>
							<tr>
								<td><?php 
                echo $folder['name'];
                ?>
</td>
								<td>
<?php 
                if (file_exists(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . AC_FOLDER_APPLICATIONS . DIRECTORY_SEPARATOR . $folder['name'] . DIRECTORY_SEPARATOR . "install_config.php")) {
                    ?>
Ejemplo n.º 8
0
				</div>
			</div>
			<div class="title_bg"> 
				<div class="title">Themes</div> 
				<div class="module_content">
					<div class="subtitle">Uninstalled Themes</div>
					<table cellspacing="0" cellpadding="0" class="table_table">
						<thead>
							<tr>
								<th>Name</th>
								<th>Actions</th>
							</tr>
						</thead>
						<tbody>
<?php 
    $folders = get_folders(AC_FOLDER_THEMES);
    $no_installed = true;
    foreach ($folders as $folder) {
        if (!in_array($folder['name'], $theme_array)) {
            $no_installed = false;
            ?>
							<tr>
								<td><?php 
            echo $folder['name'];
            ?>
</td>
								<td><a href="themes.php?do=install&f=<?php 
            echo $folder['name'];
            ?>
">Install</a></td>
							</tr>
Ejemplo n.º 9
0
function unprotect_folder($vars)
{
    $fl = get_folders();
    $folder = $fl[$vars['folder_id']];
    if (!$folder) {
        die("Folder not found: {$vars['folder_id']}");
    }
    if (is_dir($folder['path'])) {
        $errs = 0;
        foreach ($folder['files_content'] as $fname => $content) {
            $f = "{$folder['path']}/{$fname}";
            if (!is_file($f)) {
                continue;
            }
            $res = unlink($f);
            if (!$res) {
                $errs++;
                $err[] = "File {$f} couldn't be removed - please remove it manually";
            }
        }
    } else {
        print "Folder {$folder['path']} seems to be removed...skipping protection removing step<br />";
    }
    // save folder info now
    global $config, $db;
    $files = $db->escape(serialize($files));
    $db->query("DELETE FROM {$db->config[prefix]}folders\n    WHERE folder_id={$vars[folder_id]}\n    ");
    admin_log("Folder protection removed ({$path}) - {$method}", "folders", $vars['folder_id']);
    if ($errs) {
        print "<font color=red><b>";
        print "Protection has removed, but some errors happened - please follow our recommenendations to fix:<br />";
        foreach ($err as $e) {
            print "<li>{$e}";
        }
        print "<br /><br />after fixing all problems listed above, click <a href='protect.php'>here</a>";
    } else {
        admin_html_redirect("protect.php?added=ok", "Folder un-protected", "Protection has been removed from the folder");
    }
    exit;
}
Ejemplo n.º 10
0
/**
 * Retrieves backups from backup folder and sort them in creation date
 *
 * @param string $folder
 * @return array
 */
function backup_module_get_backups($folder)
{
    $existing_backups = get_folders($folder);
    $existing_backups_list = array();
    if (is_foreachable($existing_backups)) {
        foreach ($existing_backups as $existing_backup) {
            $pathinfo = pathinfo($existing_backup);
            if (strpos($pathinfo['filename'], 'backup ') === 0) {
                $backup_name = $pathinfo['filename'];
                if (preg_match("/backup (.*)-(.*)-(.*) (.*)-(.*) GMT/", $backup_name, $results)) {
                    $timestamp = mktime($results[4], $results[5], 0, $results[2], $results[3], $results[1]);
                    $existing_backups_list[] = array('time' => new DateTimeValue($timestamp), 'timestamp' => $timestamp, 'size' => dir_size($existing_backup), 'complete' => backup_module_backup_is_valid($backup_name), 'path' => $existing_backup);
                }
                // if
            }
            // if
        }
        // foreach
    }
    // if
    // sort arrays by date
    usort($existing_backups_list, 'backup_module_compare_backup_dates');
    return $existing_backups_list;
}
Ejemplo n.º 11
0
/**
 * Recursive remove directory
 *
 * @param string $folder
 * @param string $restriction_path
 * @return boolean
 */
function recursive_rmdir($folder, $restriction_path = '/')
{
    if (DIRECTORY_SEPARATOR == '/') {
        if (strpos($folder, $restriction_path) !== 0) {
            return false;
        }
        // if
    } else {
        if (strpos(strtolower($folder), strtolower($restriction_path)) !== 0) {
            return false;
        }
        // if
    }
    // if
    if (is_dir($folder)) {
        $paths = array_merge(get_files($folder), get_folders($folder));
        foreach ($paths as $path) {
            if (is_dir($path) && !is_link($path)) {
                recursive_rmdir($path, $restriction_path);
            } else {
                unlink($path);
            }
            // if
        }
        // foreach
        return rmdir($folder);
    }
    // if
    return true;
}
Ejemplo n.º 12
0
<h1><?php 
echo $params['title'];
?>
</h1>
<p><?php 
echo $params['subtitle'];
?>
</p>

<h2>Albums</h2>
<ul class="album_list">
	<?php 
foreach (get_folders(ALBUMS_ROOT) as $album) {
    echo '<li>' . l($album, $album) . '</li>';
}
?>
  <br class="clear"/>

</ul>
<?php 
echo '<p>Subscribe feed of all albums as <a href="photo://' . $_SERVER['HTTP_HOST'] . BASE_URL . '?rss">iPhoto photocast</a> or <a href="http://' . $_SERVER['HTTP_HOST'] . BASE_URL . '?rss">RSS</a>.</p>';
?>

<p>&copy; <a href="http://www.naehrstoff.ch" title="Portfolio of Peter Gassner">Peter Gassner</a> &amp; <a href="http://www.artillery.ch" title="Portfolio of Benjamin Wiederkehr">Benjamin Wiederkehr</a> &amp; <a href="http://www.minze.org" title="Portfolio of Carlo Joerges">Carlo Joerges</a> 2008</p>
Ejemplo n.º 13
0
    header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=files');
}
// delete folder
if (isset($_POST['remove_folder'])) {
    if (!empty($_GET['folder'])) {
        $rm_folder = WW_ROOT . '/ww_files/' . $_GET['folder'] . '/';
        rmdir($rm_folder);
        header('Location: ' . WW_WEB_ROOT . '/ww_edit/index.php?page_name=files');
    }
}
// show a 'portal' page if no folder is selected
if (!isset($_GET['folder'])) {
    // list attachment folders
    $attachment_folders = get_folders(WW_ROOT . "/ww_files/attachments/");
    // create link list of custom folders
    $file_folders = get_folders(WW_ROOT . "/ww_files/");
    $exclude = array('_cache', 'attachments', 'images');
    $custom_folders = array();
    foreach ($file_folders as $ff) {
        if (!in_array($ff, $exclude)) {
            $custom_folders[] = array('title' => $ff, 'link' => $_SERVER["PHP_SELF"] . '?page_name=files&amp;folder=' . $ff);
        }
    }
    $right_text = 'files home';
} elseif (isset($_GET['folder'])) {
    $files = get_files(WW_ROOT . '/ww_files/' . $_GET['folder'] . '/');
    $total_files = count($files);
    $right_text = $total_files . ' found';
} elseif (isset($_GET['filename'])) {
    $file_details = get_file_details(WW_ROOT . '/ww_files/' . $_GET['folder'] . '/' . $_GET['filename']);
    $right_text = $_GET['filename'];
Ejemplo n.º 14
0
if ($do == "language") {
    ?>
					<div class="subtitle">Languages</div>
                    <div class="subExplain">
                        <i>If you'd like to add another language, copy the /language/en folder and rename the folder and filename to something else.  The folder and filename MUST be the same.  For example, language/french/french.php or language/fr/fr.php.</i>
                    </div>
					<table cellspacing="0" cellpadding="0" class="table_table">
						<thead>
							<tr>
								<th>Name</th>
								<th>Actions</th>
							</tr>
						</thead>
						<tbody>
<?php 
    $folders = get_folders(AC_FOLDER_LANGUAGE);
    $result = $db->execute("\n\t\t\tSELECT config_value \n\t\t\tFROM arrowchat_config\n\t\t\tWHERE config_name = 'language'\n\t\t");
    $row = $db->fetch_array($result);
    foreach ($folders as $folder) {
        ?>
							<tr>
								<td><?php 
        echo $folder['name'];
        ?>
</td>
<?php 
        if (strtolower($row['config_value']) == strtolower($folder['name'])) {
            ?>
								<td>Currently Activated</td>
<?php 
        } else {