Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

administer all accounts #9

Open
Iron-Tongue opened this issue Mar 19, 2019 · 11 comments
Open

administer all accounts #9

Iron-Tongue opened this issue Mar 19, 2019 · 11 comments

Comments

@Iron-Tongue
Copy link

Admin needs to be able to administer all accounts with options to delete images and ban the user/s.

Everything else is fantastic.

Just seems to be missing this important feature in my opinion.

@jixunmoe
Copy link

Currently, if you know the offensive image id, you can go to the view page and ban them there (as well as deleting all images uploaded by that user).

@Iron-Tongue
Copy link
Author

I have a solution:

I added this page and named it admin-index.php.

This page can only be viewed by the admin.

(Might not be perfect, but it works great!)

<?PHP
	error_reporting(-1);
	ini_set("display_errors", "on");
	
	require('config.php');
	require('common.php');
	require('inc/header.php');
	
	echo "<br><div align='center'><font size='+2'>ADMINISTRATION AREA</font></div><br>";
	$url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
	
	if (isset($_SESSION['admin'])) {

		$showExtensions = array('jpg', 'jpeg', 'png', 'gif');

		$dir = opendir("images/");

		$template = <<<EOT
		<a href="images/{basename}"><img src="images/{basename}" style="max-height: 100px; max-width:100px;" align="ABSmiddle" /></a> <strong>--></strong> 
		<input type="text" value="http://$url/images/{basename}" style="width:500px" onmouseover="this.select()">
		<a href="view.php?id={filename}">Edit/Delete/Ban</a>
		<br /><br />
EOT;

		while ($file = readdir($dir)) {
			$info = pathinfo($file);
			if (!in_array($info['extension'], $showExtensions)) continue;

			echo str_replace(
				array('{basename}', '{filename}'),
				array($info['basename'], $info['filename']),
				$template
			);
		}
	} else {
		echo "<br><div align='center'><font size='+2'>You are not allowed to view this page.<br><br>PLEASE <a href='login.php'>LOGIN</a> FIRST.</font></div><br>";
	}

	require('inc/footer.php');
	echo "<br><br>";
?>

Then I changed this div in the inc/footer.php

	<div id="footer">
		<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a>
		<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
	</div>

To look like this:

This adds a link that can only be viewed by admin that takes you to the view page where you can delete and/or ban, (administer).

	<div id="footer">
		<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a><?PHP if (isset($_SESSION['admin'])) { ?>|<a href="admin-index.php">Admin</a><?PHP } ?>
		<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
	</div>

@Barrnet
Copy link
Contributor

Barrnet commented Apr 14, 2019

Better than nothing, but show all images can kill the browser :P
We need a proper admin panel where we can see all reports, users stats or the file uploaded from other user.

@Iron-Tongue
Copy link
Author

Better than nothing, but show all images can kill the browser :P
We need a proper admin panel where we can see all reports, users stats or the file uploaded from other user.

Almost done with a new solution. :)

@lfiore
Copy link
Owner

lfiore commented Apr 22, 2019

The original idea of this script was just a way for users to easily upload any images they have to share with others, so I don't think it's necessary for the admin to be able to easily browse through all uploaded images.

However, I have added another option on the "view image" page to allow the admin to view all images uploaded by that specific user/IP address, just as a way to deal with possible abuse issues.

This also required a fix for Cloudflare users, since the real IP address wasn't being passed to the script.

@Iron-Tongue
Copy link
Author

Iron-Tongue commented Apr 28, 2019

New improved solution for an admin section.

I added two pages, one admin.tpl.html and admin-index.php.

This page can only be viewed by the admin.

(Might not be perfect, but it works great!)

