⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 users.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");if( $_SESSION['userlevel'] !== 4){	global $page;	$page->contentA['Admin Only'] = 'You must be an administrator to access this page.';	return;}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		General Info//function getUserInfo(){	includeFile('search/all.php');		class queryUsers extends query{		var $classes;				function queryUsers(){			global $dbInfo,$page,$pageOwner,$lang,$wbTables;						$userTable = $wbTables['users'];			$this->classes[] = ' class="tableRowEven" ';			$this->classes[] = ' class="tableRowOdd" ';			$this->rowLimit = 10;						//$this->fieds[-display value-] = -database value-						$this->fields[$lang['user_account']] = 'owner';			$this->fields[$lang['entries']] = 'count';			$this->fields[$lang['last_visit']] = $userTable.'.`visited`';			$this->fields['&nbsp;'] = '';						$this->searchUrl = $page->formAction = '/Admin/'.$pageOwner['username'].'/User_Stats'; //needed because of delete!									///	New			$this->query = 'SELECT SQL_CALC_FOUND_ROWS UNIX_TIMESTAMP('.$userTable.'.`visited`) as `visited`,'.$userTable.'.`username` as owner, count(*) as count ';			$this->query .= 'FROM ';			$this->query .= ' '.$userTable.' LEFT JOIN '.$wbTables['all_files'];			$this->query .= ' ON '.$userTable.'.`user_id` = '.$wbTables['all_files'].'.`owner_id` ';			$this->query .= ' GROUP BY `user_id` ';						$this->orderBy();			//message($this->query.'<p>');			browseSearch3($this,$lang['user_stats']);						}		function orderBy(){			global $lang;			if( !isset($_GET['field']) ){				$this->field = $lang['last_visit'];			}			parent::orderBy();		}				function mysqlFetch(&$result){			return mysql_fetch_object($result);		}		function displayPre(){			global $lang;			echo '<table width="100%" class="tableRows">';			echo '<tr>';			foreach($this->fields as $key => $value ){				echo '<th>'.$key.'</th>';			}			echo '</tr>';		}		function displayPost(&$prev,&$pages,&$next){			echo '</table> <p> <br/> </p>';			parent::displayPost($prev,$pages,$next);		}		function displayNumbers(&$from,&$to,&$rowsFound,&$prev,&$next){			global $lang;			echo '<div style="text-align:right">';			echo $rowsFound.' '.$lang['users_found'].'<br/>';			echo '<span style="font-size:85%">';			echo wbLang::text('showing_of_found',$from,$to);			echo '<br/>'.$prev.' &nbsp; '.$next;			echo '</span></div>';		}		function abbrevOutput(&$row,$i){			global $lang, $wbConfig;						echo '<tr'.$this->classes[($i%2)].'>';			echo '<td>'.$row->owner.'</td>';						echo '<td>'.$row->count.'</td>';			//echo '<td>'.$row->count2.'</td>';			echo '<td>';			//echo $row->visited;			echo $this->timeDiff($row->visited);			echo '</td>';									echo '<td class="sm">';				echo wbLinks::local('/'.$row->owner.'/Home',$lang['homepage']).' &nbsp; ';				echo wbLinks::special('ControlPanel','cpanel','',$row->owner).' &nbsp; ';				echo wbLinks::special('AccountDetails','details','',$row->owner).' &nbsp; ';												if( strcasecmp($row->owner,$GLOBALS['wbAdminUser']) !== 0 ){					echo ' <input type="submit" name="cmd['.htmlspecialchars($row->owner).']" value="'.$lang['delete'].'" />';				}			echo '</td>';			echo '</tr>';				}				function timeDiff(&$mod){			global $lang;						$div[$lang['hours']] = 3600;	//sec -> hours			$div[$lang['days']] = 24;	//hours -> days			$div[$lang['months']] = 30;	//days -> months			$div[$lang['years']] = 12;	//months -> years						$diff = time() - $mod;			//$diff = mktime() - $mod;			if( $diff < 3600 ){				return $lang['within_the_hour'];			}			foreach( $div as $time => $val ){				$diff = $diff/$val;				if( $diff < 1){					return $result.' '.$lang['ago'];				}				$result = number_format($diff) .' '.$time;			}			return $result.' '.$lang['ago'];		}	}		new queryUsers();}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	Deleting User//function deleteUser(){	global $dbInfo,$page,$rootDir,$lang,$pageOwner,$wbConfig,$wbTables;	$txtArray = array();	$bool = true;		$_POST += array('confirm'=>0);		$page->formAction = '/Admin/'.$pageOwner['username'].'/User_Stats?cmd['.$page->cmdArg[0].']='.$page->userCmd; //needed because of delete!		$username =& $page->cmdArg[0];	if( empty($username)){		trigger_error('User Delete not supplied username');		return;	}		ob_start();		//dont delete certain accounts	if( strcasecmp(wbDB::escape($page->cmdArg[0]),$GLOBALS['wbAdminUser']) === 0 ){		echo $lang['NOT_MAIN_ACCT'];		return;	}	if( strcasecmp(wbDB::escape($page->cmdArg[0]),$GLOBALS['wbConfig']['pUser']) === 0 ){		echo $lang['NOT_MAIN_ACCT'];		return;	}			$userDir = $rootDir.'/userfiles/'.$username;	$templateDir = $rootDir.'/templates/'.$username;		////	Confirm		$time = substr(time(),-6);		$diff = ($time - $_POST['confirm']);		$timeLimit = 10;					$mess = '<input type="hidden" name="confirm" value="'.htmlspecialchars($time).'" />';		$mess .= wbLang::text('CONFIRM_DELETE_USER',$page->cmdArg[0]);		$mess .= '<ul>'.$lang['CONFIRM_DELETE_USER2'];		$mess .= '<li>'.$lang['userfiles_directory'].$userDir.'</li>';		$mess .= '<li>'.$lang['template_directory'].$templateDir.'</li>';		$mess .= '<li>'.$lang['database_entries'].'</li>';		$mess .= '</ul>';		$mess .= '<p><input type="submit" name="cmd['.htmlspecialchars($username).']" value="'.$lang['confirm_delete'].'" /></p>';						if( $page->userCmd !== wbStrtolower($lang['confirm_delete'])){			$page->contentA[$lang['user'].': '.$page->cmdArg[0]] = $mess;			wb::get_clean();			return;		}				if( $diff > $timeLimit){			message('TIMEOUT',$diff);			$page->contentA[$lang['user'].': '.$page->cmdArg[0]] = $mess;			wb::get_clean();			return;		}				// 		$userTable = $wbTables['users'].'';// 		$tableList = $wbTables['all_history'].', '.$wbTables['all_files'].', '.$userTable;// 		$join = $userTable.'.`username` = "'.$username.'" AND ';// 		$join .= $wbTables['all_files'].'.`owner_id` = '.$userTable.'.`user_id` AND '.$wbTables['all_files'].'.`file_id` = '.$wbTables['all_history'].'.`file_id` ';// 		$queriesWorked = true;					////	Deleting Files		$userTable = $wbTables['users'];		$tableList = $wbTables['all_files'].', '.$userTable;		$join = $userTable.'.`username` = "'.$username.'" AND ';		$join .= $wbTables['all_files'].'.`owner_id` = '.$userTable.'.`user_id` ';		$queriesWorked = true;				$tables = array();		$tables[] = $wbTables['all_history'];		$tables[] = $wbTables['all_search'];			foreach($dbInfo as $space){			if( !isset($space['dbTable']) ){				continue;			}			$tables[] = $space['dbTable'];		}				foreach($tables as $table){			$query = ' DELETE ';			$query .= $wbTables['all_files'].', '.$table;			$query .= ' FROM ';			$query .= $tableList.', '.$table;			$query .= ' WHERE ';			$query .= $join.' AND '.$wbTables['all_files'].'.`file_id` = '.$table.'.`file_id` ';			$result = wbDB::runQuery($query);			if( mysql_affected_rows() == -1){				$queriesWorked = false;			}		}				//user table			$query = 'DELETE ';			$query .= $userTable;			$query .= ' FROM ';			$query .= $userTable;			$query .= ' WHERE ';			$query .= $userTable.'.`username` = "'.$username.'" ';			$result = wbDB::runQuery($query);			if( mysql_affected_rows() == -1){				$queriesWorked = false;			}						if( !$queriesWorked ){			$bool = false;			$txtArray[] = wbLang::text('NOT_DELETED_DATABASE_ENTRIES');		}else{			$txtArray[] = wbLang::text('DELETED_DATABASE_ENTRIES');		}			////	Deleting Folders		$result = removeDir($userDir);		if( $result === true ){			$txtArray[] = $lang['DELETED_USERFILES'];		}else{			$bool = false;			$txtArray[] = $lang['NOT_DELETED_USERFILES'].$result;		}				$result = removeDir($templateDir);		if( $result === true){			$txtArray[] = $lang['DELETED_TEMPLATES'];		}else{			$bool = false;			$txtArray[] = $lang['NOT_DELETED_TEMPLATES'].$result;		}			////	Finish		$content =& $page->contentA['User: '.$page->cmdArg[0]];		if( $bool ){			$content .= '<h3>'.wbLang::text('USER_DELETED',$page->cmdArg[0]).'</h3>';		}else{			$content .= '<h3>'.wbLang::text('USER_NOT_DELETED',$page->cmdArg[0]).'</h3>';		}			$content .= '<ul>';		foreach($txtArray as $txt){			$content .= '<li>'.$txt.'</li>';		}		$content .= '</ul>';		$content .= wb::get_clean();}function removeDir($dir,$return='bool'){		wbData::loadFileFunctions();		$paths = array();	if( !is_dir($dir) ){		return true;	}		if( $dh = opendir($dir) ){		while (($file = readdir($dh)) !== false) {			if($file == '..' || $file == '.'){				continue;			}			$fullPath = $dir.'/'.$file;						if( is_dir($fullPath) ){				$array = removeDir($fullPath,'array');				$paths = array_merge($paths,$array);							}elseif( is_file($fullPath) ){				if( !@wbUnlink($fullPath) ){					array_unshift($paths,$fullPath);				}			}else{				$paths[] = $fullPath;				//echo 'Not a file or dir: ';			}		}	}		closedir($dh);	$bool = @wbRmdir($dir);	if( !$bool){		array_unshift($paths,$dir);	}	if( $return === 'array'){		return $paths;	}		if( count($paths) > 0 ){		includeFile('error.php');		return showArray($paths);	}	return true;	}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			FLOW CONTROL//global $pageOwner,$dbInfo,$dbObject,$lang;$dbObject->links[$lang['user_stats']] = '/Admin/'.$pageOwner['username'].'/UserStats';$dbObject->links['?'] = 'Admin/User_Stats';$page->displayTitle = $lang['user_statistics'];switch($page->userCmd){		case wbStrtolower($lang['delete']):	case wbStrtolower($lang['confirm_delete']):	case 'delete':	case 'delete account':	case 'confirm delete':		deleteUser();	break;		default:		getUserInfo();	break;		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -