Exemplo n.º 1
0
	public static function enforceSK($name='__LPC_SK')
	{
		if (self::checkSK($name))
			return;
		echo _LH('genericErrorSessionKey');
		exit;
	}
Exemplo n.º 2
0
function rhr($row)
{
	$th=new LPC_HTML_node('th');
	$row->a($th);
	$th->a(_LH('scaffoldingActionHeader'));
	return true;
}
Exemplo n.º 3
0
	function getCheckbox($bool)
	{
		if ($bool) {
			$labelKey="scaffoldingBooleanYes";
			$idTag="yes";
		} else {
			$labelKey="scaffoldingBooleanNo";
			$idTag="no";
		}
		$id=$this->GET_key."_".$idTag;
		$name=$this->GET_key."[".((int) $bool)."]";
		$checked=$_GET[$this->GET_key][$bool];
		if ($checked)
			$checked=" checked";
		else
			$checked="";
		return "<div style='min-width: 50px'><input type='checkbox' name='".$name."' $checked value='1' id='".$id."'><label for='".$id."'>"._LH($labelKey)."</label></div>";
	}
Exemplo n.º 4
0
Arquivo: index.php Projeto: Gutza/LPC
<?php

require "common.php";

$p=LPC_Page::getCurrent();
$p->title=_LS('scaffoldingTitle');
$p->st();

$p->a("<div>"._LH('scaffoldingMsgAvailableClasses')."</div>");
$list=new LPC_HTML_node('ul');
$p->a($list);

$classes=exposeDirClasses(LPC_classes);
foreach($LPC_extra_class_dirs as $dir)
	$classes=array_merge($classes,exposeDirClasses($dir));

array_multisort(
	$classes['formal'],SORT_ASC, SORT_STRING,
	$classes['name'],SORT_ASC, SORT_STRING
);
foreach($classes['name'] as $idx=>$className) {
	$classFormal=$classes['formal'][$idx];
	$xtra="";
	if (isset($className::$formalDesc))
		$xtra=" &mdash; <i>".$className::$formalDesc."</i>";
	$list->a("<li><a href='objectList.php?c=".rawurlencode($className)."'>$classFormal</a>$xtra</li>");
}
Exemplo n.º 5
0
	function passwordProblems($pwd1,$pwd2)
	{
		if ($pwd1!==$pwd2)
			return _LH('lpcAuthErrConfirm');

		$min=$this->password_conditions['min_length'];
		if (strlen($pwd1)<$min)
			return _LH('lpcAuthErrMinLength',$min);

		if ($this->password_conditions['need_alpha'] && !preg_match("/[a-zA-Z]/",$pwd1))
			return _LH('lpcAuthErrNeedAlpha');

		if ($this->password_conditions['need_numeric'] && !preg_match("/[0-9]/",$pwd1))
			return _LH('lpcAuthErrNeedNumber');

		if ($this->password_conditions['need_lowercase'] && !preg_match("/[a-z]/", $pwd1))
			return _LH('lpcAuthErrNeedLowercase');

		if ($this->password_conditions['need_uppercase'] && !preg_match("/[A-Z]/", $pwd1))
			return _LH('lpcAuthErrNeedUppercase');

		return false;
	}
