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

📄 rename.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");wbLang::getFile('toolRename');function renameObject(&$dbObject){	global $lang,$wbTables;	$files = false;			//Must be able to edit the file	if( !$dbObject->editable ){		message('PROTECTED_FILE');		return false;	}		end($dbObject->dbInfo['keys']);	$key = key($dbObject->dbInfo['keys']);	reset($dbObject->dbInfo['keys']);		//compare case sensitive (space-insensitive)	$toName =& $_POST['to'];	$toName = toStorage($toName);	if( toStorage($dbObject->$key) == $toName){ 		message('NAME_UNCHANGED');		return false;	}			//	//	Going to need information for later insertion/creation of redirect	//		$redirRow = $dbObject->keyArray();			if( method_exists($dbObject,'setFileLocations')){			$files = array();			foreach($dbObject->files as $file => $nothing){				$files[$file] = $dbObject->$file;			}		}		//	//	Reset the key information 	//		$dbObject->$key = $toName;		$dbObject->links = array();//need to reset it, should probably be in the $dbObject setLinks function		$dbObject->setUniqLink();		$dbObject->checkKeys();		$dbObject->setLinks();			if( !$dbObject->validData ){			message('COULDNT_RENAMED');			return false;		}				//	//	Rename the existing rows/files 	//		if( is_array($files) ){			$dbObject->setFileLocations();			wbData::loadFileFunctions();			foreach($files as $file => $oldName){				if( !renameFile($oldName,$dbObject->$file) ){					message('COULDNT_RENAMED');					return false;				}			}		}		//	//	Update the existing row	//	//		if the file was recently deleted.. this won't work..			$query1 = 'UPDATE IGNORE '.$dbObject->dbInfo['dbTable'].' SET ';		$query1 .= wbDB::toSet($dbObject->keyArray());		$query1 .= 'WHERE `file_id`="'.$dbObject->file_id.'"';		$query1 .= ' LIMIT 1';		wbDB::runQuery($query1);		$num = mysql_affected_rows();		if( $num !=1 ){			message('NOT_RENAMED',$toName);			return false;		}				message('RENAMED');		$field = $dbObject->outputObj();		$dbObject->addFooter($field);			//	//	Changed to/from Template:	//				if( $dbObject->objectType === 'page'){			$nowTemplate = false;			$wasTemplate = false;			$temp = strtolower($toName);			if( strpos($temp,'template:') === 0){				$nowTemplate = true;			}			if( strpos($dbObject->flags,'template') !== false ){				$wasTemplate = true;			}			if( $nowTemplate !== $wasTemplate ){				if( $nowTemplate ){					if( empty($dbObject->flags) ){						$dbObject->flags = 'template';					}else{						$dbObject->flags .= ',template';					}				}else{					$dbObject->flags = str_replace(array('template',',,'),array('',','),$dbObject->flags);				}			}		}		$query1a = 'UPDATE IGNORE '.$wbTables['all_files'].' SET ';		$query1a .= ' `modified` = `modified` ';		$query1a .= ', `flags` = "'.wbDB::escape($dbObject->flags).'" ';		$query1a .= 'WHERE `file_id`="'.$dbObject->file_id.'" ';		$query1a .= ' LIMIT 1';		wbDB::runQuery($query1a);					//	//	Insert Redirect Page	//		//if the name change is only a case change then we don't want to do this		$check2 = $dbObject->keyArray();		$check2 = implode('\\',$check2);		$check1 = implode('\\',$redirRow);		if( wbStrtolower($check2) === wbStrtolower($check1)){			return;		}							$allFilesRow = array();		$allFilesRow['username'] = $_SESSION['username'];		$allFilesRow['created'] = 'now()';		$allFilesRow['modified'] = 'now()';		$allFilesRow['posted'] = 'now()';		$allFilesRow['flags'] = 'safe,redirect,locked'; //only the owner can remove the redirect		$allFilesRow['info'] = $dbObject->uniqLink;		$allFilesRow['keywords'] = '';		$allFilesRow['owner_id'] = $dbObject->owner_id;		wbDB::dbInsert2($wbTables['all_files'],$allFilesRow);				$newId = mysql_insert_id();		$redirRow['file_id'] = $newId;		$redirRow['summary'] = 'Redirected to '.$dbObject->uniqLink;		wbDB::dbInsert2($dbObject->dbInfo['dbTable'],$redirRow);			//	//	all_links	//		1) Change the to_id for the old title	//		2) Update to_id rows with new title			$query = 'UPDATE '.$wbTables['all_links'];		$query .= ' SET `to_id` = "'.$newId.'" ';		$query .= ' WHERE `to_id` = "'.$dbObject->file_id.'" ';		wbDB::runQuery($query);				$query = 'UPDATE '.$wbTables['all_links'];		$query .= ' SET `to_id` = "'.$dbObject->file_id.'" ';		$query .= ' WHERE `to_link` = "'.wbDB::escape($dbObject->uniqStorage).'" ';		wbDB::runQuery($query);		}global $dbObject,$lang;if( !cookies() ){	message('COOKIES_REQUIRED');	return;}switch( $page->userCmd ){	case 'rename':		renameObject($dbObject);	break;}

⌨️ 快捷键说明

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