Created
November 12, 2021 17:56
-
-
Save tradesouthwest/6452530abc2bcb7f253f09ae5bc329ea to your computer and use it in GitHub Desktop.
list images with tow files drop into img folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* TSW Listing Nano Directory | |
* Author: Larry Judd Oliver @tradesouthwest | http://tradesouthwest.com | |
* Contributors in readme.md file | |
* License in LICENSE.md file | |
* ///////////////////////////////////////////////////////////////////// | |
* MUST BE USED ALONG WITH [list-images.php] | |
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | |
*/ | |
session_start(); | |
if (!isset($_SESSION['user_session'])) | |
{ | |
header('Location: ../../lib/user/login.php'); | |
die(); | |
} | |
?> | |
<?php | |
include_once '../../inc/settings.php'; | |
include_once '../../inc/controls.php'; | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width,initial-scale=1"> | |
<link rel="stylesheet" href="<?php esc( $theme_url ); ?>/lib/bootstrap.min.css"> | |
<link rel="stylesheet" href="<?php esc( $theme_url ); ?>/theme-style.css"> | |
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,700,700italic,900,900italic' rel='stylesheet' type='text/css'> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> | |
<link rel="shortcut icon" href="<?php esc( $theme_url ); ?>/favicon.png"> | |
<link rel="apple-itouch-icon" href="<?php esc( $theme_url ); ?>/lib/img/apple-touch-icon.png"> | |
<style> | |
body{ | |
font-family: 'Lato', sans-serif; | |
background-color: rgb(255, 255, 255); | |
margin-top: 50px; | |
font-size: inherit; | |
font-size: 1em; | |
font-size: 16px; | |
} | |
span.textcenter { | |
margin: 0 auto; | |
position: relative; | |
left: 41.5%; | |
text-align: center; | |
} | |
/* Admin styles | |
======================================== */ | |
.table.table-condensed tr { | |
padding-top: 2px; | |
padding-bottom: 2px; | |
} | |
#admin-nav-top { | |
margin-top: .812em; | |
} | |
.det-list-anchor { | |
min-width: 42px; height: 1.67em; padding: 1px 5px; background-image: linear-gradient(#efefef, #fcfcfc, #e4e4e4); | |
margin:0; border: thin solid #ddd; border-radius:4px; | |
} | |
.det-list-container table { | |
width: 100%; | |
} | |
.det-list-container thead tr th { | |
border-right: 1px dotted white; padding-left: 3px; color: #000; | |
} | |
.det-list-container table td { | |
max-width: 200px; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
white-space: nowrap; | |
padding: 0 10px; | |
} | |
.editForm .form-group { | |
max-width: 98%; | |
min-height: 82px; | |
margin: 10px auto; | |
box-shadow: 0 1px 1px rgba(0,0,0,.15); | |
border-radius: 4px; | |
border: 1px solid #ddd; | |
} | |
.editForm#editTheme .form-group { | |
min-height: 132px; | |
} | |
.det-list-container .cat-list-container .form-context { | |
max-width: 95%; | |
margin-bottom: 5px; | |
min-height:30px; | |
} | |
#submit_newcat { | |
position: relative; | |
top: 28px; | |
} | |
.help-block{ | |
padding-left: 8px; | |
} | |
input[type="text"]:focus { | |
outline: none; | |
} | |
.editForm div.form-group input[type=""], | |
.editForm div.form-group input[type=text], | |
.editForm div.form-group input[type=url], | |
.editForm div.form-group input[type=email], | |
.editForm div.form-group input[type=number], | |
.editForm div.form-group radio { | |
max-width: 91.67%; | |
margin: 0 auto; | |
padding: 3px; | |
border-color: #aaa; | |
background-color: #ffe; | |
color: #111; | |
font-size: 1.5rem; | |
} | |
.editForm .form-group#curr { | |
min-height: 82px; | |
margin: 10px auto; | |
box-shadow: 0 1px 1px rgba(0,0,0,.15); | |
border-radius: 4px; | |
border: 1px solid #ddd; | |
padding-left: 20px; | |
} | |
.editForm .form-group#curr input{ | |
text-align: right; | |
letter-spacing: 1.72px; | |
border-radius: 4px; | |
max-width: 132px; | |
} | |
.editForm div.form-group span { padding-left: 12px; background: transparent; } | |
.editForm .bg-j {background-color: #ebeeef; } | |
.editForm input[readonly] { background: #fafafa !important; } | |
.editForm .form-group label.control-label{ | |
padding-left: 30px; | |
} | |
#myFile { | |
margin-left: 20px; | |
} | |
#mySubmit{ | |
padding-left: 30px; | |
} | |
.editForm .form-group#private { | |
min-height: 48px; | |
height: auto; | |
max-height: 48px; | |
padding-left: 20px; | |
background: #fcf3f3; | |
} | |
#det-panels label { | |
height: 28px; | |
width: 100%; | |
padding: 3px 0 5px 0; | |
margin-bottom: 10px; | |
position: relative; | |
top: 0; | |
background:#fafafa; | |
color: #678 !important; | |
padding-left: 1em; | |
} | |
#det-panels #righthalf .form-group { | |
min-height: 82px !important; | |
margin: 10px auto; | |
} | |
#det-panels .form-group .col-sm-6 input { | |
width: 98%; | |
} | |
#det-panels .form-group label .col-det-panel-6, | |
#det-panels #righthalf .form-group label .col-det-panel-6 { | |
position: relative; | |
left: 24%; | |
} | |
.marg-l1{margin-left: 1em;} | |
.sm-header{ text-shadow: 0 1px 1px #555; text-align: center;color: white;position: relative; top: -10px; | |
background: #608f99; height: auto;padding: 0 8px 8px 8px; margin: 0 auto; box-shadow: 0 1px 1px #999; } | |
.no-well-top{ padding-top:0 !important;margin-top:0 !important;position: relative; top:-1px; } | |
.no-well-bottom{padding-bottom:0 !important;margin-bottom:0 !important; } | |
i.fa { color: #739993;background-color: #fafafa; padding: 2px; border-radius: 3px;box-shadow: 0 0 2px #888;margin-right: 5px; } | |
#noreply_radio .help-block i.fa { text-decoration: line-through !important; /* fa icons this not working */ } | |
.compress { max-width: 100px !important; text-align: right; } | |
.text-j { color: #777; } | |
.text-d { color: #000; } | |
.text-r { color: #900; } | |
.marg-r2 { position: relative; margin-left: 20%; text-decoration: underline; font-style: italic; } | |
.text-right { text-align: right !important; } | |
.text-center { text-align: center !important; } | |
.text-left { text-align: left !important; } | |
form#editPub select {background: none; background: transparent;} | |
form#editPub select option.bkg-success {background: green; color: white;} | |
form#editPub select option.bkg-danger{background: red; color: white;} | |
form#editPub select option.bkg-primary{background: blue; color: white;} | |
@media all and (max-width: 980px){ | |
.editForm div.form-group input[type=""], | |
.editForm div.form-group input[type=text], | |
.editForm div.form-group input[type=url], | |
.editForm div.form-group input[type=email], | |
.editForm div.form-group input[type=number], | |
.editForm div.form-group radio { | |
font-size: 1.67rem; | |
padding: 2px 5px; | |
} | |
} | |
#manage img.img-thumbnail { | |
max-height: 150px; | |
} | |
.table.table-condensed{font-size: 87.5%;}.table.table-condensed tbody > tr td{padding: 2px 2px; vertical-align: bottom;} | |
</style> | |
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> | |
<script src="<?php esc($theme_url); ?>/lib/jquery.min.js"></script> | |
<!-- Latest compiled and minified JavaScript --> | |
<script src="<?php esc($theme_url); ?>/lib/bootstrap.min.js"></script> | |
<title>Listing Nano Directory Admin Page</title> | |
<SCRIPT language="JavaScript" type="text/javascript"> | |
var newwindow = '' | |
function popitup(url) { | |
if (newwindow.location && !newwindow.closed) { | |
newwindow.location.href = url; | |
newwindow.focus(); } | |
else { | |
newwindow=window.open(url,'htmlname','width=404,height=316,resizable=1');} | |
} | |
function tidy() { | |
if (newwindow.location && !newwindow.closed) { | |
newwindow.close(); } | |
} | |
// Based on JavaScript provided by Peter Curtis at www.pcurtis.com | |
</SCRIPT> | |
</head> | |
<body> | |
<?php | |
// gets the user level | |
include '../../inc/dbh.php'; | |
$idm = $_SESSION['user_id']; | |
$stmt = $dbh->prepare("SELECT idm, level FROM tsw_members WHERE idm = :idm"); | |
$stmt->execute(array( ':idm' => $idm )); | |
if ($stmt->rowCount() > 0){ | |
$row = $stmt->fetch(PDO::FETCH_ASSOC); | |
$is_memlevel = $row['level']; | |
} | |
?> | |
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a class="navbar-brand" href="index.php"><img src="<?php esc( $theme_url ); ?>/lib/img/tsw-logoem.png" /></a> | |
</div> | |
<div id="navbar" class="navbar-collapse collapse"> | |
<ul class="nav navbar-nav grad-menu"> | |
<div class="btn-group btn-group-sm list-inline" id="admin-nav-top"> | |
<li><a class="btn btn-default" href="<?php esc( $theme_url ); ?>/index.php" title="home page please">Read Listings</a></li> | |
<li><a class="btn btn-default" href="<?php esc( $theme_url ); ?>/lib/user/myaccount.php" title="to my account page">My Account</a></li> | |
<?php if( $is_memlevel == 0 ) { ?> | |
<li><a class="btn btn-default" href="<?php esc( $theme_url ); ?>/admin/index.php" title="lists">Configuration</a></li> | |
<li><a class="btn btn-default" href="<?php esc( $theme_url ); ?>/admin/admin-list.php" title="listings">Manage Listings</a></li> | |
<li><a class="btn btn-default" href="<?php esc( $theme_url ); ?>/admin/uploads/image-list.php" title="manager">Manage Images</a></li> | |
<?php } ?> | |
</div> | |
</ul> | |
<h1 id="nav-header-title" class="nopadding"><?php esc( $det_name ); ?></h1> | |
</div><!--/.nav-collapse --> | |
</div><!--/.container-fluid --> | |
</nav><div class="clearfix"></div> | |
<div class="container"> | |
<div class="row"> | |
<header class="col-md-12 text-center"> | |
<h3 class="page-header">Admin Control Panel</h3> | |
</header> | |
</div> | |
</div> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-12 col-sm-12"> | |
<div class="det-list-container"> | |
<?php include 'list-images.php'; ?> | |
</div><!-- ends det-list-container --> | |
</div> | |
</div> | |
</div> | |
<?php include '../footer.php'; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!isset($_SESSION['user_session'])) | |
{ | |
header('Location: ../../lib/user/login.php'); | |
die(); | |
} | |
?> | |
<div id="container"> | |
<?php | |
function countFolder($dir) { | |
$get = (count(scandir($dir)) - 2); | |
if ($get == -2) { | |
$get = 0; | |
} | |
return $get; | |
} | |
?> <p><?php esc(countFolder('.')); ?> - Total images uploaded (might include other files). </p> | |
<h5>Directory Contents</h5> | |
<style>.hidden{display:none;}</style> | |
<?php | |
if(isset($_GET['delete'])){ | |
$delurl=$_GET['delete']; | |
unlink($delurl); | |
esc( "file removed from directory" ); | |
} | |
?> | |
<table class="table table-condensed sortable" style="font-size:87.5%;"> | |
<thead> | |
<tr> | |
<th>Filename</th> | |
<th>!Remove</th> | |
<th>Type</th> | |
<th>Size <small>(bytes)</small></th> | |
<th>Date Modified</th> | |
<th>View</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php | |
// Opens directory | |
$myDirectory=opendir("."); | |
// Gets each entry | |
while($entryName=readdir($myDirectory)) { | |
$dirArray[]=$entryName; | |
} | |
// Finds extensions of files (dep. split)$ext = explode(" ", $tag[1]); | |
function findexts ($filename) { | |
$filename=strtolower($filename); | |
$exts=explode("[/\\.]", $filename); | |
$n=count($exts)-1; | |
$exts=$exts[$n]; | |
return $exts; | |
} | |
// Closes directory | |
closedir($myDirectory); | |
// Counts elements in array | |
$indexCount=count($dirArray); | |
// Sorts files | |
sort($dirArray); | |
// Loops through the array of files | |
for($index=0; $index < $indexCount; $index++) { | |
// Allows ./?hidden to show hidden files | |
if($_SERVER['QUERY_STRING']=="hidden") | |
{$hide=""; | |
$ahref="./"; | |
$atext="Hide";} | |
else | |
{$hide="."; | |
$ahref="./?hidden"; | |
$atext="Show";} | |
if(substr("$dirArray[$index]", 0, 1) != $hide) { | |
// Gets File Names | |
$name=$dirArray[$index]; | |
$namehref=$dirArray[$index]; | |
// Gets Extensions | |
$extn=findexts($dirArray[$index]); | |
// Gets file size | |
$size= number_format(filesize($dirArray[$index])); | |
if( ! ini_get('date.timezone') ) | |
{ | |
date_default_timezone_set('America/Los_Angeles'); | |
} | |
// Gets Date Modified Data | |
$modtime=date("M j Y g:i A", filemtime($dirArray[$index])); | |
$timekey=date("YmdHis", filemtime($dirArray[$index])); | |
// Prettifies File Types, add more to suit your needs. | |
switch ($extn){ | |
case "png": $extn="PNG Image"; break; | |
case "jpg": $extn="JPG Image"; break; | |
case "jpeg": $extn="JPEG Image"; break; | |
case "svg": $extn="SVG Image"; break; | |
case "gif": $extn="GIF Image"; break; | |
case "ico": $extn="Windows Icon"; break; | |
case "txt": $extn="Text File"; break; | |
case "log": $extn="Log File"; break; | |
case "htm": $extn="HTML File"; break; | |
case "php": $extn="PHP Script"; break; | |
case "js": $extn="Javascript"; break; | |
case "css": $extn="Stylesheet"; break; | |
case "pdf": $extn="PDF Document"; break; | |
case "zip": $extn="ZIP Archive"; break; | |
case "bak": $extn="Backup File"; break; | |
default: $extn=strtoupper($extn)." File"; break; | |
} | |
// Separates directories | |
if(is_dir($dirArray[$index])) { | |
$extn="<Directory>"; | |
$size="<Directory>"; | |
$class="dir"; | |
} else { | |
$class="file"; | |
} | |
// Cleans up . and .. directories | |
if($name=="."){$name=". (Current Directory)"; $extn="<System Dir>";} | |
if($name==".."){$name=".. (Parent Directory)"; $extn="<System Dir>";} | |
if($name=="image-list.php"){$name=""; $extn="php"; $class="hidden";} | |
if($name=="list-images.php"){$name=""; $extn="php"; $class="hidden";} | |
if($name=="index.html"){$name=""; $extn="html"; $class="hidden";} | |
// Print 'em | |
print(" | |
<tr class='$class'> | |
<td style=\"padding:1px\"><a href='$namehref'>$name</a></td> | |
<td><a href=\"?delete=$name\"> [-] </a></td> | |
<td style=\"padding:1px\"><a href='$namehref'>$extn</a></td> | |
<td style=\"padding:1px\"><a href='$namehref'>$size</a></td> | |
<td sorttable_customkey='$timekey' style=\"padding:1px\"><a href='$namehref'>$modtime</a></td> | |
<td style=\"padding:1px\"><a href=\"".$name."\" onclick=\"window.open(this.href, 'mywin', | |
'width=500,height=500,toolbar=1,resizable=0'); return false;\"><img src=\"".$name."\" height=\"30\" /></a></td> | |
</tr>"); | |
} | |
} | |
?> | |
</tbody> | |
</table> | |
<h2><?php //print("<a href='$ahref'>$atext hidden files</a>"); ?></h2> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment