/** * This function returns a recursive list of all subdirectories from a given directory * * @access public * @param string $directory: from this dir the recursion will start. * @param bool $show_hidden (optional): if set to TRUE also hidden dirs (.dir) will be shown. * @param int $recursion_deep (optional): An optional integer to test the recursions-deep at all. * @param array $aList (optional): A simple storage list for the recursion. * @param string $ignore (optional): This is the part of the "path" to be "ignored" * * @return array * * @example: * /srv/www/httpdocs/wb/media/a/b/c/ * /srv/www/httpdocs/wb/media/a/b/d/ * * if $ignore is set - directory_list('/srv/www/httpdocs/wb/media/') will return: * /a * /a/b * /a/b/c * /a/b/d * */ function directory_list($directory, $show_hidden = false, $recursion_deep = 0, &$aList = null, &$ignore = "") { if ($aList == null) { $aList = array(); } if (is_dir($directory)) { // Open the directory $dir = dir($directory); if ($dir != NULL) { while (false !== ($entry = $dir->read())) { // Skip hidden files if ($entry[0] == '.' && $show_hidden == false) { continue; } $temp_dir = $directory . "/" . $entry; if (is_dir($temp_dir)) { // Add dir and contents to list $aList[] = str_replace($ignore, "", $temp_dir); $temp_result = directory_list($temp_dir, $show_hidden, $recursion_deep + 1, $aList, $ignore); } } $dir->close(); } } if ($recursion_deep == 0) { natcasesort($aList); return $aList; } }
/** * directory_list * return an array containing optionally all files, only directiories or only files at a file system path * @author cgray The Metamedia Corporation www.metamedia.us * * @param $base_path string either absolute or relative path * @param $filter_dir boolean Filter directories from result (ignored except in last directory if $recursive is true) * @param $filter_files boolean Filter files from result * @param $exclude string Pipe delimited string of files to always ignore * @param $recursive boolean Descend directory to the bottom? * @return $result_list array Nested array or false * @access public * @license GPL v3 */ function directory_list($directory_base_path, $filter_dir = false, $filter_files = false, $exclude = ".|..|.DS_Store|.svn", $recursive = true) { $directory_base_path = rtrim($directory_base_path, "/") . "/"; if (!is_dir($directory_base_path)) { error_log(__FUNCTION__ . "File at: {$directory_base_path} is not a directory."); return false; } $result_list = array(); $exclude_array = explode("|", $exclude); if (!($folder_handle = opendir($directory_base_path))) { error_log(__FUNCTION__ . "Could not open directory at: {$directory_base_path}"); return false; } else { while (false !== ($filename = readdir($folder_handle))) { if (!in_array($filename, $exclude_array)) { if (is_dir($directory_base_path . $filename . "/")) { if ($recursive && strcmp($filename, ".") != 0 && strcmp($filename, "..") != 0) { // prevent infinite recursion error_log($directory_base_path . $filename . "/"); $result_list[$filename] = directory_list("{$directory_base_path}{$filename}/", $filter_dir, $filter_files, $exclude, $recursive); } elseif (!$filter_dir) { $result_list[] = $filename; } } elseif (!$filter_files) { $result_list[] = $filename; } } } closedir($folder_handle); return $result_list; } }
public function test_directory_clear() { directory_create(self::getDir() . '/another_dir'); file_create(self::getDir() . '/another_file.txt'); $this->assertTrue(count(directory_list(self::getDir())) > 0); directory_clear(self::getDir()); $this->assertEquals(0, count(directory_list(self::getDir()))); }
function media_dirs_rw(&$wb) { global $database; // if user is admin or home-folders not activated then there are no restrictions // at first read any dir and subdir from /media $full_list = directory_list(LEPTON_PATH . MEDIA_DIRECTORY); $allow_list = array(); if ($wb->get_user_id() == 1 || !HOME_FOLDERS) { return $full_list; } //( $wb->get_user_id() == 1 ) || !HOME_FOLDERS // add own home_folder to allow-list if ($wb->get_home_folder()) { $allow_list[] = $wb->get_home_folder(); } //$wb->get_home_folder() // get groups of current user $curr_groups = $wb->get_groups_id(); // if current user is in admin-group if (($admin_key = array_search('1', $curr_groups)) !== false) { // remove admin-group from list unset($curr_groups[$admin_key]); // search for all users where the current user is admin from foreach ($curr_groups as $group) { $sql = 'SELECT `home_folder` FROM `' . TABLE_PREFIX . 'users` '; $sql .= 'WHERE (FIND_IN_SET(\'' . $group . '\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> ' . $wb->get_user_id(); if (($res_hf = $database->query($sql)) != null) { while (false !== ($rec_hf = $res_hf->fetchrow(MYSQL_ASSOC))) { $allow_list[] = $rec_hf['home_folder']; } //false !== ( $rec_hf = $res_hf->fetchrow( MYSQL_ASSOC ) ) } //( $res_hf = $database->query( $sql ) ) != null } //$curr_groups as $group } //( $admin_key = array_search( '1', $curr_groups ) ) !== false $tmp_array = $full_list; // create a list for readwrite dir $array = array(); while (sizeof($tmp_array) > 0) { $tmp = array_shift($tmp_array); $x = 0; while ($x < sizeof($allow_list)) { if (strpos($tmp, $allow_list[$x])) { $array[] = $tmp; } //strpos( $tmp, $allow_list[ $x ] ) $x++; } //$x < sizeof( $allow_list ) } //sizeof( $tmp_array ) > 0 $tmp = array(); $full_list = array_merge($tmp, $array); return $full_list; }
} /** * TinyMCE beallitasai */ if ($_REQUEST['type'] == "mce") { $lang_title = $locale->get('mce_title'); //szukseges tombok feltoltese $mce_theme = array('advanced' => 'advanced', 'simple' => 'simple'); //tema kivalasztasa $form->addElement('select', 'theme', $locale->get('mce_field_theme'), $mce_theme); //nyelv kivalasztasa $form->addElement('select', 'lang', $locale->get('mce_field_lang'), directory_list($libs_dir . '/tiny_mce/langs/', 'js', array(), '1')); //mappa, ahova a tiny-bol feltolti a fileokat $form->addElement('text', 'mcedir', $locale->get('mce_field_updir')); //a css, amit hasznalunk az oldalon $form->addElement('select', 'css', $locale->get('mce_field_css'), directory_list($theme_dir . '/' . $theme . '/', 'css', array(), '1')); //oldal tartalmi reszenek a szelessege - kell az elonezet plugin-hoz $form->addElement('text', 'pwidth', $locale->get('mce_field_pagewidth')); //lekerdezzuk a config tablat, es az eredmenyeket beallitjuk alapertelmezettnek $query = "\n\t\t\tSELECT *\n\t\t\tFROM iShark_Configs\n\t\t"; $result = $mdb2->query($query); while ($row = $result->fetchRow()) { if ($row['mce_uploaddir'] == "") { $uploaddir = substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) - strlen('admin.php')) . 'uploads/tiny_mce/'; } else { $uploaddir = $row['mce_uploaddir']; } $form->setDefaults(array('theme' => $row['mce_theme'], 'lang' => $row['mce_lang'], 'mcedir' => $uploaddir, 'css' => $row['mce_css'], 'pwidth' => $row['mce_pagewidth'])); } $form->applyFilter('__ALL__', 'trim'); $form->addRule('theme', $locale->get('mce_error_theme'), 'required');
function directory_selection($source_value, $command, $entryToExclude, $directoryToExclude) { global $langParentDir, $langTo, $langMove, $langCancel; global $groupset; $backUrl = documentBackLink($entryToExclude); if (!empty($groupset)) { $groupset = '?' . $groupset; } $dirList = directory_list(); $dialogBox = "\n <div class='row'>\n <div class='col-xs-12'>\n <div class='form-wrapper'>\n <form class='form-horizontal' role='form' action='{$_SERVER['SCRIPT_NAME']}{$groupset}' method='post'>\n <fieldset>\n <input type='hidden' name='source' value='" . q($source_value) . "'>\n <div class='form-group'>\n <label for='{$command}' class='col-sm-2 control-label' >{$langMove} {$langTo}:</label>\n <div class='col-sm-10'>\n <select name='{$command}' class='form-control'>"; if ($entryToExclude !== '/' and $entryToExclude !== '') { $dialogBox .= "<option value=''>{$langParentDir}</option>"; } /* build html form inputs */ foreach ($dirList as $path => $filename) { $disabled = ''; $depth = substr_count($path, '/'); $tab = str_repeat(' ', $depth); if ($directoryToExclude !== '/' and $directoryToExclude !== '') { $disabled = strpos($path, $directoryToExclude) === 0 ? ' disabled' : ''; } if ($disabled === '' and $entryToExclude !== '/' and $entryToExclude !== '') { $disabled = $path === $entryToExclude ? ' disabled' : ''; } $dialogBox .= "<option{$disabled} value='" . q($path) . "'>{$tab}" . q($filename) . "</option>"; } $dialogBox .= "</select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-offset-2 col-sm-10'>\n <input class='btn btn-primary' type='submit' value='{$langMove}' >\n <a href='{$backUrl}' class='btn btn-default' >{$langCancel}</a>\n </div>\n </div>\n </fieldset>\n </form>\n </div>\n </div>\n </div>"; return $dialogBox; }
make_dir($temp_subdir); // Include the PclZip class file require_once LEPTON_PATH . '/modules/lib_lepton/pclzip/pclzip.lib.php'; // Setup the PclZip object $archive = new PclZip($temp_file); // Unzip the files to the temp unzip folder $list = $archive->extract(PCLZIP_OPT_PATH, $temp_subdir); /** ***************************** * Check for GitHub zip archive. */ if (!file_exists($temp_subdir . "info.php")) { if (!function_exists("directory_list")) { require LEPTON_PATH . "/framework/functions/function.directory_list.php"; } $temp_dirs = array(); directory_list($temp_subdir, false, 0, $temp_dirs); foreach ($temp_dirs as &$temp_path) { if (file_exists($temp_path . "/info.php")) { $temp_subdir = $temp_path . "/"; break; } } } // Check if uploaded file is a valid Add-On zip file if (!($list && file_exists($temp_subdir . 'index.php'))) { cleanup($temp_unzip, $temp_file); $admin->print_error($MESSAGE['GENERIC_INVALID_ADDON_FILE'] . "[1]"); } // As we are going to check for a valid info.php, let's unset all vars expected // there to see if they're set correctly foreach (array('module_license', 'module_author', 'module_name', 'module_directory', 'module_version', 'module_function', 'module_description', 'module_platform') as $varname) {
/** * @param string|callable $directory * @param int|callable $order_flag * @param resource|callable|null $context * @return callable */ function directory_list_dg($directory, $order_flag = SCANDIR_SORT_ASCENDING, $context = null) { if (!is_callable($directory)) { $directory = return_dg($directory); } if (!is_callable($order_flag)) { $order_flag = return_dg($order_flag); } if (!is_callable($context)) { $context = return_dg($context); } return function () use($directory, $order_flag, $context) { $args = func_get_args(); return directory_list(call_user_func_array($directory, $args), call_user_func_array($order_flag, $args), call_user_func_array($context, $args)); }; }
// initialize template data $dir = pathinfo(dirname(__FILE__), PATHINFO_BASENAME); $data = array_merge(array('FTAN' => method_exists($admin, 'getFTAN') ? $admin->getFTAN() : '', 'files' => array()), $fetch_content); if (!defined('WYSIWYG_EDITOR') || WYSIWYG_EDITOR == "none" || !file_exists(WB_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php')) { function show_wysiwyg_editor($name, $id, $content, $width, $height) { return '<textarea name="' . $name . '" id="' . $id . '" style="width: ' . $width . '; height: ' . $height . ';">' . $content . '</textarea>'; } } else { $id_list = array("content"); require_once WB_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php'; } // list of existing files $wbpath = str_replace('\\', '/', WB_PATH); $basepath = str_replace('\\', '/', WB_PATH . MEDIA_DIRECTORY . '/' . $dlgmodname); $folder_list = directory_list($basepath); array_push($folder_list, $basepath); sort($folder_list); foreach ($folder_list as $name) { // note: the file_list() method returns the full path $file_list = file_list($name, array('index.php')); sort($file_list); foreach ($file_list as $filename) { $thumb_count = substr_count($filename, '/thumbs/'); if ($thumb_count == 0) { $data['files'][] = array(WB_URL . str_replace($wbpath, '', $filename), str_replace($basepath . '/', '', $filename)); } $thumb_count = ""; } } // list of existing groups
function ivr_show_edit($id, $nbroptions, $post) { global $db; global $tabindex; $ivr_details = ivr_get_details($id); $ivr_dests = ivr_get_dests($id); ?> <div class="content"> <h2><?php echo _("Digital Receptionist"); ?> </h2> <h3><?php echo _("Edit Menu") . " " . $ivr_details['displayname']; ?> </h3> <?php ?> <form name="prompt" action="<?php $_SERVER['PHP_SELF']; ?> " method="post" onsubmit="return prompt_onsubmit();"> <input type="hidden" name="action" value="edited" /> <input type="hidden" name="display" value="ivr" /> <input type="hidden" name="id" value="<?php echo $id; ?> " /> <input name="Submit" type="submit" value="<?php echo _("Save"); ?> " tabindex="<?php echo ++$tabindex; ?> " disabled> <?php $usage_list = array(); if (function_exists('queues_ivr_usage')) { $usage_list = queues_ivr_usage($id); } if (count($usage_list)) { ?> <a href="#" class="info"><?php echo _("Queue Breakout Menu Usage List"); ?> <span><?php echo _("This IVR is being used by the following Queues, providing an ability for callers to hear this Queue's announcement periodically and giving callers an option to break out of the queue into this IVR's menu options. This queue can not be deleted when being used in this mode"); ?> </span></a> <?php $count = 0; foreach ($usage_list as $link) { $label = '<span><img width="16" height="16" border="0" title="' . $link['description'] . '" alt="" src="images/queue_link.png"/> ' . $link['description'] . '</span>'; echo "<br /><a href=" . $link['url_query'] . ">" . $label . "</a>"; } echo "<br />"; } else { ?> <input name="delete" type="submit" value="<?php echo _("Delete") . " " . _("Digital Receptionist") . " {$ivr_details['displayname']}"; ?> " disabled/> <?php } if ($id) { $usage_list = framework_display_destination_usage(ivr_getdest($id)); if (!empty($usage_list)) { ?> <br /><a href="#" class="info"><?php echo $usage_list['text']; ?> :<span><?php echo $usage_list['tooltip']; ?> </span></a> <?php } } ?> <table> <tr><td colspan=2><hr /></td></tr> <tr> <td><a href="#" class="info"><?php echo _("Change Name"); ?> <span><?php echo _("This changes the short name, visible on the right, of this IVR"); ?> </span></a></td> <td><input type="text" name="displayname" value="<?php echo $ivr_details['displayname']; ?> " tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php $annmsg_id = isset($ivr_details['announcement_id']) ? $ivr_details['announcement_id'] : ''; if (function_exists('recordings_list')) { //only include if recordings is enabled ?> <tr> <td><a href="#" class="info"><?php echo _("Announcement"); ?> <span><?php echo _("Message to be played to the caller. To add additional recordings please use the \"System Recordings\" MENU to the left"); ?> </span></a></td> <td> <select name="annmsg_id" tabindex="<?php echo ++$tabindex; ?> "> <?php $tresults = recordings_list(); echo '<option value="">' . _("None") . "</option>"; if (isset($tresults[0])) { foreach ($tresults as $tresult) { echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $annmsg_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n"; } } ?> </select> </td> </tr> <?php } else { ?> <tr> <td><a href="#" class="info"><?php echo _("Announcement"); ?> <span><?php echo _("Message to be played to the caller.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option"); ?> </span></a></td> <td> <?php $default = isset($annmsg_id) ? $annmsg_id : ''; ?> <input type="hidden" name="annmsg_id" value="<?php echo $default; ?> "><?php echo $default != '' ? $default : 'None'; ?> </td> </tr> <?php } ?> <tr> <td><a href="#" class="info"><?php echo _("Timeout"); ?> <span><?php echo _("The amount of time (in seconds) before the 't' option, if specified, is used"); ?> </span></a></td> <td><input type="text" name="timeout" value="<?php echo $ivr_details['timeout']; ?> " tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php if ($ivr_details['enable_directory'] && function_exists('voicemail_getVoicemail')) { ?> <tr> <td><a href="#" class="info"><?php echo _("Enable Directory"); ?> <span><?php echo _("Let callers into the IVR dial '#' to access the directory. WARNING: this feature is deprecated and will be removed from future versions. You should install the Directory module and assign an IVR destination to use Directory functionality."); ?> </span></a></td> <td><input type="checkbox" name="ena_directory" <?php echo $ivr_details['enable_directory']; ?> tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <tr> <td><a href="#" class="info"><?php echo _("Directory Context"); ?> <span><?php echo _("When # is selected, this is the voicemail directory context that is used"); ?> </span></a></td> <td> <select name="dircontext" tabindex="<?php echo ++$tabindex; ?> "> <?php $vm_results = voicemail_getVoicemail(); $vmcontexts = array_keys($vm_results); foreach ($vmcontexts as $vmc) { if ($vmc != 'general' && $vmc != 'zonemessages') { echo '<option value="' . $vmc . '"' . ($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '') . '>' . $vmc . "</option>\n"; } } ?> </select> </td> </tr> <?php } ?> <tr> <td><a href="#" class="info"><?php echo _("VM Return to IVR"); ?> <span><?php echo _("If checked, upon exiting voicemail a caller will be returned to this IVR if they got a users voicemail"); ?> </span></a></td> <td><input type="checkbox" name="retvm" <?php echo $ivr_details['retvm']; ?> tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php if (!function_exists('directory_list')) { ?> <tr> <td><a href="#" class="info"><?php echo _("Enable Direct Dial"); ?> <span><?php echo _("Let callers into the IVR dial an extension directly"); ?> </span></a></td> <td><input type="checkbox" name="ena_directdial" <?php echo $ivr_details['enable_directdial']; ?> tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php } else { ?> <tr> <td><a href="#" class="info"><?php echo _("Direct Dial Options"); ?> <span><?php echo _("Provides options for callers to direct dial an extension. Direct dialing can be completely disabled, it can be enabled for all extensions on a system, or it can be tied to a Company Directory allowing any member listed in that directory to be dialed directly if their extension is known. If an extension in the chosen directory is overridden, only that overridden number is dialable"); ?> </span></a></td> <td> <select name="ena_directdial" tabindex="<?php echo ++$tabindex; ?> "> <?php $dlist = directory_list(); echo '<option value=""' . ($ivr_details['enable_directdial'] == '' ? ' SELECTED' : '') . '>' . _('Disabled') . "</option>\n"; echo '<option value="CHECKED"' . (strtoupper($ivr_details['enable_directdial']) == 'CHECKED' ? ' SELECTED' : '') . '>' . _('All Extensions') . "</option>\n"; foreach ($dlist as $dir) { echo '<option value="' . $dir['id'] . '"' . ($ivr_details['enable_directdial'] == $dir['id'] ? ' SELECTED' : '') . '>' . $dir['dirname'] . "</option>\n"; } ?> </select> </td> </tr> <?php } ?> <tr> <td><a href="#" class="info"><?php echo _("Loop Before t-dest"); ?> <span><?php echo _("If checked, and there is a 't' (timeout) destination defined below, the IVR will loop back to the beginning if no input is provided for the designated loop counts prior to going to the timeout (t) destination."); ?> </span></a></td> <td><input type="checkbox" name="alt_timeout" <?php echo $ivr_details['alt_timeout']; ?> tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php $timeout_id = isset($ivr_details['timeout_id']) ? $ivr_details['timeout_id'] : ''; if (function_exists('recordings_list')) { //only include if recordings is enabled ?> <tr> <td><a href="#" class="info"><?php echo _("Timeout Message"); ?> <span><?php echo _("If a timeout occurs and a message is selected, it will be played in place of the announcement message when looping back to the top of the IVR. It will not be played if the t destination is the next target."); ?> </span></a></td> <td> <select name="timeout_id" tabindex="<?php echo ++$tabindex; ?> "> <?php //$tresults obtained above echo '<option value="">' . _("None") . "</option>"; if (isset($tresults[0])) { foreach ($tresults as $tresult) { echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $timeout_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n"; } } ?> </select> </td> </tr> <?php } ?> <tr> <td><a href="#" class="info"><?php echo _("Loop Before i-dest"); ?> <span><?php echo _("If checked, and there is an 'i' (invalid extension) destination defined below, the IVR will play invalid option and then loop back to the beginning for the designated loop counts prior to going to the invalid (i) destination."); ?> </span></a></td> <td><input type="checkbox" name="alt_invalid" <?php echo $ivr_details['alt_invalid']; ?> tabindex="<?php echo ++$tabindex; ?> "></td> </tr> <?php $invalid_id = isset($ivr_details['invalid_id']) ? $ivr_details['invalid_id'] : ''; if (function_exists('recordings_list')) { //only include if recordings is enabled ?> <tr> <td><a href="#" class="info"><?php echo _("Invalid Message"); ?> <span><?php echo _("If an invalid extension is pressed and a message is selected, it will be played in place of the announcement message when looping back to the top of the IVR. It will not be played if the t destination is the next target. If nothing is selected, the system will play a default invalid extension message before going back to the main announcement"); ?> </span></a></td> <td> <select name="invalid_id" tabindex="<?php echo ++$tabindex; ?> "> <?php //$tresults obtained above echo '<option value="">' . _("None") . "</option>"; if (isset($tresults[0])) { foreach ($tresults as $tresult) { echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $invalid_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n"; } } ?> </select> </td> </tr> <?php } ?> <tr> <td><a href="#" class="info"><?php echo _("Repeat Loops:"); ?> <span><?php echo _("The number of times we should loop when invalid input or no input has been entered before going to the defined or default generated 'i' or 't' options. If the 'i' or 't' options are defined, the above check boxes must be checked in order to loop."); ?> </span></a></td> <td> <select name="loops" tabindex="<?php echo ++$tabindex; ?> "> <?php $default = isset($ivr_details['loops']) ? $ivr_details['loops'] : 2; for ($i = 0; $i <= 9; $i++) { echo '<option value="' . $i . '" ' . ($i == $default ? 'SELECTED' : '') . '>' . $i . '</option>'; } ?> </select> </td> </tr> <tr><td colspan=2><hr /></td></tr> <tr><td colspan=2> <input name="increase" type="submit" value="<?php echo _("Increase Options"); ?> " disabled> <input name="Submit" type="submit" value="<?php echo _("Save"); ?> " tabindex="<?php echo ++$tabindex; ?> " disabled> <?php if ($nbroptions > 1) { ?> <input name="decrease" type="submit" value="<?php echo _("Decrease Options"); ?> " disabled> <?php } ?> </td> </tr> <tr><td colspan=2><hr /></td></tr></table> <style type="text/css"> #ivr-dests tr:nth-child(odd){ background-color: #FCE7CE; } </style> <table id="ivr-dests"> <?php // Draw the destinations $dests = ivr_get_dests($id); $count = 0; if (!empty($dests)) { foreach ($dests as $dest) { drawdestinations($count, $dest['selection'], $dest['dest'], $dest['ivr_ret']); $count++; } } while ($count < $nbroptions) { drawdestinations($count, null, null, 0); $count++; } ?> </table> <?php if ($nbroptions < $count) { echo "<input type='hidden' name='nbroptions' value={$count} />\n"; } else { echo "<input type='hidden' name='nbroptions' value={$nbroptions} />\n"; } global $module_hook; echo $module_hook->hookHtml; ?> <input name="increase" type="submit" value="<?php echo _("Increase Options"); ?> " disabled> <input name="Submit" type="submit" value="<?php echo _("Save"); ?> " disabled> <?php if ($nbroptions > 1) { ?> <input name="decrease" type="submit" value="<?php echo _("Decrease Options"); ?> " disabled> <?php } ?> <script language="javascript"> <!-- $(document).ready(function() { $(':submit:disabled').removeAttr('disabled'); }); function delEntry(e){ $('[name=option'+e+'],[name=goto'+e+']').val('').parent().parent().fadeOut(500,function(){$(this).remove();}); } var theForm = document.prompt; theForm.displayname.focus(); function prompt_onsubmit() { var msgInvalidOption = "<?php echo _("Invalid option"); ?> "; defaultEmptyOK = true; // go thru the form looking for options // where the option isn't blank (as that will be removed) do the validation var allelems = theForm.elements; if (allelems != null) { var i, elem; for (i = 0; elem = allelems[i]; i++) { if (elem.type == 'text' && elem.name.indexOf('option') == 0) { if (elem.value != '') { if (!isIVROption(elem.value)) return warnInvalid(elem, msgInvalidOption); var gotoNum = elem.name.charAt(6); var isok = validateSingleDestination(theForm,gotoNum,true); if (!isok) return false; } } } } return true; } //--> </script> </form> </div> <?php }
}); echo color('(' . ($c = count($s3_files)) . ')', 'g') . ' - 100% - ' . color('取得檔案成功!', 'C') . "\n"; echo str_repeat('-', 80) . "\n"; } catch (Exception $e) { echo ' - ' . color('取得檔案失敗!', 'R') . "\n"; exit; } // // ======================================================================== // // ======================================================================== // // ======================================================================== $i = 0; $c = 5; $local_files = array(); echo ' ➜ ' . color('列出即將上傳所有檔案', 'g'); $files = array(); merge_array_recursive(directory_list('..'), $files, '..'); $files = array_filter($files, function ($file) { return in_array(pathinfo($file, PATHINFO_EXTENSION), array('html', 'txt')); }); $files = array_map(function ($file) { return array('path' => $file, 'md5' => md5_file($file), 'uri' => preg_replace('/^(\\.\\.\\/)/', '', $file)); }, $files); echo "\r ➜ " . color('列出即將上傳所有檔案', 'g') . color('(' . count($local_files = array_merge($local_files, $files)) . ')', 'g') . ' - ' . sprintf('% 3d%% ', 100 / $c * ++$i); $files = array(); merge_array_recursive(directory_map('../css'), $files, '../css'); $files = array_filter($files, function ($file) { return in_array(pathinfo($file, PATHINFO_EXTENSION), array('css')); }); $files = array_map(function ($file) { return array('path' => $file, 'md5' => md5_file($file), 'uri' => preg_replace('/^(\\.\\.\\/)/', '', $file)); }, $files);
function directory_selection($source_value, $command, $entryToExclude) { global $langParentDir, $langTo, $langMoveFrom, $langMove, $moveFileNameAlias; global $groupset; if (!empty($groupset)) { $groupset = '?' . $groupset; } $dirList = directory_list(); $dialogBox = "\n <div class='row'>\n <div class='col-xs-12'>\n <div class='form-wrapper'>\n <form class='form-horizontal' role='form' action='{$_SERVER['SCRIPT_NAME']}{$groupset}' method='post'>\n <fieldset>\n <input type='hidden' name='source' value='{$source_value}'>\n <div class='form-group'>\n <label for='{$command}' class='col-sm-4 control-label word-wrapping' >{$langMoveFrom} <b>{$moveFileNameAlias}</b> {$langTo}:</label>\n <div class='col-sm-8'>\n <select name='{$command}' class='form-control'>"; if ($entryToExclude != '/') { $dialogBox .= "<option value=''>{$langParentDir}</option>"; } /* build html form inputs */ foreach ($dirList as $path => $filename) { $depth = substr_count($path, '/'); $tab = str_repeat(' ', $depth); if ($path != $entryToExclude) { $dialogBox .= "<option value='{$path}'>{$tab}{$filename}</option>"; } } $dialogBox .= "</select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-offset-3 col-sm-9'>\n <input class='btn btn-primary' type='submit' value='{$langMove}' >\n </div>\n </div>\n </fieldset>\n </form>\n </div>\n </div>\n </div>"; return $dialogBox; }
function save_media_settings($pathsettings) { global $database, $admin; $retvalue = 0; include_once get_include(LEPTON_PATH . '/framework/summary.functions.php'); if (!is_null($admin->get_post_escaped("save"))) { $sql = 'SELECT COUNT(`name`) FROM `' . TABLE_PREFIX . 'settings` '; $where_sql = 'WHERE `name` = \'mediasettings\' '; $sql = $sql . $where_sql; //Check for existing settings entry, if not existing, create a record first! if (($row = $database->get_one($sql)) == 0) { $sql = 'INSERT INTO `' . TABLE_PREFIX . 'settings` SET '; $where_sql = ''; } else { $sql = 'UPDATE `' . TABLE_PREFIX . 'settings` SET '; } /** * directory_list has been modify. */ $dirs = array(); $skip = LEPTON_PATH; directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip); foreach ($dirs as &$name) { $r = str_replace(array('/', ' '), '_', $name); if ($admin->get_post_escaped($r . '-w') != null) { $w = (int) $admin->get_post_escaped($r . '-w'); $retvalue++; } else { $w = isset($pathsettings[$r]['width']) ? $pathsettings[$r]['width'] : '-'; } $pathsettings[$r]['width'] = $w; if ($admin->get_post_escaped($r . '-h') != null) { $h = (int) $admin->get_post_escaped($r . '-h'); $retvalue++; } else { $h = isset($pathsettings[$r]['height']) ? $pathsettings[$r]['height'] : '-'; } $pathsettings[$r]['height'] = $h; } $pathsettings['global']['admin_only'] = $admin->get_post_escaped('admin_only') != null ? (bool) $admin->get_post_escaped('admin_only') : false; $pathsettings['global']['show_thumbs'] = $admin->get_post_escaped('show_thumbs') != null ? (bool) $admin->get_post_escaped('show_thumbs') : false; $fieldSerialized = serialize($pathsettings); $sql .= '`value` = \'' . $fieldSerialized . '\' '; $sql .= $where_sql; if ($database->query($sql)) { return $retvalue; } } return $retvalue; }
$codelistfile = !($argv[3] == "default") ? $argv[3] : null; if (file_exists("../data/rdf/codelists.rdf")) { $codelists->load("../data/rdf/codelists.rdf"); log_message("Found an existing code-list file to work from", 0); } else { log_message("No code-list file found"); } //Set set up our target model for questions $questions = ModelFactory::getDefaultModel(); $questions->addWithoutDuplicates(new Statement(new Resource("http://www.w3.org/Home/Lassila"), new Resource("http://description.org/schema/Description"), new Literal("Lassila's personal Homepage", "en"))); //Add namespaces add_namespaces(&$questions, $ns); add_namespaces(&$codelists, $ns); print_r($codelists); //Get our list of files and now loop through them to process $files = directory_list(); foreach ($files as $file => $name) { $n++; if ($n > 2) { break 1; } // Limit routine - make sure we only run through a few times if (!file_exists("../data/rdf/{$name}.rdf")) { log_message("Processing {$name}"); parse_file($file, $name, $context, $ns, &$questions, &$codelists); log_message("Processed"); } else { log_message("{$name} has already been converted"); } } $questions->writeAsHTML();
$acttpl = 'error'; $tpl->assign('errormsg', $locale->get('error_permission_denied')); return; } $tpl->assign('self', $module_name); $tpl->assign('title_module', $title_module); if (isset($_GET['file'])) { include_once 'admin/settings/' . $_GET['file']; } else { if ($act == "lst") { //lekerdezzuk es kiirjuk a rendszerben talalhato fooldali modulokat $query = "\n\t\t\tSELECT DISTINCT m.module_id AS mid, m.module_name AS mname, m.file_name AS mfname, m.file_ext AS mfext, \n\t\t\t\tm.description AS mdesc, m.is_active AS mactive, m.type AS mtypem \n\t\t\tFROM iShark_Modules AS m \n\t\t\tWHERE m.is_active = 1 \n\t\t\tGROUP BY m.file_name \n\t\t\tORDER BY m.module_name\n\t\t"; $result = $mdb2->query($query); //ha ures a lista, akkor uzenet if ($result->numRows() != 0) { $dirlist = directory_list('admin/settings', 'php', array(), 1); $i = 0; $itemdata = array(); while ($row = $result->fetchRow()) { //csak akkor rakjuk bele a tombbe, ha letezik hozza adminisztracios file is if (is_array($dirlist) && count($dirlist) > 0 && in_array($row['mfname'], $dirlist) && file_exists('admin/settings/' . $row['mfname'] . $row['mfext'])) { $itemdata[$i]['mname'] = $row['mname']; $itemdata[$i]['mfile'] = $row['mfname']; $itemdata[$i]['mext'] = $row['mfext']; $i++; } } //atadjuk a smarty-nak a kiirando cuccokat $tpl->assign('settinglist', $itemdata); } //megadjuk a tpl file nevet, amit atadunk az admin.php-nek
/** * Delete filesystem files and directories. * * Code taken from WP_Filesystem_Direct class. * * @param string $file Path to the file or directory to delete. * @param boolean $recursive Descend into subdirectories? Defaults to FALSE. * @return boolean Returns TRUE on success, FALSE on failure. */ function delete_path($file, $recursive = false) { if (empty($file)) { //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. return false; } $file = str_replace('\\', '/', $file); //for win32, occasional problems deleting files otherwise if (@is_file($file)) { return @unlink($file); } if (!$recursive && @is_dir($file)) { return @rmdir($file); } //At this point its a folder, and we're in recursive mode $file = trailingslashit($file); $filelist = directory_list($file, true); $retval = true; if (is_array($filelist)) { //false if no files, So check first. foreach ($filelist as $filename) { if (!delete_path($filename, $recursive)) { $retval = false; } } } if (file_exists($file) && !@rmdir($file)) { $retval = false; } return $retval; }
/** * clearCaptcha - kitorli a captcha altal gyartott fajlokat, amik mar felslegesek */ function clearCaptcha() { global $mdb2; $files = directory_list('files/', 'png'); //kiszedjuk a session id-ket a file-okbol $search_sess = array(); if (is_array($files) && !empty($files)) { foreach ($files as $key => $file) { $sess_id = explode('_', $file); //ha tobb elemu a tomb, akkor a masodik elem kell (elso elem a modulra utal) if (count($sess_id) > 1) { $search_sess[$key]['type'] = $sess_id[0]; $search_sess[$key]['id'] = $sess_id[1]; } else { $search_sess[$key]['type'] = ''; $search_sess[$key]['id'] = $sess_id[0]; } } } //vegigmegyunk a session id tombon, es megnezzuk, hogy letezik-e a session a tablaban, ha nem, akkor toroljuk if (is_array($search_sess) && !empty($search_sess)) { foreach ($search_sess as $sess) { $query = "\n\t\t\t\tSELECT session_id\n\t\t\t\tFROM iShark_Sessions\n\t\t\t\tWHERE md5(session_id) = '" . $sess['id'] . "'\n\t\t\t"; $result =& $mdb2->query($query); //ha nincs ilyen mezo, akkor torolheto file if ($result->numRows() == 0) { if ($sess['type'] == '') { @unlink('files/' . $sess['id'] . '.png'); } else { @unlink('files/' . $sess['type'] . '_' . $sess['id'] . '.png'); } } } } }
function directory_configpageinit($pagename) { global $currentcomponent; if ($pagename == 'directory') { //$currentcomponent->addprocessfunc('directory_configprocess'); //$currentcomponent->addguifunc('directory_configpageload'); return true; } if ($pagename == 'ivr') { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; if ($action || $id) { //add help text $currentcomponent->addgeneralarrayitem('directdial_help', 'directory', _('Tied to a Directory allowing all entries in that directory ' . 'to be dialed directly, as they appear in the directory')); //add gui items foreach ((array) directory_list() as $dir) { $name = $dir['dirname'] ? $dir['dirname'] : 'Directory ' . $dir['id']; $currentcomponent->addoptlistitem('directdial', $dir['id'], $name); } } return true; } // We only want to hook 'users' or 'extensions' pages. if ($pagename != 'users' && $pagename != 'extensions') { return true; } $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null; $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null; $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null; if ($tech_hardware != null || $pagename == 'users') { directory_applyhooks(); $currentcomponent->addprocessfunc('directory_configprocess_exten', 8); } elseif ($action == "add") { // We don't need to display anything on an 'add', but we do need to handle returned data. $currentcomponent->addprocessfunc('directory_configprocess_exten', 8); } elseif ($extdisplay != '') { // We're now viewing an extension, so we need to display _and_ process. directory_applyhooks(); $currentcomponent->addprocessfunc('directory_configprocess_exten', 8); } }
// Remove any vars with name "template_directory" and "theme_directory" unset($template_directory); unset($theme_directory); // Setup the PclZip object $archive = new PclZip($temp_file); // Unzip the files to the temp unzip folder $list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip); /** ***************************** * Check for GitHub zip archive. */ if (!file_exists($temp_unzip . "info.php")) { if (!function_exists("directory_list")) { require LEPTON_PATH . "/framework/functions/function.directory_list.php"; } $temp_dirs = array(); directory_list($temp_unzip, false, 0, $temp_dirs); foreach ($temp_dirs as &$temp_path) { if (file_exists($temp_path . "/info.php")) { $temp_unzip = $temp_path . "/"; break; } } } // Check if uploaded file is a valid Add-On zip file if (!($list && file_exists($temp_unzip . 'index.php'))) { $admin->print_error($MESSAGE['GENERIC']['INVALID_ADDON_FILE']); } // Include the templates info file require $temp_unzip . 'info.php'; // Perform Add-on requirement checks before proceeding require LEPTON_PATH . '/framework/summary.addon_precheck.php';
$i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $username_fieldname = $username_fieldname . $tmp; $i++; } // Work-out if home folder should be shown if (!HOME_FOLDERS) { $template->set_var('DISPLAY_HOME_FOLDERS', 'display:none;'); } // Include the WB functions file require_once WB_PATH . '/framework/functions.php'; // Add media folders to home folder list $template->set_block('main_block', 'folder_list_block', 'folder_list'); foreach (directory_list(WB_PATH . MEDIA_DIRECTORY) as $name) { $template->set_var('NAME', str_replace(WB_PATH, '', $name)); $template->set_var('FOLDER', str_replace(WB_PATH . MEDIA_DIRECTORY, '', $name)); if ($user['home_folder'] == str_replace(WB_PATH . MEDIA_DIRECTORY, '', $name)) { $template->set_var('SELECTED', ' selected="selected"'); } else { $template->set_var('SELECTED', ' '); } $template->parse('folder_list', 'folder_list_block', true); } // Insert language text and messages $template->set_var(array('TEXT_RESET' => $TEXT['RESET'], 'TEXT_CANCEL' => $TEXT['CANCEL'], 'TEXT_ACTIVE' => $TEXT['ACTIVE'], 'TEXT_DISABLED' => $TEXT['DISABLED'], 'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], 'TEXT_USERNAME' => $TEXT['USERNAME'], 'TEXT_PASSWORD' => $TEXT['PASSWORD'], 'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], 'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], 'TEXT_EMAIL' => $TEXT['EMAIL'], 'TEXT_GROUP' => $TEXT['GROUP'], 'TEXT_NONE' => $TEXT['NONE'], 'TEXT_HOME_FOLDER' => $TEXT['HOME_FOLDER'], 'USERNAME_FIELDNAME' => $username_fieldname, 'CHANGING_PASSWORD' => $MESSAGE['USERS_CHANGING_PASSWORD'], 'HEADING_MODIFY_USER' => $HEADING['MODIFY_USER'])); // Parse template object $template->parse('main', 'main_block', false); $template->pparse('output', 'page'); // Print admin footer
function build_page(&$admin, &$database) { global $HEADING, $TEXT, $MENU, $MESSAGE; // Include the functions file include_once get_include(LEPTON_PATH . '/framework/summary.functions.php'); include_once get_include(ADMIN_PATH . '/media/function.inc.php'); $memory_limit = ini_get('memory_limit'); $post_max_size = ini_get('post_max_size'); $upload_max_filesize = ini_get('upload_max_filesize'); $maxUploadFiles = 12; $request = $_SERVER['REQUEST_METHOD']; $allowed_img_types = 'jpg|png|gif|tif'; $actions = isset($_POST['action']) ? trim(stripslashes($admin->get_post('action'))) : 'show'; $actions = isset($_POST['media_reload']) && $_POST['media_reload'] == true ? 'media_reload' : $actions; $actions = isset($_POST['cancel']) ? 'show' : $actions; // Get home folder not to show $home_folders = get_home_folders(); $currentHome = $admin->get_home_folder(); $pathsettings = get_media_settings(); // Get the user specified dir parent_path if ($request == 'GET' && isset($_REQUEST)) { $directory = rawurldecode(trim(stripslashes($admin->get_get('dir')))); } elseif (isset($_POST['current_select'])) { $directory = str_replace(MEDIA_DIRECTORY, '', rawurldecode(trim(stripslashes($admin->get_post('current_select'))))); } elseif (isset($_POST['current_dir'])) { $directory = rawurldecode(trim(stripslashes($admin->get_post('current_dir')))); } //$directory = is_null($directory) ? $currentHome : $directory; // $directory is not always null ... 8-/ $directory = is_null($directory) || empty($directory) ? $currentHome : $directory; $directory = $directory == '/' || $directory == '\\' ? '' : $directory; $target = $current_dir = $directory; $backlink = 'index.php?dir=' . $directory; $FILE = array(); $dirs = array(); $skip = LEPTON_PATH; directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip); // dirs with readWrite access $dirs_rw = media_dirs_rw($admin); array_walk($dirs_rw, 'remove_path', LEPTON_PATH); if ($admin->get_user_id() == 1) { $id = array_unshift($dirs_rw, MEDIA_DIRECTORY); } // Define absolute path to WB media directory (using Unix path seperator) $mediaPath = str_replace('\\', '/', LEPTON_PATH . MEDIA_DIRECTORY); /* comment out to show only Home Folder till yet not build in overall $acess_denied = (($currentHome != '') && (strpos($mediaPath.$directory, $currentHome))) ? false : true; */ // sytem_admin if not superadmin, no homefolder, groupmember 1 $system_admin = $admin->ami_group_member('1') == true || $admin->get_user_id() == 1; $group_admin = empty($currentHome) == true && $admin->ami_group_member('1') == true; //$full_home_folder_access = $directory == '' || in_array(MEDIA_DIRECTORY.$directory, $dirs_rw) || $group_admin ; /* * If HOME_FOLDERS are not active the user have access to all media files, * otherwise check if the shown folders in list are within the personal folder * and grant desired rights only for this folders (upload, create directory a.s.o.) */ $full_home_folder_access = !HOME_FOLDERS ? true : empty($_SESSION['HOME_FOLDER']) || in_array(MEDIA_DIRECTORY . $directory, $dirs_rw) || $group_admin; if (strstr($current_dir, '..')) { // target_path contains ../ $admin->print_error($MESSAGE['MEDIA_TARGET_DOT_DOT_SLASH'], $backlink); } // Build canonicalized absolute path from user input and check if path exists (False if not) $userPath = str_replace('\\', '/', realpath($mediaPath . $directory)); // Ensure that the user specified path is located inside WB media folder if ($userPath == false || strpos($userPath, $mediaPath) !== 0) { // User defined path is invalid or is located outside the WB media directory $admin->print_error($MESSAGE['MEDIA_DIR_ACCESS_DENIED'], $backlink); } if (!is_writeable($mediaPath . $directory)) { $admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], $backlink); } $tpl = new Template(THEME_PATH . '/templates', 'keep'); // false | true $tpl->debug = false; $file_array = array('page' => 'media.htt', 'browse' => 'media_browse.htt', 'rename' => 'media_rename.htt', 'settings' => 'setparameter.htt'); $tpl->set_file($file_array); $tpl->set_block('page', 'main_block', 'main'); // BEGIN left side always with main_block and the dropdown list may later as dirtree // First insert language text and messages $tpl->set_var(array('TEXT_RELOAD' => $TEXT['RELOAD'], 'TEXT_TARGET_FOLDER' => $TEXT['TARGET_FOLDER'], 'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], 'TEXT_NAME' => $TEXT['TITLE'], 'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], 'TEXT_UNZIP_FILE' => $TEXT['UNZIP_FILE'], 'TEXT_DELETE_ZIP' => $TEXT['DELETE_ZIP'], 'TEXT_OVERWRITE_EXISTING' => $TEXT['OVERWRITE_EXISTING'], 'TEXT_FILES' => $TEXT['FILES'])); $tpl->set_var(array('USER_ID' => $admin->is_authenticated() ? $admin->get_user_id() : '', 'ADMIN_URL' => ADMIN_URL, 'LEPTON_URL' => LEPTON_URL, 'LEPTON_PATH' => LEPTON_PATH, 'THEME_URL' => THEME_URL)); // && (($admin->ami_group_member('1') != true) || ($admin->get_user_id() != 1)) // set optionen media_settings_block $tpl->set_block('main_block', 'media_settings_block', 'media_settings'); // Only show admin the settings link if ($pathsettings['global']['admin_only'] == true) { if ($system_admin != true) { $tpl->set_var('DISPLAY_SETTINGS', 'hide'); $tpl->set_block('media_settings', ''); } else { $tpl->parse('media_settings', 'media_settings_block', true); } } else { $tpl->parse('media_settings', 'media_settings_block', true); } // set optionen media_upload_block $tpl->set_var(array('CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'], 'HEADING_BROWSE_MEDIA' => $HEADING['BROWSE_MEDIA'], 'HEADING_MEDIA' => $MENU['MEDIA'] . ' ' . $TEXT['FOLDERS'], 'HEADING_CREATE_FOLDER' => $HEADING['CREATE_FOLDER'], 'HEADING_UPLOAD_FILES' => $HEADING['UPLOAD_FILES'], 'OPTIONS' => $TEXT['OPTION'], 'SETTINGS_URL' => $_SERVER['SCRIPT_NAME'])); $tpl->set_var(array('HOME_DIRECTORY' => $currentHome, 'MEDIA_DIRECTORY' => MEDIA_DIRECTORY, 'CURRENT_DIR' => $directory)); // create dropdownlist dir_list_block $tpl->set_block('main_block', 'dir_list_block', 'dir_list'); // select the correct directory list $use_dirs = !HOME_FOLDERS ? $dirs : empty($_SESSION['HOME_FOLDER']) ? $dirs : $dirs_rw; if (count($use_dirs) > 0) { foreach ($use_dirs as $name) { // prevent duplicate entries - default directory is also set by template! if ($name == MEDIA_DIRECTORY . $currentHome) { continue; } $tpl->set_var(array('MEDIA_NAME' => $name, 'SELECTED' => MEDIA_DIRECTORY . $directory == $name ? ' selected="selected"' : '')); $tpl->parse('dir_list', 'dir_list_block', true); } } else { $tpl->set_var('dir_list', ''); } // Insert permissions values, hide for some actions // workout action should show default blocks switch ($actions) { // all others remove from left side case 'none': case 'show': case 'media_reload': case 'media_create': case 'media_upload': case 'media_delete': case 'save_media_rename': $tpl->set_block('main_block', 'media_create_block', 'media_create'); if ($admin->get_permission('media_create') != true || $full_home_folder_access == false) { $tpl->set_var('DISPLAY_CREATE', 'hide'); $tpl->set_block('media_create', ''); } else { $tpl->set_var(array('DISPLAY_CREATE' => '', 'MAX_UPLOADS' => $maxUploadFiles, 'ALLOW_EXTS' => RENAME_FILES_ON_UPLOAD)); $tpl->parse('media_create', 'media_create_block', true); } $tpl->set_block('main_block', 'input_upload_block', 'input_upload'); for ($x = 0; $x <= $maxUploadFiles; $x++) { $tpl->parse('input_upload', 'input_upload_block', true); } $tpl->set_block('main_block', 'media_upload_block', 'media_upload'); if ($admin->get_permission('media_upload') != true || $full_home_folder_access == false) { $tpl->set_var('DISPLAY_UPLOAD', 'hide'); $tpl->set_block('media_upload', ''); } else { $tpl->set_var(array('DISPLAY_UPLOAD' => '')); $tpl->parse('media_upload', 'media_upload_block', true); } break; default: // all the other action has to hide the blocks $tpl->set_block('main_block', 'media_create_block', 'media_create'); $tpl->set_var('DISPLAY_CREATE', 'hide'); $tpl->parse('media_create', ''); $tpl->set_block('main_block', 'media_upload_block', 'media_upload'); $tpl->set_var('DISPLAY_UPLOAD', 'hide'); $tpl->parse('media_upload', ''); break; } // END workout main_wrapper // Now prepare and parse values for the wrapper template show modus switch ($actions) { case 'none': case 'show': case 'media_reload': case 'media_create': case 'media_upload': case 'media_delete': case 'save_media_rename': $tpl->loadfile('browse'); $tpl->set_block('main_block', 'main_wrapper_block', 'browse'); // Workout the parent dir link PARENT_PATH //$parent_path = !empty($directory) ? dirname($directory) : $directory; if (!empty($directory)) { if (HOME_FOLDERS && !empty($_SESSION['HOME_FOLDER'])) { $parent_path = $_SESSION['HOME_FOLDER']; } else { $parent_path = dirname($directory); } } else { $parent_path = $directory; } // $parent_dir_link = ADMIN_URL.'/media/index.php?dir='.$directory.'&up=1'; $parent_dir_link = 1; // Workout if the up arrow should be shown $display_up_arrow = ''; // $display_up_arrow = (($directory == '') || ($directory == $currentHome)) ? 'hide' : ''; // Insert header info values main_wrapper_block $tpl->set_var(array('THEME_URL' => THEME_URL, 'ROOT_DIRECTORY' => MEDIA_DIRECTORY, 'MEDIA_DIRECTORY' => MEDIA_DIRECTORY, 'CURRENT_PATH' => $directory, 'PARENT_DIR_LINK' => $parent_dir_link, 'PARENT_PATH' => $parent_path)); $tpl->set_block('browse', 'up_link_block', 'up_link'); if (!empty($directory) && $directory != $parent_path) { // show only if parent <> directory $tpl->set_var(array('PARENT_DIR_LINK' => $parent_dir_link, 'TEXT_UP' => $TEXT['UP'], 'DISPLAY_UP_ARROW' => '')); $tpl->parse('up_link', 'up_link_block', true); } else { $tpl->set_block('up_link', ''); $tpl->set_var(array('UP_LINK_COL' => ' display_up_arrow', 'TEXT_UP' => $TEXT['UP'], 'DISPLAY_UP_ARROW' => ' display_up_arrow')); } // now set the dirs and files file_list_block and permissions $tpl->set_block('browse', 'file_list_block', 'file_list'); $tpl->set_block('file_list', 'media_rename_block', 'media_rename'); $tpl->set_block('file_list', 'media_delete_block', 'media_delete'); // get dirs and files in currentDir $FILE = scan_current_dir(LEPTON_PATH . MEDIA_DIRECTORY . '/' . $directory); $temp_id = 0; $line = $row_id = 1; if (count($FILE['path']) > 0) { foreach ($FILE['path'] as $name) { $temp_id++; $link_name = str_replace(' ', '%20', $name); $tpl->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $temp_id, 'LINK' => 'index.php?dir=' . $directory . '/' . $link_name, 'LINK_RELATION' => '', 'ROW_ID' => $line++ & 1, 'FT_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE' => 'dir', 'FILENAME' => '/' . addslashes($name), 'LINK_TARGET' => '_self', 'ENABLE_OVERLIB' => '', 'EXTENSION' => '', 'MOUSEOVER' => '', 'CLASS_PREVIEW' => '', 'IMAGEDETAIL' => '', 'DISPLAY_ICON' => '', 'SIZE' => '', 'DATE' => '', 'PREVIEW' => '', 'LINK_PATH' => $directory . '/' . $link_name, 'MEDIA_PATH' => MEDIA_DIRECTORY)); $tpl->parse('file_list', 'file_list_block', true); } } // now set the files file_list_block and permissions if (count($FILE['filename']) > 0) { // convert to correct searchpattern $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD); foreach ($FILE['filename'] as $name) { $preview = 'preview'; if (!preg_match("/\\." . $allowed_file_types . "\$/i", $name)) { $preview = ''; continue; } $temp_id++; $overlib = preg_match("/\\." . $allowed_img_types . "\$/i", $name) ? ' overlib' : ''; if ($preview) { $filetype = get_filetype(LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name); $size = filesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name); $bytes = byte_convert($size); $fdate = filemtime(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name); $date = date(DATE_FORMAT . ' ' . TIME_FORMAT, $fdate); $filetypeicon = get_filetype_icon(LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name); $tooltip = ''; $imgdetail = $bytes; $icon = THEME_URL . '/images/files/unknown.png'; if (!$pathsettings['global']['show_thumbs']) { $info = @getimagesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name); if ($info[0]) { $imgdetail = fsize(filesize(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name)) . '<br /> ' . $info[0] . ' x ' . $info[1] . ' px'; $icon = 'thumb.php?t=1&img=' . $directory . '/' . $name; $tooltip = ShowTip('thumb.php?t=2&img=' . $directory . '/' . $name, $allowed_img_types); } else { $icon = THEME_URL . '/images/files/' . $filetypeicon . '.png'; } } else { $filetypeicon = get_filetype_icon(LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $name); $icon = THEME_URL . '/images/files/' . $filetypeicon . '.png'; } $tpl->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $temp_id, 'LINK' => LEPTON_URL . MEDIA_DIRECTORY . $directory . '/' . $name, 'LINK_RELATION' => '', 'ROW_ID' => $line++ & 1, 'FT_ICON' => $icon, 'FILETYPE_ICON' => THEME_URL . '/images/files/' . $filetypeicon . '.png', 'FILENAME' => addslashes($name), 'LINK_TARGET' => '_top', 'ENABLE_OVERLIB' => $overlib, 'FILETYPE' => 'file', 'EXTENSION' => $filetype, 'MOUSEOVER' => $tooltip, 'CLASS_PREVIEW' => '', 'IMAGEDETAIL' => $imgdetail, 'DISPLAY_ICON' => '', 'SIZE' => $bytes, 'DATE' => $date, 'PREVIEW' => $preview)); $tpl->parse('file_list', 'file_list_block', true); } } } $tpl->set_var(array('TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'], 'TEXT_RELOAD' => $TEXT['RELOAD'], 'TEXT_RENAME' => $TEXT['RENAME'], 'TEXT_DELETE' => $TEXT['DELETE'], 'TEXT_SIZE' => $TEXT['SIZE'], 'TEXT_DATE' => $TEXT['DATE'], 'TEXT_NAME' => $TEXT['NAME'], 'TEXT_TYPE' => $TEXT['TYPE'], 'MEDIA_BROWSE' => '', 'NONE_FOUND' => $MESSAGE['MEDIA_NONE_FOUND'], 'CHANGE_SETTINGS' => $TEXT['MODIFY_SETTINGS'], 'CONFIRM_DELETE' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE']), 'CONFIRM_DELETE_FILE' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE_FILE']), 'CONFIRM_DELETE_DIR' => js_alert_encode($MESSAGE['MEDIA_CONFIRM_DELETE_DIR']))); // If no files are in the media folder say so if ($temp_id == 0) { $tpl->set_var('DISPLAY_LIST_TABLE', ' hide'); $tpl->set_var('DISPLAY_NONE_FOUND', ' center'); $tpl->set_var("file_list_block", "<tr><td></td></tr>"); $tpl->parse('file_list', 'file_list_block', true); } else { $tpl->set_var('DISPLAY_LIST_TABLE', ''); $tpl->set_var('DISPLAY_NONE_FOUND', ' hide'); } $tpl->set_block('file_list', 'media_rename_block', 'media_rename'); $tpl->set_block('file_list', 'media_delete_block', 'media_delete'); // Insert permissions values if ($admin->get_permission('media_rename') != true || $full_home_folder_access == false) { $tpl->set_var('DISPLAY_RENAME', 'hide'); $tpl->set_var('RENHAME_CONTENT', ''); $tpl->parse('media_rename', ''); } else { $tpl->set_var('RENHAME_CONTENT', ''); $tpl->parse('media_rename', 'media_rename_block', true); } if ($admin->get_permission('media_delete') != true || $full_home_folder_access == false) { $tpl->set_var('DISPLAY_DELETE', 'hide'); $tpl->set_var('DELETE_CONTENT', ''); $tpl->parse('media_delete', ''); } else { $tpl->set_var('DELETE_CONTENT', ''); $tpl->parse('media_delete', 'media_delete_block', true); } break; } // begin with save modus actions switch ($actions) { // save actions case 'save_media_settings': if (($x = save_media_settings($pathsettings)) == 0) { $admin->print_error($MESSAGE['SETTINGS_UNABLE_WRITE_CONFIG'], $backlink); } else { $admin->print_success($MESSAGE['SETTINGS_SAVED'], $backlink); } break; case 'save_media_rename': $ext = trim(stripslashes($admin->get_post('extension'))); $ext = empty($ext) ? '' : '.' . $ext; $old_file = media_filename(trim(stripslashes($admin->get_post('old_name')))) . $ext; $rename_file = media_filename(trim(stripslashes($admin->get_post('name')))) . $ext; $type = trim(stripslashes($admin->get_post('filetype'))); // perhaps change dots in underscore by tpye = directory $rename_file = trim($rename_file, '.'); $old_file = LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $old_file; $rename_file = LEPTON_PATH . MEDIA_DIRECTORY . $directory . '/' . $rename_file; if ($type == 'dir') { $rename_file = str_replace('.', '_', $rename_file); } elseif (!preg_match("/\\." . $allowed_file_types . "\$/i", $rename_file)) { $admin->print_error($TEXT['EXTENSION'] . ': ' . $MESSAGE['GENERIC_INVALID'], $backlink); } if (rename($old_file, $rename_file)) { $admin->print_success($MESSAGE['MEDIA_RENAMED'], $backlink); } else { $admin->print_error($MESSAGE['MEDIA_CANNOT_RENAME'], $backlink); } break; } // mask input modus switch ($actions) { case 'media_rename': clearstatcache(); $rename_file = media_filename(trim(stripslashes($admin->get_post('filename')))); $ext = trim(stripslashes($admin->get_post('fileext'))); $type = trim(stripslashes($admin->get_post('filetype'))); $rename_file = basename($rename_file); $tpl->loadfile('rename'); $tpl->set_block('main_block', 'main_wrapper_block', 'rename'); // false | true $tpl->debug = false; $tpl->set_var(array('THEME_URL' => THEME_URL, 'TEXT_CURRENT_FOLDER' => $TEXT['CURRENT_FOLDER'], 'FILENAME' => $rename_file, 'BASENAME' => trim(str_replace($ext, '', basename($rename_file)), '.'), 'ROOT_DIRECTORY' => MEDIA_DIRECTORY, 'DISPLAY_UP_ARROW' => ' display_up_arrow', 'CURRENT_PATH' => $directory, 'DIR' => $directory, 'FILE_TYPE' => $type, 'EXTENSION' => '.' . ltrim($ext, '.'), 'FILE_EXT' => ltrim($ext, '.'), 'TEXT_OVERWRITE_EXIST' => $TEXT['OVERWRITE_EXISTING'], 'TEXT_TO' => '', 'MEDIA_BROWSE' => '', 'TEXT_RENAME' => $TEXT['RENAME'], 'TEXT_CANCEL' => $TEXT['CANCEL'])); $tpl->parse('rename', 'main_wrapper_block', true); break; case 'media_settings': // load template language file $lang = THEME_PATH . '/languages/' . LANGUAGE . '.php'; include_once !file_exists($lang) ? THEME_PATH . '/languages/EN.php' : $lang; $tpl->loadfile('settings'); $tpl->set_block('main_block', 'main_wrapper_block', 'settings'); // false | true $tpl->debug = false; $admin_only = isset($pathsettings['global']['admin_only']) && $pathsettings['global']['admin_only'] == true ? ' checked="checked"' : ''; $show_thumbs = isset($pathsettings['global']['show_thumbs']) && $pathsettings['global']['show_thumbs'] == true ? ' checked="checked"' : ''; $tpl->set_var(array('TEXT_HEADER' => $TEXT['TEXT_HEADER'], 'SAVE_TEXT' => $TEXT['SAVE'], 'CANCEL' => $TEXT['CANCEL'], 'RESET' => $TEXT['RESET'], 'NO_SHOW_THUMBS' => $TEXT['NO_SHOW_THUMBS'], 'MEDIA_BROWSE' => '', 'ADMIN_ONLY' => $TEXT['ADMIN_ONLY'], 'SETTINGS' => $TEXT['SETTINGS'], 'CURRENT_PATH' => $directory, 'ADMIN_URL' => ADMIN_URL, 'WIDTH' => $TEXT['WIDTH'], 'HEIGHT' => $TEXT['HEIGHT'], 'ADMIN_ONLY_SELECTED' => $admin_only, 'NO_SHOW_THUMBS_SELECTED' => $show_thumbs, 'NONE_FOUND' => '', 'DISPLAY_NONE' => '')); // Get dirs in currentDir $dirs = array(); $skip = LEPTON_PATH; directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip); $line = $row_id = 1; $tpl->set_block('settings', 'dir_settings_block', 'dir_settings'); if (isset($dirs)) { $good_dirs = 0; $dir_filter = MEDIA_DIRECTORY . $directory; $parent = substr_count($dir_filter, '/') + 1; $dir_filter = str_replace(array('/', ' '), '_', $dir_filter); foreach ($dirs as $name) { $relative = $name; // str_replace(LEPTON_PATH, '', $name); $subparent = substr_count($relative, '/') + 1; $safepath = str_replace(array('/', ' '), '_', $relative); $continue = strlen(str_replace($safepath, '', $dir_filter)); // if( (substr_count($safepath,$dir_filter) == 0) || ( $dir_filter == $safepath ) ) if ($parent != $subparent - 1 || substr_count($safepath, $dir_filter) == 0 || $dir_filter == $safepath) { continue; } $good_dirs++; $cur_width = $cur_height = ''; if (isset($pathsettings[$safepath]['width'])) { $cur_width = $pathsettings[$safepath]['width']; } if (isset($pathsettings[$safepath]['height'])) { $cur_height = $pathsettings[$safepath]['height']; } $cur_width = $cur_width != 0 ? (int) $cur_width : '-'; $cur_height = $cur_height != 0 ? (int) $cur_height : '-'; $tpl->set_var(array('PATH_NAME' => basename($relative), 'FIELD_NAME' => $safepath, 'CUR_WIDTH' => $cur_width, 'CUR_HEIGHT' => $cur_height, 'ROW_ID' => $line++ & 1)); $tpl->parse('dir_settings', 'dir_settings_block', true); } if ($good_dirs == 0) { $tpl->set_var(array('PATH_NAME' => '', 'FIELD_NAME' => '', 'CUR_WIDTH' => '', 'CUR_HEIGHT' => '', 'ROW_ID' => '', 'DISPLAY_NONE' => ' hide')); $tpl->parse('dir_settings', 'dir_settings_block', true); $tpl->set_var('NONE_FOUND', $MESSAGE['MEDIA_NONE_FOUND']); $tpl->parse('settings', 'dir_settings_block', true); } } else { $tpl->set_var('NONE_FOUND', $MESSAGE['MEDIA_NONE_FOUND']); $tpl->parse('settings', 'dir_settings_block', true); } break; } // normal actions switch ($actions) { case 'media_upload': $target_path = str_replace('\\', '/', LEPTON_PATH . MEDIA_DIRECTORY . $directory); // Create relative path of the new dir name $resizepath = MEDIA_DIRECTORY . $directory; $resizepath = str_replace(array('/', ' '), '_', $resizepath); // Find out whether we should replace files or give an error $overwrite = $admin->get_post('overwrite') != '' ? true : false; // convert to correct searchpattern $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD); $good_uploads = 0; // If the user chose to unzip the first file, unzip into the current folder if (isset($_POST['unzip']) && $_POST['unzip'] == true) { // include_once(get_include('thumb.php')); if (isset($_FILES['upload']['error'][0]) && $_FILES['upload']['error'][0] == UPLOAD_ERR_OK) { $src_file = isset($_FILES['upload']['name'][0]) ? $_FILES['upload']['name'][0] : null; if ($src_file && preg_match('/\\.zip$/i', $src_file)) { /* * Callback function to skip files not in white-list */ function pclzipCheckValidFile($p_event, &$p_header) { // return 1; $allowed_file_types = str_replace(',', '|', RENAME_FILES_ON_UPLOAD); $info = pathinfo($p_header['filename']); $ext = isset($info['extension']) ? $info['extension'] : ''; $dots = substr($info['basename'], 0, 1) == '.' || substr($info['basename'], -1, 1) == '.'; if (preg_match('/' . $allowed_file_types . '$/i', $ext) && $dots != '.') { // ----- allowed file types are extracted return 1; } else { // ----- all other files are skiped return 0; } } /* ********************************* */ require_once get_include(LEPTON_PATH . '/modules/lib_lepton/pclzip/pclzip.lib.php'); $archive = new PclZip($_FILES['upload']['tmp_name'][0]); $list = $archive->extract(PCLZIP_OPT_PATH, $target_path, PCLZIP_CB_PRE_EXTRACT, 'pclzipCheckValidFile'); $good_uploads = sizeof($list); if ($archive->error_code != 0) { $admin->print_error('UNABLE TO UNZIP FILE' . ' :: ' . $archive->errorInfo(true), $backlink); } } } } else { // proceed normal multi-upload $file_count = sizeof($_FILES['upload']['error']); for ($x = 0; $x < $file_count; $x++) { // If file was upload to tmp if (isset($_FILES['upload']['name'][$x])) { // Remove bad characters $filename = media_filename($_FILES['upload']['name'][$x]); // Check if there is still a filename left and allowed filetyp if ($filename != '' && preg_match("/\\." . $allowed_file_types . "\$/i", $filename)) { // Move to relative path (in media folder) if (file_exists($target_path . '/' . $filename) && $overwrite === true) { if (move_uploaded_file($_FILES['upload']['tmp_name'][$x], $target_path . '/' . $filename)) { $good_uploads++; // Chmod the uploaded file change_mode($target_path . '/' . $filename, 'file'); } } elseif (!file_exists($target_path . '/' . $filename)) { if (move_uploaded_file($_FILES['upload']['tmp_name'][$x], $target_path . '/' . $filename)) { $good_uploads++; // Chmod the uploaded file change_mode($target_path . '/' . $filename); } } if (file_exists($target_path . '/' . $filename) && preg_match("/\\." . $allowed_img_types . "\$/i", $filename)) { if (isset($pathsettings[$resizepath])) { include_once get_include(ADMIN_PATH . '/media/resize_img.php'); if ($pathsettings[$resizepath]['width'] || $pathsettings[$resizepath]['height']) { $rimg = new RESIZEIMAGE($target_path . '/' . $filename); $rimg->resize_limitwh($pathsettings[$resizepath]['width'], $pathsettings[$resizepath]['height'], $target_path . '/' . $filename); $rimg->close(); } } } // store file name of first file for possible unzip action if ($x == 1) { $filename1 = $target_path . '/' . $filename; } } } } } if (isset($_POST['delzip'])) { if (file_exists($filename1)) { unlink($filename1); } } if ($good_uploads == 1) { $admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_SINGLE_UPLOADED'], $backlink); } else { $admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_UPLOADED'], $backlink); } break; case 'media_create': // $directory = rawurldecode(trim(stripslashes($admin->get_post('current_dir')))); // Remove bad characters from user folder name $target = $admin->get_post('target') != null ? media_filename(trim(stripslashes($admin->get_post('target')))) : $current_dir; $userPath = LEPTON_PATH . MEDIA_DIRECTORY; $err_msg = array(); if ($target == null || $target == $current_dir) { $err_msg[] = $MESSAGE['MEDIA_BLANK_NAME']; } else { // Try and make the dir $target = trim($target, '.'); $dirname = $userPath . $current_dir . '/' . $target; if (file_exists($dirname)) { $err_msg[] = $MESSAGE['MEDIA_DIR_EXISTS']; } else { if (make_dir($dirname)) { change_mode($dirname); if (is_writable($dirname)) { // Create default "index.php" file $rel_pages_dir = str_replace(LEPTON_PATH . MEDIA_DIRECTORY, '', dirname($dirname)); $step_back = str_repeat('../', substr_count($rel_pages_dir, '/') + 1); $content = '<?php' . "\n"; $content .= '// This file is generated by LEPTON Ver.' . VERSION . ';' . "\n"; $content .= "\t" . 'header(\'Location: ' . $step_back . 'index.php\');' . "\n"; $content .= '?>'; $filename = $dirname . '/index.php'; // write content into file $handle = fopen($filename, 'w'); fwrite($handle, $content); fclose($handle); change_mode($filename, 'file'); } else { $err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS']; } } else { $err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS']; } } } if (sizeof($err_msg) > 0) { $admin->print_error(implode('<br />', $err_msg)); } else { $admin->print_success($MESSAGE['MEDIA_DIR_MADE'], $backlink); } break; case 'media_delete': $filetype = isset($_POST['filetype']) ? trim(stripslashes($admin->get_post('filetype'))) : ''; $filename = isset($_POST['filename']) ? trim(stripslashes($admin->get_post('filename'))) : ''; $relative_path = LEPTON_PATH . MEDIA_DIRECTORY . $directory; // Find out whether its a file or folder if ($filetype == 'dir') { // Try and delete the directory if (rm_full_dir($relative_path . '/' . $filename)) { $admin->print_success($MESSAGE['MEDIA_DELETED_DIR'], $backlink); } else { $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_DIR'], $backlink); } } elseif ($filetype == 'file') { // Try and delete the file if (unlink($relative_path . '/' . $filename)) { $admin->print_success($MESSAGE['MEDIA_DELETED_FILE'], $backlink); } else { $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink); } } else { $admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink); } break; } // Parse template for preferences form $tpl->parse('main', 'main_wrapper_block', false); $tpl->parse('main', 'main_block', false); $output = $tpl->finish($tpl->parse('output', 'page')); return $output; }
public function ivrHook($request) { if (isset($request['id'])) { $ivr = \FreePBX::Ivr()->getDetails($request['id']); } $directdial = isset($ivr['directdial']) ? $ivr['directdial'] : ''; $dirs = directory_list(); $options = '$("<option />", {text: \'' . _("Disabled") . '\'}).appendTo(sel);'; $options .= '$("<option />", {val: \'ext-local\', text: \'' . _("Enabled") . '\'}).appendTo(sel);'; foreach ($dirs as $dir) { $name = $dir['dirname'] ? $dir['dirname'] : 'Directory ' . $dir['id']; $options .= '$("<option />", {val: \'' . $dir['id'] . '\', text: \'' . $name . '\'}).appendTo(sel);'; } $html = ' <script type="text/javascript"> var sel = $("<select id=\\"directdial\\" name=\\"directdial\\" class=\\"form-control\\" />"); var target = $("#directdialyes").parent(); '; $html .= $options; $html .= ' $(target).html(sel); $("#directdial").find("option").each( function() { var $this = $(this); if ($this.val() == "' . $directdial . '") { $this.attr("selected","selected"); return false; } }); </script> '; return $html; }
/** * Return a list of directories. * * @param $path * @param bool $absolute * * @return array */ function directory_list_directories($path, $absolute = false) { return array_values(array_filter(directory_list($path, $absolute), function ($item) use($path, $absolute) { if (!$absolute) { $item = path($path, $item); } return is_dir($item); })); }
// $('#folder_tree').live('change', function() { // if ($(this).attr('checked') == true) { // alert('checked'); // } else { // alert('unchecked'); // } // }); //--> </script> <script type="text/javascript"> var subFolder = new Array(); <?php $directories = directory_list($repo_path, false, true); $mainFoldersArrayScript = "var mainFolders = new Array( "; $subFoldersArrayScript = "subFolder = new Array(); \n"; $first_main = true; foreach ($directories as $dir_level_one => $val) { if (!preg_match('/^\\./', $dir_level_one)) { if ($first_main) { $mainFoldersArrayScript = $mainFoldersArrayScript . "\"{$dir_level_one}\""; } else { $mainFoldersArrayScript = $mainFoldersArrayScript . ",\"{$dir_level_one}\""; } $first_main = false; $subFoldersArrayScript = $subFoldersArrayScript . " subFolder['{$dir_level_one}'] = new Array( "; $first_sub = true; foreach ($val as $dir_level_two => $trash) { if ($first_sub) {
require_once LEPTON_PATH . "/framework/functions/function.random_string.php"; $username_fieldname = 'username_' . random_string(AUTH_MIN_PASS_LENGTH + mt_rand(0, 4), 'pass'); // Work-out if home folder should be shown if (!HOME_FOLDERS) { $template->set_var('DISPLAY_HOME_FOLDERS', 'display:none;'); } // Include the functions file require_once LEPTON_PATH . '/framework/summary.functions.php'; // Add media folders to home folder list $template->set_block('main_block', 'folder_list_block', 'folder_list'); /** * 'directory_list' has been modify in LEPTON-CMS 2 */ $dirs = array(); $skip = LEPTON_PATH; directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip); foreach ($dirs as &$name) { $template->set_var('NAME', $name); $temp_name = str_replace(MEDIA_DIRECTORY, '', $name); $template->set_var('FOLDER', $temp_name); $template->set_var('SELECTED', $user['home_folder'] == $temp_name ? ' selected="selected"' : ''); $template->parse('folder_list', 'folder_list_block', true); } // Insert text and messages $template->set_var(array('TEXT_RESET' => $TEXT['RESET'], 'TEXT_ACTIVE' => $TEXT['ACTIVE'], 'TEXT_DISABLED' => $TEXT['DISABLED'], 'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], 'TEXT_USERNAME' => $TEXT['USERNAME'], 'TEXT_PASSWORD' => $TEXT['PASSWORD'], 'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], 'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], 'TEXT_EMAIL' => $TEXT['EMAIL'], 'TEXT_GROUP' => $TEXT['GROUP'], 'TEXT_NONE' => $TEXT['NONE'], 'TEXT_HOME_FOLDER' => $TEXT['HOME_FOLDER'], 'USERNAME_FIELDNAME' => $username_fieldname, 'CHANGING_PASSWORD' => $MESSAGE['USERS_CHANGING_PASSWORD'], 'HEADING_MODIFY_USER' => $HEADING['MODIFY_USER'])); // Parse template object $template->parse('main', 'main_block', false); $template->pparse('output', 'page'); } elseif ($_POST['action'] == 'delete') { /** ************************ * Try to delete the selected User
//elinditjuk a form-ot $form =& new HTML_QuickForm('frm_contents', 'post', 'admin.php?p=' . $module_name); $form->removeAttribute('name'); //a szukseges szoveget jelzo resz beallitasa $form->setRequiredNote($locale->get('sendnews_form_required_note')); //form-hoz elemek hozzadasa $form->addElement('header', $locale->get('sendnews_form_header')); $form->addElement('hidden', 'act', $page); $form->addElement('hidden', 'sub_act', $sub_act); $form->addElement('hidden', 'field', $field); $form->addElement('hidden', 'ord', $ord); $form->addElement('hidden', 'cid', $cid); //ha tobbnyelvu az oldal, akkor kirakunk egy select mezot, ahol beallithatja a nyelvet if (isset($_SESSION['site_multilang']) && $_SESSION['site_multilang'] == 1) { include_once $include_dir . '/functions.php'; $form->addElement('select', 'languages', $locale->get('field_news_lang'), directory_list($lang_dir, 'php', array(), 1)); } $form->addElement('text', 'title', $locale->get('sendnews_field_title')); //ha engedelyeztuk a vezeto hireket, akkor kirakjuk a valasztot hozza if (isset($_SESSION['site_lead']) && $_SESSION['site_lead'] == 1) { $mainnews = array(); $mainnews[] =& HTML_QuickForm::createElement('radio', null, null, $locale->get('sendnews_form_yes'), '1'); $mainnews[] =& HTML_QuickForm::createElement('radio', null, null, $locale->get('sendnews_form_no'), '0'); $form->addGroup($mainnews, 'mainnews', $locale->get('sendnews_field_mainnews'), ' '); } //fooldalon tartjuk-e a hirt, fuggetlenul attol, hogy van-e frissebb nala $indexpage = array(); $indexpage[] =& HTML_QuickForm::createElement('radio', null, null, $locale->get('sendnews_form_yes'), '1'); $indexpage[] =& HTML_QuickForm::createElement('radio', null, null, $locale->get('sendnews_form_no'), '0'); $form->addGroup($indexpage, 'indexpage', $locale->get('sendnews_field_index'), ' '); //ha engedelyeztuk a kategoriakat, akkor megjelenitjuk oket
exit; } // Read data to display $caller = "setparameter"; // Setup template object, parse vars to it, then parse it // Create new template object $template = new Template(dirname($admin->correct_theme_source('setparameter.htt'))); $template->set_file('page', 'setparameter.htt'); $template->set_block('page', 'main_block', 'main'); if ($_SESSION['GROUP_ID'] != 1) { $template->set_var('DISPLAY_ADMIN', 'hide'); } $template->set_var(array('TEXT_HEADER' => $TEXT['TEXT_HEADER'], 'SAVE_TEXT' => $TEXT['SAVE'], 'BACK' => $TEXT['BACK'])); $template->set_block('main_block', 'list_block', 'list'); $row_bg_color = ''; $dirs = directory_list(WB_PATH . MEDIA_DIRECTORY); $dirs[] = WB_PATH . MEDIA_DIRECTORY; $array_lowercase = array_map('strtolower', $dirs); array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $dirs); foreach ($dirs as $name) { $relative = str_replace(WB_PATH, '', $name); $safepath = str_replace(array('/', ' '), '_', $relative); $cur_width = $cur_height = ''; if (isset($pathsettings[$safepath]['width'])) { $cur_width = $pathsettings[$safepath]['width']; } if (isset($pathsettings[$safepath]['height'])) { $cur_height = $pathsettings[$safepath]['height']; } $cur_width = $cur_width ? (int) $cur_width : '-'; $cur_height = $cur_height ? (int) $cur_height : '-';
$tpl_data['PASSWORD'] = isset($_SESSION['au']['password']) ? $_SESSION['au']['password'] : false; $tpl_data['DISPLAY_NAME'] = isset($_SESSION['au']['display_name']) ? $_SESSION['au']['display_name'] : false; $tpl_data['EMAIL'] = isset($_SESSION['au']['email']) ? $_SESSION['au']['email'] : false; $tpl_data['HOME_FOLDERS'] = HOME_FOLDERS; $tpl_data['INITIAL_PAGE'] = INITIAL_PAGE; $tpl_data['NEWUSERHINT'] = preg_split('/, /', $backend->lang()->translate('Minimum length for user name: {{ name }} chars, Minimum length for Password: {{ password }} chars!', array('name' => CAT_Registry::get('AUTH_MIN_LOGIN_LENGTH'), 'password' => CAT_Registry::get('AUTH_MIN_PASS_LENGTH')))); // ============================ // ! Add groups to $tpl_data // ============================ $tpl_data['groups'] = $users->get_groups(); // ====================================================================================== // ! Only allow the user to add a user to the Administrators group if he belongs to it // ====================================================================================== $tpl_data['is_admin'] = in_array(1, $users->get_groups_id()) ? true : false; // Add media folders to home folder list foreach (directory_list(CAT_PATH . MEDIA_DIRECTORY) as $index => $name) { $tpl_data['home_folders'][$index]['NAME'] = str_replace(CAT_PATH, '', $name); $tpl_data['home_folders'][$index]['FOLDER'] = str_replace(CAT_PATH . MEDIA_DIRECTORY, '', $name); } // initial page selection $pages = CAT_Helper_Page::getPages(); $frontend_pages = array(); foreach ($pages as $page) { $frontend_pages[$page['menu_title']] = 'pages/modify.php?page_id=' . $page['page_id']; } $tools = CAT_Helper_Addons::get_addons(NULL, 'module', 'tool'); $admin_tools = array(); foreach ($tools as $tool) { $admin_tools[$tool['name']] = 'admintools/tool.php?tool=' . $tool['directory']; } $tpl_data['backend_pages'] = $backend->getPages();