function bp_group_documents_forum_attachments_document_link($document) { $html = "<br /><a class='group-documents-title' id='group-document-link-{$document->id}' href='{$document->get_url()}' target='_blank'>{$document->name}"; if (get_option('bp_group_documents_display_file_size')) { $html .= " <span class='group-documents-filesize'>(" . get_file_size($document) . ")</span>"; } $html .= "</a>"; if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS && $document->description) { $html .= "<br /><span class='group-documents-description'>" . nl2br($document->description) . "</span>"; } return apply_filters('bp_group_documents_forum_document_link', $html, $document); }
/** * Get the rendered contents of the Profiler. * * @param Response $response * @return string */ public static function render($response) { // We only want to send the profiler toolbar if the request is not an AJAX // request, as sending it on AJAX requests could mess up JSON driven API // type applications, so we will not send anything in those scenarios. if (!Request::ajax()) { static::$data['memory'] = get_file_size(memory_get_usage(true)); static::$data['memory_peak'] = get_file_size(memory_get_peak_usage(true)); static::$data['time'] = number_format((microtime(true) - LARAVEL_START) * 1000, 2); return render('path: ' . __DIR__ . '/template' . BLADE_EXT, static::$data); } }
function download_item($dir, $item) { // download file // Security Fix: $item = base_name($item); if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } if (!get_is_file($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]); } if (!get_show_item($dir, $item)) { show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]); } $abs_item = get_abs_item($dir, $item); $browser = id_browser(); header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream')); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . get_file_size($dir, $item)); header('Content-Description: File Download'); if ($browser == 'IE') { header('Content-Disposition: attachment; filename="' . $item . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $item . '"'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); } //@readfile($abs_item); flush(); $fp = popen("tail -c " . get_file_size($dir, $item) . " {$abs_item} 2>&1", "r"); while (!feof($fp)) { // Send the current file part to the browser. print fread($fp, 1024); // Flush the content to the browser. flush(); } fclose($fp); exit; }
<?php if ($argv[1] == "join parts") { if (file_exists($argv[2])) { echo "{$argv['2']} exists.\n"; exit; } for ($i = 0; file_exists("part{$i}.mp4"); $i++) { $in = file_get_contents("part{$i}.mp4"); file_put_contents($argv[2], $in, FILE_APPEND); } echo "{$argv['2']} FileSize = " . filesize($argv[2]) . "\n"; array_map('unlink', glob("part*.mp4")); exit; } $remsize = get_file_size($argv[1]); if ($remsize == 0) { echo "get_file_size error, returned 0\n"; exit; } else { echo "FileSize = " . $remsize . "\n"; } $partsize = 4 * 1024 * 1024; // 4MB $numparts = (int) ($remsize / $partsize); $partmod = $remsize % $partsize; echo "PartSize = " . $partsize . "\n"; echo "NumParts = " . $numparts . "\n"; echo "PartMod = " . $partmod . "\n"; $i = 0; for ($i = 0, $off_from = 0, $off_to = $partsize; $i < $numparts; $i++, $off_from = $off_to + 1, $off_to += $partsize) {
function bp_group_documents_display_content() { global $bp; //instanciating the template will do the heavy lifting with all the superglobal variables $template = new BP_Group_Documents_Template(); ?> <div id="bp-group-documents"> <?php do_action('template_notices'); ?> <?php //-----------------------------------------------------------------------LIST VIEW-- ?> <?php if ($template->document_list && count($template->document_list >= 1)) { ?> <?php if (get_option('bp_group_documents_use_categories')) { ?> <div id="bp-group-documents-categories"> <form id="bp-group-documents-category-form" method="get" action="<?php echo $template->action_link; ?> "> <?php echo __('Category:', 'bp-group-documents'); ?> <select name="category"> <option value="" ><?php echo __('All', 'bp-group-documents'); ?> </option> <?php foreach ($template->get_group_categories() as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php if ($template->category == $category->term_id) { echo 'selected="selected"'; } ?> ><?php echo $category->name; ?> </option> <?php } ?> </select> <input type="submit" class="button" value="<?php echo __('Go', 'bp-group-documents'); ?> " /> </form> </div> <?php } ?> <div id="bp-group-documents-sorting"> <form id="bp-group-documents-sort-form" method="get" action="<?php echo $template->action_link; ?> "> <?php _e('Order by:', 'bp-group-documents'); ?> <select name="order"> <option value="newest" <?php if ('newest' == $template->order) { echo 'selected="selected"'; } ?> ><?php _e('Newest', 'bp-group-documents'); ?> </option> <option value="alpha" <?php if ('alpha' == $template->order) { echo 'selected="selected"'; } ?> ><?php _e('Alphabetical', 'bp-group-documents'); ?> </option> <option value="popular" <?php if ('popular' == $template->order) { echo 'selected="selected"'; } ?> ><?php _e('Most Popular', 'bp-group-documents'); ?> </option> </select> <input type="submit" class="button" value="<?php _e('Go', 'bp-group-documents'); ?> " /> </form> </div> <?php if ('1.1' != substr(BP_VERSION, 0, 3)) { ?> <h3><?php _e('Document List', 'bp-group-documents'); ?> </h3> <?php } ?> <div class="pagination no-ajax"> <div id="group-documents-page-count" class="pag-count"> <?php $template->pagination_count(); ?> </div> <?php if ($template->show_pagination()) { ?> <div id="group-documents-page-links" class="pagination-links"> <?php $template->pagination_links(); ?> </div> <?php } ?> </div> <?php if ('1.1' == substr(BP_VERSION, 0, 3)) { ?> <ul id="forum-topic-list" class="item-list"> <?php } else { ?> <ul id="bp-group-documents-list" class="item-list"> <?php } ?> <?php //loop through each document and display content along with admin options $count = 0; foreach ($template->document_list as $document_params) { $document = new BP_Group_Documents($document_params['id'], $document_params); ?> <li <?php if (++$count % 2) { echo 'class="alt"'; } ?> > <?php if (get_option('bp_group_documents_display_icons')) { $document->icon(); } ?> <a class="group-documents-title" id="group-document-link-<?php echo $document->id; ?> " href="<?php $document->url(); ?> " target="_blank"><?php echo $document->name; ?> <?php if (get_option('bp_group_documents_display_file_size')) { echo ' <span class="group-documents-filesize">(' . get_file_size($document) . ')</span>'; } ?> </a> <span class="group-documents-meta"><?php printf(__('Uploaded by %s on %s', 'bp-group-documents'), bp_core_get_userlink($document->user_id), date(get_option('date_format'), $document->created_ts)); ?> </span> <?php if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS && $document->description) { echo '<br /><span class="group-documents-description">' . nl2br($document->description) . '</span>'; } //show edit and delete options if user is privileged echo '<div class="admin-links">'; if ($document->current_user_can('edit')) { $edit_link = wp_nonce_url($template->action_link . 'edit/' . $document->id, 'group-documents-edit-link'); echo "<a href='{$edit_link}'>" . __('Edit', 'bp-group-documents') . "</a> | "; } if ($document->current_user_can('delete')) { $delete_link = wp_nonce_url($template->action_link . 'delete/' . $document->id, 'group-documents-delete-link'); echo "<a href='{$delete_link}' id='bp-group-documents-delete'>" . __('Delete', 'bp-group-documents') . "</a>"; } echo '</div>'; echo '</li>'; } ?> </ul> <?php } else { ?> <div id="message" class="info"> <p><?php _e('There have been no documents uploaded for this group', 'bp-group-documents'); ?> </p> </div> <?php } ?> <div class="spacer"> </div> <?php //-------------------------------------------------------------------DETAIL VIEW-- ?> <?php if ($template->show_detail) { ?> <?php if ($template->operation == 'add') { ?> <div id="bp-group-documents-upload-new"> <?php } else { ?> <div id="bp-group-documents-edit"> <?php } ?> <h3><?php echo $template->header; ?> </h3> <form method="post" id="bp-group-documents-form" class="standard-form" action="<?php echo $template->action_link; ?> " enctype="multipart/form-data" /> <input type="hidden" name="bp_group_documents_operation" value="<?php echo $template->operation; ?> " /> <input type="hidden" name="bp_group_documents_id" value="<?php echo $template->id; ?> " /> <?php if ($template->operation == 'add') { ?> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo return_bytes(ini_get('post_max_size')); ?> " <label><?php _e('Choose File:', 'bp-group-documents'); ?> </label> <input type="file" name="bp_group_documents_file" class="bp-group-documents-file" /> <?php } ?> <?php if (BP_GROUP_DOCUMENTS_FEATURED) { ?> <label class="bp-group-documents-featured-label"><input type="checkbox" name="bp_group_documents_featured" class="bp-group-documents-featured" value="1" <?php if ($template->featured) { echo 'checked="checked"'; } ?> > <?php _e('Featured Document', 'bp-group-documents'); ?> </label> <?php } ?> <div id="document-detail-clear" class="clear"></div> <div class="document-info"> <label><?php _e('Display Name:', 'bp-group-documents'); ?> </label> <input type="text" name="bp_group_documents_name" id="bp-group-documents-name" value="<?php echo $template->name; ?> " /> <?php if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS) { ?> <label><?php _e('Description:', 'bp-group-documents'); ?> </label> <textarea name="bp_group_documents_description" id="bp-group-documents-description"><?php echo $template->description; ?> </textarea> <?php } ?> <label></label> <input type="submit" class="button" value="<?php _e('Submit', 'bp-group-documents'); ?> " /> </div> <?php if (get_option('bp_group_documents_use_categories')) { ?> <div class="bp-group-documents-category-wrapper"> <label><?php _e('Category:', 'bp-group-documents'); ?> </label> <div class="bp-group-documents-category-list"> <ul> <?php foreach ($template->get_group_categories(false) as $category) { ?> <li><input type="checkbox" name="bp_group_documents_categories[]" value="<?php echo $category->term_id; ?> " <?php if ($template->doc_in_category($category->term_id)) { echo 'checked="checked"'; } ?> /><?php echo $category->name; ?> </li> <?php } ?> </ul> </div> <input type="text" name="bp_group_documents_new_category" class="bp-group-documents-new-category" /> </div><!-- .bp-group-documents-category-wrapper --> <?php } ?> </form> </div><!--end #post-new-topic--> <?php if ($template->operation == 'add') { ?> <a class="button" id="bp-group-documents-upload-button" href="" style="display:none;"><?php _e('Upload a New Document', 'bp-group-documents'); ?> </a> <?php } ?> <?php } ?> </div><!--end #group-documents--> <?php }
function print_table($dir, $list) { if (!is_array($list)) { return; } while (list($item, ) = each($list)) { // link to dir / file $abs_item = get_abs_item($dir, $item); $target = ""; //$extra=""; //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item); if (is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) { //?? CK Hier wird kuenftig immer mit dem download-Link gearbeitet, damit //?? CK die Leute links klicken koennen //?? CK $link = $GLOBALS["home_url"]."/".get_rel_item($dir, $item); $link = make_link("download", $dir, $item); $target = "_blank"; } //else $link = ""; echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (permissions_grant($dir, $item, "read")) { echo "<A HREF=\"" . $link . "\">"; } //else echo "<A>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (permissions_grant($dir, $item, "read")) { echo "</A>"; } echo "</TD>\n"; // ...$extra... // Size echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n"; // Type echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions echo "<TD>"; if (permissions_grant($dir, NULL, "change")) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if (permissions_grant($dir, NULL, "change")) { echo "</A>"; } echo "</TD>\n"; // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { _print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n"; } // DOWNLOAD if (get_is_file($dir, $item)) { _print_link("download", permissions_grant($dir, $item, "read"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } }
print "<div style='margin-bottom: 5px'><a href='?type=cabinet'><< к списку заказов</a></div>" . "<div style='font-size: 12pt; font-weight: bold; margin-bottom: 10px;'>" . $order["subject"] . "</div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Номер заказа:</div><div class='cab_ord_row_val'>" . $order["id"] . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Вид работы:</div><div class='cab_ord_row_val'>" . $type . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Направление:</div><div class='cab_ord_row_val'>" . $napr . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Дисциплина:</div><div class='cab_ord_row_val'>" . $disc . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Принят:</div><div class='cab_ord_row_val'>" . date("d.m.Y", $order["created"]) . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Дата сдачи:</div><div class='cab_ord_row_val'>" . date("d.m.Y", $order["time_kln"]) . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Статус:</div><div class='cab_ord_row_val'>" . $status . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Стоимость, руб.:</div><div class='cab_ord_row_val'>" . $cost . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Оплачено, руб.:</div><div class='cab_ord_row_val'>" . $order["oplata_kln"] . "</div><div class='clear'></div></div>" . "<div class='cab_ord_row'><div class='cab_ord_row_capt'>Требования:</div><div class='cab_ord_row_val'>" . $order["about_kln"] . "</div><div class='clear'></div></div>"; $html = array(); $files = get_order_files($order["id"], 0); if (count($files)) { $html[] = '<p style="margin-top: 20px;">Файлы</p>'; $html[] = '<table cellpadding="4" cellspacing="1" width="100%">'; $html[] = '<tr class="header">'; $html[] = '<td>Название</td>'; $html[] = '<td>Размер</td>'; $html[] = '<td>Дата добавления</td>'; $html[] = '<td>Скачать</td>'; $html[] = '</tr>'; foreach ($files as $file) { $html[] = '<tr>'; $html[] = '<td>' . $file['name'] . '</td>'; $html[] = '<td>' . get_file_size($file['size']) . '</td>'; $html[] = '<td>' . _get_fmt_date_time($file['created']) . '</td>'; $html[] = '<td>' . generate_file_link_for_frame($file) . '</td>'; $html[] = '</tr>'; } $html[] = '</table>'; } print join("\n", $html); print ' <form id="zakaz_form" method="post" enctype="multipart/form-data"> <input type="hidden" name="add_file"> <div style="height:50px; margin-bottom: 20px;margin-top: 20px; width: 580px;"> <div>Если имеются методические указания и материалы прикрепите файл (макс. размер 1го файла = ' . ini_get("upload_max_filesize") . ')</div> <div id="add_file_field" style="margin-top: 5px"> <input type=file name="zf_work_file" value="Выбрать" onchange="mkorder_add_file_change(this)"> </div>
function print_table($dir, $list, $allow) { // print table of files global $dir_up; if (!is_array($list)) { return; } if ($dir != "" || strstr($dir, _EXT_PATH)) { echo "<tr class=\"sectiontableentry1\"><td valign=\"baseline\"><a href=\"" . make_link("list", $dir_up, NULL) . "\">"; echo "<img border=\"0\" align=\"absmiddle\" src=\"" . _EXT_URL . "/images/up.png\" "; echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/> ..</a></td>\n"; echo "<td> </td><td> </td><td> </td>"; echo "</tr>"; } $i = 0; while (list($item, ) = each($list)) { if ($item == 'index.html') { continue; } $abs_item = get_abs_item($dir, $item); $is_writable = is_writable($abs_item); $is_chmodable = $GLOBALS['ext_File']->is_chmodable($abs_item); $is_readable = is_readable($abs_item); $is_deletable = $GLOBALS['ext_File']->is_deletable($abs_item); $file_info = @stat($abs_item); $is_file = false; //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item); if (@is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) { $link = make_link("download", $dir, $item); $is_file = true; } //else $link = ""; $class = $i % 2 ? 'sectiontableentry1' : 'sectiontableentry2'; //echo "<tr class=\"rowdata\">" echo '<tr class="' . $class . '">'; // Icon + Link echo "<td nowrap=\"nowrap\">"; if ($is_readable) { echo "<a href=\"" . $link . "\""; if ($is_file) { echo " title=\"" . $GLOBALS["messages"]["downlink"] . ": " . $item . "\""; } echo ">"; } //else echo "<A>"; echo "<img border=\"0\" "; echo "align=\"absmiddle\" vspace=\"5\" hspace=\"5\" src=\"" . _EXT_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } $s_item = htmlspecialchars($s_item); if (!$is_file) { echo '<strong>' . $s_item . '</strong>'; } else { echo $s_item; } if ($is_readable) { echo "</a>"; // ...$extra... } echo "</td>\n"; // Size echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n"; // type echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n"; // modified echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n"; // actions echo "</tr>\n"; $i++; } }
/** * This function assembles an array (list) of files or directories in the directory specified by $dir * The result array is send using JSON * * @param string $dir * @param string $sendWhat Can be "files" or "dirs" */ function send_dircontents($dir, $sendWhat = 'files') { // print table of files global $dir_up, $mainframe; // make file & dir tables, & get total filesize & number of items get_dircontents($dir, $dir_list, $file_list, $tot_file_size, $num_items); if ($sendWhat == 'files') { $list = $file_list; } elseif ($sendWhat == 'dirs') { $list = $dir_list; } else { $list = make_list($dir_list, $file_list); } $i = 0; $items['totalCount'] = count($list); $items['items'] = array(); $dirlist = array(); if ($sendWhat != 'dirs') { // Replaced array_splice, because it resets numeric indexes (like files or dirs with a numeric name) // Here we reduce the list to the range of $limit beginning at $start $a = 0; $output_array = array(); foreach ($list as $key => $value) { if ($a >= $GLOBALS['start'] && $a - $GLOBALS['start'] < $GLOBALS['limit']) { $output_array[$key] = $value; } $a++; } $list = $output_array; } while (list($item, $info) = each($list)) { // link to dir / file if (is_array($info)) { $abs_item = $info; if (extension_loaded('posix')) { $user_info = posix_getpwnam($info['user']); $file_info['uid'] = $user_info['uid']; $file_info['gid'] = $user_info['gid']; } } else { $abs_item = get_abs_item(ext_TextEncoding::fromUTF8($dir), $item); $file_info = @stat($abs_item); } $is_dir = get_is_dir($abs_item); if ($GLOBALS['use_mb']) { if (ext_isFTPMode()) { $items['items'][$i]['name'] = $item; } else { if (mb_detect_encoding($item) == 'ASCII') { $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item); } else { $items['items'][$i]['name'] = ext_TextEncoding::toUTF8($item); } } } else { $items['items'][$i]['name'] = ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item); } $items['items'][$i]['is_file'] = get_is_file($abs_item); $items['items'][$i]['is_archive'] = ext_isArchive($item) && !ext_isFTPMode(); $items['items'][$i]['is_writable'] = $is_writable = @$GLOBALS['ext_File']->is_writable($abs_item); $items['items'][$i]['is_chmodable'] = $is_chmodable = @$GLOBALS['ext_File']->is_chmodable($abs_item); $items['items'][$i]['is_readable'] = $is_readable = @$GLOBALS['ext_File']->is_readable($abs_item); $items['items'][$i]['is_deletable'] = $is_deletable = @$GLOBALS['ext_File']->is_deletable($abs_item); $items['items'][$i]['is_editable'] = get_is_editable($abs_item); $items['items'][$i]['icon'] = _EXT_URL . "/images/" . get_mime_type($abs_item, "img"); $items['items'][$i]['size'] = parse_file_size(get_file_size($abs_item)); // type $items['items'][$i]['type'] = get_mime_type($abs_item, "type"); // modified $items['items'][$i]['modified'] = parse_file_date(get_file_date($abs_item)); // permissions $perms = get_file_perms($abs_item); if ($perms) { if (strlen($perms) > 3) { $perms = substr($perms, 2); } $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')'; } else { $items['items'][$i]['perms'] = ' (unknown) '; } $items['items'][$i]['perms'] = $perms . ' (' . parse_file_perms($perms) . ')'; if (extension_loaded("posix")) { if ($file_info["uid"]) { $user_info = posix_getpwuid($file_info["uid"]); //$group_info = posix_getgrgid($file_info["gid"]); $items['items'][$i]['owner'] = $user_info["name"] . " (" . $file_info["uid"] . ")"; } else { $items['items'][$i]['owner'] = " (unknown) "; } } else { $items['items'][$i]['owner'] = 'n/a'; } if ($is_dir && $sendWhat != 'files') { $id = str_replace('/', $GLOBALS['separator'], $dir) . $GLOBALS['separator'] . $item; $id = str_replace($GLOBALS['separator'], '_RRR_', $id); $qtip = "<strong>" . ext_Lang::mime('dir', true) . "</strong><br /><strong>" . ext_Lang::msg('miscperms', true) . ":</strong> " . $perms . "<br />"; $qtip .= '<strong>' . ext_Lang::msg('miscowner', true) . ':</strong> ' . $items['items'][$i]['owner']; if ($GLOBALS['use_mb']) { if (ext_isFTPMode()) { $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } else { if (mb_detect_encoding($item) == 'ASCII') { $dirlist[] = array('text' => htmlspecialchars(ext_TextEncoding::toUTF8($item)), 'id' => utf8_encode($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } else { $dirlist[] = array('text' => htmlspecialchars($item), 'id' => $id, 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } } } else { $dirlist[] = array('text' => htmlspecialchars(ext_isFTPMode() ? $item : ext_TextEncoding::toUTF8($item)), 'id' => ext_isFTPMode() ? $id : ext_TextEncoding::toUTF8($id), 'qtip' => $qtip, 'is_writable' => $is_writable, 'is_chmodable' => $is_chmodable, 'is_readable' => $is_readable, 'is_deletable' => $is_deletable, 'cls' => 'folder'); } } if (!$is_dir && $sendWhat == 'files' || $sendWhat == 'both') { $i++; } } while (@ob_end_clean()) { } if ($sendWhat == 'dirs') { $result = $dirlist; } else { $result = $items; } $classname = class_exists('ext_Json') ? 'ext_Json' : 'Services_JSON'; $json = new $classname(); echo $json->encode($result); ext_exit(); }
function widget($args, $instance) { global $bp; $instance['group_id'] = bp_get_current_group_id(); if ($instance['group_id'] > 0) { $group = $bp->groups->current_group; // If the group public, or the user is super_admin or the user is member of group if ($group->status == 'public' || is_super_admin() || groups_is_user_member(bp_loggedin_user_id(), $group_id)) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? sprintf(__('Recent %s for the group', 'bp-group-documents'), $this->bp_group_documents_name) : sanitize_text_field($instance['title'])); echo $before_widget . $before_title . $title . $after_title; do_action('bp_group_documents_current_group_widget_before_html'); $document_list = BP_Group_Documents::get_list_for_newest_widget(absint($instance['num_items']), $instance['group_id'], (bool) $instance['featured']); if ($document_list && count($document_list) >= 1) { echo '<ul id="bp-group-documents-current-group" class="bp-group-documents-list">'; foreach ($document_list as $item) { $document = new BP_Group_Documents($item['id']); echo '<li>'; if (get_option('bp_group_documents_display_icons')) { $document->icon(); } ?> <a class="bp-group-documents-title" id="group-document-link-<?php echo $document->id; ?> " href="<?php $document->url(); ?> " target="_blank"><?php echo esc_html($document->name); ?> <?php if (get_option('bp_group_documents_display_file_size')) { echo ' <span class="group-documents-filesize">(' . get_file_size($document) . ')</span>'; } ?> </a> <div class="bp-group-documents-meta"> <?php $document->categories(); printf(__('Uploaded by %s on %s', 'bp-group-documents'), bp_core_get_userlink($document->user_id), date_i18n(get_option('date_format'), $document->created_ts)); ?> <?php echo '</li>'; } echo '</ul>'; } else { echo '<div class="widget-error">' . sprintf(__('There are no %s to display.', 'bp-group-documents'), $this->bp_group_documents_name) . '</div></p>'; } echo '<div class="view-all"><a href="' . bp_get_group_permalink($bp->groups->current_group) . BP_GROUP_DOCUMENTS_SLUG . '#object-nav">' . __("View all", 'bp-group-documents') . '</a></div>'; echo $after_widget; } } }
/** * * @version 1.2.2, 3/10/2013, stergatu esc_textarea * v2, 21/5/2013, stergatu, added documents categories */ function bp_group_documents_display_content() { $bp = buddypress(); //instanciating the template will do the heavy lifting with all the superglobal variables $template = new BP_Group_Documents_Template(); ?> <div id="bp-group-documents"> <?php do_action('template_notices'); ?> <h3><?php echo get_option('bp_group_documents_nav_page_name') . ' ' . __('List', 'bp-group-documents'); ?> </h3> <?php //-----------------------------------------------------------------------LIST VIEW-- ?> <div class="item-list-tabs no-ajax" id="subnav" role="navigation"> <?php if (get_option('bp_group_documents_use_categories')) { ?> <div id="bp-group-documents-categories"> <form class="standard-form" id="bp-group-documents-category-form" method="get" action="<?php echo $template->action_link; ?> "> <?php echo __('Category:', 'bp-group-documents'); ?> <select name="category"> <option value="" ><?php echo __('All', 'bp-group-documents'); ?> </option> <?php foreach ($template->get_group_categories() as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php if ($template->category == $category->term_id) { echo 'selected="selected"'; } ?> ><?php echo $category->name; ?> </option> <?php } ?> </select> <input type="submit" class="button" value="<?php echo __('Go', 'bp-group-documents'); ?> " /> </form> </div> <?php } ?> <div id="bp-group-documents-sorting"> <form class="standard-form" id="bp-group-documents-sort-form" method="get" action="<?php echo $template->action_link; ?> "> <?php _e('Order by:', 'bp-group-documents'); ?> <select name="order" id="order"> <option value="newest" <?php selected('newest', $template->order); ?> ><?php _e('Newest', 'bp-group-documents'); ?> </option> <option value="alpha" <?php selected('alpha', $template->order); ?> ><?php _e('Alphabetical', 'bp-group-documents'); ?> </option> <option value="popular" <?php selected('popular', $template->order); ?> ><?php _e('Most Popular', 'bp-group-documents'); ?> </option> </select> <input type="submit" class="button" value="<?php _e('Go', 'bp-group-documents'); ?> " /> </form> </div> <?php if ($template->document_list && count($template->document_list >= 1)) { ?> <div class="pagination no-ajax"> <div id="group-documents-page-count" class="pag-count"> <?php $template->pagination_count(); ?> </div> <?php if ($template->show_pagination()) { ?> <div id="group-documents-page-links" class="pagination-links"> <?php $template->pagination_links(); ?> </div> <?php } ?> </div> <?php } ?> </div> <!-- // subnav --> <?php if ($template->document_list && count($template->document_list >= 1)) { if ('1.1' == substr(BP_VERSION, 0, 3)) { ?> <ul id="forum-topic-list" class="item-list"> <?php } else { ?> <ul id="bp-group-documents-list" class="item-list"> <?php } //loop through each document and display content along with admin options $count = 0; foreach ($template->document_list as $document_params) { $document = new BP_Group_Documents($document_params['id'], $document_params); ?> <li <?php if (++$count % 2) { echo 'class="alt"'; } ?> > <?php if (get_option('bp_group_documents_display_icons')) { $document->icon(); } ?> <a class="bp-group-documents-title" id="group-document-link-<?php echo $document->id; ?> " href="<?php $document->url(); ?> " target="_blank"> <?php echo str_replace("\\", "", esc_html(stripslashes($document->name))); ?> <?php if (get_option('bp_group_documents_display_file_size')) { echo ' <span class="group-documents-filesize">(' . get_file_size($document) . ')</span>'; } ?> </a> <div class="bp-group-documents-meta"> <?php $document->categories(); printf(__('Uploaded by %s on %s', 'bp-group-documents'), bp_core_get_userlink($document->user_id), date_i18n(get_option('date_format'), $document->created_ts)); ?> . <?php if (get_option('bp_group_documents_display_download_count')) { echo ' <span class="group-documents-download-count">' . $document->download_count . __(' downloads since then.', 'bp-group-documents') . '</span>'; } ?> </div> <?php //show edit and delete options if user is privileged echo '<div class="admin-links">'; if ($document->current_user_can('edit')) { $edit_link = wp_nonce_url($template->action_link . 'edit/' . $document->id, 'group-documents-edit-link') . '#edit-document-form'; echo "<a href='{$edit_link}'>" . __('Edit', 'bp-group-documents') . "</a> | "; } if ($document->current_user_can('delete')) { $delete_link = wp_nonce_url($template->action_link . 'delete/' . $document->id, 'group-documents-delete-link'); echo "<a href='{$delete_link}' class='bp-group-documents-delete'>" . __('Delete', 'bp-group-documents') . "</a>"; } echo '</div>'; if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS && $document->description) { echo '<span class="group-documents-description">' . wp_kses(stripslashes($document->description), wp_kses_allowed_html('post')) . '</span>'; } //eleni add this in order to display the Addthis button on 3/2/2011 include_once ABSPATH . 'wp-admin/includes/plugin.php'; if (is_plugin_active('buddypress-addthis-ls/bp-addthis-ls.php')) { echo get_bp_addthis_ls_button($document->get_url(), $document->name); } // end eleni add echo '</li>'; } ?> </ul> <?php } else { ?> <div id="message" class="info"> <p><?php if ($template->category > 0) { _e('There are no documents in the selected category.', 'bp-group-documents'); } else { _e('There are no documents uploaded for this group.', 'bp-group-documents'); } ?> </p> </div> <?php } //-------------------------------------------------------------------DETAIL VIEW-- if ($template->show_detail) { if ($template->operation == 'add') { ?> <div id="bp-group-documents-upload-new"> <?php } else { ?> <div id="bp-group-documents-edit"><a name="edit-document-form"></a> <?php } ?> <h3><?php echo $template->header; ?> </h3> <form method="post" id="bp-group-documents-form" class="standard-form" action="<?php echo $template->action_link; ?> " enctype="multipart/form-data"> <input type="hidden" name="bp_group_documents_operation" value="<?php echo $template->operation; ?> " /> <input type="hidden" name="bp_group_documents_id" value="<?php echo $template->id; ?> " /> <?php if ($template->operation == 'add') { ?> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo return_bytes(ini_get('post_max_size')); ?> " /> <label class="bp-group-documents-file-label"><?php _e('Choose File:', 'bp-group-documents'); ?> </label> <input type="file" name="bp_group_documents_file" class="bp-group-documents-file" /> <p class="bp-group-documents-valid-file-formats"> <?php $valid_file_formats1 = get_option('bp_group_documents_valid_file_formats'); _e('Valid File Formats', 'bp-group-documents'); echo ':<br />' . str_replace(',', ', ', $valid_file_formats1); ?> </p> <?php } else { ?> <label><?php _e('Document:', 'bp-group-documents'); ?> :</label><span><?php echo $template->name; ?> </span> <?php } if (BP_GROUP_DOCUMENTS_FEATURED) { ?> <label class="bp-group-documents-featured-label"><?php _e('Featured Document', 'bp-group-documents'); ?> : </label> <input type="checkbox" name="bp_group_documents_featured" class="bp-group-documents-featured" value="1" <?php if ($template->featured) { echo 'checked="checked"'; } ?> /> <?php } ?> <div id="document-detail-clear" class="clear"></div> <div class="bp-group-documents-document-info"> <label><?php _e('Display Name:', 'bp-group-documents'); ?> </label> <input type="text" name="bp_group_documents_name" id="bp-group-documents-name" value="<?php echo $template->name; ?> " /> <?php if (BP_GROUP_DOCUMENTS_SHOW_DESCRIPTIONS) { ?> <label><?php _e('Description:', 'bp-group-documents'); ?> </label> <?php if (BP_GROUP_DOCUMENTS_ALLOW_WP_EDITOR) { if (function_exists('wp_editor')) { wp_editor($template->description, 'bp_group_documents_description', array('media_buttons' => false, 'dfw' => false)); } else { the_editor($template->description, 'bp_group_documents_description', 'bp_group_documents_description', false); } } else { ?> <textarea name="bp_group_documents_description" id="bp-group-documents-description" rows="5" cols="100"><?php echo esc_textarea($template->description); ?> </textarea> <?php } } ?> </div> <?php if (get_option('bp_group_documents_use_categories')) { ?> <div class="bp-group-documents-category-wrapper"> <label><?php _e('Category:', 'bp-group-documents'); ?> </label> <?php $group_categories = $template->get_group_categories(false); if (count($group_categories) > 0) { ?> <div class="bp-group-documents-category-list"> <ul> <?php foreach ($template->get_group_categories(false) as $category) { ?> <li><input type="checkbox" name="bp_group_documents_categories[]" value="<?php echo $category->term_id; ?> " <?php if ($template->doc_in_category($category->term_id)) { echo 'checked="checked"'; } ?> /><?php echo $category->name; ?> </li> <?php } ?> </ul> </div> <?php } ?> <input type="text" name="bp_group_documents_new_category" class="bp-group-documents-new-category" /> </div><!-- .bp-group-documents-category-wrapper --> <?php } ?> <?php wp_nonce_field('bp_group_document_save_' . $template->operation, 'bp_group_document_save'); ?> <input type="submit" class="button" value="<?php _e('Save', 'bp-group-documents'); ?> " /> </form> </div><!--end #post-new-topic--> <?php if ($template->operation == 'add') { ?> <a class="button" id="bp-group-documents-upload-button" href="" style="display:none;"><?php _e('Upload a New Document', 'bp-group-documents'); ?> </a> <?php } } ?> </div><!--end #group-documents--> <?php }
/** * @param string $spotify_id * @param string $artist * @param string $title * @param int $duration * @param string $access_token */ function find_and_download($spotify_id, $artist, $title, $duration, $access_token) { $artist = decode_special_chars(trim($artist)); $title = decode_special_chars(trim($title)); /** * API request */ $q = urlencode("{$artist} - {$title}"); $result = json_decode(file_get_contents("https://api.vk.com/method/audio.search?q={$q}&count=20&&access_token={$access_token}"), true); /** * Error happened */ if (isset($result['error'])) { /** * If too many requests - wait for 3 seconds and try again */ if ($result['error']['error_code'] == 6) { unset($q, $result); sleep(3); find_and_download($spotify_id, $artist, $title, $duration, $access_token); } else { echo "{$artist} - {$title}: {$result['error']['error_msg']}\n"; } return; } $result = array_slice($result['response'], 1); if (!$result) { file_put_contents(__DIR__ . '/spotify_fail.csv', "{$spotify_id};{$artist} - {$title};{$duration}\n", FILE_APPEND); echo "Failed: {$artist} - {$title}\n"; return; } /** * Normalize found tracks and calculate file size */ foreach ($result as &$r) { $r['title'] = decode_special_chars(trim($r['title'])); $r['artist'] = decode_special_chars(trim($r['artist'])); $r = ['title' => $r['title'], 'title_levenshtein' => levenshtein($r['title'], $title), 'artist' => $r['artist'], 'artist_levenshtein' => levenshtein($r['artist'], $artist), 'size' => get_file_size($r['url']), 'url' => $r['url'], 'duration' => $r['duration'], 'duration_diff' => abs($r['duration'] - $duration), 'not_remix' => !preg_match('/remix/i', $title) && !preg_match('/remix/i', $r['title'])]; } unset($r); /** * Sort found tracks by better fit and quality */ usort($result, function ($track1, $track2) use($artist, $title) { if ($track1['title_levenshtein'] != $track2['title_levenshtein']) { return $track1['title_levenshtein'] < $track2['title_levenshtein'] ? -1 : 1; } if ($track1['artist_levenshtein'] != $track2['artist_levenshtein']) { return $track1['artist_levenshtein'] < $track2['artist_levenshtein'] ? -1 : 1; } if ($track1['not_remix'] != $track2['not_remix']) { return $track1['not_remix'] ? -1 : 1; } if ($track1['duration_diff'] != $track2['duration_diff']) { return $track1['duration_diff'] < $track2['duration_diff'] ? -1 : 1; } return $track1['size'] > $track2['size'] ? -1 : 1; }); if (!is_dir('spotify')) { mkdir('spotify'); } $found = $result[0]; unset($result); file_put_contents(__DIR__ . '/spotify/' . str_replace('/', '|', "{$artist} - {$title}.mp3"), file_get_contents($found['url'])); file_put_contents(__DIR__ . '/spotify_success.csv', "{$spotify_id};{$artist} - {$title};{$duration};{$found['artist']} - {$found['title']};{$found['duration']}\n", FILE_APPEND); echo "Succeed: {$artist} - {$title}\n"; echo "Actually downloaded: {$found['artist']} - {$found['title']}\n"; }
/** print table of files */ function print_table($dir, $list) { if (!is_array($list)) { return; } while (list($item) = each($list)) { // link to dir / file $abs_item = get_abs_item($dir, $item); $target = ""; if (is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { $link = make_link("download", $dir, $item); $target = "_blank"; } echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (permissions_grant($dir, $item, "read")) { echo "<A HREF=\"" . $link . "\">"; } //else echo "<A>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (permissions_grant($dir, $item, "read")) { echo "</A>"; } echo "</TD>\n"; // ...$extra... // Size echo '<TD>' . parse_file_size(get_file_size($dir, $item)) . sprintf("%10s", " ") . "</TD>\n"; // Type echo "<td>" . _get_link_info($dir, $item, "type") . "</td>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions echo "<TD>"; if (permissions_grant($dir, NULL, "change")) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if (permissions_grant($dir, NULL, "change")) { echo "</A>"; } echo "</TD>\n"; // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { _print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item); } else { // UNZIP if (get_is_unzipable($dir, $item)) { _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } } // DOWNLOAD if (get_is_file($dir, $item)) { _print_link("download", permissions_grant($dir, $item, "read"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } }
function print_table($dir, $list) { if (!is_array($list)) { return; } while (list($item, ) = each($list)) { // link to dir / file $abs_item = get_abs_item($dir, $item); $target = ""; //$extra=""; //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item); if (is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) { //?? CK Hier wird kuenftig immer mit dem download-Link gearbeitet, damit //?? CK die Leute links klicken koennen //?? CK $link = $GLOBALS["home_url"]."/".get_rel_item($dir, $item); $link = make_link("download", $dir, $item); $target = "_blank"; } //else $link = ""; if ($item == 'hn') { echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (permissions_grant($dir, $item, "read")) { echo "<A HREF=\"" . $link . "\">"; } //else echo "<A>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (permissions_grant($dir, $item, "read")) { echo "</A>"; } echo "</TD>\n"; // ...$extra... // Size echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n"; // Type echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions /* echo "<TD>"; if (permissions_grant($dir, NULL, "change")) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if (permissions_grant($dir, NULL, "change")) echo "</A>"; echo "</TD>\n"; */ // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { //_print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item); echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } else { // UNZIP if (get_is_unzipable($dir, $item)) { _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } } // DOWNLOAD if (get_is_file($dir, $item)) { //_print_link("download", permissions_grant($dir, $item, "read"), $dir, $item); echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } else { if ($dir == 'hn') { echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (permissions_grant($dir, $item, "read")) { echo ""; } //else echo "<A>"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (permissions_grant($dir, $item, "read")) { if (get_mime_type($dir, $item, "type") == 'Directory') { echo '<span style="display:inline-block;padding:0 5px"></span>| Kopírovať slug pre vydanie: <input type="text" onclick="this.focus();this.select();" readonly="readonly" value="' . $item . '" style="border:1px solid #aaa">'; } } echo ""; echo "</TD>\n"; // ...$extra... // Size echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n"; // Type echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions /* echo "<TD>"; if (permissions_grant($dir, NULL, "change")) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if (permissions_grant($dir, NULL, "change")) echo "</A>"; echo "</TD>\n"; */ // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { //_print_link("edit", permissions_grant($dir, $item, "change"), $dir, $item); echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } else { // UNZIP if (get_is_unzipable($dir, $item)) { _print_link("unzip", permissions_grant($dir, $item, "create"), $dir, $item); } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } } // DOWNLOAD if (get_is_file($dir, $item)) { //_print_link("download", permissions_grant($dir, $item, "read"), $dir, $item); echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"" . $GLOBALS["baricons"]["none"] . "\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } } } }
function postmode_file_selection() { $param_name = 'file'; // there are two ways into the file selection mode; // either the user has just arrived at the import page, // or they've selected a file *and might progress to file-parsing mode* $error = ''; if (@$_FILES[$param_name]) { if ($_FILES[$param_name]['size'] == 0) { $error = 'no file was uploaded'; } else { //DEBUG print $_FILES['import_file']['error']; switch ($_FILES[$param_name]['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error = "The uploaded file was too large. Please consider importing it in several stages."; break; case UPLOAD_ERR_PARTIAL: $error = "The uploaded file was only partially uploaded."; break; case UPLOAD_ERR_NO_FILE: $error = "No file was uploaded."; break; case UPLOAD_ERR_NO_TMP_DIR: $error = "Missing a temporary folder."; break; case UPLOAD_ERR_CANT_WRITE: $error = "Failed to write file to disk"; break; default: $error = "Unknown file error"; } $content_length = fix_integer_overflow((int) @$_SERVER['CONTENT_LENGTH']); $post_max_size = get_config_bytes(ini_get('post_max_size')); if ($post_max_size && $content_length > $post_max_size) { $error = 'The uploaded file exceeds the post_max_size directive in php.ini'; } else { if ($_FILES[$param_name]['tmp_name'] && is_uploaded_file($_FILES[$param_name]['tmp_name'])) { $file_size = get_file_size($_FILES[$param_name]['tmp_name']); } else { $file_size = $content_length; } $file_max_size = get_config_bytes(ini_get('upload_max_filesize')); if ($file_max_size && $content_length > $file_max_size) { $error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; } } print $error; } if (!$error) { // move on to the next stage! //$error = postmode_file_load_to_db($_FILES[$param_name]['tmp_name'], $_FILES[$param_name]['name'], true); } } return $error; }
/** * Return list of files from given path. * @param string $path where to look for files. * @return array<mixed> list of files. */ private function get_files($path) { $files = array(); if (file_exists($path)) { $files_in_dir = scandir($path); foreach ($files_in_dir as $file) { if (is_file($path . $file)) { $ext = strrpos($path . $file, '.'); if (substr($path . $file, $ext) !== 'upload_part') { $files[] = array('file' => $file, 'filepath' => $path . $file, 'size' => get_file_size($path . $file)); } } } } return $files; }
$files_result .= '<form><input type="hidden" name="f-id" class="f-id" value="' . $f_data[3] . '" /><input type="hidden" name="f-filename" class="f-filename" value="' . $f_data[1] . '.' . $f_data[2] . '" /><input type="hidden" name="f-ext" class="f-ext" value="' . $f_data[2] . '" /><input type="hidden" name="f-url" class="f-url" value="' . $conf['admin_url'] . '/' . $dir[$f_data[5]] . $f_data[1] . '.' . $f_data[2] . '" /><input type="hidden" name="f-folder" class="f-folder" value="' . $f_data[5] . '" /><input type="hidden" name="f-title" class="f-title" value="' . $f_data[9] . '" /><input type="hidden" name="f-description" class="f-description" value="' . $f_data[10] . '" /><input type="hidden" name="f-size" class="f-size" value="' . get_file_size($f_data[4], 2, false) . '" />'; $files_result .= $f_data[5] == 'images' ? '<input type="hidden" name="f-thumb" class="f-thumb" value="' . $conf['admin_url'] . '/' . $dir['thumbs'] . '_' . $f_data[1] . '.' . $f_data[2] . '" /><input type="hidden" name="f-imgsize" class="f-imgsize" value="' . $f_data[7] . ' × ' . $f_data[8] . '" />' : ''; $files_result .= '</form></div>'; } else { $files_result .= '<tr' . $tr_class . '> <td><!-- ' . $f_data[3] . ' --><input type="checkbox" name="files[]" value="' . $f_data[3] . '" class="checkbox" /></td> <td class="cell-icon"><!-- ' . $f_data[2] . ' -->' . $file_image . '</td> <td><!-- ' . $f_data[1] . ' --> <a href="' . MN_ROOT . $dir[$f_data[5]] . $f_data[1] . '.' . $f_data[2] . '"' . $file_class . '>' . $f_data[1] . '<span class="ext">.' . $f_data[2] . '</span></a><br /> <span class="links hide"> <a href="./mn-files.php?action=edit&id=' . $f_data[3] . '">' . $lang['uni_edit'] . '</a> · <a href="./mn-files.php?action=delete&id=' . $f_data[3] . '" class="fancy">' . $lang['uni_delete'] . '</a> <!-- · <input type="text" class="file-link" value="' . $conf['admin_url'] . '/' . $dir[$f_data[5]] . $f_data[1] . '.' . $f_data[2] . '" />--> </span> </td> <td><!-- ' . $f_data[4] . ' -->' . get_file_size($f_data[4], 2, false) . $img_size . '</td> <td>' . $lang['files_dir_' . $f_data[5]] . '</td> <td>' . $uploaders[$f_data[6]] . '</td> <td>' . date('d.m.Y', $f_data[0]) . '<br /><span class="trivial">' . date('H:i', $f_data[0]) . '</span></td> </tr>'; } } if (isset($_GET['ajaxcall'])) { $admin_tmpl['mce_gallery_list'] = true; } else { $admin_tmpl['files_list'] = true; } } if (isset($admin_tmpl['mce_gallery_list']) && $admin_tmpl['mce_gallery_list']) { if (is_writeable($dir['images']) && is_writeable($dir['thumbs'])) { $file_exts = '';
} elseif ($size_in == 'KB') { $size = $size_in_bytes / 1024; $precision = 2; } elseif ($size_in == 'MB') { $size = $size_in_bytes / 1024 / 1024; $precision = 2; } elseif ($size_in == 'GB') { $size = $size_in_bytes / 1024 / 1024 / 1024; $precision = 2; } $size = round($size, $precision); return $size . ' ' . $size_in; } for ($i = 0; $i < count($rows); ++$i) { $record = $rows[$i]; $filesize = get_file_size(JPATH_SITE . DS . $record->filename_small); ?> <tr class="audiorow <?php echo $i % 2 == 0 ? 'audiooddrow' : 'audioevenrow'; ?> <?php echo 'audiorow' . $i; ?> "> <td class="center audiorowdate"><?php echo date('F j, Y', strtotime($record->performed_date)); ?> </td> <td class="center audiorowvenue"><?php echo htmlentities($record->venue); ?>
<table class="tablesorter" id="backup-table"> <thead> <?php echo '<tr><th id="file_name">' . $lang['backup_file_name'] . '</th><th id="file_size" class="num">' . $lang['backup_file_size'] . '</th><th id="file_date" class="date">' . $lang['backup_file_date'] . '</th></tr>'; ?> </thead> <?php echo $backup_result; ?> </table> <script type="text/javascript" src="./stuff/etc/jquery-tablesorter-min.js"></script> <script type="text/javascript">$(function() {$("table") .tablesorter({widthFixed: false})});</script> <?php echo '<p class="c">' . $lang['backup_dir_size'] . ': <strong>' . get_file_size($backup_dir_size, 2, false) . '</strong></p>'; } ?> <p class="disclaimer"> <?php echo '<strong>' . $lang['backup_disclaimer'] . ':</strong> ' . $lang['backup_disclaimer_text']; ?> </p> <?php } if (isset($admin_tmpl['backup_delete']) && $admin_tmpl['backup_delete']) { ?> <form action="./mn-tools.php" method="post" id="backup-delete" class="item-delete">
<?php if (get_post_meta($post->ID, 'attachment', TRUE)) { $fileurl = wp_get_attachment_url(get_post_meta($post->ID, 'attachment', TRUE)); $fileinfo = pathinfo($fileurl); ?> 関連資料:<a href="<?php echo $fileurl; ?> " target="_blank"><?php echo get_post_meta($post->ID, 'attachment_title', TRUE) ? get_post_meta($post->ID, 'attachment_title', TRUE) : get_post_meta($post->ID, 'attachment', TRUE); ?> (<?php echo strtoupper($fileinfo['extension']); ?> :<?php echo get_file_size(get_attached_file(get_post_meta($post->ID, 'attachment', TRUE))); ?> )</a> <?php } ?> </p> </div> </div> <!-- 同カテゴリ新着 --> <div class="fixHeight event-list sub-list"> <?php query_posts(array('posts_per_page' => 3, 'meta_query' => array(array('key' => 'category', 'value' => $category))));
function print_table($dir, $list, $allow) { // print table of files global $dir_up; if (!is_array($list)) { return; } if ($dir != "" || strstr($dir, _QUIXPLORER_PATH)) { echo "<tr class=\"row1\">\n\t \t\t\t<td> </td>\n\t \t\t\t<td valign=\"baseline\">\n\t \t\t\t\t<a href=\"" . make_link("list", $dir_up, NULL) . "\">\n\t \t\t\t\t<img border=\"0\" width=\"22\" height=\"22\" align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/_up.png\" alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/> ..</a>\n\t \t\t\t</td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>\n\t \t\t\t<td> </td>"; if (extension_loaded("posix")) { echo "<td> </td>"; } echo "</tr>"; } $i = 0; $toggle = false; while (list($item, $info) = each($list)) { // link to dir / file if (is_array($info)) { $abs_item = $info; if (extension_loaded('posix')) { $user_info = posix_getpwnam($info['user']); $file_info['uid'] = $user_info['uid']; $file_info['gid'] = $user_info['gid']; } } else { $abs_item = get_abs_item($dir, $item); $file_info = @stat($abs_item); } $is_writable = @$GLOBALS['jx_File']->is_writable($abs_item); $is_chmodable = @$GLOBALS['jx_File']->is_chmodable($abs_item); $is_readable = @$GLOBALS['jx_File']->is_readable($abs_item); $is_deletable = @$GLOBALS['jx_File']->is_deletable($abs_item); $target = ""; $extra = ""; if (@$GLOBALS['jx_File']->is_link($abs_item)) { $extra = " -> " . @readlink($abs_item); } if (@get_is_dir($abs_item, '')) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { if (get_is_editable($abs_item) && $is_writable) { $link = make_link('edit', $dir, $item); } elseif ($is_readable) { if (strstr(get_abs_dir($dir), $GLOBALS['mosConfig_absolute_path']) && !$GLOBALS['jx_File']->is_link($abs_item)) { $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item); $target = '_blank'; } else { $link = make_link('download', $dir, $item); } } } if (jx_isIE()) { echo '<tr onmouseover="style.backgroundColor=\'#D8ECFF\';" onmouseout="style.backgroundColor=\'#EAECEE\';" bgcolor=\'#EAECEE\'>'; } else { $toggle = $toggle ? '1' : '0'; echo "<tr class=\"row{$toggle}\">"; $toggle = !$toggle; } echo "<td><input type=\"checkbox\" id=\"item_{$i}\" name=\"selitems[]\" value=\""; echo urlencode($item) . "\" onclick=\"javascript:Toggle(this);\" /></td>\n"; // Icon + Link echo "<td nowrap=\"nowrap\" align=\"left\">"; if ($is_readable) { echo "<a href=\"" . $link . "\" target=\"" . $target . "\">"; } //else echo "<<>"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "align=\"absmiddle\" src=\"" . _QUIXPLORER_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\" /> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item . $extra); if ($is_readable) { echo "</a>"; // ...$extra... } echo "</td>\n"; // Size echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n"; // type echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n"; // modified echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n"; // permissions echo "<td>"; if ($allow && $is_chmodable) { echo "<a href=\"" . make_link("chmod", $dir, $item) . "\" title=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } $perms = get_file_perms($abs_item); if (strlen($perms) > 3) { $perms = substr($perms, 2); } echo '<strong>' . $perms . '</strong><br />' . parse_file_type($dir, $item) . parse_file_perms($perms); if ($allow && $is_chmodable) { echo "</a>"; } echo "</td>\n"; // Owner error_reporting(E_ALL); if (extension_loaded("posix")) { echo "<td>\n"; $user_info = posix_getpwuid($file_info["uid"]); $group_info = posix_getgrgid($file_info["gid"]); echo $user_info["name"] . " (" . $file_info["uid"] . ") /<br/>"; echo $group_info["name"] . " (" . $file_info["gid"] . ")"; echo "</td>\n"; } // actions echo "<td style=\"white-space:nowrap;\">\n"; // Rename // A file that could be deleted can also be renamed if ($allow && $is_deletable) { echo "<a href=\"" . make_link("rename", $dir, $item) . "\">"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_rename.gif\" alt=\"" . $GLOBALS["messages"]["renamelink"] . "\" title=\""; echo $GLOBALS["messages"]["renamelink"] . "\" /></a>\n"; } else { echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_rename_.gif\" alt=\"" . $GLOBALS["messages"]["renamelink"] . "\" title=\""; echo $GLOBALS["messages"]["renamelink"] . "\" />\n"; } // EDIT if (get_is_editable($abs_item)) { if ($allow && $is_writable) { echo "<a href=\"" . make_link("edit", $dir, $item) . "\">"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_edit.png\" alt=\"" . $GLOBALS["messages"]["editlink"] . "\" title=\""; echo $GLOBALS["messages"]["editlink"] . "\" /></a>\n"; } else { echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_edit_.png\" alt=\"" . $GLOBALS["messages"]["editlink"] . "\" title=\""; echo $GLOBALS["messages"]["editlink"] . "\" />\n"; } } else { // Extract Link if (jx_isArchive($item) && !jx_isFTPMode()) { echo "<a "; echo "onclick=\"javascript: ClearAll();if( confirm('" . $GLOBALS["messages"]["extract_warning"] . "') ) { return true } else { return false;}\" "; echo "href=\"" . make_link("extract", $dir, $item) . "\" title=\"" . $GLOBALS["messages"]["extractlink"] . "\">"; echo "<img border=\"0\" width=\"22\" height=\"20\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_extract.png\" alt=\"" . $GLOBALS["messages"]["extractlink"]; echo "\" title=\"" . $GLOBALS["messages"]["extractlink"] . "\" /></a>\n"; } else { echo "<img border=\"0\" width=\"16\" height=\"16\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n"; } } // VIEW if (get_is_editable($abs_item) && $GLOBALS['jx_File']->is_readable($abs_item) && get_is_file($abs_item)) { $link = str_replace('/index2.php', '/index3.php', make_link("view", $dir, $item)); $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=750,height=580,directories=no,location=no,screenX=100,screenY=100'; echo "<a href=\"" . $link . "\" onclick=\"window.open('{$link}','win2','{$status}'); return false;\" title=\"" . $GLOBALS["messages"]["viewlink"] . "\">"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/src.gif\" alt=\"" . $GLOBALS["messages"]["viewlink"] . "\" /></a>\n"; } // DOWNLOAD / Extract if (get_is_file($abs_item)) { if ($allow) { echo "<a href=\"" . make_link("download", $dir, $item) . "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\">"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_download.png\" alt=\"" . $GLOBALS["messages"]["downlink"]; echo "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\" /></a>\n"; } else { if (!$allow) { echo "<td><img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_download_.png\" alt=\"" . $GLOBALS["messages"]["downlink"]; echo "\" title=\"" . $GLOBALS["messages"]["downlink"] . "\" />\n"; } } } else { echo "<img border=\"0\" width=\"16\" height=\"16\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n"; } // DELETE if (get_is_file($abs_item)) { if ($allow && $GLOBALS['jx_File']->is_deletable($abs_item)) { $confirm_msg = sprintf($GLOBALS["messages"]["confirm_delete_file"], $item); echo "<a name=\"link_item_{$i}\" href=\"#link_item_{$i}\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" \n\t\t\t\tonclick=\"javascript: ClearAll(); getElementById('item_{$i}').checked = true; if( confirm('" . $confirm_msg . "') ) { document.selform.do_action.value='delete'; document.selform.submit(); } else { getElementById('item_{$i}').checked = false; return false;}\">"; echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_delete.gif\" alt=\"" . $GLOBALS["messages"]["dellink"]; echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" /></a>\n"; } else { echo "<img border=\"0\" width=\"22\" height=\"22\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_delete_.gif\" alt=\"" . $GLOBALS["messages"]["dellink"]; echo "\" title=\"" . $GLOBALS["messages"]["dellink"] . "\" />\n"; } } else { echo "<img border=\"0\" width=\"16\" height=\"16\" "; echo "src=\"" . _QUIXPLORER_URL . "/images/_.gif\" alt=\"\" />\n"; } echo "</td></tr>\n"; $i++; } }
function print_table($dir, $list, $allow) { // print table of files if (!is_array($list)) { return; } while (list($item, ) = each($list)) { // link to dir / file $abs_item = get_abs_item($dir, $item); $target = ""; //$extra=""; //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item); if (is_dir($abs_item)) { $link = make_link("list", get_rel_item($dir, $item), NULL); } else { //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) { $link = $GLOBALS["home_url"] . "/" . get_rel_item($dir, $item); $target = "_blank"; } //else $link = ""; echo "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\""; echo htmlspecialchars($item) . "\" onclick=\"javascript:Toggle(this);\"></TD>\n"; // Icon + Link echo "<TD nowrap>"; if (get_is_dir($dir, $item)) { /*if($link!="") */ echo "<A HREF=\"" . $link . "\" TARGET=\"" . $target . "\">"; //else echo "<A>"; } echo "<IMG border=\"0\" width=\"16\" height=\"16\" "; echo "align=\"ABSMIDDLE\" src=\"_img/" . get_mime_type($dir, $item, "img") . "\" ALT=\"\"> "; $s_item = $item; if (strlen($s_item) > 50) { $s_item = substr($s_item, 0, 47) . "..."; } echo htmlspecialchars($s_item); if (get_is_dir($dir, $item)) { echo "</A>"; } echo "</TD>\n"; // ...$extra... // Size echo "<TD>" . parse_file_size(get_file_size($dir, $item)) . "</TD>\n"; // Type echo "<TD>" . get_mime_type($dir, $item, "type") . "</TD>\n"; // Modified echo "<TD>" . parse_file_date(get_file_date($dir, $item)) . "</TD>\n"; // Permissions echo "<TD>"; if ($allow) { echo "<A HREF=\"" . make_link("chmod", $dir, $item) . "\" TITLE=\""; echo $GLOBALS["messages"]["permlink"] . "\">"; } echo parse_file_type($dir, $item) . parse_file_perms(get_file_perms($dir, $item)); if ($allow) { echo "</A>"; } echo "</TD>\n"; // Actions echo "<TD>\n<TABLE>\n"; // EDIT if (get_is_editable($dir, $item)) { if ($allow) { echo "<TD><A HREF=\"" . make_link("edit", $dir, $item) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_edit.gif\" ALT=\"" . $GLOBALS["messages"]["editlink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["editlink"] . "\"></A></TD>\n"; } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_edit_.gif\" ALT=\"" . $GLOBALS["messages"]["editlink"] . "\" TITLE=\""; echo $GLOBALS["messages"]["editlink"] . "\"></TD>\n"; } } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n"; } // DOWNLOAD if (get_is_file($dir, $item)) { if ($GLOBALS["display_file_download_icon"]) { if ($allow) { echo "<TD><A HREF=\"" . make_link("download", $dir, $item) . "\">"; echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_download.gif\" ALT=\"" . $GLOBALS["messages"]["downlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["downlink"] . "\"></A></TD>\n"; } else { if (!$allow) { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_download_.gif\" ALT=\"" . $GLOBALS["messages"]["downlink"]; echo "\" TITLE=\"" . $GLOBALS["messages"]["downlink"] . "\"></TD>\n"; } } } } else { echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" "; echo "src=\"_img/_.gif\" ALT=\"\"></TD>\n"; } echo "</TABLE>\n</TD></TR>\n"; } }
/** * Return info about solution file with specific real file name. * @param string $real_filename solution file name. * @return boolean|array<mixed> returns FALSE if file is not found or array of file informations if it is found. */ public function get_specific_file_info($real_filename) { if (!is_null($this->id)) { $path = 'private/uploads/solutions/task_set_' . intval($this->id) . '/'; if (file_exists($path)) { $all_files = scandir($path); if (in_array($real_filename, $all_files) && preg_match(self::STUDENT_FILE_NAME_REGEXP, $real_filename, $matches)) { return array('file' => $real_filename, 'filepath' => $path . $real_filename, 'size' => get_file_size($path . $real_filename), 'student_id' => $matches['student_id'], 'file_name' => $matches['file_name'], 'random_hash' => $matches['random_hash'], 'last_modified' => filemtime($path . $real_filename), 'version' => intval($matches['solution_version'])); } } } return FALSE; }
function gallery_tmpl($line, $template, $url, $gallery_id) { global $dir, $conf, $default_template; $g = get_values('files', $line, false); $tmpl_file = file_exists(MN_ROOT . $dir['templates'] . $template . '.html') ? file_get_contents(MN_ROOT . $dir['templates'] . $template . '.html') : $default_template[19]; $image_url = $conf['admin_url'] . '/' . $dir['images'] . $g['filename'] . '.' . $g['ext']; $thumb_url = file_exists(MN_ROOT . $dir['thumbs'] . '_' . $g['filename'] . '.' . $g['ext']) ? $conf['admin_url'] . '/' . $dir['thumbs'] . '_' . $g['filename'] . '.' . $g['ext'] : $image_url; $tmpl_search = array('{IMAGE}', '{IMAGE_DESCRIPTION}', '{IMAGE_EXT}', '{IMAGE_FILE}', '{IMAGE_FILENAME}', '{IMAGE_FILESIZE}', '{IMAGE_HEIGHT}', '{IMAGE_TITLE}', '{IMAGE_URL}', '{IMAGE_WIDTH}', '{GALLERY_ID}', '{THUMBNAIL}', '{THUMBNAIL_URL}'); $tmpl_replace = array('<img src="' . $image_url . '" alt="" width="' . $g['img_width'] . '" height="' . $g['img_height'] . '" />', $g['description'], $g['ext'], $g['filename'] . '.' . $g['ext'], $g['filename'], get_file_size($g['filesize'], 2, false), $g['img_height'], $g['title'], $image_url, $g['img_width'], $gallery_id, '<img src="' . $thumb_url . '" alt="" />', $thumb_url); $result = str_ireplace($tmpl_search, $tmpl_replace, $tmpl_file); $result = common_tmpl($g['timestamp'], $result); return $result; }