Ejemplo n.º 1
0
	
	$_SESSION['murrix']['system']->firstrun = false;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<meta name="robots" content="nofollow"/>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
		
		<?
		$xml = new mXml();
		$feeds = $xml->getFeeds();
		
		foreach ($feeds as $feed)
			echo "<link rel=\"alternate\" type=\"application/rss+xml\" href=\"?rss&id=".$feed['id']."\" title=\"".$feed['title']."\"/>";
		?>
		
		<link rel="shortcut icon" href="<?php 
echo geticon("murrix");
?>
" type="image/x-icon"/>
		<title><?php 
echo getSetting("TITLE", "Welcome to MURRiX");
?>
</title>
		
Ejemplo n.º 2
0
	function actionFinish(&$system, $args)
	{
		global $abspath, $db_prefix, $root_id, $anonymous_id;
		$db_prefix = $this->db['prefix'];
		
		if (empty($args['theme']))
		{
			$system->addAlert("You must enter select a theme");
			return;
		}
		
		if (empty($args['imgsize']))
		{
			$system->addAlert("You must enter a imagesize");
			return;
		}
		
		if (empty($args['thumbsize']))
		{
			$system->addAlert("You must enter a thumbnailsize");
			return;
		}
		
		if (empty($args['default_lang']))
		{
			$system->addAlert("You must enter a default language");
			return;
		}
		
		if (empty($args['default_path']))
		{
			$system->addAlert("You must enter a default path");
			return;
		}
		
		if (empty($args['password']))
		{
			$system->addAlert("You must enter a password");
			return;
		}
		
		unset($args['action']);
		$this->config = $args;
		
		
		$logtext = "";
			
		if (!$db_conn = mysql_pconnect($this->db['adress'], $this->db['username'], $this->db['password']))
		{
			$system->addAlert("Error connecting to MySQL: " . mysql_errno() . " " . mysql_error());
			return;
		}
			
		if (!mysql_select_db($this->db['name']))
		{
			if (mysql_query("CREATE DATABASE `".$this->db['name']."`"))
				$logtext .= "Database ".$this->db['name']." created.<br/>";
			else
			{
				$system->addAlert("Failed to create database ".$this->db['name'].". Error: " . mysql_errno() . " " . mysql_error());
				return;
			}
		}

		mysql_select_db($this->db['name']);
		
		$files = GetSubfiles("$abspath/scripts/install/db");
		foreach ($files as $file)
		{
			$query = "DROP TABLE IF EXISTS `".$this->db['prefix'].basename($file, ".sql")."`";
			mysql_query($query);
		
			$query = str_replace("%PREFIX%", $this->db['prefix'], implode("", file("$abspath/scripts/install/db/$file")));
			
			if (mysql_query($query))
				$logtext .= "Imported $file successfully.<br/>";
			else
			{
				$system->addAlert("Failed to import $file. Error: " . mysql_errno() . " " . mysql_error()."\n$query");
				return;
			}
		}
		
		$xml = new mXml();
		
		$files = GetSubfiles("$abspath/scripts/install/classes");
		foreach ($files as $file)
		{
			$filedata = getFileData($file, "$abspath/scripts/install/classes/$file");
			$msgid = $xml->parseXML(array("node_id" => 0, "data" => $filedata));
			
			$logtext .= mMsg::getText($msgid);
			
			if (mMsg::isError($msgid))
			{
				$system->addAlert(mMsg::getError($msgid));
				return;
			}
			else
				$logtext .= "Imported $file successfully.<br/>";
		}

		$files = GetSubfiles("$abspath/scripts/install/objects");
		foreach ($files as $file)
		{
			$filedata = getFileData($file, "$abspath/scripts/install/objects/$file");
			$msgid = $xml->parseXML(array("node_id" => 0, "data" => $filedata));
			
			$logtext .= mMsg::getText($msgid);
			
			if (mMsg::isError($msgid))
			{
				$system->addAlert(mMsg::getError($msgid));
				return;
			}
			else
				$logtext .= "Imported $file successfully.<br/>";
		}
		
		$root_id = 1;
		
		$admin_group_id = createGroup("admins", "Administrators group", true);
		$anon_group_id = createGroup("anonymous", "Anonymous group", false);
		
		$anon_user_id = createUserSimple("Anonymous", "anonymous", "", "", "anonymous", false);
		$anonymous_id = $anon_user_id;
		$admin_user_id = createUserSimple("Administrator", "admin", $this->config['password'], "", "admins", true);
		
		
		$files = GetSubfiles("$abspath/cache");
		foreach ($files as $file)
			unlink("$abspath/cache/$file");
			
		$files = GetSubfiles("$abspath/files");
		foreach ($files as $file)
			unlink("$abspath/files/$file");
			
		$files = GetSubfiles("$abspath/thumbnails");
		foreach ($files as $file)
			unlink("$abspath/thumbnails/$file");
		
		// Insert initial objects
/*
		$root_obj = new mObject();
		$root_obj->setClassName("folder");
		$root_obj->loadVars();
		$root_obj->setLanguage("eng");
		$root_obj->setName("root");
		$root_obj->setIcon("murrix");
		$root_obj->setRights("all=r");
		
		$root_obj->setVarValue("description", "This is the root node");

		if ($root_obj->save())
		{
			$root_obj->setMeta("initial_rights", "admins=rwc");
			$logtext .= "Created ".$root_obj->getName().".<br/>";
		}
		else
		{
			$logtext .= "Failed to create ".$root_obj->getName().".<br/>";
			$logtext .= $root_obj->error;
			$this->done = false;
		}

		$home_obj = new mObject();
		$home_obj->setClassName("folder");
		$home_obj->loadVars();
		$home_obj->setLanguage("eng");
		$home_obj->setName("home");
		$home_obj->setIcon("home");
		$home_obj->setRights("all=r");

		$home_obj->setVarValue("description", "This folder contain home folders");
		
		if ($home_obj->save())
		{
			$home_obj->linkWithNode($root_obj->getNodeId());
			$logtext .= "Created ".$home_obj->getName().".<br/>";
		}
		else
		{
			$logtext .= "Failed to create ".$home_obj->getName().".<br/>";
			$logtext .= $home_obj->error;
			$this->done = false;
		}
		
		$users_home_obj = new mObject();
		$users_home_obj->setClassName("folder");
		$users_home_obj->loadVars();
		$users_home_obj->setLanguage("eng");
		$users_home_obj->setName("users");
		$users_home_obj->setIcon("user");
		$users_home_obj->setRights("all=r");

		$users_home_obj->setVarValue("description", "This folder contain home folders");
		
		if ($users_home_obj->save())
		{
			$users_home_obj->linkWithNode($home_obj->getNodeId());
			$logtext .= "Created ".$users_home_obj->getName().".<br/>";
		}
		else
		{
			$logtext .= "Failed to create ".$users_home_obj->getName().".<br/>";
			$logtext .= $users_home_obj->error;
			$this->done = false;
		}
		
		$group_home_obj = new mObject();
		$group_home_obj->setClassName("folder");
		$group_home_obj->loadVars();
		$group_home_obj->setLanguage("eng");
		$group_home_obj->setName("groups");
		$group_home_obj->setIcon("group2");
		$group_home_obj->setRights("all=r");

		$users_home_obj->setVarValue("description", "This folder contain group folders");
		
		if ($group_home_obj->save())
		{
			$group_home_obj->linkWithNode($home_obj->getNodeId());
			$logtext .= "Created ".$group_home_obj->getName().".<br/>";
		}
		else
		{
			$logtext .= "Failed to create ".$group_home_obj->getName().".<br/>";
			$logtext .= $group_home_obj->error;
			$this->done = false;
		}
		
		$adminhome_obj = new mObject();
		$adminhome_obj->setClassName("folder");
		$adminhome_obj->loadVars();
		$adminhome_obj->setLanguage("eng");
		$adminhome_obj->setName($this->admin_username);
		$adminhome_obj->setRights("admins=rwc");

		$adminhome_obj->setVarValue("description", "This is the home for ".$this->admin_username);
		
		if ($adminhome_obj->save())
		{
			$adminhome_obj->linkWithNode($users_home_obj->getNodeId());
			$logtext .= "Created ".$adminhome_obj->getName().".<br/>";
			
			$administrator->home_id = $adminhome_obj->getNodeId();
			$administrator->save();
		}
		else
		{
			$logtext .= "Failed to create ".$adminhome_obj->getName().".<br/>";
			$logtext .= $adminhome_obj->error;
			$this->done = false;
		}
		
		$adminshome_obj = new mObject();
		$adminshome_obj->setClassName("folder");
		$adminshome_obj->loadVars();
		$adminshome_obj->setLanguage("eng");
		$adminshome_obj->setName("admins");
		$adminshome_obj->setRights("admins=rwc");

		$adminshome_obj->setVarValue("description", "This is the home for admins");
		
		if ($adminshome_obj->save())
		{
			$adminshome_obj->linkWithNode($group_home_obj->getNodeId());
			$logtext .= "Created ".$adminshome_obj->getName().".<br/>";
			
			$administrator_group->home_id = $adminshome_obj->getNodeId();
			$administrator_group->save();
		}
		else
		{
			$logtext .= "Failed to create ".$adminshome_obj->getName().".<br/>";
			$logtext .= $adminshome_obj->error;
			$this->done = false;
		}
		
		$public_obj = new mObject();
		$public_obj->setClassName("folder");
		$public_obj->loadVars();
		$public_obj->setLanguage("eng");
		$public_obj->setName("public");
		$public_obj->setRights("all=r");

		$public_obj->setVarValue("description", "This folder is readable by anyone");
		
		if ($public_obj->save())
		{
			$public_obj->linkWithNode($root_obj->getNodeId());
			$logtext .= "Created ".$public_obj->getName().".<br/>";
		}
		else
		{
			$logtext .= "Failed to create ".$public_obj->getName().".<br/>";
			$logtext .= $public_obj->error;
			$this->done = false;
		}
		*/
		
		
		
		setSetting("ROOT_NODE_ID",	1,				"any");
		setSetting("ANONYMOUS_ID",	$anonymous->id,			"any");
		setSetting("TRANSPORT",		$this->config['transport'],	"any");
		setSetting("DEFAULT_THEME",	$this->config['theme'],		"any");
		
		setSetting("IMGSIZE",		$this->config['imgsize'],	$this->config['theme']);
		setSetting("THUMBSIZE",		$this->config['thumbsize'],	$this->config['theme']);
		setSetting("INSTANTTHUMBS",	$this->config['instantthumbs'],	$this->config['theme']);
		setSetting("DEFAULT_PATH",	$this->config['default_path'],	$this->config['theme']);
		setSetting("DEFAULT_LANG",	$this->config['default_lang'],	$this->config['theme']);

		$confdata = "<?\n";
		$confdata .= "\$mysql_address = \"".$this->db['adress']."\";\n";
		$confdata .= "\$mysql_user = \"".$this->db['username']."\";\n";
		$confdata .= "\$mysql_pass = \"".$this->db['password']."\";\n";
		$confdata .= "\$mysql_db = \"".$this->db['name']."\";\n";
		$confdata .= "\$db_prefix = \"".$this->db['prefix']."\";\n";
		$confdata .= "?>";

		if (is_writable($abspath))
		{
			$conffile = fopen("$abspath/config.inc.php", "w");
			fwrite($conffile, $confdata);
			fclose($conffile);
			chmod("$abspath/config.inc.php", 0600);
			$logtext .= "Wrote config, $abspath/config.inc.php.<br/>";
		}
		else
		{
			$logtext .= "Unable to write config file.<br/>";
			$logtext .= "Please put the folowing into \"config.inc.php\" and place it in MURRiXs rootpath:<br/>";
			$logtext .= "<br/>";
			$logtext .= nl2br(htmlentities($confdata));
			$logtext .= "<br/>";
		}
		
		$logtext .= "Installation complete!<br/>";
		
		
		$data = compiletpl("finish", array("logtext"=>$logtext));
		$system->setZoneData($this->zone, utf8e($data));
		
		$data = compiletpl("menu", array("action"=>"finish"));
		$system->setZoneData("zone_menu", utf8e($data));
	}
Ejemplo n.º 3
0
	function actionImport_xml(&$system, $args)
	{
		$object = new mObject($this->getNodeId($args));

		if ($object->getNodeId() == 0 || !$object->hasRight("write"))
		{
			$system->addAlert(ucf(i18n("you do not have enough rights")));
			return;
		}
	
		if (empty($args['file']))
		{
			$system->addAlert(ucf(i18n("you must upload a file to import")));
			return;
		}
		
		list($filename, $full_filename) = explode(":", $args['file']);
		$filedata = getFileData($filename, $full_filename);
		
		
		$logtext = "<strong>Beginning import from xml file</strong> - ".date("Y-m-d H:i:s")."<hr/>";
		
		$xml = new mXml();
		
		$msgid = $xml->parseXML(array("node_id" => $object->getNodeId(), "data" => $filedata));
		
		$logtext .= mMsg::getText($msgid);
		
		$logtext .= "<hr/><strong>Finished import</strong> - ".date("Y-m-d H:i:s")."<br/><br/>";
		
		$system->paddZoneData("zone_import_log", utf8e($logtext));
	}
Ejemplo n.º 4
0
}
else if (isset($_GET['xml']) || isset($_POST['xml']))
{
	if (!isAdmin())
		echo "Only the administrator are allowed to export";
	else
	{
		$xml = new mXml();
		$xml->outputBackupXML(isset($_GET['xml']) ? $_GET : $_POST);
	}
	
	return;
}
else if (isset($_GET['rss']))
{
	$xml = new mXml();

	if (!isset($_GET['id']))
	{
		$list = $xml->getFeeds();
		echo compiletpl("rsslist", $list);
	}
	else
		$xml->outputFeed($_GET['id']);
	
	return;
}

