コード例 #1
0
	public function action()
	{
		// Params
		$name = SLS_String::trimSlashesFromString($this->_http->getParam("name"));
		
		// Objects
		$user = $this->hasAuthorative();
		$xmlRights = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/rights.xml"));
		$result = $xmlRights->getTags("//sls_configs/entry[@login='******']");
		
		if (!empty($result))
		{
			$xmlRights->setTagAttributes('//sls_configs/entry[@login="******"]', array("enabled" => ($xmlRights->getTag('//sls_configs/entry[@login="******"]/@enabled')=='false') ? 'true' : 'false'));
			$xmlRights->saveXML($this->_generic->getPathConfig("configSls")."/rights.xml");
		}
		
		$this->_generic->forward("SLS_Bo","ManageRights");
	}
コード例 #2
0
	/**
	 * Check if an admin is authorized to log in
	 *
	 * @access public static
	 * @param string $login login
	 * @param string $pwd password
	 * @return mixed 1 if connected, 0 if expired, -1 not logged, -2 disabled
	 * @since 1.0
	 */
	public static function connect($login,$pwd)
	{
		$generic = SLS_Generic::getInstance();
		$session = $generic->getObjectSession();
		$sessionToken = substr(substr(sha1($generic->getSiteConfig("privateKey")),12,31).substr(sha1($generic->getSiteConfig("privateKey")),4,11),6);
		
		$pathsHandle = file_get_contents($generic->getPathConfig("configSls")."/rights.xml");
		$xmlRights = new SLS_XMLToolbox($pathsHandle);
		$result = array_shift($xmlRights->getTagsAttributes("//sls_configs/entry[@login='******' and @password='******' and count(action) > 0]",array("login")));
		
		if (!empty($result))
		{
			$attributes = array_shift($xmlRights->getTagsAttributes("//sls_configs/entry[@login='******' and @password='******']",array("reset_pwd","renew_pwd","last_renew_pwd","name","firstname","last_connection","enabled")));
			
			$reset_pwd = $attributes["attributes"][0]["value"];
			$renew_pwd = $attributes["attributes"][1]["value"];
			$last_renew_pwd = $attributes["attributes"][2]["value"];
			$name = $attributes["attributes"][3]["value"];
			$firstname = $attributes["attributes"][4]["value"];
			$lastLogin = $attributes["attributes"][5]["value"];
			$enabled = $attributes["attributes"][6]["value"];
			
			if ($reset_pwd == "true" || (!empty($last_renew_pwd) && !empty($renew_pwd) && (strtotime("+".$renew_pwd, SLS_Date::dateToTimestamp($last_renew_pwd)) < SLS_Date::dateToTimestamp(date("Y-m-d")))))
				return 0;
			if ($enabled == "false")
				return -2;
				
			$xmlRights->setTagAttributes("//sls_configs/entry[@login='******']",array("last_connection" => date("Y-m-d H:i:s")));
			$xmlRights->saveXML($generic->getPathConfig("configSls")."/rights.xml",$xmlRights->getXML());
			
			$session->setParam("SLS_BO_VALID_".$sessionToken,"true");	
			$session->setParam("SLS_BO_USER_".$sessionToken,$login);
			$session->setParam("SLS_BO_PREVIOUS_LOGIN",$lastLogin);
			$session->setParam("SLS_BO_LOGGED","true");
			$session->setParam("SLS_BO_USER",$login);
			$session->setParam("SLS_BO_USER_NAME",$name);
			$session->setParam("SLS_BO_USER_FIRSTNAME",$firstname);
			$session->setParam("ckfinderAuthorized",true);
			return 1;
		}
		else
			return -1;
	}
コード例 #3
0
	public function action()
	{
		$user = $this->hasAuthorative();
		$sql = SLS_Sql::getInstance();
		
		$xml = $this->getXML();
		$xml = $this->makeMenu($xml);
		$errors = array();
		
		// Get the table name
		$table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_");
		$db	   = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_");
		$class = ucfirst($db)."_".SLS_String::tableToClass($table);
		$file  = ucfirst($db).".".SLS_String::tableToClass($table);
		
		// If current db is not this one
		if ($sql->getCurrentDb() != $db)
			$sql->changeDb($db);
		
		if ($sql->tableExists($table))
		{
			if ($this->_http->getParam("reload") == "true")
			{
				$replacements = array('&amp;','&gt;','&lt;','&#61;','"',"'");
				$masks = array('&','>','<','=','','','');
				
				$columnWanted 	= $this->_http->getParam("column");
				$tableWanted 	= $this->_http->getParam("table");
				$labelWanted 	= $this->_http->getParam($tableWanted.'_fkLabel');
				$labelSpecified = SLS_String::trimSlashesFromString($this->_http->getParam("fkLabel_specified"));				
				$multilang 		= $this->_http->getParam("multilanguage");
				$onDelete 		= $this->_http->getParam("ondelete");
								
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml");
				$xmlFk = new SLS_XMLToolbox($pathsHandle);
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml");
				$xmlType = new SLS_XMLToolbox($pathsHandle);
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml");
				$xmlFilter = new SLS_XMLToolbox($pathsHandle);
				if (!empty($labelSpecified))
					$labelSpecified = str_replace(array('='),array('&#61;'),htmlentities(strtolower($labelSpecified),ENT_QUOTES,"UTF-8"));				
				$result = $xmlFk->getTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$columnWanted."' and @tablePk='".$tableWanted."']");
				
				// If an entry already exists in the XML, delete this record
				if (!empty($result))
				{
					$xmlTmp = $xmlFk->deleteTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$columnWanted."' and @tablePk='".$tableWanted."']");
					$xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlTmp);
					$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml");
					$xmlFk = new SLS_XMLToolbox($pathsHandle);
				}
				
				// Save it into the XML
				$xmlNode = '<entry tableFk="'.$db."_".$table.'" columnFk="'.$columnWanted.'" multilanguage="'.$multilang.'" ondelete="'.$onDelete.'" labelPk="'.(empty($labelSpecified) ? $labelWanted : $labelSpecified).'" tablePk="'.$tableWanted.'" />';					
				$xmlFk->appendXMLNode("//sls_configs",$xmlNode);
				$xmlFk->saveXML($this->_generic->getPathConfig("configSls")."/fks.xml",$xmlFk->getXML());

				// Disable UserBo quick-edit feature on this column
				$xmlBo = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bo.xml"));
				$boPath = "//sls_configs/entry[@type='table' and @name='".strtolower($db."_".$table)."']/columns/column[@name='".$columnWanted."']";
				$boExists = $xmlBo->getTag($boPath."/@allowEdit");
				if (empty($boExists))		
					$boPath = "//sls_configs/entry/entry[@type='table' and @name='".strtolower($db."_".$table)."']/columns/column[@name='".$columnWanted."']";
				$boExists = $xmlBo->getTag($boPath."/@allowEdit");
				if (!empty($boExists))
				{
					$xmlBo->setTagAttributes($boPath,array("allowEdit" => "false"));
					$xmlBo->saveXML($this->_generic->getPathConfig("configSls")."/bo.xml",$xmlBo->getXML());
					$xmlBo->refresh();	
				}
				
				// Update model
				$this->_generic->goDirectTo("SLS_Bo","UpdateModel",array(array("key"=>"name","value"=>$this->_http->getParam("name"))));
			}
			
			// Get generic object
			$this->_generic->useModel(SLS_String::tableToClass($table),$db,"user");
			$object = new $class();
			
			// Get object's infos
			$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml");
			$xmlFk = new SLS_XMLToolbox($pathsHandle);
			$columnsP = $object->getParams();
			$pk = $object->getPrimaryKey();
			$multilanguage = $object->isMultilanguage();		
			$xml->startTag("model");
			$xml->addFullTag("table",$table,true);
			$xml->addFullTag("db",$db,true);
			$xml->addFullTag("class",$class,true);
			$xml->addFullTag("pk",$pk,true);
			$xml->addFullTag("multilanguage",($multilanguage) ? "true" : "false",true);
			$xml->startTag("columns");
			foreach($columnsP as $column => $value)
			{
				$res = $xmlFk->getTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$column."']/@tablePk");				
				if ($object->getPrimaryKey() != $column && $column != "pk_lang" && empty($res))			
					$xml->addFullTag("column",$column,true);
			}
			$xml->endTag("columns");
			$tables = $this->getAllModels();
			
			sort($tables,SORT_REGULAR);			
				
			$xml->startTag("tables");			
			for($i=0 ; $i<$count=count($tables) ; $i++)
			{
				if (SLS_String::startsWith($tables[$i],$db))
				{
					$xml->startTag("table");
					$xml->addFullTag("name",SLS_String::substrAfterFirstDelimiter($tables[$i],"."));
					$xml->addFullTag("db",SLS_String::substrBeforeFirstDelimiter($tables[$i],"."));
					$tableN = SLS_String::substrAfterFirstDelimiter($tables[$i],".");
					$dbN = SLS_String::substrBeforeFirstDelimiter($tables[$i],".");
					$classN = ucfirst($dbN)."_".SLS_String::tableToClass($tableN);								
					$this->_generic->useModel($tableN,$dbN,"user");				
					$obj = new $classN();
					$properties = $obj->getParams();
					$xml->startTag("columns");
					foreach($properties as $key => $value)
						if ($key != "pk_lang")
							$xml->addFullTag("column",$key,true);
					$xml->endTag("columns");
					$xml->endTag("table");
				}
			}
				
			$xml->endTag("tables");	
			$xml->endTag("model");
		}
		else
		{
			$xml->addFullTag("error","Sorry this table doesn't exist anymore",true);
		}
		
		$this->saveXML($xml);
	}