readme.txt
`+----------------------------------------------------+
| Admin section for upld, Image Hosting Script
| https://github.com/lfiore/upld
| Administration Section - v.1.1
| Donations are accepted for Erik on Paypal: http://paypal.me/ErikGroen
| Donations are accepted for Iron Tongue on Paypal: http://paypal.me/lomsc
| Contents: admin-index.php, admin.tpl.html & this file.
+----------------------------------------------------+

Features:

Admin Index Section
--- 10 most recently registered users.
------ Showing Email, User IP and date registered.
--------- Clicking user's email address will take you to user's details.

--- 10 most recently uploaded images.
------ Showing user's email, user IP, image name and date uploaded.
--------- Clicking user's email address will take you to user's details.
--------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section.
--------- Ability to unmark for removal.
--------- With confirmation of each action taken.

--- 10 most recently unhandled reports
------ Showing Email, image name and extension and date image was uploaded.
--------- Clicking user's email address will take you to user's details.
--------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section.
--------- Ability to unmark for removal.
--------- Ability to acknowledge the report and leave the image or to delete the image permanently from the Manage Images section.
--------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Users Section
--- Shows total users in database.
--- Change order of users by Ascending/Descending.
------ Shows all users in the database, 20 per page.( Editable in the admin.tpl.html file. )
------ Shows User Email, User IP, Number of Images Uploaded, Ban Status, Admin Status and the option to Delete the User.
--------- Clicking user's email address will take you to user's details.
--------- Ability to Ban the user, Unban the User and Delete User.
--------- Ability to Add Admin Status and Remove Admin Status.
--------- With Pagination.
--------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Images Section

--- Shows total images in the database.
--- Change order of users by Ascending/Descending.
------ Shows a thumbanil image of all images in database, 10 per page.( Editable in the admin.tpl.html file. )
------ Clicking and image takes you to the view page.
--------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email.
--------- Clicking user's email address will take you to user's details.
--------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section.
--------- Ability to unmark for removal.
--------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section.
--------- With confirmation of each action taken.
--------- Ability to Ban the user, Unban the User.
--------- Bottom of this page allows you to permanently delete all removed images at once.
--------- With Pagination.
--------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Reports Section

--- Shows all images reported.
--- Change order of users by Ascending/Descending.
------ Shows a thumbanil image of all images in database, 10 per page.( Editable in the admin.tpl.html file. )
------ Clicking and image takes you to the view page.
--------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email.
--------- Clicking user's email address will take you to user's details.
--------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section.
--------- Ability to unmark for removal.
--------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section.
--------- With confirmation of each action taken.
--------- Ability to Ban the user, Unban the User.
--------- With Pagination.
--------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

User Info Section

--- Get to this section by clicking user's email address anywhere.
------ This section shows the user's stats.
------ Shows user's email address.
------ Shows user's IP address at the time of registration.
------ Whether the user is banned or not and the ability to ben the user or unban the user.
------ Ability to give or revoke admin from the user.
------ Shows total number of images this user has uploaded.
------ Shows a DELETE link to take you to the MANAGE USERS section to delete the user.
--------- Shows all thumbanil images of that user in database, 10 per page.( Editable in the admin.tpl.html file. )
--------- Clicking and image takes you to the view page.
--------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email.
--------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section.
--------- Ability to unmark for removal.
--------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section.
--------- With confirmation of each action taken.
--------- With Pagination.
--------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

TO INSTALL

--- Upload admin-index.php & admin.tpl.html into the root directory of your image host.

TO ADD AN ADMIN LINK (HEADER LINK RECOMMENDED)
--- Open inc/header.php

--- Find:

		--><li><a href="account.php">my account</a></li><!--
		--><li><a href="logout.php">logout</a></li>

--- Replace with:

This adds a link that can only be viewed by admin.

		--><li><?PHP if (isset($_SESSION['admin'])) { ?><a href="admin-index.php">Admin</a><?PHP } ?></li><!--
		--><li><a href="account.php">my account</a></li><!--
		--><li><a href="logout.php">logout</a></li>

OR ADD A LINK IN THE FOOTER

---Open inc/footer.php

--- Find:

<div id="footer">
	<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a>
	<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
</div>

Replace with:

This adds a link that can only be viewed by admin.

<div id="footer">
	<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a><?PHP if (isset($_SESSION['admin'])) { ?>|<a href="admin-index.php">Admin</a><?PHP } ?>
	<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
</div>`

Download Here ---> image-host.zip

@Iron-Tongue
Copy link
Author

Opened this back up so people could find it. :)

@jixunmoe
Copy link

jixunmoe commented May 9, 2019

Opened this back up so people could find it. :)

... or to mention it in your README.MD :p

@Iron-Tongue
Copy link
Author

Opened this back up so people could find it. :)

... or to mention it in your README.MD :p

It's not my readme.md file. I was only contributing.

@ImAmirhv
Copy link

ImAmirhv commented Nov 9, 2023

New improved solution for an admin section.

I added two pages, one admin.tpl.html and admin-index.php.

This page can only be viewed by the admin.

(Might not be perfect, but it works great!)