Exemplo n.º 6
0
	public function getScaffoldingEditRow($attName,$options=array())
	{
		$row=$this->getScaffoldingFileRow($attName,$options);
		if ($row!==false)
			return $row;

		$link="";
		if (isset($this->dataStructure['fields'][$attName]['link_class'])) {
			$class=$this->dataStructure['fields'][$attName]['link_class'];
			if (
				$this->id &&
				$this->getAttr($attName)
			) {
				$obj=$this->getObject($attName);
				$name=$obj->getNameH();
				if ($name)
					$name=" (".$name.")";
				$link=$name." <a href='objectEdit.php?c=".rawurlencode($class)."&amp;id=".rawurlencode($this->getAttr($attName))."'>"._LS('scaffoldingEditLink',htmlspecialchars($class),$this->getAttrH($attName))."</a>";
			}
			$link.=" <a href='#' onClick='return LPC_scaffolding_pickObject(\"".addslashes($class)."\",$(this).prevAll(\"input\").get(0))'>☞</a>";
		}
		if (!$this->id)
			$this->setAttr($attName,$this->getScaffoldingDefault($attName));
		$type="";
		if (isset($this->dataStructure['fields'][$attName]['type']))
			$type=$this->dataStructure['fields'][$attName]['type'];
		switch($type) {
			case 'integer':
				$input="<input type='text' name='attr[$attName]' size='6' value=\"".$this->getAttrH($attName)."\">".$link;
				break;
			case 'date':
				if ($val=$this->getAttr($attName))
					$val=date('Y-m-d',$val);
			case 'datetime':
				if (!isset($val) && ($val=$this->getAttr($attName)))
					$val=date('Y-m-d H:i',$val);
				$input=
					"<input type='text' name='attr[$attName]' value=\"".$val."\" class='input-date' id='attr_$attName'>".
					"<input type='button' value=\"".addslashes(_LS('scaffoldingSetDateNow'))."\" onClick=\"$('#attr_$attName').val('+0 minutes')\">";
				break;
			case 'longtext':
			case 'html':
				// HTML + longtext
				$input = new LPC_HTML_node('textarea');
				$input->setAttrs(array(
					'name' => "attr[$attName]",
					'style' => 'width: 100%; height: 150px',
				));
				$input->a($this->getAttrH($attName));
				if ('longtext' == $type)
					break;

				// HTML only
				$input->setAttr('style', $input->getAttr('style')."; min-width: 600px; height: 250px");
				$input = new LPC_HTML_html_editor($input, true);

				break;
			case 'boolean':
				if ($this->getAttr($attName)) {
					$checked_yes=" checked";
					$checked_no="";
				} else {
					$checked_yes="";
					$checked_no=" checked";
				}
				$input=
					"<input type='radio' name='attr[$attName]' value='1'$checked_yes id='{$attName}_yes'> <label for='{$attName}_yes'>"._LH('scaffoldingBooleanYes')."</label><br>".
					"<input type='radio' name='attr[$attName]' value='0'$checked_no id='{$attName}_no'> <label for='{$attName}_no'>"._LH('scaffoldingBooleanNo')."</label>";
				break;
			case 'enum':
			case 'set':
				if (!isset($this->dataStructure['fields'][$attName]['options']))
					throw new RuntimeException("You need to define the options explicitly for enum and set fields (key 'options' in the data structure).");
				$input=new LPC_HTML_node('div');

				$inputS=new LPC_HTML_select("attr[$attName]");
				$input->a($inputS);
				if ($type=='set') {
					// Allow for an empty set by providing an empty option which will be processed on POST
					$input->a("<input type='hidden' name=\"attr[$attName][]\" value='NULL'>");

					$inputS->setAttr('name',"attr[$attName][]");
					$inputS->setAttr('multiple','multiple');
					$inputS->setAttr('size',min(5,count($this->dataStructure['fields'][$attName]['options'])));
				}
				$values=explode(",",$this->getAttr($attName));
				foreach($this->dataStructure['fields'][$attName]['options'] as $option) {
					$optionH=new LPC_HTML_node('option');
					$optionH->compact=true;
					if (in_array($option,$values))
						$optionH->setAttr('selected',1);
					$optionH->setAttr('value',addslashes($option));
					$optionH->a(htmlspecialchars($option));
					$inputS->a($optionH);
				}
				break;
			default:
				$input="<input type='text' name='attr[$attName]' oninput=\"LPC_scaffolding_onTextInput(this)\" value=\"".$this->getAttrH($attName)."\" style='width:90%;'>".$link;
		}
		if (isset($this::$scaffoldingDesc[$attName]))
			$attDesc=_LS($this::$scaffoldingDesc[$attName]['name']);
		else
			$attDesc=$attName;
		if (empty($options['NO_SQL_DESC'])) {
			$rs=$this->query("DESCRIBE ".$this->getTableName()." ".$this->getFieldName($attName,true));
			$attDesc = "<span title=\"".htmlspecialchars($rs->fields['Type'])."\">".$attDesc."</span>";
		}
		if (isset($this::$scaffoldingDesc[$attName]['desc']) && empty($options['NO_LPC_DESC']))
			$attDesc.="<div style='font-weight:normal; font-size:80%'>"._LS($this::$scaffoldingDesc[$attName]['desc'])."</div>";

		$row=new LPC_HTML_form_row(array(
			'label'=>$attDesc,
			'input'=>$input,
		));
		$row->compact=true;
		return $row;
	}