コード例 #4
0
	public function action()
	{
		$user = $this->hasAuthorative();
		$sql = SLS_Sql::getInstance();		
		$xml = $this->getXML();
		$xml = $this->makeMenu($xml);
		$errors = array();
		
		// Get the table name
		$table = SLS_String::substrAfterFirstDelimiter($this->_http->getParam("name"),"_");
		$db	   = SLS_String::substrBeforeFirstDelimiter($this->_http->getParam("name"),"_");
		$class = ucfirst($db)."_".SLS_String::tableToClass($table);
		$file  = ucfirst($db).".".SLS_String::tableToClass($table);
		
		// If current db is not this one
		if ($sql->getCurrentDb() != $db)
			$sql->changeDb($db);
		
		if ($sql->tableExists($table))
		{
			if ($this->_http->getParam("reload") == "true")
			{
				$columnWanted = $this->_http->getParam("column");
				$typeWanted = $this->_http->getParam("type");
				
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml");
				$xmlFk = new SLS_XMLToolbox($pathsHandle);
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml");
				$xmlType = new SLS_XMLToolbox($pathsHandle);
				$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/filters.xml");
				$xmlFilter = new SLS_XMLToolbox($pathsHandle);
				
				$result = $xmlType->getTags("//sls_configs/entry[@table='".$db."_".$table."' and @column='".$columnWanted."']");
				
				// If an entry already exists in the XML, delete this record
				if (!empty($result))
				{
					$xmlTmp = $xmlType->deleteTags("//sls_configs/entry[@table='".$db."_".$table."' and @column='".$columnWanted."']");					
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlTmp);
					$xmlType->refresh();
					$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/types.xml");
					$xmlType = new SLS_XMLToolbox($pathsHandle);
				}
								
				// If file type, check possible thumbs
				if ($typeWanted == "file")
				{
					$typeFile = $this->_http->getParam("file");
					$file_thumb = $this->_http->getParam("file_thumb");
					$multilang = $this->_http->getParam("multilanguage");
					$thumbs = array();
										
					$typeWanted = $typeWanted."_".$typeFile;
					
					if ($typeFile == "img" && !empty($file_thumb))
					{
						for($i=0 ; $i<10 ; $i++)
						{
							$width = $this->_http->getParam("width".$i);
							$height = $this->_http->getParam("height".$i);
							$suffix = $this->_http->getParam("suffix".$i);
							
							if (!empty($suffix) && (!empty($width) || !empty($height)))
								array_push($thumbs,array('width' => $width, 'height' => $height, 'suffix' => $suffix));
						}
					}
					$rules = "*|*|*";
					if ($typeFile == "img")
					{
						$settings = $this->_http->getParam("imgSettings");
						$ratio = str_replace(",",".",$settings["ratio"]);
						$minWidth = str_replace(",",".",$settings["min-width"]);
						$minHeight = str_replace(",",".",$settings["min-height"]);
						$ratio = (!is_numeric($ratio) || (is_numeric($ratio) && $ratio <= 0)) ? "*" : round($ratio,2);
						$minWidth = (!is_numeric($minWidth) || (is_numeric($minWidth) && $minWidth < 0)) ? "*" : round($minWidth,0);
						$minHeight = (!is_numeric($minHeight) || (is_numeric($minHeight) && $minHeight < 0)) ? "*" : round($minHeight,0);
						$rules = $ratio."|".$minWidth."|".$minHeight;
					}
					
					// Save it into the XML
					$xmlNode = '<entry table="'.$db.'_'.$table.'" column="'.$columnWanted.'" rules="'.$rules.'" thumbs="'.str_replace('"','||#||',serialize($thumbs)).'" multilanguage="'.$multilang.'" type="'.$typeWanted.'" />';				
					$xmlType->appendXMLNode("//sls_configs",$xmlNode); 
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlType->getXML());
				}				
				else if ($typeWanted == "ip")
				{
					$type = $this->_http->getParam("ip");
					
					// Save it into the XML
					$xmlNode = '<entry table="'.$db.'_'.$table.'" column="'.$columnWanted.'" type="'.$typeWanted."_".$type.'" />';				
					$xmlType->appendXMLNode("//sls_configs",$xmlNode); 
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlType->getXML());
				}
				else if ($typeWanted == "complexity")
				{
					$complexity = $this->_http->getParam("complexity");
					$complexityMin = $this->_http->getParam("complexity_min");					
					$complexity = (empty($complexity)) ? array() : $complexity;
					if (!empty($complexityMin) && is_numeric($complexityMin) && $complexityMin >= 0)
						$complexity[] = "min".$complexityMin;
					$complexity = implode("|",$complexity);
					
					// Save it into the XML
					$xmlNode = '<entry table="'.$db.'_'.$table.'" column="'.$columnWanted.'" rules="'.$complexity.'" type="complexity" />';				
					$xmlType->appendXMLNode("//sls_configs",$xmlNode); 
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlType->getXML());					
				}			
				else if ($typeWanted == "num")
				{
					$type = $this->_http->getParam("num");
					
					// Save it into the XML
					$xmlNode = '<entry table="'.$db.'_'.$table.'" column="'.$columnWanted.'" type="'.$typeWanted."_".$type.'" />';				
					$xmlType->appendXMLNode("//sls_configs",$xmlNode); 
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlType->getXML());
				}
				// Else, it's email, url, color, uniqid, position, address
				else
				{
					// Save it into the XML
					$xmlNode = '<entry table="'.$db.'_'.$table.'" column="'.$columnWanted.'" type="'.$typeWanted.'" />';				
					$xmlType->appendXMLNode("//sls_configs",$xmlNode); 
					$xmlType->saveXML($this->_generic->getPathConfig("configSls")."/types.xml",$xmlType->getXML());
				}
				
				// Disable UserBo quick-edit feature on this column
				if ($typeWanted == "file")
				{
					$xmlBo = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configSls")."/bo.xml"));
					$boPath = "//sls_configs/entry[@type='table' and @name='".strtolower($db."_".$table)."']/columns/column[@name='".$columnWanted."']";
					$boExists = $xmlBo->getTag($boPath."/@allowEdit");
					if (empty($boExists))
						$boPath = "//sls_configs/entry/entry[@type='table' and @name='".strtolower($db."_".$table)."']/columns/column[@name='".$columnWanted."']";
					$boExists = $xmlBo->getTag($boPath."/@allowEdit");
					if (!empty($boExists))
					{
						$xmlBo->setTagAttributes($boPath,array("allowEdit" => "false"));
						$xmlBo->saveXML($this->_generic->getPathConfig("configSls")."/bo.xml",$xmlBo->getXML());
						$xmlBo->refresh();	
					}
				}
				
				// Update model
				$this->_generic->goDirectTo("SLS_Bo","UpdateModel",array(array("key"=>"name","value"=>$this->_http->getParam("name"))));			
			}
			
			// Get generic object
			$this->_generic->useModel($table,$db,"user");
			$object = new $class();
			
			// Get object's infos
			$pathsHandle = file_get_contents($this->_generic->getPathConfig("configSls")."/fks.xml");
			$xmlFk = new SLS_XMLToolbox($pathsHandle);
			$columnsP = $object->getParams();
			$pk = $object->getPrimaryKey();
			$multilanguage = $object->isMultilanguage();		
			$xml->startTag("model");
			$xml->addFullTag("table",$table,true);
			$xml->addFullTag("db",$db,true);
			$xml->addFullTag("class",$class,true);
			$xml->addFullTag("pk",$pk,true);
			$xml->addFullTag("multilanguage",($multilanguage) ? "true" : "false",true);
			$xml->startTag("columns");
			foreach($columnsP as $column => $value)
			{
				$res = $xmlFk->getTags("//sls_configs/entry[@tableFk='".$db."_".$table."' and @columnFk='".$column."']/@tablePk");				
				if ($object->getPrimaryKey() != $column && $column != "pk_lang" && empty($res))			
					$xml->addFullTag("column",$column,true);
			}		
			$xml->endTag("columns");
			$xml->endTag("model");
			
			$plugin = new SLS_XMLToolbox(file_get_contents($this->_generic->getPathConfig("configPlugins")."/plugins.xml"));
			$pluginImg = array_shift($plugin->getTags("//plugins/plugin[@code='image']"));
			$xml->addFullTag("plugin_img",empty($pluginImg) ? 'false' : 'true',true);
			$xml->addFullTag("plugin_url",$this->_generic->getFullPath("SLS_Bo","Plugins"),true);
		}
		else
		{
			$xml->addFullTag("error","Sorry this table doesn't exist anymore",true);
		}
		
		$this->saveXML($xml);
	}