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

📄 datatypes.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");global $page,$pageOwner,$dbObject,$lang;$dbObject->links['Create Plugin'] = '/Admin/'.$pageOwner['username'].'/CreatePlugin';$dbObject->links['Manage Types'] = $page->formAction = '/Admin/'.$pageOwner['username'].'/ManageTypes';$dbObject->links['?'] = 'Manage Types';$page->displayTitle = 'Manage Types';if( $_SESSION['userlevel'] !== 4){	$page->contentA[$page->displayTitle] = 'You must be an administrator to access this page.';	return;}includeFile('admin/ToolDbObjects.php');class dataTypes extends toolDbObjects{	var $standardTypes = array('page'=>1,'comment'=>1,'map'=>1,'template'=>1,'special'=>1,'admin'=>1,'help'=>1,'talk'=>1);	var $dropTable = false;	var $isPlugin = false;		function dataTypes(){		global $page,$lang;			ob_start();		$show = true;		switch( $page->userCmd ){						case wbStrtolower($lang['all_users']):				$this->disable();			break;						case 'admin only':			case 'disabled':				$this->enable();			break;						case 'remove':				$show = false;				if( !$this->remove() ){					return;				}			break;						case 'confirm removal':				$this->removeConfirm();			break;						case wbStrtolower($lang['edit']):				$show = false;				$this->edit($page->cmdArg[0]);			break;			case 'save changes':				$this->saveChanges();			break;					}				if( $show ){			$this->showExisting();		}				$page->contentA['Manage Types'] = wb::get_clean();	}		function showExisting(){		global $dbInfo,$wbConfig,$lang,$page;						echo '<table class="tableRows" style="width:100%">';		echo '<tr><th style="white-space:nowrap">'.$lang['existing_types'].'</th>';		echo '<th style="white-space:nowrap">'.$lang['create_new'].'</th>';		echo '<th >'.$lang['options'].'</th>';		echo '</tr>';				$i = 0;		$classes[] = ' class="tableRowOdd" ';		$classes[] = ' class="tableRowEven" ';		ksort($dbInfo);		foreach($dbInfo as $space => $info){			if( !isset($info['dbTable']) ){				continue;			}						echo '<tr'.$classes[($i%2)].'>';			echo '<td>';			if( isset($lang[$space])){				echo $lang[$space];			}else{				echo $space; //shouldn't happen.. 			}			echo '</td><td>';							if( isset($info['dbTable']) && (!isset($info['dTitle']) || ($space == 'page')) ){										// 1 .. admin and user					// 2 .. admin only										if( isset($wbConfig['createNew'][$space]) ){						if( $wbConfig['createNew'][$space] === 1 ){							echo '<input type="submit" name="cmd['.$space.']" value="'.$lang['all_users'].'"  title="Disable" />';						}else{							echo '<input type="submit" name="cmd['.$space.']" value="Admin Only"  title="Set to All Users"/>';						}					}else{						echo '<input type="submit" name="cmd['.$space.']" value="Disabled" title="Set to Admin Only" />';					}				}						echo '</td>';			echo '<td style="white-space:nowrap">';				if( isset($this->standardTypes[$space]) ){										if( ($space !== 'page')&&($space !=='template')&&($space !== 'help') ){						//echo '<input type="submit" name="cmd['.$space.']" value="Remove" />';						echo ' &nbsp; ';					}else{						echo ' &nbsp; ';					}				}else{					if( isset($dbInfo[$space]['dbPlugin']) ){						echo wbLinks::admin('updateplugin?plugin='.$space,'update');						echo '<input type="submit" name="cmd['.$space.']" value="'.$lang['edit'].'" />';					}					echo '<input type="submit" name="cmd['.$space.']" value="Remove" />';				}			echo '</td>';			echo '</tr>';			$i++;		}		echo '</table>';			}		////////////////////////////////////////////////////////////////////////	//	//		ENABLE / DISABLE	//	function enable(){		global $dbInfo,$wbConfig,$page;				if( isset($dbInfo[$page->cmdArg[0]]) && isset($dbInfo[$page->cmdArg[0]]['dbTable'])){						if( isset($wbConfig['createNew'][$page->cmdArg[0]]) ){				$wbConfig['createNew'][$page->cmdArg[0]] = 1; //all users			}else{				$wbConfig['createNew'][$page->cmdArg[0]] = 2; //admin only			}			$this->saveConfig($wbConfig['createNew']);			return;		}	}		function disable(){		global $dbInfo,$wbConfig,$page;				if( isset($wbConfig['createNew'][$page->cmdArg[0]]) ){			unset($wbConfig['createNew'][$page->cmdArg[0]]);			$this->saveConfig($wbConfig['createNew']);			return;		}	}		//This should just update the current config..	function saveConfig($arg=array()){		global $wbTables,$dbObject,$page;				$data = $dbObject->getConfiguration();		$data['wbConfig']['createNew'] = $arg;				if( $dbObject->updateConfig($data) ){			$page->session = true; //send a new userMenu			message('Your configuration has been updated.');		}	}		/////////////////////////////////////////////////////////////////////////////////////////////////	//	//	Remove	//		function modifyStart(){		global $dbInfo,$page;				if( !isset($dbInfo[$page->cmdArg[0]]) ){			message('Invalid space: '.$page->cmdArg[0]);			return false;		}				if( isset($dbInfo[$page->cmdArg[0]]['dbPlugin']) ){			$this->isPlugin = true;						includeFile('admin/CheckPrivs.php');			if( checkPrivs::isGrantedCheck(array('DROP')) ){				$this->dropTable = true;			}		}		return true;	}		function remove(){		global $page,$dbInfo;				if( !$this->modifyStart() ){			return false;		}				if( !isset($dbInfo[$page->cmdArg[0]]) ){			message('Invalid data type: '.$page->cmdArg[0]);			return true;		}		echo '<div style="text-align:center;width:40em;margin-left:auto;margin-right:auto;">';		echo '<p>';		echo 'Please confirm the removal of '.$page->cmdArg[0].'.';		echo '</p>';		echo '<p><b>Notice:</b> ';		echo 'Removing will delete database entries and optionally remove tables. Backup your data before continuing if you want to save it.';		echo '</p>';		echo '<p>';		if( $this->dropTable ){			echo '<label>Drop Table<input type="checkbox" name="drop" value="true" checked="checked" /></label>';		}		echo ' &nbsp; &nbsp; <input type="submit" name="cmd['.$page->cmdArg[0].']" value="Confirm Removal" /> ';		echo ' &nbsp; &nbsp; <input type="submit" name="cmd" value="Cancel" />';		echo '</p>';				echo '</div>';		return true;	}		function removeConfirm(){		global $page,$dbInfo,$wbTables,$wbTables,$dbObject;		$this->dropTable = false;				if( !$this->modifyStart() ){			return false;		}				$this->disable();				if( $this->isPlugin ){			includeFile('admin/PluginAdd.php');			pluginAdd::removeObject('class:'.$dbInfo[$page->cmdArg[0]]['class']);			includeFile('admin/CheckPrivs.php');			if( checkPrivs::isGrantedCheck(array('DROP')) ){				$this->dropTable = true;			}		}		//get rid of entries in all_files, all_search, all_history		$table = $dbInfo[$page->cmdArg[0]]['dbTable'];				//keyword_count		$query = 'UPDATE '.$wbTables['users'].', '.$wbTables['all_files'].', '.$table;		$query .= ' SET '.$wbTables['users'].'.`keyword_count` = "reset" ';		$query .= ' ,'.$wbTables['users'].'.`modified` = '.$wbTables['users'].'.`modified` ';		$query .= ' WHERE '.$wbTables['all_files'].'.`file_id` = '.$table.'.`file_id` ';		$query .= ' AND '.$wbTables['all_files'].'.`owner_id` = '.$wbTables['users'].'.`user_id` ';		$query .= ' AND ('.$wbTables['all_files'].'.`keywords` IS NOT NULL OR '.$wbTables['all_files'].'.`keywords` = "") ';		wbDB::runQuery($query);						//Delete from all_search		$query = 'DELETE '.$wbTables['all_search'];		$query .= ' FROM '.$wbTables['all_search'].', '.$table;		$query .= ' WHERE '.$wbTables['all_search'].'.`file_id` = '.$table.'.`file_id` ';		wbDB::runQuery($query);				//Delete from all_history		$query = 'DELETE '.$wbTables['all_history'];		$query .= ' FROM '.$wbTables['all_history'].', '.$table;		$query .= ' WHERE '.$wbTables['all_history'].'.`file_id` = '.$table.'.`file_id` ';		wbDB::runQuery($query);				//fix all_links		$query = 'DELETE '.$wbTables['all_links'];		$query .= ' FROM '.$wbTables['all_links'].', '.$table;		$query .= ' WHERE '.$wbTables['all_links'].'.`file_id` = '.$table.'.`file_id` ';		wbDB::runQuery($query);				$query = 'UPDATE '.$wbTables['all_links'].', '.$table;		$query .= ' SET '.$wbTables['all_links'].'.`to_id` = NULL ';		$query .= ' WHERE '.$wbTables['all_links'].'.`to_id` = '.$table.'.`file_id` ';		wbDB::runQuery($query);						//Delete from all_files		$query = 'DELETE '.$wbTables['all_files'].', '.$table;		$query .= ' FROM '.$wbTables['all_files'].', '.$table;		$query .= ' WHERE '.$wbTables['all_files'].'.`file_id` = '.$table.'.`file_id` ';		wbDB::runQuery($query);				if( $this->dropTable && isset($_POST['drop'])){			$query = 'DROP TABLE '.$table;			wbDB::runQuery($query);			message('Table '.$table.' was removed.');		}else{			message('Database entries were successfully deleted.');		}				$className = $dbInfo[$page->cmdArg[0]]['class'];		$data = $dbObject->getConfiguration();		unset($data['dbInfo'][$page->cmdArg[0]]);		if( $dbObject->updateConfig($data) ){			message('<tt>'.$page->cmdArg[0].'</tt> was uninstalled.');		}	}}	new dataTypes();

⌨️ 快捷键说明

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