Exemplo n.º 7
0
function validation_conditions()
{
	$u=LPC_User::newUser();
	$conds=array();
	$conds[]=_LH('lpcAuthValidCondMinLength',$u->password_conditions['min_length']);
	if ($u->password_conditions['need_alpha'])
		$conds[]=_LH('lpcAuthValidCondAlpha');
	if ($u->password_conditions['need_numeric'])
		$conds[]=_LH('lpcAuthValidCondNumeric');
	return "<ul><li>".implode($conds,"</li><li>")."</li></ul>";
}
Exemplo n.º 8
0
	$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedDependency')));
	return;
}
$rd=$_GET['rd'];

if (empty($_GET['rc'])) {
	$p->a(new LPC_HTML_error(__LH('scaffoldingErrorNeedClass')));
	return;
}
$rclass=$_GET['rc'];

if (empty($_GET['rid'])) {
	$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedID')));
	return;
}
$rid=$_GET['rid'];

if (
	!validClassName($rclass) ||
	!($robj=new $rclass($rid)) ||
	!$robj->hasScaffoldingRight('D') // there should be a separate right for adding/dropping links
) {
	$p->a(new LPC_HTML_error(_LH('genericErrorRights')));
	return;
}

$obj->dropLink($rd, $robj);
header("Location: ".$_GET['rt']);
exit;

Exemplo n.º 9
0
	public function validate_date($value)
	{
		if (preg_match("/^[0-9]+$/",$value))
			return NULL;
		return _LH('validationFieldDate',$this->field_name);
	}
Exemplo n.º 10
0
$p->title=_LS('lpcAuthRecoverTitle');
$p->st();

if (LPC_User::getCurrent(true)) {
	$p->a(new LPC_HTML_error(_LH('lpcAuthErrAlreadyLoggedOn')));
	return;
}

if (!empty($_POST['email'])) {
	// Requesting e-mail
	$us=LPC_User::newUser();
	$us=$us->search($us->user_fields["email"],$_POST['email']);
	if ($us && !$us[0]->sendRecover())
		$p->a(new LPC_HTML_error(_LH('lpcAuthErrFailEmail',$_POST['email'])));
	else
		$p->a(new LPC_HTML_confirm(_LH('lpcAuthConfirmRecoverEmail',$_POST['email'])));
	return;
}

