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

📄 pluginbackup.php

📁 太烦了
💻 PHP
📖 第 1 页 / 共 2 页
字号:
       xml_set_element_handler($this->parser, 'tag_open', 'tag_close');       xml_set_character_data_handler($this->parser, 'cdata');       xml_parse($this->parser, $data);           $this->data = $this->data['child'];       xml_parser_free($this->parser);   }   function tag_open($parser, $tag, $attribs)   {       $this->data['child'][$tag][] = array('data' => '', 'attribs' => $attribs, 'child' => array());       $this->datas[] =& $this->data;       $this->data =& $this->data['child'][$tag][count($this->data['child'][$tag])-1];   }   function cdata($parser, $cdata)   {       $this->data['data'] .= $cdata;   }   function tag_close($parser, $tag)   {       $this->data =& $this->datas[count($this->datas)-1];       array_pop($this->datas);   }   /**   * Restores by parsing the uploaded file   *   * @return none   * @access public   */  function restore()  {	//geting vars	$file=$_FILES['userfile']['name'];	$fis=explode(".",$file);	$file=explode("_",$fis[0]);	$size=$_FILES['userfile']['size'];	//getting restoration file content	$restoreFile = TEMP_DIR."restore_{$hash}_{$this->uid}.xml";	move_uploaded_file($_FILES['userfile']['tmp_name'], $restoreFile);	$handle=fopen($restoreFile,"r");	$content=fread($handle,filesize($restoreFile));	fclose($handle);	unlink($restoreFile);	// parsing restoration file	$this->parse($content);	if ($this->datas)		$data=$this->datas;	else $data=$this->data;	//testing if file is valid	$error=0;	if ($data[0]['child']['DATA'])	 $data=$data[0]['child'];	$userid=$data['DATA']['0']['attribs']['USERID'];	$hash=$data['DATA']['0']['attribs']['HASH'];	$rtime=$data['DATA']['0']['attribs']['TS'];	$data=$data['DATA'][0]['child'];	if($userid!=$this->uid) $error=1;	$max=$this->getRow("SELECT * FROM ! WHERE uid=? AND hash=? AND size=? AND ts=?",array($this->lang_backup_table,$this->uid,$hash,$size,$rtime));	if(!$max) $error=1;	if($fis[1]!="xml") $error=1;	if($error==0)	{	//restoring personal profile	$p1=$data['PERSONAL_DETAILS'][0]['child'];	if ($p1)	{		//print_r($p1);		$fields=array('id','active','username','password','lastvisit','regdate','level','rank','actkey','picture','status','levelend'); //except these fields		foreach ($p1 as $field => $key)		{			$fielddata=$key[0]['data'];			$field=strtolower($field);			if(!in_array($field,$fields))				$this->query("UPDATE ".USER_TABLE." SET $field='$fielddata' WHERE id='{$this->uid}'");		}	}	$p2=$data['USER_PREFERENCE'][0]['child']['QUESTION'];	if($p2)	{		$this->query("DELETE FROM ".USER_PREFERENCE_TABLE." WHERE userid='{$this->uid}'");		foreach($p2 as $field => $key)		{			$questionid=$key['attribs']['ID'];			$answer=$key['attribs']['ANSWERID'];			$this->query("INSERT INTO ".USER_PREFERENCE_TABLE."(userid,questionid,answer) VALUES('{$this->uid}','{$questionid}','{$answer}')");		}	}	$p3=$data['PICS'][0]['child']['SNAP'];	if ($p3)	{		$this->query("DELETE FROM ".USER_SNAP_TABLE." WHERE userid='{$this->uid}'");		$fields=array('id');		foreach ($p3 as $item)		{			$pic['picno']=$item['attribs']['ID'];			foreach ($item['child'] as $item2=>$key2)				$pic[$item2]=$key2[0]['data'];			$field="";			$values="";			$pic['userid']=$this->uid;			foreach ($pic as $item=>$key)			{				if(!in_array($item,$fields))				{					$field.=strtolower($item).",";					$values.="'".$key."',";				}			}			$field="(".substr($field,0,strlen($field)-1).")";			$values="(".substr($values,0,strlen($values)-1).")";			$query="INSERT INTO ".USER_SNAP_TABLE."$field VALUES$values";			$this->query($query);		}	}	$p4=$data['MAILBOX'][0]['child']['MESSAGE'];	if($p4)	{		$this->query("DELETE FROM ".MAILBOX_TABLE." WHERE owner='{$this->uid}' AND sendtime<'$rtime'");		$fields=array('id');		foreach ($p4 as $item) {			foreach ($item['child'] as $item2=>$key2)				$mailbox[$item2]=$key2[0]['data'];			$field="";			$values="";			$mailbox['owner']=$this->uid;			foreach ($mailbox as $item=>$key)			{				if(!in_array($item,$fields))				{					$field.=strtolower($item).",";					$values.="'".$key."',";				}			}			$field="(".substr($field,0,strlen($field)-1).")";			$values="(".substr($values,0,strlen($values)-1).")";			$query="INSERT INTO ".MAILBOX_TABLE."$field VALUES$values";			$this->query($query);		}	}	$p5=$data['WINKS'][0]['child']['WINK'];	if($p5)	{		$this->query("DELETE FROM ".VIEWS_WINKS_TABLE." WHERE userid='{$this->uid}' AND act_time<'$rtime'");		$fields=array('id');		foreach ($p5 as $item=>$key)		{			foreach ($key['child'] as $item2=>$key2)				$wink[$item2]=$key2[0]['data'];			$field="";			$values="";			$wink['userid']=$this->uid;			foreach ($wink as $item=>$key)			{				if(!in_array($item,$fields))				{					$field.=strtolower($item).",";					$values.="'".$key."',";				}			}			$field="(".substr($field,0,strlen($field)-1).")";			$values="(".substr($values,0,strlen($values)-1).")";			$query="INSERT INTO ".VIEWS_WINKS_TABLE."$field VALUES$values";			$this->query($query);		}	}	$p6=$data['BUDDYBANHOTLIST'][0]['child']['ITEM'];	if ($p6)	{		$this->query("DELETE FROM ".BUDDY_BAN_TABLE." WHERE username='{$this->username}' AND act_date<'$rtime'");		foreach ($p6 as $item=>$key) {			$act=$key['child']['ACT']['0']['data'];			$ref_username=$key['child']['REF_USERNAME']['0']['data'];			$act_date=$key['child']['ACT_DATE']['0']['data'];			$this->query("INSERT INTO ".BUDDY_BAN_TABLE."(username,act,ref_username,act_date) VALUES('$this->username','$act','$ref_username','$act_date')");		}	}	$p7=$data['BLOG_PREFERENCE'][0]['child'];	if($p7)	{		$this->query("DELETE FROM ".BLOG_PREFERENCES_TABLE." WHERE userid='$this->uid'");		$fields=array('id','userid','adminid'); //except these fields		$this->query("INSERT INTO ".BLOG_PREFERENCES_TABLE."(userid) VALUES('$this->uid')");		foreach ($p7 as $item => $key)		{			$value=$key['0']['data'];			if(!in_array($item,$fields))				$this->query("UPDATE ".BLOG_PREFERENCES_TABLE." SET $item='$value' WHERE userid='{$this->uid}'");		}	}	$p8=$data['BLOG_STORY'][0]['child'];	if($p8)	{		$this->query("DELETE FROM ".BLOG_STORY_TABLE." WHERE userid='{$this->uid}'");		$fields=array('id','userid','adminid','views'); //except these fields		foreach ($p8 as $item=>$key)		{			$field="";			$values="";			foreach ($key[0]['child'] as $item2=>$key2)			{				if(!in_array($item2,$fields))				{					$field.=strtolower($item2).",";					$values.="'".$key2[0]['data']."',";				}			}			$field="({$field}userid)";			$values="({$values}$this->uid)";			$query="INSERT INTO ".BLOG_STORY_TABLE."$field VALUES$values";			$this->query($query);		}	}	$p9=$data['USER_CHOICES'][0]['child'];	if($p9)	{		$this->query("DELETE FROM ".USER_CHOICES_TABLE." WHERE userid='{$this->uid}'");		foreach ($p9 as $item=>$key)		{			$iteml=strtolower($item);			$this->query("INSERT INTO ".USER_CHOICES_TABLE."(userid,choice_name,choice_value) VALUES('{$this->uid}','{$iteml}','{$key['0']['data']}')");		}	}	}  	$this->modSmartyAssign("error",$error);	return  $this->modSmartyFetch("restore2.tpl");  }   /**   * Deletes backup files from temp folder which are have been made by more than $this->config['backup_save_time'] seconds.   *   * @return none   * @access public   */  function deleteBackupFiles()  {  	$time=time()-$this->config['backup_save_time'];  	$data=$this->getAll("SELECT * FROM ! WHERE deleted=? AND ts<?",array($this->lang_backup_table,0,$time));  	foreach ($data as $row)  	{  		$hash=$row['hash'];  		$ts=$row['ts'];  		$bid=$row['id'];  		$uid=$row['uid'];  		$date=date("Y_m_d_H_i_s",$ts);  		$file=TEMP_DIR."backup_{$hash}_{$uid}_{$date}.xml";  		unlink($file);  		$this->query("UPDATE ! SET deleted=? WHERE id=?",array($this->lang_backup_table,1,$bid));  	}  }   /**   * Does the processing to display a user page.  Called from plugin.php   *   * @return array   * @access public   */   function  displayPluginPage() {   	 $this->modSmartyAssign('lang',$this->modGetLang());   	 $this->modSmartyAssign('plugin_name',$this->plugin_class_name);   	 $udata = $this->modGetLoggedInUser();   	 $this->modSmartyAssign('udata',$udata);	 $this->uid=$udata['id'];	 $this->username=$udata['username'];	 $this->time=time();	 include LANG_DIR."lang_".$this->modGetLoadedLanguage()."/profile_questions.php";	 $this->modSmartyAssign('question',$profile_questions);	 $text=$this->modSmartyFetch("backuprestore.tpl");	 $this->deleteBackupFiles();   	 if($_POST['backup']==1)   	 	$text=$this->backup();   	 if(isset($_POST['restore']))   	 	$text=$this->restore();	return $text;   }   /**   * WARNING: USER IS NOT VALIDATED HERE.  BE CAREFUL   * Does the processing to display 100% plugin content.  Called from pluginraw.php   *   * @return array   * @access public   */   function  displayPluginContent() {   }    /**   * Returns the content that will appear in the left column of a page.  Designed to be overridden by plugins   *   * @return array   * @access public   */  function displayLeftCol() {  }    /**   * Returns the content that will appear in the main content area of the page.  This content will appear after the existing main content.  Designed to be overridden by plugins   *   * @return array   * @access public   */  function displayMain() {  }  /**   * Does the processing to display a admin page.  Called from plugin.php   *   * @return array   * @access public   */   function  displayPluginAdminPage() {   }}?>

⌨️ 快捷键说明

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