remove svn files
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 47
|
||||
/svn/!svn/ver/203/trunk/current_version/classes
|
||||
END
|
||||
page_switch.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 63
|
||||
/svn/!svn/ver/142/trunk/current_version/classes/page_switch.php
|
||||
END
|
||||
qcm.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 55
|
||||
/svn/!svn/ver/132/trunk/current_version/classes/qcm.php
|
||||
END
|
||||
session.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 59
|
||||
/svn/!svn/ver/187/trunk/current_version/classes/session.php
|
||||
END
|
||||
database.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 60
|
||||
/svn/!svn/ver/181/trunk/current_version/classes/database.php
|
||||
END
|
||||
query.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 57
|
||||
/svn/!svn/ver/187/trunk/current_version/classes/query.php
|
||||
END
|
||||
input_box.php
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 61
|
||||
/svn/!svn/ver/203/trunk/current_version/classes/input_box.php
|
||||
END
|
||||
@@ -1,232 +0,0 @@
|
||||
10
|
||||
|
||||
dir
|
||||
204
|
||||
https://qcmmaker.googlecode.com/svn/trunk/current_version/classes
|
||||
https://qcmmaker.googlecode.com/svn
|
||||
|
||||
|
||||
|
||||
2011-02-04T12:53:02.612682Z
|
||||
203
|
||||
Francois.Lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1abcc3b6-0f78-11df-b47a-af0d17c1a499
|
||||
|
||||
page_switch.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-05-27T12:39:51.000000Z
|
||||
2329eae6f4e08390ea0f3b6473c032ac
|
||||
2010-05-26T15:19:46.928829Z
|
||||
142
|
||||
francois.lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2262
|
||||
|
||||
qcm.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-05-17T13:58:31.000000Z
|
||||
a42c09f4317dbd6b042ea456cd133504
|
||||
2010-05-16T21:14:21.358495Z
|
||||
132
|
||||
Francois.Lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2410
|
||||
|
||||
session.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-11T11:41:49.000000Z
|
||||
b3fd2f8bc728ba7b9218c44d4ee0c0c3
|
||||
2010-09-09T13:24:00.096915Z
|
||||
187
|
||||
francois.lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2547
|
||||
|
||||
database.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-06-24T18:14:17.000000Z
|
||||
091eec56e6da0e3e8b4f7dae2cf907de
|
||||
2010-06-24T15:03:08.973390Z
|
||||
181
|
||||
francois.lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1361
|
||||
|
||||
query.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-09-11T11:41:49.000000Z
|
||||
93106e8c9d51d8c84482b91a00d71949
|
||||
2010-09-09T13:24:00.096915Z
|
||||
187
|
||||
francois.lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2006
|
||||
|
||||
input_box.php
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-02-05T22:56:04.669525Z
|
||||
dc3493321c6afd35e661efdb1b43ee1f
|
||||
2011-02-04T12:53:02.612682Z
|
||||
203
|
||||
Francois.Lutran
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3460
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* DataBase table
|
||||
*
|
||||
* Manage installation and access
|
||||
*
|
||||
*
|
||||
*/
|
||||
class DataBase
|
||||
{
|
||||
/**
|
||||
* @var object connection
|
||||
*/
|
||||
public $oConnection;
|
||||
|
||||
/**
|
||||
* Constructor php5
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setConnection();
|
||||
}
|
||||
|
||||
//TODO from here on
|
||||
|
||||
private function setConnection()
|
||||
{
|
||||
$this->oConnection = connection();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function install($oConnection)
|
||||
{
|
||||
install();
|
||||
}
|
||||
|
||||
function getInstallQuery($sTable)
|
||||
{
|
||||
getInstallQuery($sTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return array db tables
|
||||
*/
|
||||
public function getTables()
|
||||
{
|
||||
return getTables();
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return array db qcm related tables
|
||||
*/
|
||||
public function getQcmTables()
|
||||
{
|
||||
return getQcmTables();
|
||||
}
|
||||
|
||||
public function getChangeLogEnum()
|
||||
{
|
||||
return getChangeLogEnum();
|
||||
}
|
||||
|
||||
function getTableColumns($sTable, $sColumnName=false)
|
||||
{
|
||||
return getTableColumns($sTable, $sColumnName);
|
||||
}
|
||||
function getTableConstraints($sTable)
|
||||
{
|
||||
return getTableConstraints($sTable);
|
||||
}
|
||||
|
||||
function getQuote($sTable, $sColumnName)
|
||||
{
|
||||
return getQuote($sTable, $sColumnName);
|
||||
}
|
||||
|
||||
function getTableColumnNames($sTableName, $iTableColumn=0)
|
||||
{
|
||||
return getTableColumnNames($sTableName, $iTableColumn);
|
||||
}
|
||||
function getId($sTableName)
|
||||
{
|
||||
return getId($sTableName);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Input box (get user typed info), replacing javascript messageBox */
|
||||
|
||||
class InputBox
|
||||
{
|
||||
private $iBoxId;
|
||||
private $sBoxTitle;
|
||||
private $sQuestion;
|
||||
private $asAnswers;
|
||||
private $asStyle;
|
||||
private $sAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $sBoxTitle
|
||||
* @param $sQuestion
|
||||
* @param $asAnswers
|
||||
* @param $asStyle
|
||||
* @return unknown_type
|
||||
*/
|
||||
function __construct($sBoxTitle, $sQuestion, $asAnswers=array(), $asStyle=array())
|
||||
{
|
||||
$this->iBoxId = 'input_box_id_'.rand(1, 1000);
|
||||
$this->sBoxTitle = $sBoxTitle;
|
||||
$this->sQuestion = $sQuestion;
|
||||
$this->setAnswers($asAnswers);
|
||||
$this->setStyle($asStyle);
|
||||
$this->setTags(array());
|
||||
}
|
||||
|
||||
function setAnswers($asAnswers)
|
||||
{
|
||||
if(count($asAnswers)==0)
|
||||
{
|
||||
$this->asAnswers = array('Oui'=>'submitForm(\'#formName#\')', 'Non'=>'');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->asAnswers = $asAnswers;
|
||||
}
|
||||
}
|
||||
|
||||
function getAnswers()
|
||||
{
|
||||
$sAnswers = '';
|
||||
foreach($this->asAnswers as $sAnswertext=>$sAnswerAction)
|
||||
{
|
||||
$sAnswers .= '<input type="button" style="margin:auto 10px;" onclick="setInputBoxDisplay_'.$this->iBoxId.'();'.$sAnswerAction.';" value="'.$sAnswertext.'" />';
|
||||
}
|
||||
return $sAnswers;
|
||||
}
|
||||
|
||||
function setStyle($asStyle)
|
||||
{
|
||||
$this->asStyle = array('display'=>'none', 'position'=>'absolute');
|
||||
$this->asStyle = array_merge($this->asStyle, $asStyle);
|
||||
}
|
||||
|
||||
function getStyle()
|
||||
{
|
||||
$sStyle = '';
|
||||
foreach($this->asStyle as $sStyleTag=>$sStyleValue)
|
||||
{
|
||||
$sStyle .= $sStyleTag.':'.$sStyleValue.';';
|
||||
}
|
||||
return $sStyle;
|
||||
}
|
||||
|
||||
function setTags($asTags)
|
||||
{
|
||||
$this->asTagNames = $asTags;
|
||||
}
|
||||
|
||||
function getTag($sTagName=false, $bKey=false, $bJavaScript=false)
|
||||
{
|
||||
return ($sTagName===false)?$this->asTagNames:$this->asTagNames[$sTagName];
|
||||
}
|
||||
|
||||
function getTagNames()
|
||||
{
|
||||
return array_keys($this->getTag());
|
||||
}
|
||||
|
||||
function getJavaScript()
|
||||
{
|
||||
$asTagReplace = array();
|
||||
foreach($this->getTagNames() as $sTagName)
|
||||
{
|
||||
$asTagReplace[] = 'box = box.replace(/\#'.$sTagName.'\#/g, '.$sTagName.');';
|
||||
}
|
||||
|
||||
return '<script type="text/javascript">
|
||||
function setInputBox_'.$this->iBoxId.'('.implode(', ', $this->getTagNames()).')
|
||||
{
|
||||
//initiate box HTML
|
||||
var box = \''.printJsString($this->getBox()).'\';
|
||||
|
||||
//replace specific values
|
||||
'.implode("\n", $asTagReplace).'
|
||||
|
||||
//display the box
|
||||
document.getElementById(\''.$this->iBoxId.'\').innerHTML = box;
|
||||
setInputBoxDisplay_'.$this->iBoxId.'();
|
||||
}
|
||||
function setInputBoxDisplay_'.$this->iBoxId.'()
|
||||
{
|
||||
document.getElementById(\''.$this->iBoxId.'\').style.top = (Y-80)+"px";
|
||||
document.getElementById(\''.$this->iBoxId.'\').style.left = (X-250)+"px";
|
||||
setBoxDisplay(\''.$this->iBoxId.'\');
|
||||
setBoxDisplay("layer");
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
function getAction()
|
||||
{
|
||||
return 'setInputBox_'.$this->iBoxId.'(\''.implode('\', \'', array_map('addslashes', $this->getTag())).'\');';
|
||||
}
|
||||
|
||||
function getBox()
|
||||
{
|
||||
return ' <fieldset class="inputBox rounded">
|
||||
<legend class="rounded">'.$this->sBoxTitle.'</legend>
|
||||
<p style="font-weight:bold;text-align:center;">'.$this->sQuestion.'</p>
|
||||
<form style="text-align:center;">'.$this->getAnswers().'</form>
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
function getHtml()
|
||||
{
|
||||
return "\n".$this->getJavaScript()."\n".'<div id="'.$this->iBoxId.'" style="'.$this->getStyle().'"></div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Switch from page to page to display a list of data */
|
||||
|
||||
class PageSwitch
|
||||
{
|
||||
public $sPageVar;
|
||||
public $iPageNumber;
|
||||
|
||||
private $iItemNb;
|
||||
private $iLimit;
|
||||
|
||||
private $sRefPage;
|
||||
private $sExtraRefPageVar;
|
||||
|
||||
private $sNextPageLinkTitle;
|
||||
private $sPrevPageLinkTitle;
|
||||
|
||||
public function __construct($sPageVar, $iTotalItemNb, $iLimit, $sExtraRefPageVar='')
|
||||
{
|
||||
$this->sPageVar = $sPageVar;
|
||||
$this->iItemNb = $iTotalItemNb;
|
||||
$this->iLimit = $iLimit;
|
||||
$this->sExtraRefPageVar = $sExtraRefPageVar;
|
||||
|
||||
//parse url
|
||||
$asUrlParts = parse_url($_SERVER['REQUEST_URI']);
|
||||
if(isset($asUrlParts['query']))
|
||||
{
|
||||
parse_str($asUrlParts['query'], $asUrlVariables);
|
||||
|
||||
$this->sRefPage = $asUrlVariables['page'];
|
||||
$this->iPageNumber = isset($asUrlVariables[$this->sPageVar])?$asUrlVariables[$this->sPageVar]:1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sRefPage = DEFAULT_LOGGED_PAGE;
|
||||
$this->iPageNumber = 1;
|
||||
}
|
||||
|
||||
$this->setNextPageLinkTitle();
|
||||
$this->setPrevPageLinkTitle();
|
||||
}
|
||||
|
||||
public function setNextPageLinkTitle($sTitle='>')
|
||||
{
|
||||
$this->sNextPageLinkTitle = $sTitle;
|
||||
}
|
||||
public function setPrevPageLinkTitle($sTitle='<')
|
||||
{
|
||||
$this->sPrevPageLinkTitle = $sTitle;
|
||||
}
|
||||
|
||||
public function getItemStartPointer()
|
||||
{
|
||||
return (max(0, $this->iPageNumber-1))*$this->iLimit;
|
||||
}
|
||||
|
||||
public function getItemRange()
|
||||
{
|
||||
$iItemStartPointer = $this->getItemStartPointer();
|
||||
return array('start'=>$iItemStartPointer+1, 'end'=>min($this->iItemNb, $iItemStartPointer+$this->iLimit));
|
||||
}
|
||||
|
||||
public function getNextLink()
|
||||
{
|
||||
return $this->isNextPage()?$this->getPage($this->sNextPageLinkTitle, 1):'';
|
||||
}
|
||||
|
||||
public function getPrevLink()
|
||||
{
|
||||
return $this->isPrevPage()?$this->getPage($this->sPrevPageLinkTitle, -1):'';
|
||||
}
|
||||
|
||||
private function isNextPage()
|
||||
{
|
||||
return (($this->iItemNb - ($this->iPageNumber-1)*$this->iLimit) > $this->iLimit);
|
||||
}
|
||||
|
||||
private function isPrevPage()
|
||||
{
|
||||
return ($this->iPageNumber > 1);
|
||||
}
|
||||
|
||||
private function getPage($sTitle, $iDir)
|
||||
{
|
||||
$iPageNb = max(1, $this->iPageNumber + $iDir);
|
||||
return getHtml($sTitle, 'a', 'XButton rounded', 'font-size:12px;border-color:white;', array('href'=>'?page='.$this->sRefPage.'&'.$this->sPageVar.'='.$iPageNb));
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Qcm Class */
|
||||
|
||||
class qcm
|
||||
{
|
||||
public $oDataBase;
|
||||
|
||||
//Qcm
|
||||
public $iQcmId;
|
||||
public $sQcmName;
|
||||
private $sAuthor;
|
||||
private $sLastModifiedOn;
|
||||
private $bValid;
|
||||
|
||||
//Questions
|
||||
private $asQuestions; //all
|
||||
private $asQuestionTitle; // id_question => question
|
||||
private $asImages;
|
||||
|
||||
//Answers
|
||||
private $asAnswerTitle; // id_answer => answer
|
||||
private $asRightAnswers;
|
||||
private $asAnswerQuestion; // id_question =>> id_answers
|
||||
|
||||
//Results
|
||||
private $asResults; // id_user => mark
|
||||
private $asDates; // id_user => led
|
||||
|
||||
public function __construct($oDataBase, $iQcmId=false)
|
||||
{
|
||||
$this->oDataBase = $oDataBase;
|
||||
|
||||
if($iQcmId!==false)
|
||||
{
|
||||
//Qcm
|
||||
$test = array_values(selectRow(QCM_TABLE, array($iQcmId), false, true));
|
||||
list($this->iQcmId, $this->sAuthor, $this->sQcmName, $this->bValid, $this->sLastModifiedOn) = $test;
|
||||
|
||||
//Questions
|
||||
$asQuestions = selectRows(array('from'=>QUESTION_TABLE, 'constraint'=>array('id_'.QCM_TABLE=>$this->iQcmId)));
|
||||
pre($asQuestions, '', true);
|
||||
foreach($asQuestions as $asRow)
|
||||
{
|
||||
$this->asQuestionTitle[$asRow['id_'.QUESTION_TABLE]] = $asRow[QUESTION_TABLE];
|
||||
$this->asImages[$asRow['id_'.QUESTION_TABLE]] = $asRow['image'];
|
||||
$this->asQuestions[$asRow['id_'.QUESTION_TABLE]] = array(QUESTION_TABLE=>$asRow[QUESTION_TABLE], 'image'=>$asRow['image']);
|
||||
}
|
||||
|
||||
//Answers
|
||||
$asAnswers = selectRows(array('from'=>ANSWER_TABLE, 'constraint'=>array('id_'.QCM_TABLE=>$this->iQcmId)));
|
||||
foreach($asAnswers as $asRow)
|
||||
{
|
||||
$this->asAnswerTitle[$asRow['id_'.ANSWER_TABLE]] = $asRow[ANSWER_TABLE];
|
||||
$this->asRightAnswers[$asRow['id_'.ANSWER_TABLE]] = $asRow[RIGHT_ANSWER];
|
||||
$this->asAnswerQuestion[$asRow['id_'.ANSWER_TABLE]] = $asRow['id_'.QUESTION_TABLE];
|
||||
$this->asAnswers[$asRow['id_'.ANSWER_TABLE]] = array(); //TODO
|
||||
}
|
||||
|
||||
//Results
|
||||
$asResults = selectRows(array('from'=>RESULT_TABLE, 'constraint'=>array('id_'.QCM_TABLE=>$this->iQcmId)));
|
||||
foreach($asResults as $asRow)
|
||||
{
|
||||
$this->asResults[$asRow['id_'.USER_TABLE]] = $asRow[RESULT_TABLE];
|
||||
$this->asDates[$asRow['id_'.USER_TABLE]] = $asRow['led'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getQcm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function getQuestions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function getAnswers($iQuestionId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function cloneQcm()
|
||||
{
|
||||
$oClonedQcm = new qcm($this->oDataBase);
|
||||
|
||||
return $oClonedQcm;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* SQL Select Query Class */
|
||||
|
||||
class Query
|
||||
{
|
||||
private $oMySql;
|
||||
|
||||
private $asSelections;
|
||||
private $asSources;
|
||||
private $asConstraints;
|
||||
private $asOrders;
|
||||
private $asGroups;
|
||||
|
||||
function __construct($oMySql)
|
||||
{
|
||||
$this->oMySql = $oMySql;
|
||||
$asSelections = $asSources = $asConstraints = $asOrders = $asGroups = array();
|
||||
}
|
||||
|
||||
public function addSelect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
function selectRows($asInfo)
|
||||
{
|
||||
$sAttributes = array('select'=>"SELECT", 'from'=>"FROM", 'constraint'=>"WHERE", 'groupBy'=>"GROUP BY", 'orderBy'=>"ORDER BY");
|
||||
$asRowSeparators = array('select'=>", ", 'from'=>"", 'constraint'=>" AND ", 'groupBy'=>", ", 'orderBy'=>", ");
|
||||
$asOperators = array('constraint'=>" = ", 'orderBy'=>" ");
|
||||
|
||||
$sQuery = "";
|
||||
foreach($sAttributes as $sStatement => $sKeyWord)
|
||||
{
|
||||
$asSelection = array_key_exists($sStatement, $asInfo)?$asInfo[$sStatement]:array();
|
||||
if(!is_array($asSelection))
|
||||
{
|
||||
$asSelection = array($asSelection);
|
||||
}
|
||||
|
||||
//if provided values
|
||||
if(count($asSelection)>0)
|
||||
{
|
||||
cleanSql($asSelection);
|
||||
$sQuery .= " ".$sKeyWord." ";
|
||||
|
||||
//in case of double value input
|
||||
if(array_key_exists($sStatement, $asOperators))
|
||||
{
|
||||
$sQuery .= implodeAll($asSelection, $asOperators[$sStatement], $asRowSeparators[$sStatement]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sQuery .= implode($asRowSeparators[$sStatement], $asSelection);
|
||||
}
|
||||
}
|
||||
//default value for select
|
||||
elseif($sStatement=='select')
|
||||
{
|
||||
$sQuery .= " ".$sKeyWord." * ";
|
||||
}
|
||||
}
|
||||
|
||||
return getArrayQuery($sQuery, true);
|
||||
}
|
||||
|
||||
function implodeAll($asText, $sKeyValueSeparator='', $sRowSeparator='', $sKeyPre='', $sValuePost=false)
|
||||
{
|
||||
if($sValuePost===false)
|
||||
{
|
||||
$sValuePost = $sKeyPre;
|
||||
}
|
||||
$asCombinedText = array();
|
||||
foreach($asText as $sKey=>$sValue)
|
||||
{
|
||||
$asCombinedText[] = $sKeyPre.$sKey.$sKeyValueSeparator.$sValue.$sValuePost;
|
||||
}
|
||||
return implode($sRowSeparator, $asCombinedText);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Session Class */
|
||||
|
||||
class PhpObject
|
||||
{
|
||||
private $asErrorStack;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->asErrorStack = array();
|
||||
}
|
||||
|
||||
function addError($sError)
|
||||
{
|
||||
$this->asErrorStack[] = $sError;
|
||||
}
|
||||
|
||||
function getCleanErrorStack()
|
||||
{
|
||||
$sErrorStack = implode("\n", $this->asErrorStack);
|
||||
$this->asErrorStack = array();
|
||||
return $sErrorStack;
|
||||
}
|
||||
|
||||
function __destruct()
|
||||
{
|
||||
file_put_contents('log.html', "\n\n".date('r')."\n".$this->getCleanErrorStack(), FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
class Session extends PhpObject
|
||||
{
|
||||
private $iUserId;
|
||||
private $sLogin;
|
||||
private $oMySql;
|
||||
|
||||
public function __construct($oMySql)
|
||||
{
|
||||
parent::__construct();
|
||||
$iUserId = $sLogin = false;
|
||||
$this->oMySql = $oMySql;
|
||||
$this->syncSession();
|
||||
}
|
||||
|
||||
private function syncSession()
|
||||
{
|
||||
if(isset($_SESSION['id_user']))
|
||||
{
|
||||
$this->iUserId = $_SESSION['id_user'];
|
||||
}
|
||||
if(isset($_SESSION['login']))
|
||||
{
|
||||
$this->sLogin = $_SESSION['login'];
|
||||
}
|
||||
}
|
||||
|
||||
private function setSession($iUserId, $sLogin)
|
||||
{
|
||||
$_SESSION['id_user'] = $iUserId;
|
||||
$_SESSION['login'] = $sLogin;
|
||||
$this->syncSession();
|
||||
}
|
||||
|
||||
public function logMeIn($sLogin, $sPass)
|
||||
{
|
||||
$asUser = $this->oMySql->selectRow(MySqlManager::USER_TABLE, array(MySqlManager::USER_TABLE=>$sLogin));
|
||||
if(!$asUser)
|
||||
{
|
||||
$this->addError('Utilisateur inconnu');
|
||||
}
|
||||
elseif($this->checkPassword($sPass, $asUser['pass']))
|
||||
{
|
||||
$this->setSession($asUser['id_'.MySqlManager::USER_TABLE], $sLogin);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->addError('mot de pass incorrect');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isLogguedIn()
|
||||
{
|
||||
$bLogguedIn = false;
|
||||
if(isset($_SESSION['id_user']) && isset($_SESSION['login']) && $_SESSION['id_user']!='' && $_SESSION['login']!='')
|
||||
{
|
||||
$bLogguedIn = $this->oMySql->selectValue(MySqlManager::USER_TABLE, 'COUNT(1)', array('id_'.MySqlManager::USER_TABLE=>$_SESSION['id_user'], MySqlManager::USER_TABLE=>$_SESSION['login']));
|
||||
}
|
||||
return $bLogguedIn;
|
||||
}
|
||||
|
||||
public function logMeOut()
|
||||
{
|
||||
$_SESSION = array();
|
||||
return session_destroy();
|
||||
}
|
||||
|
||||
public static function encryptPassword($sPass)
|
||||
{
|
||||
$sRandomText = 'F_RA-1H2dsdj)5fsd3sdPKUsdIN@(sZ.';
|
||||
for($iIndex=0; $iIndex < strlen($sPass); $iIndex++)
|
||||
{
|
||||
$sPass[$iIndex] = $sRandomText[$iIndex%strlen($sRandomText)] ^ $sPass[$iIndex];
|
||||
}
|
||||
return md5($sPass);
|
||||
}
|
||||
private function checkPassword($sClearPass, $sEncodedPass)
|
||||
{
|
||||
return $this->encryptPassword($sClearPass) == $sEncodedPass;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user