public function work($info, $settings, $getter) { // Gain access to translations global $lang; // Say we're called more than once. Kill previous remnants if (count($this->_windows) > 0) { $this->_kill_windows(); } // Get dimensions and give lovely header text $fullscreen = ncurses_newwin(0, 0, 0, 0); ncurses_wrefresh($fullscreen); ncurses_getmaxyx($fullscreen, $x, $y); ncurses_mvwaddstr($fullscreen, 0, 0, 'Generated by ' . AppName . ' (' . VERSION . ') on ' . date('m/d/Y @ h:i:s A (T)')); ncurses_wrefresh($fullscreen); $this->_max_dims = array($x, $y); // Some important windows $core_wins = array(array('name' => $lang['core'], 'content' => array(array($lang['os'], $info['OS']), array_key_exists('Distro', $info) ? array($lang['distro'], $info['Distro']['name'] . ($info['Distro']['version'] ? ' ' . $info['Distro']['version'] : '')) : false, array($lang['kernel'], $info['Kernel']), array_key_exists('Model', $info) && !empty($info['Model']) ? array($lang['model'], $info['Model']) : false, array($lang['uptime'], str_ireplace(array(' ', 'days', 'minutes', 'hours', 'seconds'), array('', 'd', 'm', 'h', 's'), reset(explode(';', $info['UpTime'])))), array($lang['hostname'], $info['HostName']), array_key_exists('CPUArchitecture', $info) ? array($lang['cpu_arch'], $info['CPUArchitecture']) : false, array($lang['load'], implode(' ', (array) $info['Load'])))), array('name' => $lang['memory'], 'content' => array(array($lang['size'], byte_convert($info['RAM']['total'])), array($lang['used'], byte_convert($info['RAM']['total'] - $info['RAM']['free'])), array($lang['free'], byte_convert($info['RAM']['free']))))); // Show them $h = 1; foreach ($core_wins as $win) { list($width, $height) = $this->_window_with_lines($win['name'], $win['content'], $h, 0); $h += $height + 1; } // Makeshift event loop while (true) { // Die on input $getch = ncurses_getch(); if ($getch > 0 && $getch == 113) { $this->__destruct(); echo "\nEnding at your request.\n"; exit(0); } // Stop temporariy ncurses_napms(1000); // Call ourselves $this->work($getter->getAll(), $settings, $getter); } }
function get_item_description($activity) { global $dbh; global $settings; if ($activity['type'] == 'backed up') { ?> <a href="<?php echo $activity['table']; ?> " target="_blank">File</a> - <?php echo byte_convert($activity['row']); echo file_exists($activity['table']) ? '' : ' - <span class="warning">Missing File!</span>'; } elseif ($activity['type'] == 'error') { $view_error = true ? ellipses($activity['sql']) : $activity['sql']; return '<a href="#" class="dialog_note" title="Error Detail" message="<b>User:</b> ' . get_username($activity['user']) . '<br><b>Page:</b> ' . $activity['table'] . '<br><b>Time:</b> ' . date('M jS Y, g:i:s a', strtotime($activity['datetime'])) . '<br><br>' . str_replace('"', '\\"', strip_tags($activity['sql'])) . '">View Error</a>: ' . $view_error; } elseif ($activity['type'] == 'installed') { return 'Directus install'; } elseif ($activity['table'] == 'directus_users') { return '<a href="users.php">' . $activity['sql'] . '</a> has been added to Directus Users'; } elseif ($activity['table'] == 'directus_media') { // Get name of media $sth = $dbh->prepare("SELECT * FROM `directus_media` WHERE `id` = :id "); $sth->bindParam(':id', $activity['row']); $sth->execute(); if ($row = $sth->fetch()) { $title = $row['title']; } $title = $title ? ellipses($title, 20) : '<i>No title</i>'; $return = '<a href="#" class="open_media" media_id="' . $activity['row'] . '">' . $title . '</a> within Directus Media'; $return .= $activity['sql'] == 'batch' ? ' - <b>Batch upload</b>' : ''; return $return; } elseif ($activity['table'] && $activity['row']) { $first_field = get_primary_field_value($activity['table'], $activity['row']); return '<a href="edit.php?table=' . $activity['table'] . '&item=' . $activity['row'] . '" title="' . ellipses(str_replace('"', '\\"', $first_field), 200) . '">' . ellipses($first_field, 20) . '</a> within ' . uc_table($activity['table']); } }
public function voicemail_messages() { $sql = "select * from v_voicemail_messages as m, v_voicemails as v "; $sql .= "where m.domain_uuid = '{$this->domain_uuid}' "; $sql .= "and m.voicemail_uuid = v.voicemail_uuid "; if (is_array($this->voicemail_id)) { $sql .= "and ("; $x = 0; foreach ($this->voicemail_id as $row) { if ($x > 0) { $sql .= "or "; } $sql .= "v.voicemail_id = '" . $row['voicemail_id'] . "' "; $x++; } $sql .= ") "; } else { $sql .= "and v.voicemail_id = '{$this->voicemail_id}' "; } if (strlen($this->order_by) == 0) { $sql .= "order by v.voicemail_id, m.created_epoch desc "; } else { $sql .= "order by v.voicemail_id, m.{$this->order_by} {$this->order} "; } //$sql .= "limit $this->rows_per_page offset $this->offset "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $result_count = count($result); unset($prep_statement, $sql); if ($result_count > 0) { foreach ($result as &$row) { //set the greeting directory $path = $_SESSION['switch']['voicemail']['dir'] . '/default/' . $_SESSION['domain_name'] . '/' . $row['voicemail_id']; if (file_exists($path . '/msg_' . $row['voicemail_message_uuid'] . '.wav')) { $row['file_path'] = $path . '/msg_' . $row['voicemail_message_uuid'] . '.wav'; } if (file_exists($path . '/msg_' . $row['voicemail_message_uuid'] . '.mp3')) { $row['file_path'] = $path . '/msg_' . $row['voicemail_message_uuid'] . '.mp3'; } $row['file_size'] = filesize($row['file_path']); $row['file_size_label'] = byte_convert($row['file_size']); $row['file_ext'] = substr($row['file_path'], -3); $message_length = $row['message_length']; if ($message_length < 60) { $message_length = $message_length . " sec"; } else { $message_length = round($message_length / 60, 2) . " min"; } $row['message_length_label'] = $message_length; $row['created_date'] = date("j M Y g:i a", $row['created_epoch']); } } return $result; }
} echo "\t</tr>"; if ($emails) { rsort($emails); // most recent on top foreach ($emails as $email_id) { $metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID)); $attachment = parse_attachments($connection, $email_id, FT_UID); $file_name = $attachment[0]['filename']; $caller_id_name = substr($file_name, 0, strpos($file_name, '-')); $caller_id_number = is_numeric($caller_id_name) ? format_phone((int) $caller_id_name) : null; echo "\t<tr " . ($metadata[0]['seen'] == 0 ? "style='font-weight: bold;'" : null) . ">\n"; echo "\t\t<td valign='top' class='" . $row_style[$c] . "'>" . $caller_id_name . "</td>\n"; echo "\t\t<td valign='top' class='" . $row_style[$c] . "'>" . $caller_id_number . "</td>\n"; echo "\t\t<td valign='top' class='" . $row_style[$c] . "'><a href='?id=" . $fax_uuid . "&email_id=" . $email_id . "&download'>" . $file_name . "</a></td>\n"; echo "\t\t<td valign='top' class='" . $row_style[$c] . "'>" . byte_convert(strlen($attachment[0]['attachment'])) . "</td>\n"; echo "\t\t<td valign='top' class='" . $row_style[$c] . "'>" . $metadata[0]['date'] . "</td>\n"; if (permission_exists('fax_inbox_delete')) { echo "\t\t<td style='width: 25px;' class='list_control_icons'><a href='?id=" . $fax_uuid . "&email_id=" . $email_id . "&delete' onclick=\"return confirm('" . $text['confirm-delete'] . "')\">" . $v_link_label_delete . "</a></td>\n"; } echo "\t</tr>\n"; // $fax_message = imap_fetchbody($connection, $email_id, '1.1', FT_UID); // if ($fax_message == '') { // $fax_message = imap_fetchbody($connection, $email_id, '1', FT_UID); // } $c = $c ? 0 : 1; } } else { echo "<tr valign='top'>\n"; echo "\t<td colspan='4' style='text-align: center;'><br><br>" . $text['message-no_faxes_found'] . "<br><br></td>\n"; echo "</tr>\n";
/** * getRAID * * @access private * @return array of raid arrays */ private function getRAID() { // Time? if (!empty($this->settings['timer'])) { $t = new LinfoTimerStart('RAID'); } // Store it here $raidinfo = array(); // mdadm? if (array_key_exists('mdadm', (array) $this->settings['raid']) && !empty($this->settings['raid']['mdadm'])) { // Try getting contents $mdadm_contents = getContents('/proc/mdstat', false); // No? if ($mdadm_contents === false) { $this->error->add('Linux softraid mdstat parser', '/proc/mdstat does not exist.'); } // Parse @preg_match_all('/(\\S+)\\s*:\\s*(\\w+)\\s*raid(\\d+)\\s*([\\w+\\[\\d+\\] (\\(\\w\\))?]+)\\n\\s+(\\d+) blocks\\s*(?:super \\d\\.\\d\\s*)?(level \\d\\, [\\w\\d]+ chunk\\, algorithm \\d\\s*)?\\[(\\d\\/\\d)\\] \\[([U\\_]+)\\]/mi', (string) $mdadm_contents, $match, PREG_SET_ORDER); // Store them here $mdadm_arrays = array(); // Deal with entries foreach ((array) $match as $array) { // Temporarily store drives here $drives = array(); // Parse drives foreach (explode(' ', $array[4]) as $drive) { // Parse? if (preg_match('/([\\w\\d]+)\\[\\d+\\](\\(\\w\\))?/', $drive, $match_drive) == 1) { // Determine a status other than normal, like if it failed or is a spare if (array_key_exists(2, $match_drive)) { switch ($match_drive[2]) { case '(S)': $drive_state = 'spare'; break; case '(F)': $drive_state = 'failed'; break; case null: $drive_state = 'normal'; break; // I'm not sure if there are status codes other than the above // I'm not sure if there are status codes other than the above default: $drive_state = 'unknown'; break; } } else { $drive_state = 'normal'; } // Append this drive to the temp drives array $drives[] = array('drive' => '/dev/' . $match_drive[1], 'state' => $drive_state); } } // Add record of this array to arrays list $mdadm_arrays[] = array('device' => '/dev/' . $array[1], 'status' => $array[2], 'level' => $array[3], 'drives' => $drives, 'size' => byte_convert($array[5] * 1024), 'algorithm' => $array[6], 'count' => $array[7], 'chart' => $array[8]); } // Append MD arrays to main raidinfo if it's good if (is_array($mdadm_arrays) && count($mdadm_arrays) > 0) { $raidinfo = array_merge($raidinfo, $mdadm_arrays); } } // Return info return $raidinfo; }
function generate_media_item($id, $title, $extension, $source, $height, $width, $file_size, $uploaded, $user, $caption, $search = false, $tags = '', $modal = false) { global $cms_all_users; global $cms_user; $click_type = $modal ? 'checkable' : 'editable'; ?> <tr class="media_item" id="media_<?php echo $id; ?> "> <td class="check" raw="X"><?php if ($cms_user['media'] || $modal) { ?> <input class="status_action_check" type="checkbox" name="media_ids_checked[]" value="<?php echo $id; ?> " id="<?php echo $id; ?> "><?php } ?> </td> <td class="thumb <?php echo $click_type; ?> " raw="X"> <?php if (!$modal) { ?> <input name="media_ids[]" type="hidden" value="<?php echo $id; ?> " /> <?php } generate_media_image($extension, $source, $height, $width, $file_size); $extension = strtoupper($extension); $file_size_text = $extension == 'YOUTUBE' || $extension == 'VIMEO' ? seconds_convert($file_size) : byte_convert($file_size); ?> </td> <td class="field_title first_field <?php echo $click_type; ?> "><div class="wrap"><?php echo $title; ?> </div></td> <td class="field_type <?php echo $click_type; ?> "><div class="wrap"><?php echo $extension; ?> </div></td> <td class="field_size <?php echo $click_type; ?> "><div class="wrap"><?php echo $file_size_text; ?> </div></td> <td class="field_caption <?php echo $click_type; ?> "><div class="wrap" title="<?php echo $tags; ?> "><?php echo $caption; ?> <span class="hide"><?php echo $tags; ?> </span></div></td> <td class="field_user <?php echo $click_type; ?> "><div class="wrap"><?php echo $user == $cms_user['id'] ? '<strong>' . $cms_all_users[$user]['username'] . '</strong>' : $cms_all_users[$user]['username']; ?> </div></td> <td class="field_date <?php echo $click_type; ?> "><div class="wrap" title="<?php echo date('Y-m-d H:i:s', strtotime($uploaded)); ?> "><?php echo contextual_time(strtotime($uploaded)); ?> </div></td> </tr> <?php }
function print_files($c = '.') { global $root_path, $mode, $thmb_size, $file_class, $lng; echo('<table id="file-list">'); $d = opendir($c); $i = 0; while($f = readdir($d)) { if(strpos($f, '.') === 0) continue; $ff = $c . '/' . $f; $ext = strtolower(substr(strrchr($f, '.'), 1)); if(!is_dir($ff)) { echo '<tr' . ($i%2 ? ' class="light"' : ' class="dark"') .'>'; //show preview and different icon, if file is image $imageinfo = @getimagesize($ff); if($imageinfo && $imageinfo[2] > 0 && $imageinfo[2]< 4) { $resize = ''; if($imageinfo[0] > $thmb_size or $imageinfo[1] > $thmb_size) { if($imageinfo[0] > $imageinfo[1]) { $resize = ' style="width: ' . $thmb_size . 'px;"'; } else { $resize = ' style="height: ' . $thmb_size . 'px;"'; } } if ($imageinfo[2] == 1) { $imagetype = "image_gif"; } elseif ($imageinfo[2] == 2) { $imagetype = "image_jpg"; } elseif ($imageinfo[2] == 3) { $imagetype = "image_jpg"; } else { $imagetype = "image"; } //echo '<td><a class="file thumbnail ' . $imagetype . '" href="#" onclick="submit_url(\'' . $root_path . '/' . $ff . '\');">' . $f . '<span><img' . $resize . ' src="' . $root_path . '/' . $ff . '" /></span></a>'; echo '</td>'; echo '<td><a class="file thumbnail ' . $imagetype . '" href="#" onclick="submit_url(\''. str_replace("../../../../", BASEURLX, $ff) . '\');">' . $f . '<span><img' . $resize . ' src="' . $root_path . '/' . $ff . '" /></span></a>'; echo '</td>'; } //known file types elseif(in_array($ext,$file_class)) { echo '<td><a class="file file_' . $ext . '" href="#" onclick="submit_url(\'' . $root_path . '/' . $ff . '\');">' . $f . '</a>'; echo '</td>'; } //all other files else { echo '<td><a class="file unknown" href="#" onclick="submit_url(\'' . $root_path . '/' . $ff . '\');">' . $f . '</a>'; echo '</td>'; } echo '<td>' . byte_convert(filesize($ff)) . '</td>'; echo '<td class="delete"><a href="#" title="' . $lng['delete_title'] . '" onclick="delete_file(\'' . $c . '\',\'' . $f . '\');">' . $lng['delete'] . '</a></td>'; echo '</tr>'; $i++; } } echo('</table>'); }
if (!(permission_exists('recording_edit') || permission_exists('recording_delete'))) { $colspan = $colspan - 1; } if ($result_count > 0) { foreach ($result as $row) { //playback progress bar if (permission_exists('recording_play')) { echo "<tr id='recording_progress_bar_" . $row['recording_uuid'] . "' style='display: none;'><td class='" . $row_style[$c] . "' style='border: none; padding: 0;' colspan='" . $colspan . "'><span class='playback_progress_bar' id='recording_progress_" . $row['recording_uuid'] . "'></span></td></tr>\n"; } $tr_link = permission_exists('recording_edit') ? "href='recording_edit.php?id=" . $row['recording_uuid'] . "'" : null; echo "<tr " . $tr_link . ">\n"; echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $row['recording_name'] . "</td>\n"; if ($_SESSION['recordings']['storage_type']['text'] != 'base64') { echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $row['recording_filename'] . "</td>\n"; $tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'] . '/' . $_SESSION['domain_name'] . '/' . $row['recording_filename']); $tmp_filesize = byte_convert($tmp_filesize); echo "\t<td class='" . $row_style[$c] . "' style='text-align: center;'>" . $tmp_filesize . "</td>\n"; } if (permission_exists('recording_play') || permission_exists('recording_download')) { echo "\t<td valign='top' class='" . $row_style[$c] . " row_style_slim tr_link_void'>"; if (permission_exists('recording_play')) { $recording_file_path = $row['recording_filename']; $recording_file_name = strtolower(pathinfo($recording_file_path, PATHINFO_BASENAME)); $recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION); switch ($recording_file_ext) { case "wav": $recording_type = "audio/wav"; break; case "mp3": $recording_type = "audio/mpeg"; break;
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; }
if (!$result['status']) { $result['message'] = __('Description not updated'); } echo json_encode($result); return; } if ($get_file_row) { $id_file = (int) get_parameter("id_attachment"); $id_company = (int) get_parameter("id"); $file = get_db_row_filter('tattachment', array('id_company' => $id_company, 'id_attachment' => $id_file)); $html = ""; if ($file) { $link = "operation/common/download_file.php?id_attachment=" . $file["id_attachment"] . "&type=company"; $real_filename = $config["homedir"] . "/attachment/" . $file["id_attachment"] . "_" . rawurlencode($file["filename"]); $html .= "<tr>"; $html .= "<td valign=top>"; $html .= '<a target="_blank" href="' . $link . '">' . $file['filename'] . '</a>'; $html .= "<td valign=top class=f9>" . $file["description"]; //$html .= "<td valign=top>". $file["id_usuario"]; $html .= "<td valign=top>" . byte_convert($file['size']); $stat = stat($real_filename); $html .= "<td valign=top class=f9>" . date("Y-m-d H:i:s", $stat['mtime']); // Delete attachment if (give_acl($config['id_user'], $incident['id_grupo'], 'IM')) { $html .= "<td>" . '<a class="delete" name="delete_file_' . $file["id_attachment"] . '" href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $id . '&tab=files&id_attachment=' . $file["id_attachment"] . '&delete_file=1#incident-operations"> <img src="images/cross.png"></a>'; } } echo $html; return; }
$length_size = seconds_convert($media_detail['file_size']); if ($extension == 'youtube') { $link = 'http://www.youtube.com/watch?v=' . $media_detail["source"]; $link_text = 'http://www.youtube.com/watch?v=<b>' . $media_detail["source"] . '</b>'; } elseif ($extension == 'vimeo') { $link = 'http://vimeo.com/' . $media_detail["source"]; $link_text = 'http://vimeo.com/<b>' . $media_detail["source"] . '</b>'; } $dimensions = $media_detail['width'] . ' x ' . $media_detail['height'] . ' - '; } else { if ($extension == 'jpg' || $extension == 'gif' || $extension == 'png') { $length_size = byte_convert($media_detail['file_size']); $link = '../' . $settings['cms']['media_path'] . $media_detail["source"]; $dimensions = $media_detail['width'] . ' x ' . $media_detail['height'] . ' - '; } else { $length_size = byte_convert($media_detail['file_size']); $link = '../' . $settings['cms']['media_path'] . $media_detail["source"]; $dimensions = ''; } // Get all non-video link texts $page_url_array = explode('/inc/', CMS_PAGE_URL); // Requires directus directory name $site_path = $page_url_array[0]; $temp_path = get_absolute_path($site_path . '/../' . $settings['cms']['media_path'] . $media_detail["source"]); $link_text = highlight_custom($media_detail['source'], $temp_path, '<b>', '</b>'); } $extension = ucwords($extension); ////////////////////////////////////////////////////////////////////////////// ?> <table class="media_modal_details" cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr>
/** * This function will use CURL to download a file * * @param string $url - The URL we want to download * @param string $folder - The folder where we will save it. DEFAULT = temp * @param bool $trace - Do we output tracing info. * @param string $prefix - The string to prefix all mtrace reports with * @return string localpath or NULL on error */ function skillsoft_download_customreport($handle, $url, $folder = NULL, $trace = false, $prefix = ' ') { global $CFG; set_time_limit(0); $starttime = microtime(true); if ($trace) { mtrace($prefix . get_string('skillsoft_customreport_download_start', 'skillsoft')); mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_url', 'skillsoft', $url)); } $basefolder = str_replace('\\', '/', $CFG->tempdir); $downloadedfile = NULL; if ($folder == NULL) { $folder = 'reports'; } /// Create temp directory if necesary if (!make_temp_directory($folder, false)) { //Couldn't create temp folder if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_createdirectoryfailed', 'skillsoft', $basefolder . '/' . $folder)); } return NULL; } $filename = basename($url); $fp = fopen($basefolder . '/' . $folder . '/' . $filename, 'wb'); if (!extension_loaded('curl') or ($ch = curl_init($url)) === false) { //Error no CURL if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_curlnotavailable', 'skillsoft')); } } else { $ch = curl_init($url); //Ignore SSL errors curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_FILE, $fp); //Force SSLv3 to workaround Openssl 1.0.1 issue //See https://bugs.launchpad.net/ubuntu/+source/curl/+bug/595415 curl_setopt($ch, CURLOPT_SSLVERSION, 3); //Setup Proxy Connection if (!empty($CFG->proxyhost)) { // SOCKS supported in PHP5 only if (!empty($CFG->proxytype) and $CFG->proxytype == 'SOCKS5') { if (defined('CURLPROXY_SOCKS5')) { curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } else { curl_close($ch); if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_socksproxyerror', 'skillsoft')); } return NULL; } } curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false); if (empty($CFG->proxyport)) { curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost); } else { curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost . ':' . $CFG->proxyport); } if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $CFG->proxyuser . ':' . $CFG->proxypassword); if (defined('CURLOPT_PROXYAUTH')) { // any proxy authentication if PHP 5.1 curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM); } } } curl_exec($ch); // Check if any error occured if (!curl_errno($ch)) { $downloadresult = new stdClass(); $downloadresult->bytes = byte_convert(curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD)); $downloadresult->total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME); $downloadresult->filepath = $basefolder . '/' . $folder . '/' . $filename; fclose($fp); if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_result', 'skillsoft', $downloadresult)); } $downloadedfile = $downloadresult->filepath; //Update skillsoft_report_track table skillsoft_update_customreport_downloaded($handle, $downloadedfile); } else { fclose($fp); if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_download_error', 'skillsoft', curl_error($ch))); } return NULL; } } $endtime = microtime(true); $duration = $endtime - $starttime; if ($trace) { mtrace($prefix . get_string('skillsoft_customreport_download_end', 'skillsoft') . ' (took ' . $duration . ' seconds)'); } return $downloadedfile; }
$table->style = array (); $table->rowstyle = array (); $table->head = array (); $table->head[0] = __('Filename'); $table->head[1] = __('Description'); $table->head[2] = __('Size'); $table->head[3] = __('Date'); $table->head[4] = __('Ops.'); foreach ($files as $file) { $data = array (); $data[0] = "<a href='operation/common/download_file.php?id_attachment=".$file["id_attachment"]."&type=company'>".$file["filename"] . "</a>"; $data[1] = $file["description"]; $data[2] = byte_convert($file["size"]); $data[3] = $file["timestamp"]; // Todo. Delete files owner of lead and admins only if ( (dame_admin($config["id_user"])) || ($file["id_usuario"] == $config["id_user"]) ){ $data[4] = "<a href='index.php?sec=customers&sec2=operation/companies/company_detail&id=$id&op=files&deletef=".$file["id_attachment"]."'><img src='images/cross.png'></a>"; } array_push ($table->data, $data); array_push ($table->rowstyle, $style); } print_table ($table); } else { echo "<h3>". __('There is no files attached for this lead')."</h3>"; }
echo "</td>\n"; echo "\t</tr>"; unset($stream_icons, $icons); //add the uuid of to the link if (permission_exists('music_on_hold_edit')) { $tr_link = "href='music_on_hold_edit.php?id=" . $row['music_on_hold_uuid'] . "'"; } //get the music on hold path $stream_path = $row['music_on_hold_path']; $stream_path = str_replace("\$\${sounds_dir}", $_SESSION['switch']['sounds']['dir'], $stream_path); //show the files if (file_exists($stream_path)) { $stream_files = array_merge(glob($stream_path . '/*.wav'), glob($stream_path . '/*.mp3'), glob($stream_path . '/*.ogg')); foreach ($stream_files as $stream_file_path) { $stream_file = pathinfo($stream_file_path, PATHINFO_BASENAME); $stream_file_size = byte_convert(filesize($stream_file_path)); $stream_file_date = date("M d, Y H:i:s", filemtime($stream_file_path)); $stream_file_ext = pathinfo($stream_file, PATHINFO_EXTENSION); switch ($stream_file_ext) { case "wav": $stream_file_type = "audio/wav"; break; case "mp3": $stream_file_type = "audio/mpeg"; break; case "ogg": $stream_file_type = "audio/ogg"; break; } $row_uuid = uuid(); echo "<tr id='recording_progress_bar_" . $row_uuid . "' style='display: none;'><td colspan='4' class='" . $row_style[$c] . " playback_progress_bar_background' style='padding: 0; border: none;'><span class='playback_progress_bar' id='recording_progress_" . $row_uuid . "'></span></td></tr>\n";
echo "\t<tr>\n"; echo "\t\t<th class=\"listhdr\">" . $text['label-file_name'] . "</th>\n"; echo "\t\t<th class=\"listhdr\">" . $text['label-tools'] . "</th>\n"; echo "\t\t<th class=\"listhdr\" style='text-align: right;'>" . $text['label-uploaded'] . "</th>\n"; echo "\t\t<th class=\"listhdr\" style='text-align: right;' nowrap=\"nowrap\">" . $text['label-file-size'] . "</th>\n"; echo "\t\t<th class=\"listhdr\" style='text-align: right;' nowrap=\"nowrap\">" . $text['label-sampling'] . "</th>\n"; echo "\t\t<td width='22px' align=\"center\" style=\"padding: 2px;\"><span id='category_" . $category_number . "_delete_icon'></span></td>\n"; echo "\t</tr>"; $moh_found = false; foreach ($sampling_rate_dirs as $sampling_rate_dir) { if ($handle = opendir($music_on_hold_category_parent_dir . "/" . $category_dir . "/" . $sampling_rate_dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_file($music_on_hold_category_parent_dir . "/" . $category_dir . "/" . $sampling_rate_dir . "/" . $file)) { $row_uuid = uuid(); $file_size = filesize($music_on_hold_category_parent_dir . "/" . $category_dir . "/" . $sampling_rate_dir . "/" . $file); $file_size = byte_convert($file_size); //playback progress bar echo "<tr id='recording_progress_bar_" . $row_uuid . "' style='display: none;'><td colspan='5'><span class='playback_progress_bar' id='recording_progress_" . $row_uuid . "'></span></td></tr>\n"; echo "<tr>\n"; echo "\t<td class='" . $row_style[$c] . "'>" . $file . "</td>\n"; if (strlen($file) > 0) { echo "\t<td valign='top' class='" . $row_style[$c] . " row_style_slim tr_link_void'>"; $recording_file_path = $file; $recording_file_name = strtolower(pathinfo($row['recording_filename'], PATHINFO_BASENAME)); $recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION); switch ($recording_file_ext) { case "wav": $recording_type = "audio/wav"; break; case "mp3": $recording_type = "audio/mpeg";
$template->set_var(array('NAME' => $name, 'NAME_SLASHED' => addslashes($name), 'TEMP_ID' => $admin->getIDKEY($temp_id), 'LINK' => "browse.php?dir={$directory}/{$link_name}", 'LINK_TARGET' => '_self', 'ROW_BG_COLOR' => $row_bg_color, 'FT_ICON' => THEME_URL . '/images/folder_16.png', 'FILETYPE_ICON' => THEME_URL . '/images/folder_16.png', 'MOUSEOVER' => '', 'IMAGEDETAIL' => '', 'SIZE' => '', 'DATE' => '', 'PREVIEW' => '', 'IMAGE_TITLE' => $name, 'IMAGE_EXIST' => 'blank_16.gif')); $template->parse('list', 'list_block', true); // Code to alternate row colors if ($row_bg_color == 'FFF') { $row_bg_color = 'ECF1F3'; } else { $row_bg_color = 'FFF'; } } } if (isset($FILE)) { sort($FILE); $filepreview = array('jpg', 'gif', 'tif', 'tiff', 'png', 'txt', 'css', 'js', 'cfg', 'conf', 'pdf', 'zip', 'gz', 'doc'); foreach ($FILE as $name) { $size = filesize('../../' . MEDIA_DIRECTORY . $directory . '/' . $name); $bytes = byte_convert($size); $fdate = filemtime('../../' . MEDIA_DIRECTORY . $directory . '/' . $name); $date = gmdate(DATE_FORMAT . ' ' . TIME_FORMAT, $fdate); $filetypeicon = get_filetype_icon(WB_URL . MEDIA_DIRECTORY . $directory . '/' . $name); $filetype = get_filetype(WB_URL . MEDIA_DIRECTORY . $directory . '/' . $name); if (in_array($filetype, $filepreview)) { $preview = 'preview'; } else { $preview = ''; } $temp_id++; $imgdetail = ''; // $icon = THEME_URL.'/images/blank_16.gif'; $icon = ''; $tooltip = ''; if (!$pathsettings['global']['show_thumbs']) {
foreach ($files as $file) { $link = "operation/common/download_file.php?id_attachment=".$file["id_attachment"]."&type=incident"; $real_filename = $config["homedir"]."/attachment/".$file["id_attachment"]."_".rawurlencode ($file["filename"]); echo "<tr>"; echo "<td valign=top>"; echo '<a target="_blank" href="'.$link.'">'. $file['filename'].'</a>'; $stat = stat ($real_filename); echo "<td valign=top class=f9>".date ("Y-m-d H:i:s", $stat['mtime']); echo "<td valign=top class=f9>". $file["description"]; echo "<td valign=top>". $file["id_usuario"]; echo "<td valign=top>". byte_convert ($file['size']); // Delete attachment if (give_acl ($config['id_user'], $incident['id_grupo'], 'IM') && !$clean_output) { echo "<td>". '<a class="delete" name="delete_file_'.$file["id_attachment"].'" href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id='.$id.'&tab=files&id_attachment='.$file["id_attachment"].'&delete_file=1#incident-operations"> <img src="images/cross.png"></a>'; } } echo "</table>"; echo "</div>"; ?> <script src="include/js/jquery.fileupload.js"></script>
/** * Show it all... in very minimal HTML * @param array $info the system information * @param array $settings linfo settings */ function showInfoHTML($info, $settings) { // Gain access to language array global $lang; // Fun icons $show_icons = array_key_exists('icons', $settings) ? !empty($settings['icons']) : true; $os_icon = defined('IS_WINDOWS') ? 'windows' : strtolower(str_replace(' ', '', current(explode('(', $info['OS'])))); $distro_icon = $info['OS'] == 'Linux' && is_array($info['Distro']) && $info['Distro']['name'] ? strtolower(str_replace(' ', '', $info['Distro']['name'])) : false; // Start compressed output buffering if (!isset($settings['compress_content']) || $settings['compress_content']) { ob_start('ob_gzhandler'); } // Proceed to letting it all out echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>' . AppName . ' - ' . $info['HostName'] . '</title> <link href="' . WEB_PATH . 'layout/favicon.ico" type="image/x-icon" rel="shortcut icon" /> <link href="' . WEB_PATH . 'layout/styles.css" type="text/css" rel="stylesheet" />' . ($show_icons ? ' <link href="' . WEB_PATH . 'layout/icons.css" type="text/css" rel="stylesheet" />' : '') . ' <script src="' . WEB_PATH . 'layout/scripts.min.js" type="text/javascript"></script> <meta name="generator" content="' . AppName . ' (' . VERSION . ')" /> <meta name="author" content="Joseph Gillotti & friends" /> <!--[if lt IE 8]> <link href="' . WEB_PATH . 'layout/old_ie.css" type="text/css" rel="stylesheet" /> <![endif]--> </head> <body id="info"> <div class="header"> <h1>' . $info['HostName'] . '</h1> <div class="subtitle">' . $lang['header'] . '</div> </div> <!--<div class="time"> <h1>' . date('H:i:s') . '</h1> <div class="subtitle">' . date('Y-m-d, T') . '</div> </div>--> <br clear="all" /> <div class="col2"> <div class="col"> <div class="infoTable"> <h2>' . $lang['core'] . '</h2> <table>'; // Linfo Core. Decide what to show. $core = array(); // OS? (with icon, if we have it) if (!empty($settings['show']['os'])) { $core[] = array($lang['os'], ($show_icons && (file_exists(LOCAL_PATH . 'layout/icons/os_' . $os_icon . '.gif') || file_exists(LOCAL_PATH . 'layout/icons/os_' . $os_icon . '.png')) ? '<span class="icon icon_os_' . $os_icon . '"></span>' : '') . $info['OS']); } // Distribution? (with icon, if we have it) if (!empty($settings['show']['distro']) && is_array($info['Distro'])) { $core[] = array($lang['distro'], ($show_icons && $distro_icon && (file_exists(LOCAL_PATH . 'layout/icons/distro_' . $distro_icon . '.gif') || file_exists(LOCAL_PATH . 'layout/icons/distro_' . $distro_icon . '.png')) ? '<span class="icon icon_distro_' . $distro_icon . '"></span>' : '') . $info['Distro']['name'] . ($info['Distro']['version'] ? ' - ' . $info['Distro']['version'] : '')); } // Kernel if (!empty($settings['show']['kernel'])) { $core[] = array($lang['kernel'], $info['Kernel']); } // Model? if (!empty($settings['show']['model']) && array_key_exists('Model', $info) && !empty($info['Model'])) { $core[] = array($lang['model'], $info['Model']); } // IP $core[] = array($lang['accessed_ip'], isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'Unknown'); // Uptime if (!empty($settings['show']['uptime'])) { $core[] = array($lang['uptime'], $info['UpTime']); } // Hostname if (!empty($settings['show']['hostname'])) { $core[] = array($lang['hostname'], $info['HostName']); } // The CPUs if (!empty($settings['show']['cpu'])) { $cpus = ''; foreach ((array) $info['CPU'] as $cpu) { $cpus .= (array_key_exists('Vendor', $cpu) ? $cpu['Vendor'] . ' - ' : '') . $cpu['Model'] . (array_key_exists('MHz', $cpu) ? $cpu['MHz'] < 1000 ? ' (' . $cpu['MHz'] . ' MHz)' : ' (' . round($cpu['MHz'] / 1000, 3) . ' GHz)' : '') . '<br />'; } $core[] = array('CPUs (' . count($info['CPU']) . ')', $cpus); } // CPU architecture. Permissions goes hand in hand with normal CPU if (!empty($settings['show']['cpu']) && array_key_exists('CPUArchitecture', $info)) { $core[] = array($lang['cpu_arch'], $info['CPUArchitecture']); } // System Load if (!empty($settings['show']['load'])) { $core[] = array($lang['load'], implode(' ', (array) $info['Load'])); } // We very well may not have process stats if (!empty($settings['show']['process_stats']) && $info['processStats']['exists']) { // Different os' have different keys of shit $proc_stats = array(); // Load the keys if (array_key_exists('totals', $info['processStats']) && is_array($info['processStats']['totals'])) { foreach ($info['processStats']['totals'] as $k => $v) { $proc_stats[] = $k . ': ' . number_format($v); } } // Total as well $proc_stats[] = 'total: ' . number_format($info['processStats']['proc_total']); // Show them $core[] = array($lang['processes'], implode('; ', $proc_stats)); // We might not have threads if ($info['processStats']['threads'] !== false) { $core[] = array($lang['threads'], number_format($info['processStats']['threads'])); } } // Show for ($i = 0, $core_num = count($core); $i < $core_num; $i++) { echo ' <tr> <th>' . $core[$i][0] . '</th> <td>' . $core[$i][1] . '</td> </tr> '; } echo ' </table> </div>'; // Show memory? if (!empty($settings['show']['ram'])) { echo ' <div class="infoTable"> <h2>' . $lang['memory'] . '</h2> <table> <colgroup> <col style="width: 10%;" /> <col style="width: 30%;" /> <col style="width: 30%;" /> <col style="width: 30%;" /> </colgroup> <tr> <th>' . $lang['type'] . '</th> <th>' . $lang['free'] . '</th> <th>' . $lang['used'] . '</th> <th>' . $lang['size'] . '</th> </tr> <tr> <td>' . $info['RAM']['type'] . '</td> <td>' . byte_convert($info['RAM']['free']) . '</td> <td>' . byte_convert($info['RAM']['total'] - $info['RAM']['free']) . '</td> <td>' . byte_convert($info['RAM']['total']) . '</td> </tr>'; $have_swap = isset($info['RAM']['swapFree']) || isset($info['RAM']['swapTotal']); if ($have_swap) { // Show detailed swap info? $show_detailed_swap = is_array($info['RAM']['swapInfo']) && count($info['RAM']['swapInfo']) > 0; echo ' <tr> <td' . ($show_detailed_swap ? ' rowspan="2"' : '') . '>Swap</td> <td>' . byte_convert(@$info['RAM']['swapFree']) . '</td> <td>' . byte_convert(@$info['RAM']['swapTotal'] - $info['RAM']['swapFree']) . '</td> <td>' . byte_convert(@$info['RAM']['swapTotal']) . '</td> </tr>'; // As in we have at least one swap device present. Show them. if ($show_detailed_swap) { echo ' <tr> <td colspan="3"> <table class="mini center"> <colgroup> <col style="width: 25%;" /> <col style="width: 25%;" /> <col style="width: 25%;" /> <col style="width: 25%;" /> </colgroup> <tr> <th>' . $lang['device'] . '</th> <th>' . $lang['type'] . '</th> <th>' . $lang['size'] . '</th> <th>' . $lang['used'] . '</th> </tr>'; foreach ($info['RAM']['swapInfo'] as $swap) { echo ' <tr> <td>' . $swap['device'] . '</td> <td>' . ucfirst($swap['type']) . '</td> <td>' . byte_convert($swap['size']) . '</td> <td>' . byte_convert($swap['used']) . '</td> </tr> '; } echo ' </table> </td> </tr>'; } } echo ' </table> </div>'; } // Network Devices? if (!empty($settings['show']['network'])) { $show_type = array_key_exists('nic_type', $info['contains']) ? $info['contains']['nic_type'] === false ? false : true : true; echo ' <div class="infoTable"> <h2>' . $lang['network_devices'] . '</h2> <table> <tr> <th>' . $lang['device_name'] . '</th>', $show_type ? ' <th>' . $lang['type'] . '</th>' : '', ' <th>' . $lang['amount_sent'] . '</th> <th>' . $lang['amount_received'] . '</th> <th>' . $lang['state'] . '</th> </tr>'; if (count($info['Network Devices']) > 0) { foreach ($info['Network Devices'] as $device => $stats) { echo ' <tr> <td>' . $device . '</td>', $show_type ? ' <td>' . $stats['type'] . '</td>' : '', ' <td>' . byte_convert($stats['sent']['bytes']) . '</td> <td>' . byte_convert($stats['recieved']['bytes']) . '</td> <td class="net_' . $stats['state'] . '">' . ucfirst($stats['state']) . '</td> </tr>'; } } else { echo '<tr><td colspan="5" class="none">' . $lang['none_found'] . '</td></tr>'; } echo ' </table> </div>'; } // Show temps? if (!empty($settings['show']['temps']) && count($info['Temps']) > 0) { echo ' <div class="infoTable"> <h2>' . $lang['temps_voltages'] . '</h2> <table> <tr><th>' . $lang['path'] . '</th><th>' . $lang['device'] . '</th><th>' . $lang['value'] . '</th></tr> '; $num_temps = count($info['Temps']); if ($num_temps > 0) { for ($i = 0; $i < $num_temps; $i++) { $stat = $info['Temps'][$i]; echo ' <tr> <td>' . $stat['path'] . '</td> <td>' . $stat['name'] . '</td> <td>' . $stat['temp'] . ' ' . $stat['unit'] . '</td> </tr> '; } } else { echo '<tr><td colspan="3" class="none">' . $lang['none_found'] . '</td></tr>'; } echo ' </table> </div>'; } // Show battery? if (!empty($settings['show']['battery']) && count($info['Battery']) > 0) { echo ' <div class="infoTable"> <h2>' . $lang['batteries'] . '</h2> <table> <tr><th>' . $lang['device'] . '</th><th>' . $lang['state'] . '</th><th>' . $lang['charge'] . ' %</th></tr> '; foreach ($info['Battery'] as $bat) { echo ' <tr> <td>' . $bat['device'] . '</td> <td>' . $bat['state'] . '</td> <td>' . $bat['percentage'] . ($bat['percentage'] < 0 ? ' <span class="caption">(wtf?)</span>' : '') . '</td> </tr> '; } echo ' </table> </div>'; } // Show services? if (!empty($settings['show']['services']) && count($info['services']) > 0) { echo ' <div class="infoTable"> <h2>' . $lang['services'] . '</h2> <table> <tr> <th>' . $lang['service'] . '</th><th>' . $lang['state'] . '</th><th>' . $lang['pid'] . '</th><th>Threads</th><th>' . $lang['memory_usage'] . '</th> </tr> '; // Show them foreach ($info['services'] as $service => $state) { $state_parts = explode(' ', $state['state'], 2); echo ' <tr> <td>' . $service . '</td> <td> <span class="service_' . strtolower($state_parts[0]) . '">' . $state_parts[0] . '</span> ' . (array_key_exists(1, $state_parts) ? '<span class="faded">' . $state_parts[1] . '</span>' : '') . '</td> <td>' . $state['pid'] . '</td> <td>', $state['threads'] ? $state['threads'] : '?', '</td> <td>', $state['memory_usage'] ? byte_convert($state['memory_usage']) : '?', '</td> </tr> '; } echo ' </table> </div>'; } echo ' </div> <div class="col">'; // Show hardware? if (!empty($settings['show']['devices'])) { // Don't show vendor? $show_vendor = array_key_exists('hw_vendor', $info['contains']) ? $info['contains']['hw_vendor'] === false ? false : true : true; echo ' <div class="infoTable"> <h2>' . $lang['hardware'] . '</h2> <table> <tr> <th>' . $lang['type'] . '</th> ', $show_vendor ? '<th>' . $lang['vendor'] . '</th>' : '', ' <th>' . $lang['device'] . '</th> </tr> '; $num_devs = count($info['Devices']); if ($num_devs > 0) { for ($i = 0; $i < $num_devs; $i++) { echo ' <tr> <td class="center">' . $info['Devices'][$i]['type'] . '</td> ', $show_vendor ? '<td>' . ($info['Devices'][$i]['vendor'] ? $info['Devices'][$i]['vendor'] : 'Unknown') . '</td>' : '', ' <td>' . $info['Devices'][$i]['device'] . '</td> </tr>'; } } else { echo '<tr><td colspan="3" class="none">' . $lang['none_found'] . '</td></tr>'; } echo ' </table> </div>'; } // Show drives? if (!empty($settings['show']['hd'])) { // Should we not show the Reads and Writes columns? $show_stats = array_key_exists('drives_rw_stats', $info['contains']) ? $info['contains']['drives_rw_stats'] === false ? false : true : true; // Or vendor columns? $show_vendor = array_key_exists('drives_vendor', $info['contains']) ? $info['contains']['drives_vendor'] === false ? false : true : true; echo ' <div class="infoTable"> <h2>Drives</h2> <table> <tr> <th>' . $lang['path'] . '</th> ', $show_vendor ? '<th>' . $lang['vendor'] : '', '</th> <th>' . $lang['name'] . '</th> ', $show_stats ? '<th>' . $lang['reads'] . '</th> <th>' . $lang['writes'] . '</th>' : '', ' <th>' . $lang['size'] . '</th> </tr>'; if (count($info['HD']) > 0) { foreach ($info['HD'] as $drive) { echo ' <tr> <td>' . $drive['device'] . '</td> ', $show_vendor ? '<td>' . ($drive['vendor'] ? $drive['vendor'] : $lang['unknown']) . '</td>' : '', ' <td>', $drive['name'] ? $drive['name'] : $lang['unknown'], '</td> ', $show_stats ? '<td>' . ($drive['reads'] !== false ? number_format($drive['reads']) : $lang['unknown']) . '</td> <td>' . ($drive['writes'] !== false ? number_format($drive['writes']) : $lang['unknown']) . '</td>' : '', ' <td>', $drive['size'] ? byte_convert($drive['size']) : $lang['unknown'], '</td> </tr>'; // If we've got partitions for this drive, show them too if (is_array($drive['partitions']) && count($drive['partitions']) > 0) { echo ' <tr> <td colspan="6">'; // Each foreach ($drive['partitions'] as $partition) { echo ' └ ' . (isset($partition['number']) ? $drive['device'] . $partition['number'] : $partition['name']) . ' - ' . byte_convert($partition['size']) . '<br />'; } echo ' </td> </tr> '; } } } else { echo '<tr><td colspan="6" class="none">' . $lang['none_found'] . '</td></tr>'; } echo ' </table> </div>'; } // Show sound card stuff? if (!empty($settings['show']['sound']) && count($info['SoundCards']) > 0) { echo ' <div class="infoTable"> <h2>' . $lang['sound_cards'] . '</h2> <table> <tr> <th>' . $lang['number'] . '</th> <th>' . $lang['vendor'] . '</th> <th>' . $lang['card'] . '</th> </tr>'; foreach ($info['SoundCards'] as $card) { if (empty($card['vendor'])) { $card['vendor'] = 'Unknown'; } echo ' <tr> <td>' . $card['number'] . '</td> <td>' . $card['vendor'] . '</td> <td>' . $card['card'] . '</td> </tr>'; } echo ' </table> </div> '; } echo ' </div> </div>'; // Show file system mounts? if (!empty($settings['show']['mounts'])) { $has_devices = false; $has_labels = false; $has_types = false; foreach ($info['Mounts'] as $mount) { if (!empty($mount['device'])) { $has_devices = true; } if (!empty($mount['label'])) { $has_labels = true; } if (!empty($mount['devtype'])) { $has_types = true; } } $addcolumns = 0; if ($settings['show']['mounts_options']) { $addcolumns++; } if ($has_devices) { $addcolumns++; } if ($has_labels) { $addcolumns++; } if ($has_types) { $addcolumns++; } echo ' <div class="infoTable"> <h2>' . $lang['filesystem_mounts'] . '</h2> <table> <tr>'; if ($has_types) { echo '<th>' . $lang['type'] . '</th>'; } if ($has_devices) { echo '<th>' . $lang['device'] . '</th>'; } echo '<th>' . $lang['mount_point'] . '</th>'; if ($has_labels) { echo '<th>' . $lang['label'] . '</th>'; } echo ' <th>' . $lang['filesystem'] . '</th>', $settings['show']['mounts_options'] ? ' <th>' . $lang['mount_options'] . '</th>' : '', ' <th>' . $lang['size'] . '</th> <th>' . $lang['used'] . '</th> <th>' . $lang['free'] . '</th> <th style="width: 12%;">' . $lang['percent_used'] . '</th> </tr> '; // Calc totals $total_size = 0; $total_used = 0; $total_free = 0; // Don't add totals for duplicates. (same filesystem mount twice in different places) $done_devices = array(); // Are there any? if (count($info['Mounts']) > 0) { // Go through each foreach ($info['Mounts'] as $mount) { // Only add totals for this device if we haven't already if (!in_array($mount['device'], $done_devices)) { $total_size += $mount['size']; $total_used += $mount['used']; $total_free += $mount['free']; if (!empty($mount['device'])) { $done_devices[] = $mount['device']; } } // If it's an NFS mount it's likely in the form of server:path (without a trailing slash), // but if the path is just / it likely just shows up as server:, // which is vague. If there isn't a /, add one if (preg_match('/^.+:$/', $mount['device']) == 1) { $mount['device'] .= DIRECTORY_SEPARATOR; } echo '<tr>'; if ($has_types) { echo '<td>' . $mount['devtype'] . '</td>'; } if ($has_devices) { echo '<td>' . $mount['device'] . '</td>'; } echo '<td>' . $mount['mount'] . '</td>'; if ($has_labels) { echo '<td>' . $mount['label'] . '</td>'; } echo ' <td>' . $mount['type'] . '</td>', $settings['show']['mounts_options'] ? ' <td>' . (empty($mount['options']) ? '<em>unknown</em>' : '<ul><li>' . implode('</li><li>', $mount['options']) . '</li></ul>') . '</td>' : '', ' <td>' . byte_convert($mount['size']) . '</td> <td>' . byte_convert($mount['used']) . ' <span class="perc">(' . ($mount['used_percent'] !== false ? $mount['used_percent'] : 'N/A') . '%)</span></td> <td>' . byte_convert($mount['free']) . ' <span class="perc">(' . ($mount['free_percent'] !== false ? $mount['free_percent'] : 'N/A') . '%)</span></td> <td> <div class="bar_chart"> <div class="bar_inner" style="width: ' . (int) $mount['used_percent'] . '%;"> <div class="bar_text"> ' . ($mount['used_percent'] ? $mount['used_percent'] . '%' : 'N/A') . ' </div> </div> </div> </td> </tr>'; } } else { echo '<tr><td colspan="', 6 + $addcolumns, '" class="none">None found</td></tr>'; } // Show totals and finish table $total_used_perc = $total_size > 0 && $total_used > 0 ? round($total_used / $total_size, 2) * 100 : 0; echo ' <tr class="alt"> <td colspan="', 2 + $addcolumns, '">Totals: </td> <td>' . byte_convert($total_size) . '</td> <td>' . byte_convert($total_used) . '</td> <td>' . byte_convert($total_free) . '</td> <td> <div class="bar_chart"> <div class="bar_inner" style="width: ' . $total_used_perc . '%;"> <div class="bar_text"> ' . $total_used_perc . '% </div> </div> </div> </td> </tr> </table> </div>'; } // Show RAID Arrays? if (!empty($settings['show']['raid']) && count($info['Raid']) > 0) { echo ' <div class="infoTable"> <h2>' . $lang['raid_arrays'] . '</h2> <table> <colgroup> <col style="width: 10%;" /> <col style="width: 30%;" /> <col style="width: 10%;" /> <col style="width: 10%;" /> <col style="width: 30%;" /> <col style="width: 10%;" /> </colgroup> <tr> <th>' . $lang['name'] . '</th> <th>' . $lang['level'] . '</th> <th>' . $lang['status'] . '</th> <th>' . $lang['size'] . '</th> <th>' . $lang['devices'] . '</th> <th>' . $lang['active'] . '</th> </tr> '; if (count($info['Raid']) > 0) { foreach ($info['Raid'] as $raid) { $active = explode('/', $raid['count']); // http://en.wikipedia.org/wiki/Standard_RAID_levels switch ($raid['level']) { case 0: $type = 'Stripe'; break; case 1: $type = 'Mirror'; break; case 5: case 6: $type = 'Distributed Parity Block-Level Striping'; break; default: $type = false; break; } echo ' <tr> <td>' . $raid['device'] . '</td> <td>' . $raid['level'] . ($type ? ' <span class="caption">(' . $type . ')</span>' : '') . '</td> <td>' . ucfirst($raid['status']) . '</td> <td>' . $raid['size'] . '</td> <td><table class="mini center margin_auto"><tr><th>' . $lang['device'] . '</th><th>' . $lang['state'] . '</th></tr>'; foreach ($raid['drives'] as $drive) { echo '<tr><td>' . $drive['drive'] . '</td><td class="raid_' . $drive['state'] . '">' . ucfirst($drive['state']) . '</td></tr>'; } echo '</table></td> <td>' . $active[1] . '/' . $active[0] . '</td> </tr> '; } } else { echo '<tr><td colspan="6" class="none">' . $lang['none_found'] . '</td></tr>'; } echo ' </table> </div>'; } // Feel like showing errors? Are there any even? if (!empty($settings['show_errors']) && LinfoError::Fledging()->num() > 0) { echo ' <div id="errorList" class="infoTable"> <h2>' . $lang['error_head'] . '</h2> <table> <tr> <th>' . $lang['from_where'] . '</th> <th>' . $lang['message'] . '</th> </tr>'; foreach (LinfoError::Fledging()->show() as $error) { echo ' <tr> <td>' . $error[0] . '</td> <td>' . $error[1] . '</td> </tr> '; } echo ' </table> </div> '; } // Additional extensions if (count($info['extensions']) > 0) { foreach ($info['extensions'] as $ext) { if (is_array($ext) && count($ext) > 0) { // Decide how to show something extra switch (array_key_exists('extra_type', $ext) && !empty($ext['extra_vals']) ? $ext['extra_type'] : false) { // Table with a key->value table to the right of it // Useful for stats or other stuff pertaining to // the main info to the left case 'k->v': echo ' <div class="col2_side"> <div class="col2_side_left"> ' . create_table($ext) . ' </div> <div class="col2_side_right"> <div class="infoTable"> <h2>' . $ext['extra_vals']['title'] . '</h2> <table>'; // Give each value foreach (array_filter($ext['extra_vals']['values']) as $v) { echo ' <tr> <th>' . $v[0] . '</th> <td>' . $v[1] . '</td> </tr>'; } echo ' </table> </div> </div> </div> '; break; // Nothing extra; just the table // Nothing extra; just the table default: echo create_table($ext); break; } } } } // Feel like showing timed results? if (!empty($settings['timer'])) { echo ' <div id="timerList" class="infoTable"> <h2>' . $lang['timer'] . '</h2> <table> <tr> <th>' . $lang['area'] . '</th> <th>' . $lang['time_taken'] . '</th> </tr>'; foreach (LinfoTimer::Fledging()->getResults() as $result) { echo ' <tr> <td>' . $result[0] . '</td> <td>' . round($result[1], 3) . ' ' . $lang['seconds'] . '</td> </tr> '; } echo ' </table> </div> '; } echo ' <div id="foot"> ' . sprintf($lang['footer_app'], '<a href="http://linfo.sf.net"><em>' . AppName . ' (' . VERSION . ')</em></a>', round(microtime(true) - TIME_START, 2)) . '<br /> <em>' . AppName . '</em> © 2010 – 2011 Joseph Gillotti & friends. Source code licensed under GPL. </div> <div id="foot_time"> <br /> Generated on ' . date('m/d/y h:i A') . ' </div> <script type="text/javascript">Linfo.init()</script> </body> </html>'; // End output buffering if (!isset($settings['compress_content']) || $settings['compress_content']) { ob_end_flush(); } }
$files = crm_get_contact_files($id); echo "<h3>" . __('Files') . "</h3>"; if (!$files) { echo '<h3 class="error">' . __("This contact doesn't have any file associated") . '</h3>'; } else { $table->class = "listing"; $table->width = "99%"; $table->head[0] = __("Filname"); $table->head[1] = __("Timestamp"); $table->head[2] = __("Description"); $table->head[3] = __("Size"); if (give_acl($config['id_user'], 0, "CW")) { $table->head[4] = __('Delete'); } $table->data = array(); foreach ($files as $f) { $data = array(); $link = "operation/common/download_file.php?id_attachment=" . $f["id_attachment"] . "&type=contact"; $data[0] = '<a target="_blank" href="' . $link . '">' . $f['filename'] . '</a>'; $real_filename = $config["homedir"] . "/attachment/" . $f["id_attachment"] . "_" . rawurlencode($f["filename"]); $stat = stat($real_filename); $data[1] = date("Y-m-d H:i:s", $stat['mtime']); $data[2] = $f["description"]; $data[3] = byte_convert($f['size']); if (give_acl($config['id_user'], 0, "CW")) { $data[4] = '<a class="delete" name="delete_file_' . $f["id_attachment"] . '" href="index.php?sec=customers&sec2=operation/contacts/contact_detail&id=' . $id . '&op=files&id_attachment=' . $f["id_attachment"] . '&delete_file=1"><img src="images/cross.png"></a>'; } array_push($table->data, $data); } print_table($table); }