Ejemplo n.º 1
0
function Showbrowse_Img($spec)
{
    extract($GLOBALS);
    $s = "";
    $directory = ServerMapPath($spec);
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    $s = $s . "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" valign=\"top\" id=\"FoldersAndFiles\" style=\"width:100%\" class=sortable>";
    $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" bgcolor=\"#f0f0f0\">";
    $s = $s . "<td width=16 nowrap><img src=\"../Images/refresh.gif\" title=\"refresh\" onclick=\"parent.Refresh('" . $folpath . "');\" onMouseOver=\"parent.CuteEditor_ColorPicker_ButtonOver(this);\" style=\"VERTICAL-ALIGN: middle\"></td>";
    $s = $s . "<td width=\"60%\" Class=\"filelistHeadCol\"><b>Name</b></td>";
    $s = $s . "<td nowrap Class=\"filelistHeadCol\"><b>Size</b></td>";
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowRename == "true") {
        $s = $s . "<td nowrap></td>";
    }
    $s = $s . "</tr>";
    $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" onclick=\"Editor_upfolder();\">";
    $s = $s . "<td><img src=\"../Images/parentfolder.gif\" title=\"Go up one level\" style=\"VERTICAL-ALIGN: middle\"></td>";
    $s = $s . "<td>...</td>";
    $s = $s . "<td></td>";
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowRename == "true") {
        $s = $s . "<td nowrap></td>";
    }
    $s = $s . "</tr>";
    $dirlist = array();
    $filelist = array();
    // we open the directory
    if ($f = opendir($directory)) {
        while (($file = readdir($f)) !== false) {
            if ($file != "." && $file != "..") {
                $path = $directory . '/' . $file;
                if (is_file($path)) {
                    $filelist[] = $file;
                } elseif (is_dir($path)) {
                    $dirlist[] = $file;
                }
            }
        }
        closedir($f);
    }
    if ($dirlist) {
        asort($dirlist);
        while (list($key, $file) = each($dirlist)) {
            //add the html for the folders
            $str_openfolderEvent = "onclick=\"parent.SetUpload_FolderPath('" . $current_Path . $folpath . $file . "');location.href='browse_Media.php?" . $setting . "&loc=" . $folpath . $file . "&MP=" . $current_Path . "';\"";
            $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">";
            $s = $s . "<td " . $str_openfolderEvent . "><img vspace=\"0\" hspace=\"0\" src=\"../Images/closedfolder.gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n";
            $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" " . $str_openfolderEvent . ">" . "\r\n";
            $s = $s . $file . "&nbsp;&nbsp;</td>" . "\r\n";
            $s = $s . "<td nowrap style=\"cursor:pointer;\" " . $str_openfolderEvent . "></td>";
            if ($AllowDelete == "true") {
                $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefolder('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>";
            }
            if ($AllowRename == "true") {
                $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefolder('" . $current_Path . $folpath . $file . "')\"></td>";
            }
            $s = $s . "</tr>" . "\r\n";
        }
    }
    if ($filelist) {
        asort($filelist);
        while (list($key, $file) = each($filelist)) {
            if (ValidImage($file)) {
                //add the html for the folders
                $s = $s . "<tr onclick=\"parent.row_click('" . $current_Path . $folpath . $file . "'); \" onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">";
                $s = $s . "<td><img vspace=\"0\" hspace=\"0\" src=\"../Images/" . GetExtension($file) . ".gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n";
                $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" >" . "\r\n";
                $s = $s . $file . "&nbsp;&nbsp;</td>" . "\r\n";
                $s = $s . "<td nowrap style=\"cursor:pointer;\">" . FormatSize(filesize($directory . '/' . $file)) . "</td>";
                if ($AllowDelete == "true") {
                    $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefile('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>";
                }
                if ($AllowRename == "true") {
                    $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefile('" . $current_Path . $folpath . $file . "','{$file}')\"></td>";
                }
                $s = $s . "</tr>" . "\r\n";
            }
        }
    }
    $s = $s . "</table>";
    return $s;
}
Ejemplo n.º 2
0
function Showbrowse_Img($spec)
{
    extract($GLOBALS);
    $s = "";
    $directory = ServerMapPath($spec);
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    $s = $s . "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" valign=\"top\" id=\"FoldersAndFiles\" style=\"width:100%\" class=sortable>";
    $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" bgcolor=\"#f0f0f0\">";
    $s = $s . "<td width=16 nowrap><img src=\"../Images/refresh.gif\" title=\"refresh\" onclick=\"parent.Refresh('" . $folpath . "');\" onMouseOver=\"parent.CuteEditor_ColorPicker_ButtonOver(this);\" style=\"VERTICAL-ALIGN: middle\"></td>";
    $s = $s . "<td width=\"220\" Class=\"filelistHeadCol\"><b>Name</b></td>";
    $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Size</b></td>";
    $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Modified</b></td>";
    //  $s=$s."<td width=50 nowrap Class=\"filelistHeadCol\"><b>Created</b></td>";
    $s = $s . "<td width=15 nowrap Class=\"filelistHeadCol\"><b>Attributes</b></td>";
    $s = $s . "<td width=50 nowrap Class=\"filelistHeadCol\"><b>Type</b></td>";
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowRename == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    $s = $s . "</tr>";
    $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\" onclick=\"Editor_upfolder();\">";
    $s = $s . "<td><img src=\"../Images/parentfolder.gif\" title=\"Go up one level\" style=\"VERTICAL-ALIGN: middle\"></td>";
    $s = $s . "<td>...</td>";
    $s = $s . "<td></td>";
    $s = $s . "<td></td>";
    $s = $s . "<td></td>";
    $s = $s . "<td></td>";
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowRename == "true") {
        $s = $s . "<td nowrap></td>";
    }
    if ($AllowDelete == "true") {
        $s = $s . "<td nowrap></td>";
    }
    $s = $s . "</tr>";
    $dirlist = array();
    $filelist = array();
    // we open the directory
    if ($f = opendir($directory)) {
        while (($file = readdir($f)) !== false) {
            if ($file != "." && $file != "..") {
                $path = $directory . '/' . $file;
                if (is_file($path)) {
                    $filelist[] = $file;
                } elseif (is_dir($path)) {
                    $dirlist[] = $file;
                }
            }
        }
        closedir($f);
    }
    if ($dirlist) {
        asort($dirlist);
        while (list($key, $file) = each($dirlist)) {
            $file_stat = ServerMapPath($current_Path . $folpath . $file);
            $lastmod = date("m/d/Y", filemtime($file_stat));
            $p;
            if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
                $p = show_perms(fileperms($file_stat));
            } else {
                $p = base_convert(fileperms($file_stat), 10, 8);
                $p = substr($p, strlen($p) - 3);
            }
            //add the html for the folders
            $str_openfolderEvent = "onclick=\"parent.SetUpload_FolderPath('" . $current_Path . $folpath . $file . "');location.href='browse_Document.php?" . $setting . "&loc=" . $folpath . $file . "&Theme=" . $Theme . "&DP=" . $current_Path . "';\"";
            $s = $s . "<tr onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">";
            $s = $s . "<td " . $str_openfolderEvent . "><img vspace=\"0\" hspace=\"0\" src=\"../Images/closedfolder.gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n";
            $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" " . $str_openfolderEvent . ">" . "\r\n";
            $s = $s . $file . "&nbsp;&nbsp;</td>" . "\r\n";
            $s = $s . "<td nowrap style=\"cursor:pointer;\"></td>";
            $s = $s . "<td nowrap>" . $lastmod . "</td>";
            //	    $s=$s."<td nowrap>".$lastmod."</td>";
            $s = $s . "<td nowrap>" . $p . "</td>";
            $s = $s . "<td nowrap>Directory</td>";
            if ($AllowDelete == "true") {
                $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefolder('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>";
            }
            if ($AllowRename == "true") {
                $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefolder('" . $current_Path . $folpath . $file . "')\"></td>";
            }
            if ($AllowDelete == "true") {
                $s = $s . "<td ></td>";
            }
            $s = $s . "</tr>" . "\r\n";
        }
    }
    if ($filelist) {
        asort($filelist);
        while (list($key, $file) = each($filelist)) {
            if (ValidImage($file)) {
                $file_stat = stat(ServerMapPath($current_Path . $folpath . $file));
                $size = FormatSize($file_stat[7]);
                $lastmod = date("m/d/Y", $file_stat[10]);
                //$created = date("m/d/Y",$file_stat[8]);
                //add the html for the folders
                $p;
                if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
                    $p = show_perms(fileperms(ServerMapPath($current_Path . $folpath . $file)));
                } else {
                    $p = base_convert(fileperms(ServerMapPath($current_Path . $folpath . $file)), 10, 8);
                    $p = substr($p, strlen($p) - 3);
                }
                $f_Tooltip = "";
                $f_Tooltip = $f_Tooltip . "<nobr>Name: " . $file . "</nobr><br>";
                $f_Tooltip = $f_Tooltip . "<nobr>Size: " . $size . "</nobr><br>";
                $f_Tooltip = $f_Tooltip . "<nobr>Date modified: " . $lastmod . "</nobr><br>";
                $f_Tooltip = $f_Tooltip . "<nobr>Attributes: " . $p . "</nobr><br>";
                $s = $s . "<tr onclick=\"parent.row_click('" . $current_Path . $folpath . $file . "','" . $f_Tooltip . "'); \" onMouseOver=\"row_over(this)\" onMouseOut=\"row_out(this)\">";
                $s = $s . "<td><img vspace=\"0\" hspace=\"0\" src=\"../Images/" . strtolower(substr(strrchr($file, '.'), 1)) . ".gif\" style=\"VERTICAL-ALIGN: middle\"></td>" . "\r\n";
                $s = $s . "<td valign=\"top\" style=\"cursor:pointer\" >" . "\r\n";
                $s = $s . $file . "&nbsp;&nbsp;</td>" . "\r\n";
                $s = $s . "<td nowrap style=\"cursor:pointer;\">" . $size . "</td>";
                $s = $s . "<td nowrap>" . $lastmod . "</td>";
                //	    $s=$s."<td nowrap>".$created."</td>";
                $s = $s . "<td nowrap>" . $p . "</td>";
                $s = $s . "<td nowrap>" . FindType(GetExtension($file)) . "</td>";
                if ($AllowDelete == "true") {
                    $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/delete.gif\" onclick=\"deletefile('" . $current_Path . $folpath . $file . "')\" title=\"Delete\"></td>";
                }
                if ($AllowRename == "true") {
                    $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/edit.gif\" title=\"Rename\" onclick=\"renamefile('" . $current_Path . $folpath . $file . "','{$file}')\"></td>";
                }
                if ($AllowDelete == "true") {
                    $s = $s . "<td nowrap style=\"cursor:pointer; border:1px\" ><img vspace=\"0\" hspace=\"0\" src=\"../Images/download.gif\" onclick=\"downloadfile('" . $current_Path . $folpath . $file . "')\" title=\"Download\"></td>";
                }
                $s = $s . "</tr>" . "\r\n";
            }
        }
    }
    $s = $s . "</table>";
    return $s;
}
Ejemplo n.º 3
0
echo $data['max_upload_size'];
?>
<br />
			<input type="file" name="file[]" multiple required id="simpleupload-input"/>
		</form>
		<?php 
