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

📄 directories.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");global $page,$dbInfo,$pageOwner,$jsNum,$dbObject;$dbObject->links['Directories'] = $page->formAction = '/Admin/'.$pageOwner['username'].'/Directories';$dbObject->links['?'] = 'Manage Directories';$page->displayTitle = 'Manage Directories';if( $_SESSION['userlevel'] !== 4){	$page->contentA[$page->displayTitle] = 'You must be an administrator to access this page.';	return;}includeFile('admin/ToolDbObjects.php');class createDirectory extends toolDbObjects{	var $current = array();	var $spaces = array();	var $existStruct = array();		//for the wbParser	var $flags = '';		//	var $pre, $post = '';		function createDirectory(){		global $page;		$show = true;		$this->setSpaces();		$this->setCurrent();				ob_start();				switch($page->userCmd){			case 'finish':				if( !$this->finish() ){					$this->create();				}				$show = false;			break;						case 'save':				if( !$this->save() ){					$show = false;				}			break;						case 'create':				if( $this->create() ){					$show = false;				}			break;						case 'removedir':				$this->removeDirCheck();				$show = false;			break;			case 'confirm removal':				$this->removeDir();			break;			case 'edit':				$this->edit($_GET['name']);				$show = false;			break;			case 'save changes':				$this->saveChanges();			break;		}				if( $show ){			echo '<table>';			$this->form();			$this->showCurrent();			echo '</table>';		}				//echo 'POST: '.showArray($_POST);		$page->contentA['Directories'] = wb::get_clean();	}		function setSpaces(){		global $dbInfo;				foreach($dbInfo as $space => $info){			if( !isset($info['dbTable']) ){				continue;			}			$class = wbData::getClass($space,true);			if( !$class ){				continue;			}			$methods = get_class_methods($class); //lower-cased in php4, normal case as of php5			$methods = array_flip($methods);			if( isset($methods['abbrevoutput']) || isset($methods['abbrevOutput']) ){				$this->spaces[$space] = true;			}			unset($tempObject);		}	}		function finish(){		global $dbObject;			$_POST += array('limit'=>'20','where'=>'');		//		//	Check		//			if( !$this->check() ){				return false;			}			$name = wbStrtolower($_POST['name']);			$this->setVariables();					//		//	Start Class		//			$tab = "\t";			$class = array();			$class[] = '////////////////////////////////////////////////////////////';			$class[] = '//';			$class[] = '//		WikyBlog Generated Code';			$class[] = '//		Edit with care';			$class[] = '//';			$class[] = '////////////////////////////////////////////////////////////';			$class[] = '';			$class[] = '';			$class[] = 'includeFile(\'search/WikiDirs.php\');';			$class[] = '';			$class[] = 'class '.$name.' extends wikiDirs{';						$class[] = '';					//		//	Display		//						$class[] = $tab.'//';			$class[] = $tab.'//Structure';			$class[] = $tab.'//';			$class[] = $tab.'var $levels = array(';			$cols = false;			foreach($_POST['columns'] as $i => $column){				if( empty($column) ){					continue;				}				$temp = $this->columnSQL($column);				$class[] = $tab.$tab.$tab.$this->escape($temp[0]).' => '.$this->escape($temp[1]).',';				$cols = true;			}			if( !$cols){				message('You must define at least on level to have a valid directory.');				return false;			}			$class[] = $tab.$tab.$tab.');';						$class[] = '';			$class[] = $tab.'function '.$name.'($name){';			$class[] = $tab.$tab.'$this->dir[\'where\'] = '.$this->escape($_POST['where']).'; ';					//		//	Display		//			$class[] = '';			$class[] =  $tab.$tab.'//';			$class[] =  $tab.$tab.'//Display';			$class[] =  $tab.$tab.'//';					$variables = array_flip($this->variables);			if( is_array($_POST['order']) ){				$tempA = array();				foreach($_POST['order'] as $i => $column){					if( empty($column) ){						continue;					}					$temp = $this->columnSQL($column);					if( is_numeric($temp[1])){						$tempA[] = $temp[0].' '.$_POST['order2'][$i];					}else{						$tempA[] = $temp[1].' '.$_POST['order2'][$i];					}				}				if( count($tempA) > 0){					$class[] = $tab.$tab.'$this->dir[\'order\'] = '.$this->escape(implode(', ',$tempA)).'; ';				}			}									$class[] = $tab.$tab.'$this->dir[\'limit\'] = '.$this->escape($_POST['limit']).';';			$class[] = $tab.$tab.'$this->dir[\'pre\'] = '.$this->escape($this->pre).';';			$class[] = $tab.$tab.'$this->dir[\'post\'] = '.$this->escape($this->post).';';						$class[] = '';			$class[] =  $tab.$tab.'//';			$class[] =  $tab.$tab.'//Continue';			$class[] =  $tab.$tab.'//';			$class[] = $tab.$tab.'$this->wikiDirs($name);';						$class[] = $tab.'}';			$class[] = '';			$class[] = '}';			$class[] = '';					//		//	dbInfo		//			$newInfo= array();			$displayName = toDisplay($_POST['name']);			if( $name !== $displayName){				$newInfo['alias'] = $displayName;			}			$newInfo['dirs'] = true;			$newInfo['class'] = $name;			$newInfo['useInfo'] = $_POST['space'];			$newInfo['dbPlugin'] = true;					//		//	Output		//			$this->showCode(implode("\n",$class),$newInfo);			return true;	}	function columnSQL(&$post){		global $wbTables,$dbInfo;				$pos = strpos($post,':');		$how = substr($post,$pos+1);		$column = substr($post,0,$pos);				if( isset($this->allFilesVars[$column]) ){			$column = $wbTables['all_files'].'.`'.$column.'` ';		}else{			$column = $dbInfo[$_POST['space']]['dbTable'].'.`'.$column.'` ';		}				switch($how){						//timestamps			case 'Year':				$sql = 'YEAR('.$column.')';			break;			case 'Quarter':				$sql = 'CONCAT("Quarter ",QUARTER('.$column.'))';			break; 			case 'Month':				$sql = array('DATE_FORMAT('.$column.',"%M")','DATE_FORMAT('.$column.',"0%m")');//put a zero in front.. otherwise it won't order correctly			break;			case 'Week of Year';				$sql = 'CONCAT("Week ",WEEK('.$column.'))';			break;			case 'Day of Week':				$sql = array('DATE_FORMAT('.$column.',"%W")','DATE_FORMAT('.$column.',"0%w")');			break;			case 'Day of Month':				$sql = array('DATE_FORMAT('.$column.',"%e")','DATE_FORMAT('.$column.',"0%d")');			break;			case 'Hour':				$sql = 'Hour('.$column.')';			break;			case 'Minute':				$sql = 'Minute('.$column.')';			break;			case 'Second':				$sql = 'Second('.$column.')';			break;						case 'Year-Month':				$sql = array('DATE_FORMAT('.$column.',"%Y %M")','DATE_FORMAT('.$column.',"0%Y%m")'); 			break;						case 'Month-Day':				$sql = array('DATE_FORMAT('.$column.',"%M %e")','DATE_FORMAT('.$column.',"0%m%e")');			break;									case 'Whole Value':				$sql = $column;			break;						//			//The following have special meanings passed to wikiDirs.php			//			case 'Comma Separated':				$sql = array($column.' ',2); 			break;			case 'Comma and Colon Separated';				$sql = array($column.'  ',3); //4 is also used for thisf			break;						default:				trigger_error('No type for : '.$post);			return;				}		//return array( ---display---, ---order---)		if( is_array($sql)){			return $sql;		}else{			return array($sql,1);		}	}		function showCode($code,$dbInfo){			echo '<textarea name="code" style="width:100%;" rows="'.$_SESSION['textareaY'].'" wrap="off">';			echo htmlspecialchars($code);			echo '</textarea>';			echo '<input type="submit" name="cmd" value="Save" /> ';			echo ' &nbsp; <input type="submit" name="cmd" value="Start Over" />';			echo '<input type="hidden" name="name" value="'.htmlspecialchars($_POST['name']).'" />';			echo '<input type="hidden" name="space" value="'.htmlspecialchars($_POST['space']).'" />';			echo '<input type="hidden" name="dbInfo" value="'.htmlspecialchars(serialize($dbInfo)).'" />';			}			function save(){		global $dbObject,$dbInfo;		includeFile('admin/PluginAdd.php');				//		//	dbInfo		//					$name = wbStrtolower($_POST['name']);			$newInfo = unserialize($_POST['dbInfo']);			if( !is_array($newInfo) ){				message('Directory creation failed.');				return;			}						$testCode = $_POST['code'].'$TEST="hello";';			eval($testCode);			if( $TEST !== "hello"){				message('The PHP code did not evaluate.');				return;			}						if( !pluginAdd::ad_object('class:'.$name,$_POST['code']) ){				message('Couldn\'t save object.');				return;			}						$data = $dbObject->getConfiguration();			$data['dbInfo'][$name] = $dbInfo[$name] = $newInfo;			$this->addSimilar($data,$name);			if( !$dbObject->updateConfig($data) ){				echo 'Oops, the directory wasn\'t created successfully, please try again.';				$this->showCode($_POST['code'],$newInfo);				return false;			}						message('Directory created.');		$this->current[$name] = $_POST['space'];		return true;	}	function addSimilar(&$data,$name){		global $dbObject;		$this->setStructures();				$class = wbData::getClass($name,false);		$vars = get_class_vars($class);		$structure =& $vars['levels'];		$similar = array_keys($this->existStruct,$structure);		if( count($similar) == 0){			return;		}		$similar[] = $name;		foreach($similar as $i => $space){			$temp = $similar;			unset($temp[$i]);			$data['dbInfo'][$space]['similar'] = $temp;		}	}		function setStructures(){		foreach($this->current as $space => $null){			$class = wbData::getClass($space,false);			$vars = get_class_vars($class);			$this->existStruct[$space] = $vars['levels'];		}	}				function escape(&$text){		$text = addcslashes($text,"\'");		return '\''.str_replace(array("\r","\n"),' ',$text).'\'';	}		function checkName(){		global $dbInfo,$wbTables;				if( empty($_POST['name']) ){			message('You must provide a name.');			return false;		}				if( !isset($this->spaces[$_POST['space']]) ){			message('Invalid space requested.');			return false;		}				includeFile('admin/PluginAdd.php');		$_POST['name'] = toStorage($_POST['name']);		$lowerName = wbStrtolower($_POST['name']);		if( !pluginAdd::checkName($lowerName) ){			return false;		}		$this->space = $_POST['space'];		return true;	}		function check(){		global $dbInfo,$wbTables, $wbParser;		$done = true;				if( !empty($_POST['limit']) && !is_numeric($_POST['limit'])){			message('Limit was not a numeric value');			$done = false;		}				if( !empty($_POST['pre']) || !empty($_POST['post']) ){			initiateParser();			if( !empty($_POST['pre']) ){				$this->pre = $wbParser->parse($_POST['pre'],true,$this);				if( $wbParser->errors ){					$done = false;					foreach($wbParser->errors as $error){						message('<strong>Error Parsing Top of Page Wiki Syntax</strong><br/>'.$error);					}				}			}			if( !empty($_POST['post']) ){				$this->post = $wbParser->parse($_POST['post'],true,$this);				if( $wbParser->errors ){					$done = false;					foreach($wbParser->errors as $error){						message('<strong>Error Parsing Top of Page Wiki Syntax</strong><br/>'.$error);					}				}			}		}		if( !empty($_POST['where']) ){			$table = wbData::dbInfo($_POST['space'],'dbTable');			$query = 'SELECT * FROM '.$table;			$query .= ' INNER JOIN '.$wbTables['all_files'];			$query .= ' ON '.$wbTables['all_files'].'.`file_id` = '.$table.'.`file_id` ';			$query .= ' WHERE 1 AND '.$_POST['where'];			$result = @mysql_query($query) or $passed = false;			if( !$result ){				message('"Where" must be valid sql.');				$done = false;			}		}				return $done;	}	function setVariables(){				$tempObject = null;		wbData::newObject($_POST['space'],$tempObject,true);					$this->allFilesVars = array();			$this->allFilesVars['keywords'] = true;			$this->allFilesVars['modified'] = true;			$this->allFilesVars['posted'] = true;			$this->allFilesVars['created'] = true;					//		//	Types		//				$this->types = array();			$this->types['timestamp'] = array('Year','Quarter','Month','Week of Year','Day of Week','Day of Month','Hour','Year-Month','Month-Day','Whole Value');			$this->types['datetime'] =& $this->types['timestamp'];			$this->types['time'] = array('Hour','Minute');			$this->types['date'] = array('Year','Quarter','Month','Week of Year','Day of Week','Day of Month');			//$this->types['varchar'] = array('Comma Separated','Whole Value');			$this->types['varchar'] = array('Comma Separated','Comma and Colon Separated','Comma and Colon Separated 2','Whole Value');			$this->types['char'] =& $this->types['varchar'];			$this->types['enum'] =& $this->types['varchar'];			$this->types['set'] =& $this->types['varchar'];

⌨️ 快捷键说明

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