/* ========================= */
// Set available linktyes
/* ========================= */
Ejemplo n.º 5
0
	function execute(&$system, $args)
	{
		global $abspath, $wwwpath, $db_prefix;

		if ($args['action'] == "import" && isAdmin())
		{
			if (empty($args['node_id']))
			{
				$system->addAlert(ucf(i18n("you must specifiy a node")));
				return;
			}
			
			if (empty($args['file']))
			{
				$system->addAlert(ucf(i18n("you must upload a file to import")));
				return;
			}
			
			list($filename, $full_filename) = explode(":", $args['file']);
			
			ob_start();
			
			$xml = new mXml();
			
			echo ucf(i18n("log"))."<br/><hr/>";
			
			$data = "";
			
			$extension = pathinfo($filename, PATHINFO_EXTENSION);
			if ($extension == "bz2")
			{
				echo "Found bz2-compressed file.<br/>";
				$bz = bzopen($full_filename, "r");
				while (!feof($bz))
					$data .= bzread($bz, 4096);
				bzclose($bz);
			}
			else
			{
				echo "Found uncompressed file.<br/>";
				$bz = fopen($full_filename, "r");
				while (!feof($bz))
					$data .= fread($bz, 4096);
				fclose($bz);
			}
			
			$import_data = $xml->parseBackupXML($data);
			
			
			
			if (isset($import_data['verion']))
				echo "Version: ".$import_data['verion']."<br/>";
			
			if (isset($import_data['name']))
				echo "Created: ".$import_data['created']."<br/>";
			
			if (isset($import_data['name']))
				echo "Name: ".$import_data['name']."<br/>";
				
			if (isset($import_data['description']))
				echo "Description: ".$import_data['description']."<br/>";
			
			$this->imported_classes = array();
			$this->imported_nodes = array();
			$this->imported_links = array();
			
			//PrintPre($import_data['container']);
			
			foreach ($import_data['container'] as $container)
			{
				$xmldata = $container['xmldata'];
				unset($container['xmldata']);
				//PrintPre($container);
				//echo "<hr/>";
				switch ($xmldata)
				{
					case "node":
					$this->imported_nodes[] = $container;
					break;
					
					case "class":
					$this->imported_classes[] = $container;
					break;
					
					case "link":
					$this->imported_links[] = $container;
					break;
				}
			}
			
			$class_table = new mTable("classes");
			$vars_table = new mTable("vars");
			
			foreach ($this->imported_classes as $class)
			{
				echo "Checking database for existing class ".$class['name']."<br/>";
				
				$existing_class = $class_table->get("`name`='".$class['name']."'");
				
				if (count($existing_class) == 0)
				{
					echo "<span style=\"color:red\">No existing class named ".$class['name']." found</span><br/>";
					continue;
				}
				else
					echo "<span style=\"color:green\">Class named ".$class['name']." found, checking variables</span><br/>";
				
				$existing_vars = $vars_table->get("`class_name`='".$class['name']."'");
				
				foreach ($class['vars'] as $varname => $properties)
				{
					$found = false;
					foreach ($existing_vars as $existing_var)
					{
						if ($existing_var['name'] == $varname)
						{
							$found = true;
							break;
						}
					}
					
					if ($found)
						echo "<span style=\"color:green\">Found matching var named $varname, type ".$properties['type']."</span><br/>";
					else
						echo "<span style=\"color:red\">No matching var named $varname, type ".$properties['type']." found</span><br/>";
				}
			}
			
			$nodes_to_link = array();
			$id_conversion = array();
			$added_node_ids = array();
			$linked_node_ids = array();
			
			$node_table = new mTable("nodes");
			
			foreach ($this->imported_nodes as $container)
			{
				if (!isset($container['created']))
					$container['created'] = date("Y-m-d H:i:s");
							
				$node_id = $node_table->insert(array("created" => $container['created']));
				
				$node = new mObject();
				$node->node_id = $node_id;
				
				$id_conversion[$container['id']] = $node_id;
				$added_node_ids[] = $node_id;
				
				if (is_array($container['metadata']))
				{
					foreach ($container['metadata']['container'] as $metadata)
					{
						$node->setMeta($metadata['name'], $metadata['value']);
						echo "Created metadata name=".$metadata['name'].", value=".$metadata['value'].", node_id=".$node_id."<br/>";
					}
				}
				
				foreach ($container['objects'] as $objcontainer)
				{
					if (isset($objcontainer['xmldata']) && $objcontainer['xmldata'] == "object")
						$objects = array($objcontainer);
					else
						$objects = $objcontainer;
						
					usort(&$objects, array($this, "SortByVersion"));
					
					foreach ($objects as $object_array)
					{
						$object = new mObject();
						$object->setClassName($object_array['class_name']);
						$object->loadVars();
						
						if (!isset($object_array['created']))
							$object_array['created'] = date("Y-m-d H:i:s");
						
						$object->node_id = $node_id;
						$object->created = $object_array['created'];
						$object->version = $object_array['version'];
						$object->class_name = $object_array['class_name'];
						$object->name = $object_array['name'];
						$object->icon = $object_array['icon'];
						$object->language = $object_array['language'];
						
						if (isset($object_array['right']))
							$object->rights = $object_array['rights'];
						else
							$object->rights = "";
						
						if (isset($object_array['user']))
						{
							$user = new mUser();
							$user->setByUsername($object_array['user']);
							$object->user_id = $user->id;
						}
						else
							$object->user_id = $_SESSION['murrix']['user']->id;
						
						if (is_array($object_array['vars']))
						{
							foreach ($object_array['vars'] as $key => $value)
							{
								if ($object->checkVarExistance($key) == 0)
								{
									echo "<span style=\"color:red\">Could not resolve - $key, skipping<br/></span>";
									continue;
								}
								if (!is_array($value['value']))
									$value['value'] = html_entity_decode($value['value']);
									
								if ($value['type'] == "file")
								{
									$extension = strtolower(pathinfo($value['value'], PATHINFO_EXTENSION));
									$oldfile = $args['filepath']."/".$value['file_id'].".$extension";
									
									if (!file_exists($oldfile))
										echo "<span style=\"color:red\">Could not find file - $oldfile, skipping<br/></span>";
									else
										$object->setVarValue($key, $value['value'].":$oldfile");
								}
								else if ($value['type'] == "thumbnail")
								{
									if (!empty($value['thumb_id']))
									{
										$oldfile = $args['thumbpath']."/".$value['thumb_id'].".jpg";
										
										if (!file_exists($oldfile))
											echo "<span style=\"color:red\">Could not find thumbfile - $oldfile, skipping<br/></span>";
										else
											$object->setVarValue($key, $value['thumb_id'].".jpg:$oldfile");
									}
								}
								else
									$object->setVarValue($key, $value['value']);
							}
						}
						
						$object->save(true);
						guessObjectType($object);
						echo "Created object name=".$object->name.", node_id=$node_id, id=".$object->id.",version=".$object->version.",language=".$object->language."<br/>";
					}
				}
			}
			
			$link_table = new mTable("links");
			
			foreach ($this->imported_links as $container)
			{
				$link_array = array();
				$link_array['node_top'] = $id_conversion[$container['node_top']];
				$link_array['node_bottom'] = $id_conversion[$container['node_bottom']];
				$link_array['type'] = $container['type'];
				
				$link_table->insert($link_array);
				echo "Linked node_top=".$link_array['node_top']." to node_bottom=".$link_array['node_bottom'].", type=".$link_array['type']."<br/>";
				
				if ($link_array['type'] == "sub")
					$linked_node_ids[] = $id_conversion[$container['node_bottom']];
			}
			
			$added_node_ids = array_unique($added_node_ids);
			$linked_node_ids = array_unique($linked_node_ids);
			
			$node_ids_to_link = array_diff($added_node_ids, $linked_node_ids);
			
			foreach ($node_ids_to_link as $node_id)
			{
				$link_array = array();
				$link_array['node_top'] = $args['node_id'];
				$link_array['node_bottom'] = $node_id;
				$link_array['type'] = "sub";
				
				$link_table->insert($link_array);
				echo "Linked node_top=".$link_array['node_top']." to node_bottom=".$link_array['node_bottom'].", type=".$link_array['type']."<br/>";
			}
			
			//print_r($import_data);
			$system->setZoneData("zone_import_log", utf8e("<br/>".ob_get_end()));
			return;
		}
		
		$this->draw($system, $args);
	}