if ($settings['listfiles']) {
    ?>
			<ul id="simpleupload-ul">
				<?php 
    foreach ($file_array as $mtime => $filename) {
        $file_info = array();
        $file_owner = false;
        $file_private = $filename[0] === '.';
        if ($settings['listfiles_size']) {
            $file_info[] = FormatSize(filesize($filename));
        }
        if ($settings['listfiles_size']) {
            $file_info[] = date($settings['listfiles_date_format'], $mtime);
        }
        if ($settings['allow_deletion'] || $settings['allow_private']) {
            if (in_array(substr($filename, 1), $_SESSION['upload_user_files']) || in_array($filename, $_SESSION['upload_user_files'])) {
                $file_owner = true;
            }
        }
        $file_info = implode(', ', $file_info);
        if (strlen($file_info) > 0) {
            $file_info = ' (' . $file_info . ')';
        }
        $class = '';
        if ($file_owner) {
Ejemplo n.º 4
0
function Showbrowse_Img($spec)
{
    extract($GLOBALS);
    $s = "";
    $directory = ServerMapPath($spec);
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    $dirlist = array();
    $imglist = array();
    // we open the directory
    if ($f = opendir($directory)) {
        while (($file = readdir($f)) !== false) {
            if ($file != "." && $file != "..") {
                $path = $directory . '/' . $file;
                if (is_file($path)) {
                    if (ValidImage($file)) {
                        $imglist[] = $file;
                    }
                } elseif (is_dir($path)) {
                    $dirlist[] = $file;
                }
            }
        }
        closedir($f);
    }
    if ($dirlist) {
        $s = $s . "<div style='overflow: auto; HEIGHT: 120px;'>";
        $s = $s . "<table border='0' cellspacing='0' cellpadding='1' width='100%' align='center' valign='top'>";
        asort($dirlist);
        while (list($key, $file) = each($dirlist)) {
            //add the html for the folders
            $str_openfolderEvent = "onclick=\"parent.SetUpload_imagePath('" . $current_Path . $folpath . $file . "');location.href='browse_Img_gallery.php?" . $setting . "&loc=" . $folpath . $file . "&Theme=" . $Theme . "&GP=" . $current_Path . "';\"";
            $s = $s . "<tr>";
            $s = $s . "<td " . $str_openfolderEvent . "><img vspace=\"0\" hspace=\"0\" src=\"../Images/closedfolder.gif\" style=\"VERTICAL-ALIGN: middle\">&nbsp;" . "\r\n";
            $s = $s . $file . "&nbsp;&nbsp;</td>" . "\r\n";
            $s = $s . "<td nowrap style=\"cursor:pointer;\" " . $str_openfolderEvent . "></td>";
            $s = $s . "</tr>" . "\r\n";
        }
        $s = $s . "</table></div>";
    }
    $imgcnt = sizeof($imglist);
    $max_per_page = TABLE_COLS * TABLE_ROWS;
    $currpage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
    // set index of page's first image in image list array
    $first_image_index = ($currpage - 1) * $max_per_page;
    // set index of page's last image in image list array
    $last_image_index = $imgcnt < $currpage * $max_per_page ? $last_image_index = $imgcnt : $currpage * $max_per_page;
    $s = $s . "<div style='HEIGHT: 280px;'><table width='100%' CellSpacing='0' valign='top'>";
    // loop control var
    $column_cnt = 1;
    // loop through current page images
    for ($i = $first_image_index; $i < $last_image_index; $i++) {
        # build path to thumb
        $thumburl = $current_Path . $folpath . $imglist[$i];
        $size = getimagesize(ServerMapPath($thumburl));
        $height = $size[1];
        $width = $size[0];
        if ($width > 80) {
            $width = 80;
            $percent = $size[0] / $width;
            $height = (int) ($size[1] / $percent);
        }
        if ($height > 64) {
            $height = 64;
            $percent = $size[1] / $height;
            $width = (int) ($size[0] / $percent);
        }
        $p;
        if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
            $p = show_perms(fileperms(ServerMapPath($thumburl)));
        } else {
            $p = base_convert(fileperms(ServerMapPath($thumburl)), 10, 8);
            $p = substr($p, strlen($p) - 3);
        }
        $file_stat = stat(ServerMapPath($thumburl));
        $filesize = FormatSize($file_stat[7]);
        $lastmod = date("m/d/Y", $file_stat[10]);
        $f_Tooltip = "";
        $f_Tooltip = $f_Tooltip . "<nobr>Name: " . $imglist[$i] . "</nobr><br>";
        $f_Tooltip = $f_Tooltip . "<nobr>Size: " . $filesize . "</nobr><br>";
        $f_Tooltip = $f_Tooltip . "<nobr>Width: " . $size[0] . "</nobr><br>";
        $f_Tooltip = $f_Tooltip . "<nobr>Height: " . $size[1] . "</nobr><br>";
        $f_Tooltip = $f_Tooltip . "<nobr>Date modified: " . $lastmod . "</nobr><br>";
        $f_Tooltip = $f_Tooltip . "<nobr>Attributes: " . $p . "</nobr><br>";
        // insert row tag if this is the first column
        if ($column_cnt == 1) {
            $s .= "<tr>\n";
        }
        // insert thumbnail, and surrounding html
        $s .= "<td>";
        $s .= "<img src=\"{$thumburl}\" border=\"0\" width=\"" . $width . "\" height=\"" . $height . "\" onclick=\"parent.insert(this.src)\"";
        $s .= " onMouseover=\"Check(this,1); showTooltip('" . $f_Tooltip . "', this, event);\"";
        $s .= " onMouseout=\"Check(this,0); delayhidetip()\" ";
        $s .= " style=\"BORDER: white 1px solid\" align=\"center\"/>";
        $s .= "</td>\n";
        if ($column_cnt == TABLE_COLS) {
            $s .= "</tr>\n\n";
            $column_cnt = 1;
        } else {
            $column_cnt++;
        }
    }
    $s = $s . "</table></div>";
    $pagecnt = (int) (($imgcnt - 1) / (TABLE_COLS * TABLE_ROWS)) + 1;
    $self = $_SERVER['PHP_SELF'];
    $s = $s . "<center>";
    // Show paging indicator if multiple pages:
    $s = $s . "Pages:&nbsp;";
    if ($currpage > 1) {
        $s = $s . "<a href=\"" . $self . "?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . ($currpage - 1) . "\">&lt;&lt; Prev</a>&nbsp;";
    }
    // You can also show page numbers:
    for ($I = 1; $I <= $pagecnt; $I = $I + 1) {
        if ($I == $currpage) {
            $s = $s . $I . "&nbsp;";
        } else {
            $s = $s . "<a href=\"" . $self . "?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . $I . "\">" . $I . "</a>&nbsp;";
        }
    }
    if ($currpage < $pagecnt) {
        $s = $s . "<a href=\"?" . $setting . "&Theme=" . $Theme . "&GP=" . $current_Path . $folpath . "&page=" . ($currpage + 1) . "\">Next &gt;&gt;</a>";
    }
    $s = $s . "</center>";
    return $s;
}
Ejemplo n.º 5
0
        $savepath = $C_AbsolutePath . '/' . $f_basename;
        $savepath = str_replace("//", "/", $savepath);
        if (is_file($savepath)) {
            unlink($savepath);
        }
        $mvcfile->MoveTo($savepath);
        chmod($savepath, 0644);
        echo "The file " . $f_basename . " has been uploaded successfully! <br>";
        echo "File size: " . FormatSize($filesize) . ".";
        echo "<script language=javascript>parent.UploadSaved('" . $filepath . $f_basename . "','" . $filepath . "');</script>";
    }
} else {
    $maxsize = ini_get('upload_max_filesize');
    $maxsize = GetMaxSize($maxsize);
    echo "File is not uploaded. Server rejected file. <br>";
    echo "The uploaded file exceeds the server upload file limitation: " . FormatSize($maxsize);
}
function FormatSize($size)
{
    // Setup some common file size measurements.
    $kb = 1024;
    // Kilobyte
    $mb = 1024 * $kb;
    // Megabyte
    $gb = 1024 * $mb;
    // Gigabyte
    $tb = 1024 * $gb;
    // Terabyte
    /* If it's less than a kb we just return the size, otherwise we keep going until
    	the size is in the appropriate measurement range. */
    if ($size < $kb) {
Ejemplo n.º 6
0
 protected function Details($id)
 {
     // Details screen may use a lot of memory if there are a lot of files in a post
     ini_set('memory_limit', '512M');
     $template = new Template();
     $result = '';
     // Get post
     try {
         $post = Post::FindByID($id);
         $author = Author::FindByID($post->authorid);
     } catch (ActiveRecord_NotFoundException $e) {
         die('<b>Error</b>: post ' . SafeHTML($this->params[0]) . ' does not exist.');
     }
     // Cache newsgroups
     try {
         $newsgroups = array();
         $groups = Newsgroup::FindAll();
         if (!is_array($groups)) {
             $groups = array($groups);
         }
         foreach ($groups as $group) {
             $newsgroups[$group->id] = $group->name;
         }
     } catch (ActiveRecord_NotFoundException $e) {
         die('<b>Error</b>: database problem - no newsgroups defined.');
     }
     $result .= '<table cellspacing="0"><tr><th>Poster</th><th>Newsgroups</th></tr>' . "\n";
     $poster = trim(preg_replace('/\\s+/', ' ', str_replace(array('@', '(', ')', '[', ']', ',', '.', '!', '-', '#', '^', '$', '+', '/', '\\'), ' ', $author->name)));
     $result .= '<tr><td class="split"><a href="' . static::$config['url']['base'] . '?' . http_build_query(array('q' => '@poster ' . $poster), '', '&amp;') . '">' . SafeHTML($author->name) . '</a></td><td class="split">';
     try {
         $list = array();
         $groups = PostGroup::FindByPostID($post->id);
         if (!is_array($groups)) {
             $list[] = $newsgroups[$groups->groupid];
         } else {
             foreach ($groups as $group) {
                 $list[] = $newsgroups[$group->groupid];
             }
         }
         $result .= implode('<br />', $list);
     } catch (ActiveRecord_NotFoundException $e) {
         die('<b>Error</b>: database problem - post is not associated with any newsgroup.');
     }
     $result .= '</tr>' . "\n" . '</table><br />' . "\n";
     // Get files
     try {
         $result .= '<table cellspacing="0">' . "\n";
         $result .= '<tr><th>Date</th><th>Subject</th><th>Parts</th><th>Size</th></tr>' . "\n";
         $articles = Article::Find(null, 'SELECT * FROM `articles` WHERE `postid` = ' . $post->id . ' ORDER BY `subject` ASC');
         if (!is_array($articles)) {
             $articles = array($articles);
         }
         foreach ($articles as $article) {
             $result .= '<tr>' . "\n";
             $result .= '<td class="date">' . gmdate('Y-m-d H:i', $article->post_date) . '</td>' . "\n";
             $result .= '<td class="subject">' . SafeHTML($article->subject) . '</td>';
             if ($article->parts_found != $article->parts_total) {
                 $result .= '<td class="parts"><span class="warning">' . SafeHTML($article->parts_found) . ' / ' . SafeHTML($article->parts_total) . '</span></td>';
             } else {
                 $result .= '<td class="parts">' . SafeHTML($article->parts_found) . ' / ' . SafeHTML($article->parts_total) . '</span></td>';
             }
             $result .= '<td class="size">' . FormatSize($article->size, 2) . '</td>';
             $result .= '</tr>' . "\n";
         }
         $result .= '</table>' . "\n";
     } catch (ActiveRecord_NotFoundException $e) {
         die('<b>Error</b>: database problem - post has no associated articles.');
     }
     $template->body = $result;
     $template->Display('layout_ajax');
 }
Ejemplo n.º 7
0
 public function View()
 {
     $result = '';
     $rs = static::$conn->Execute($this->Query(), $this->values);
     while ($row = $rs->Fetch()) {
         $template = new Template('rss_item');
         $template->title = Post::FilenameFilter($row['subject']);
         $template->link = 'http://' . static::$config['url']['domain'] . static::$config['url']['nzb'] . '/' . $row['id'];
         $template->vanity = '/' . rawurlencode(Post::NZBName($row['subject']));
         $template->desc = '<i>Age</i>: ' . floor((time() - $row['post_date'] + 1) / 86400) . ' days<br />';
         $template->desc .= '<i>Size</i>: ' . FormatSize($row['size'], 2) . '<br />';
         if ($row['parts_found'] == $row['parts_total']) {
             $template->desc .= '<i>Parts</i>: 100%<br />';
         } elseif ($row['parts_total'] > 0) {
             $template->desc .= '<i>Parts</i>: ' . number_format((int) $row['parts_found'] / (int) $row['parts_total'] * 100, 2) . '%<br />';
         } else {
             $template->desc .= '<i>Parts</i>: 0%<br />';
         }
         if (!empty($row['stats'])) {
             parse_str($row['stats'], $files);
             if (count($files) > 0) {
                 $list = array();
                 foreach ($files as $type => $count) {
                     $list[] = $count . ' ' . SafeHTML($type);
                 }
                 $template->desc .= '<i>Files</i>: ' . implode(', ', $list) . '<br />';
             }
         }
         $template->desc .= '<i>Subject</i>: ' . SafeHTML($row['subject']);
         $template->cat = 'other';
         if (isset($GLOBALS['catname'][$row['catid']])) {
             $template->cat = strtolower($GLOBALS['catname'][$row['catid']]);
         }
         $template->cat = $template->cat != 'dvd' ? ucfirst($template->cat) : strtoupper($template->cat);
         $template->size = SafeHTML($row['size']);
         $template->date = gmdate('r', $row['post_date']);
         $result .= $template . "\n";
     }
     return $result;
 }
Ejemplo n.º 8
0
 /**
  * Parser function #size - formats file size
  * Usage: {#size: variable | decimals }
  */
 protected function ParserFunction_Size($name, $params)
 {
     // If decimals is "b", return file size as bytes with thousand separators
     if (isset($params[1]) && strtolower(trim($params[1])) == 'b') {
         return number_format($this->_vars[$name], 0, '.', ',');
     }
     // Otherwise return formatted file size
     $decimals = 1;
     if (isset($params[1]) && is_numeric($params[1])) {
         $decimals = intval($params[1]);
     }
     return FormatSize($this->_vars[$name], $decimals);
 }