readme.txt `+----------------------------------------------------+ | Admin section for upld, Image Hosting Script | https://github.com/lfiore/upld | Administration Section - v.1.1 | Donations are accepted for Erik on Paypal: http://paypal.me/ErikGroen | Donations are accepted for Iron Tongue on Paypal: http://paypal.me/lomsc | Contents: admin-index.php, admin.tpl.html & this file. +----------------------------------------------------+

Features:

Admin Index Section --- 10 most recently registered users. ------ Showing Email, User IP and date registered. --------- Clicking user's email address will take you to user's details.

--- 10 most recently uploaded images. ------ Showing user's email, user IP, image name and date uploaded. --------- Clicking user's email address will take you to user's details. --------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section. --------- Ability to unmark for removal. --------- With confirmation of each action taken.

--- 10 most recently unhandled reports ------ Showing Email, image name and extension and date image was uploaded. --------- Clicking user's email address will take you to user's details. --------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section. --------- Ability to unmark for removal. --------- Ability to acknowledge the report and leave the image or to delete the image permanently from the Manage Images section. --------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Users Section --- Shows total users in database. --- Change order of users by Ascending/Descending. ------ Shows all users in the database, 20 per page.( Editable in the admin.tpl.html file. ) ------ Shows User Email, User IP, Number of Images Uploaded, Ban Status, Admin Status and the option to Delete the User. --------- Clicking user's email address will take you to user's details. --------- Ability to Ban the user, Unban the User and Delete User. --------- Ability to Add Admin Status and Remove Admin Status. --------- With Pagination. --------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Images Section

--- Shows total images in the database. --- Change order of users by Ascending/Descending. ------ Shows a thumbanil image of all images in database, 10 per page.( Editable in the admin.tpl.html file. ) ------ Clicking and image takes you to the view page. --------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email. --------- Clicking user's email address will take you to user's details. --------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section. --------- Ability to unmark for removal. --------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section. --------- With confirmation of each action taken. --------- Ability to Ban the user, Unban the User. --------- Bottom of this page allows you to permanently delete all removed images at once. --------- With Pagination. --------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

Manage Reports Section

--- Shows all images reported. --- Change order of users by Ascending/Descending. ------ Shows a thumbanil image of all images in database, 10 per page.( Editable in the admin.tpl.html file. ) ------ Clicking and image takes you to the view page. --------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email. --------- Clicking user's email address will take you to user's details. --------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section. --------- Ability to unmark for removal. --------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section. --------- With confirmation of each action taken. --------- Ability to Ban the user, Unban the User. --------- With Pagination. --------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

User Info Section

--- Get to this section by clicking user's email address anywhere. ------ This section shows the user's stats. ------ Shows user's email address. ------ Shows user's IP address at the time of registration. ------ Whether the user is banned or not and the ability to ben the user or unban the user. ------ Ability to give or revoke admin from the user. ------ Shows total number of images this user has uploaded. ------ Shows a DELETE link to take you to the MANAGE USERS section to delete the user. --------- Shows all thumbanil images of that user in database, 10 per page.( Editable in the admin.tpl.html file. ) --------- Clicking and image takes you to the view page. --------- Shows image name and extension, date image was uploaded, user's IP at the time of upload and the user's email. --------- Ability to mark images for removal to permanently delete them one at a time or as a group of removed images later from the Manage Images section. --------- Ability to unmark for removal. --------- Ability to acknowledge the report and leave the image or to delete the image permanently form the Manage Images section. --------- With confirmation of each action taken. --------- With Pagination. --------- With confirmation of each action taken.

+++++++++++++++++++++++++++++++++++++++++++

TO INSTALL

--- Upload admin-index.php & admin.tpl.html into the root directory of your image host.

TO ADD AN ADMIN LINK (HEADER LINK RECOMMENDED) --- Open inc/header.php

--- Find:

		--><li><a href="account.php">my account</a></li><!--
		--><li><a href="logout.php">logout</a></li>

--- Replace with:

This adds a link that can only be viewed by admin.

		--><li><?PHP if (isset($_SESSION['admin'])) { ?><a href="admin-index.php">Admin</a><?PHP } ?></li><!--
		--><li><a href="account.php">my account</a></li><!--
		--><li><a href="logout.php">logout</a></li>

OR ADD A LINK IN THE FOOTER

---Open inc/footer.php

--- Find:

<div id="footer">
	<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a>
	<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
</div>

Replace with:

This adds a link that can only be viewed by admin.

<div id="footer">
	<a href="faq.php">FAQ</a>|<a href="tc.php">Terms &amp; Conditions</a>|<a href="contact.php">Contact</a><?PHP if (isset($_SESSION['admin'])) { ?>|<a href="admin-index.php">Admin</a><?PHP } ?>
	<!-- page generated in <?php echo round((microtime(true) - $start), 5); ?> seconds with <?php echo $db_queries; ?> DB quer<?php echo ($db_queries === 1 ? 'y' : 'ies'); ?> -->
</div>`

Download Here ---> image-host.zip

i got this error and admin panel not working
Warning: Array to string conversion in admin-index.php on line 55
any help?

@ImAmirhv
Copy link

I found a solution
change line 55:
return str_replace('{{', "{\f{", isset($value[$current_index])?$value[$current_index]:'');
to this:
return is_array($value[$current_index]) ? $value[$current_index] : str_replace('{{', "{\f{", isset($value[$current_index])?$value[$current_index]:'');

You get some new warning, but the admin panel works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants