Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Multiple User Accounts Hack For ZenPhoto

DZone's Guide to

Multiple User Accounts Hack For ZenPhoto

·
Free Resource
Multiple user accounts hack for zenPhoto

I needed support for several users, not really for any fancy reason, just so there was no password sharing, so here's a quick hack I made that shouldn't be hard to extend to be a bit more useful if you desire.

Hopefully I have used this forum's tags correctly. If I haven't perhaps a mod can lend a hand in rectifying them. :)


In admin-functions.php:
After:
	echo "\n  ";
Add:
	echo "\n  ";

Before:
  echo "\n  ";
Add:
  echo "\n    
   
   users";

In admin.php
After:
    } else if ($action == 'settheme') {
      if (isset($_GET['theme'])) {
        $gallery->setCurrentTheme($_GET['theme']);
      }
Add:
	  
/** USERS ******************************************************************/
/*****************************************************************************/

    } else if ($action == 'updateUsers') {
		$uid = explode("_",$_REQUEST['userid']);
		$uid = $uid[1];
		$name = $_REQUEST['username'];
		$pass = $_REQUEST['userpass'];
		$email = $_REQUEST['usermail'];
		$query = "SELECT * FROM users WHERE name='$name' LIMIT 1";
		$result = mysql_query($query) or die(mysql_error());
		if (mysql_num_rows($result)<1){
			//create new user
			$query = "INSERT INTO users (`name`,`pass`,`email`) VALUES ('$name',MD5('$pass'),'$email')";
			$result = mysql_query($query) or die(mysql_error());
			$r = mysql_insert_id();
			die("$r");
		}else{
			//update old user
			$query = "UPDATE users SET ";
			$query .= "name='$name'";
			if (!empty($pass) && ($pass!="")){ $query .= ",pass=MD5('$name')"; }
			$query .= ",email='$email'";
			$query .= " WHERE id='$uid'";
			$result = mysql_query($query) or die(mysql_error());
			die("Save successful!");
		}
    } else if ($action == 'removeUsers') {
		$uid = explode("_",$_REQUEST['userid']);
		$uid = $uid[1];
		$query = "DELETE FROM users WHERE id='$uid' LIMIT 1";
		$result = mysql_query($query) or die(mysql_error());
	}

Before:

    
Add:

    
      
    
   
	
	
   
	
	
   

User Management

"; echo " "; echo " "; echo " "; echo " "; echo " "; } ?>
Name Password Email
Add User
Delete | Edit".$r['name']."Saved".$r['email']."
Replace auth_zp.php with: 0){ $r = mysql_fetch_assoc($result); $check_auth = md5($r['name'].$r['pass']); } if ($rows>0 && $saved_auth==$check_auth) { $_zp_loggedin = true; } else { // Clear the cookie setcookie("zenphoto_auth", "", time()-368000, $cookiepath); setcookie("zenphoto_user", "", time()-368000, $cookiepath); } } else { // Handle the login form. if (isset($_POST['login']) && isset($_POST['user']) && isset($_POST['pass'])) { $user = $_POST['user']; $pass = MD5($_POST['pass']); $redirect = $_POST['redirect']; $query = "SELECT * FROM users WHERE name='$user' AND pass='$pass' LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result)>0) { // Correct auth info. Set the cookie. setcookie("zenphoto_auth", md5($user.$pass), time()+5184000, $cookiepath); setcookie("zenphoto_user", $user, time()+5184000, $cookiepath); $_zp_loggedin = true; //// FIXME: Breaks IIS if (!empty($redirect)) { header("Location: " . FULLWEBPATH . $redirect); } //// } else { // Clear the cookie, just in case setcookie("zenphoto_auth", "", time()-368000, $cookiepath); setcookie("zenphoto_user", "", time()-368000, $cookiepath); $error = true; } } } unset($saved_auth, $check_auth, $user, $pass); // Handle a logout action. if (isset($_POST['logout']) || isset($_GET['logout'])) { setcookie("zenphoto_auth", "", time()-368000, $cookiepath); setcookie("zenphoto_user", "", time()-368000, $cookiepath); header("Location: " . FULLWEBPATH . "/"); } function zp_loggedin() { $_zp_loggedin = false; if (isset($_COOKIE['zenphoto_auth'])) { $saved_auth = $_COOKIE['zenphoto_auth']; $saved_user = $_COOKIE['zenphoto_user']; $query = "SELECT * FROM users WHERE name='$saved_user' LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_num_rows($result); if ($rows>0){ $r = mysql_fetch_assoc($result); $check_auth = md5($r['name'].$r['pass']); if ($saved_auth==$check_auth){ $_zp_loggedin = true; } } } return $_zp_loggedin; } ?> Execute this SQL on your zenphoto table: CREATE TABLE users ( `id` INT( 255 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 255 ) NOT NULL , `pass` VARCHAR( 255 ) NOT NULL , `email` VARCHAR( 255 ) NOT NULL ); INSERT INTO users (`name`,`pass`,`email`) VALUES ('admin',MD5('password'),'you@yourdomain.com');
I recommend also changing the password info in the config file to something uninteresting. Also, as always, I recommend doing a full backup before proceeding with these directions. YMMV. These directions are provided as-is with no warranty express or implied. You use this at your own risk.
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
\";\r\nAdd:\r\n\techo \"\\n \";\r\n\r\nBefore:\r\n echo \"\\n \";\r\nAdd:\r\n echo \"\\n users\";\r\n\r\nIn admin.php\r\nAfter:\r\n } else if ($action == 'settheme') {\r\n if (isset($_GET['theme'])) {\r\n $gallery->setCurrentTheme($_GET['theme']);\r\n }\r\nAdd:\r\n\t \r\n/** USERS ******************************************************************/\r\n/*****************************************************************************/\r\n\r\n } else if ($action == 'updateUsers') {\r\n\t\t$uid =...","deleted":false,"likeStatus":{"liked":false,"score":0,"canLike":false},"zonetop":"","articleTags":[],"header":{"id":832280,"title":"Multiple User Accounts Hack For ZenPhoto","imageUrl":"/themes/dz20/images/ArticleImg_1.jpg","link":"/articles/multiple-user-accounts-hack","imageLink":"/themes/dz20/images/ArticleImg_7.jpg","titleEll":"Multiple User Accounts Hack For ZenPhoto","type":"article"},"url":"/articles/multiple-user-accounts-hack","isLocked":false,"draft":false,"articleContent":"","source":null,"modDate":1183858116000,"views":279,"isLimited":false,"tldr":null,"originalSource":"","articleType":"snippet"}]; WMODEL_DATA.perms = {"canDecidePick":false,"canPublish":false}; WMODEL_DATA.authenticated = false; WMODEL_DATA.firstArticleContent = null; WMODEL_DATA.isPreview = false; WMODEL_DATA.OPTIONS = {}; TH.installWidgetController('article.content', 'articleContent5', WMODEL_DATA, typeof controller == 'function' ? controller : null, [{name: 'partners', data: true},{name: 'DEFAULT', data: true}], ' oUhbblYOaqbcblYOaqbcC', null); })(); (function() { function controller($scope, $service, $location, SideBarService, $timeout) { if ($scope.edition) { $scope.date = moment($scope.editionDate).utc().format('MMM DD, YYYY'); } SideBarService.ctx.pageSize = $scope.pageSize; SideBarService.ctx.isPreview = $scope.isPreview; SideBarService.ctx.mode = $scope.mode; SideBarService.fn.loader = $service; var $window = $(window); function checkWidth() { var windowsize = $window.width(); $scope.width = windowsize; } // Execute on load checkWidth() // Bind event listener $(window).resize(checkWidth); if ($scope.edition) { SideBarService.ctx.edition = $scope.edition; } SideBarService.fn.scrollCheck = function() { $scope.$emit('thIfScrollCheck'); }; var currentFilter; $scope.$on('$locationChangeSuccess', function() { if (!$location.search().filter) { $scope.filter = 'latest'; } else { $scope.filter = $location.search().filter; if ($scope.filter == 'latest') { $location.search('filter', null); } } if (currentFilter == $scope.filter) { return; } currentFilter = $scope.filter; SideBarService.ctx.filter = $scope.filter; }); $scope.display = SideBarService.getList(); $scope.$watchCollection(function() { return SideBarService.getList(); }, function (n) { $scope.display = n; }); $scope.isActive = SideBarService.isActive; $scope.isExcluded = SideBarService.isExcluded; $scope.loadMore = SideBarService.load; $scope.loading = function() { return SideBarService.ctx.loading; }; TH.on('TapBarStatusChange', function(expanded) { if (expanded) { SideBarService.unblock(); } }) } var WMODEL_DATA = {}; WMODEL_DATA.edition = null; WMODEL_DATA.editionName = ""; WMODEL_DATA.pageSize = 20; WMODEL_DATA.isPreview = false; WMODEL_DATA.editionDate = null; WMODEL_DATA.OPTIONS = {}; WMODEL_DATA.mode = null; TH.installWidgetController('sidebar.content.list', 'sidebarContentList8', WMODEL_DATA, typeof controller == 'function' ? controller : null, [{name: 'DEFAULT', data: true}], ' oUhbkSMaaqbcdvVkcC', null); })(); (function() { function controller($scope) { var $window = $(window); function checkWidth() { var windowsize = $window.width(); var $element = $('div.sidebar.sidebarTapBar'); $scope.width = windowsize; if(windowsize <= 1024 && $scope.edition){ $('.fixContentRight').removeClass('fixContentRight'); // $element.removeClass('expanded'); // $element.addClass('tapNotExpanded'); $('.tap').show(); }else if($scope.edition){ $('.tap').hide(); $('.mainContentRow').addClass('fixContentRight'); $element.removeClass('tapNotExpanded'); $element.addClass('expanded'); } } // Execute on load checkWidth(); // Bind event listener $(window).resize(checkWidth); } var WMODEL_DATA = {}; WMODEL_DATA.edition = null; WMODEL_DATA.slot = null; WMODEL_DATA.OPTIONS = {}; TH.installWidgetController('sidebar.tapBar', 'sidebar', WMODEL_DATA, typeof controller == 'function' ? controller : null, null, ' oUhbkSMadabfWVcC oUhbkSMadabbWQbVkcC', null); })(); (function() { function controller($scope, shareThis, TH$Dialog, TH$Service, $location) { $scope.getEditUrl = function(id, type) { if (!type || type == 'article') { return '/content/' + id + '/edit.html'; } else { return '/dzone/staff/' + type + (type == 'refcard' ? 'z' : 's') + '/' + id + '/edit.html'; } }; $scope.share = function(socialNet, url, title){ shareThis.shareThis(socialNet, url, title); }; // $scope.mailShareLink = function(article) { // return 'mailto:?subject=' + encodeURIComponent(article.header.title) + '&body=Article: ' + encodeURIComponent('https://dzone.com/' + article.header.link); // }; $scope.canDelete = function(article) { return article.canDelete; }; $scope.canPublish = function(article) { return article.canPublish; }; $scope.canEdit = function(article) { return article.canEdit; }; $scope.toggleComments = function(article) { if(!article.isLocked) { TH$Service.action('articles.lockNode', {type: 'node', id: article.id}).then(function(result) { if(result){ article.isLocked = true; TH$Dialog.success('You have disabled all comments for this Article'); }else{ TH$Dialog.error('error','Your requested was denied') } }); }else { TH$Service.action('articles.unlockNode', {type: 'node', id: article.id}).then(function(result) { if(result){ article.isLocked = false; TH$Dialog.success('You have enabled all comments for this Article'); }else{ TH$Dialog.error('error','Your requested was denied') } }); } }; $scope.toggleLimitComments = function (article) { if (!article.isLimited) { TH$Service.action('articles.limitNode', {type: 'node', id: article.id}).then(function (result) { if (result) { article.isLimited = true; TH$Dialog.success('You have limited comments for this Article. Now all comments will go through moderation.'); } else { TH$Dialog.error('error', 'Your requested was denied') } }); } else { TH$Service.action('articles.unlimitNode', {type: 'node', id: article.id}).then(function (result) { if (result) { article.isLimited = false; TH$Dialog.success('You removed the limits for comments on this Article'); } else { TH$Dialog.error('error', 'Your requested was denied') } }); } }; $scope.shareTwitter = function($event, title, url){ $event.preventDefault(); $event.stopPropagation(); var twitter = 'https://twitter.com/intent/tweet'; var link = $location.protocol() + '://' + location.host + url; var ref = location.host; var params = '?text='+title+'&url='+link+'&ref=dzone.com&via=DZone'; var win = window.open(twitter+params, '_blank'); win.focus(); }; $scope.edit = function(link) { TH$Dialog.open({ loadWidget: 'links.postPreview', widgetArgs: { edit: link.id }, size: 'xbig' }).then(function (result) { $scope.link.title = result.title; $scope.link.linkDescription = result.content; $scope.link.thumb = result.thumb; $scope.link.tags = result.topics; }); }; $scope.deleteLink = function(article) { var title = article.title; var type = 'link'; if(article.header){ title = (article.header.type == 'article') ? article.header.title : article.title; type = (article.header.type == 'article') ? 'article' : 'link'; } TH$Dialog.confirm('Do you want to delete "' + title + '"?').then(function() { return TH$Service.action('delete', {type: type, id: article.id}); }).then(function() { article.deleted = true; }); }; } var WMODEL_DATA = {}; WMODEL_DATA.OPTIONS = {}; TH.installWidgetController('content.commentsSlider', 'contentCommentsSlider7', WMODEL_DATA, typeof controller == 'function' ? controller : null, null, ' oUhbaqbcaibvnWffWVcC', null); })(); (function() { var WMODEL_DATA = {}; WMODEL_DATA.name = "commentsSlider"; WMODEL_DATA.slot = null; WMODEL_DATA.OPTIONS = {"name":"commentsSlider"}; TH.installWidgetController('components.slider', 'componentsSlider6', WMODEL_DATA, typeof controller == 'function' ? controller : null, null, ' oUhballbvbdSaoUhM', null); })();