$form=new LPC_HTML_form();
$p->a($form);
$div=new LPC_HTML_node('div');
$form->a($div);
$div->a("
<table>
<tr>
	<td>"._LS('lpcAuthRecoverEmailField')."</td>
	<td><input type='text' name='email' id='email'></td>
</tr>
<tr>
	<td>&nbsp;</td>
Exemplo n.º 11
0
$obj=new $class();
if ($obj->hasScaffoldingRight('W')) {
	$editDiv=new LPC_HTML_node('p');
	$editDiv->a("[<a href='objectEdit.php?c=$class'>"._LS('scaffoldingCreateObject',$class)."</a>]");
	$p->a($editDiv);
}

$refdata=array('rd','rc','rid');
$rd=NULL;
foreach($refdata as $refatom) {
	if (isset($_POST['LPC_scaffolding_'.$refatom]))
		$$refatom=$_POST['LPC_scaffolding_'.$refatom];
	elseif (isset($_GET[$refatom]))
		$$refatom=$_GET[$refatom];
}
$query=$rObj=NULL;
if (strlen($rd)) {
	$rObj=new $rc($rid);
	if (!$rObj->probe()) {
		$p-a(new LPC_HTML_error(_LH('scaffoldErrorMissingRemote')));
		return;
	}
	$editDiv->a(" &bull; [<a href='objectEdit.php?c=".$_GET['rc']."&amp;id=".$_GET['rid']."'>"._LS('scaffoldingBackToParent',htmlspecialchars($_GET['rc']),htmlspecialchars($_GET['rid']))."</a>]");
	$query=$rObj->_makeGetLinksQuery($rd);
}
$p->a($obj->getScaffoldingList($query, $rObj, $rd));

if ($editDiv)
	$p->a($editDiv);

Exemplo n.º 12
0
	$id=$_GET['id'];
if (!$id) {
	$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedId')));
	return;
}
if (
	!validClassName($class) ||
	!($obj=new $class($id)) ||
	!$obj->hasScaffoldingRight('F')
) {
	$p->a(new LPC_HTML_error(_LH('genericErrorRights')));
	return;
}
if (!isset($_GET['file'])) {
	$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedFile')));
	return;
}
$fileKey=$_GET['file'];
if (!$obj->isValidFile($fileKey)) {
	$p->a(new LPC_HTML_error(_LH('scaffoldingErrorNeedValidFile',$fileKey)));
	return;
}
if ($id && !$obj->probe()) {
	$p->a(new LPC_HTML_error(_LH('genericErrorMissingObject',$class,$id)));
	return;
}

$file=new LPC_HTTP_file();
$file->fromObject($obj,$fileKey);
$file->show();
Exemplo n.º 13
0
Arquivo: common.php Projeto: Gutza/LPC
<?php

$u=LPC_User::getCurrent();

if (isset($_GET['langID'])) {
	$lang=new LPC_Language();
	$lang->fromKey($_GET, 'langID');
	if ($lang->id) {
		LPC_Language::setCurrent($lang);
		header("Location: ".LPC_URI::getCurrent()->delVar('langID')->toString());
		exit;
	}
}
$langSelect=new LPC_HTML_node('div');
$langSelect->setAttr('style','float: right');
$langSelect->a(_LH('scaffoldingSelectLang')." ");

$langs=new LPC_HTML_select();
$langSelect->a($langs);
$langObjs=new LPC_Language();
$langObjs=$langObjs->search(NULL,NULL,'name');
foreach($langObjs as $langObj)
	$langs->addOption($langObj->getAttr('name'),$langObj->id);
$langs->setAttr('onChange',"window.location=location.pathname+location.search+(location.search?'&':'?')+'langID='+this.options[this.selectedIndex].value;");
$langs->selected=LPC_Language::getCurrent()->id;
LPC_Page::getCurrent()->a($langSelect);

function exposeDirClasses($dir)
{
	$result=array(
		'name'=>array(),
Exemplo n.º 14
0
}

$class=$_REQUEST['c'];
if (!validClassName($class) || !validateClassRights($class)) {
	$p->a(new LPC_HTML_error(_LH('genericErrorRights')));
	return;
}

$p=LPC_Page::getCurrent();
$p->st(_LS('scaffoldingColumnVisibilityTitle', $class));

$p->a("<p>".
	"[<a href='objectList.php?c=".$class."'>"._LS('scaffoldingBackToList')."</a>]".
	"</p>");

$p->a("<p>"._LH('scaffoldingColumnVisibilityExplain')."</p>");

$obj=new $class();
$allAttrs=$obj->sGetAllAttributes();
$visAttrs=$obj->sGetVisibleAttributes();
$defAttrs=$obj->sGetDefaultVisibleAttributes();

if (!empty($_POST['diff'])) {
	$diff=$_POST['diff'];
	if (empty($_POST['visi'][$diff]))
		$new=false;
	else
		$new=true;
	$sv=new LPC_Scaffold_fld_visi();
	if ($new) {
		if (in_array($diff, $defAttrs))