/*---------------------------------------------------
* Class : CPreference
* Date : 25-02-2003
* Purpose : Manage user preferences.
* Version : 1.0
* Copyright : Com'onSoft 2003
* Author : Jean PENICAUD
*---------------------------------------------------
*/
class CPreference
{
var $mPageSize = 5; // Page size
var $mStyle="3Dblue"; // Color style
var $mDelopt = 1; // Delete item option 1,2,3
var $mAligntab="center"; // Items alignment
var $mWantAdv=1; // Want to receive advertasing
var $mConfirmInsert=0; // Want to confirm insert
var $mNotify=1; // Notification
var $mNewsLetter=1; // Want to receive NewsLetter
var $mLang="french"; // language
var $mConfirmSound=""; // sound
var $mViewComment=1; // Want to view comment
var $mNotifyInsert=1; // Notification when insertion from others
var $mUserId=0; // user ID
var $mAutoInsert=0; // Automatic data insertion
var $mInDirectory=1; // Present in directory or not
var $mAnonymous=1; // If present in directory anonymous or not
// constructor
function CPreference($inUserId=0) {
$this->mUserId=$inUserId;
}
//------- end constructor : CPreference() ---------------------------------------------
// createPrefs
function createPrefs() {
$lRet=false;
if( $this->mUserId>0 ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lRet = $lDb->query("INSERT INTO adbm_preference (uid) VALUES( $this->mUserId) ");
}
return $lRet;
}
//------- end method : CPreference::createPrefs() --------------------------------------
// readPrefs
function readPrefs() {
$lRet=false;
if( $this->mUserId>0 ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryallRecords("SELECT * FROM adbm_preference WHERE uid=$this->mUserId");
if( $lDb->numRows()==1 ) {
$this->mPageSize=$lDatas[0]["pagesize"];
$this->mStyle=$lDatas[0]["guistyle"];
$this->mDelopt=$lDatas[0]["delopt"];
$this->mAligntab=$lDatas[0]["align"];
$this->mWantAdv=$lDatas[0]["adv"];
$this->mConfirmInsert=$lDatas[0]["confirminsert"];
$this->mNotify=$lDatas[0]["notify"];
$this->mNewsLetter=$lDatas[0]["newsletter"];
$this->mLang=$lDatas[0]["language"];
$this->mConfirmSound=addslashes($lDatas[0]["soundinsert"]);
$this->mViewComment=$lDatas[0]["viewcomment"];
$this->mAutoInsert=$lDatas[0]["autoinsert"];
$this->mNotifyInsert=$lDatas[0]["notifyinsert"];
$this->mInDirectory=$lDatas[0]["indirectory"];
$this->mAnonymous=$lDatas[0]["anonymous"];
$lRet=true;
}
}
return $lRet;
}
//------- end method : CPreference::readPrefs() --------------------------------------
// updatePrefs
function updatePrefs() {
$sQry="update adbm_preference set pagesize=$this->mPageSize, guistyle ='$this->mStyle', delopt=$this->mDelopt, ";
$sQry.="autoinsert=$this->mAutoInsert, notifyinsert=$this->mNotifyInsert, ";
$sQry.="indirectory=$this->mInDirectory, anonymous=$this->mAnonymous, ";
$sQry.="align='$this->mAligntab', adv=$this->mWantAdv, soundinsert='$this->mConfirmSound', confirminsert=$this->mConfirmInsert, ";
$sQry.="notify=$this->mNotify, newsletter=$this->mNewsLetter, viewcomment=$this->mViewComment, language ='$this->mLang' WHERE uid = $this->mUserId";
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query($sQry);
}
//------- end method : CPreference::updatePrefs() --------------------------------------
// putInSession
function putInSession() {
$sPagesize = $this->mPageSize;
$gStyle = $this->mStyle;
$sDelopt = $this->mDelopt;
$sAligntab= $this->mAligntab;
$sConfirmInsert = $this->mConfirmInsert;
$sLang = $this->mLang;
$sViewNotes = $this->mViewComment;
$_SESSION['sPagesize']=$sPagesize;
$_SESSION['sStyle']=$gStyle;
$_SESSION['sDelopt']=$sDelopt;
$_SESSION['sAligntab']=$sAligntab;
$_SESSION['sLang']=$sLang;
$_SESSION['sViewNotes']=$sViewNotes;
}
//------- end method : CPreference::putInSession() --------------------------------------
//--- Get/Set methods ------------------------
// setInDirectory
function setCookieLang($inLang) {
setcookie("lang",$inLang,mktime(0,0,0,12,31,date("Y")+30));
}
// setInDirectory
function setInDirectory($inDirectory) {
$this->mInDirectory=$inDirectory;
}
// getInDirectory
function getInDirectory() {
return $this->mInDirectory;
}
// setAnonymous
function setAnonymous($inAnonymous) {
$this->mAnonymous=$inAnonymous;
}
// getAnonymous
function getAnonymous() {
return $this->mAnonymous;
}
// setAutoInsert
function setAutoInsert($inAutoInsert) {
$this->mAutoInsert=$inAutoInsert;
}
// setViewComment
function setViewComment($inViewNotes) {
$this->mViewComment=$inViewNotes;
}
// setStyle
function setStyle($inStyle) {
$this->mStyle=$inStyle;
}
// getStyle
function getStyle() {
return $this->mStyle ;
}
// setPagesize
function setPagesize($inPagesize) {
$this->mPageSize=$inPagesize;
}
// setDelopt
function setDelopt($indelopt) {
$this->mDelopt=$indelopt;
}
// setAligntab
function setAligntab($inaligntab) {
$this->mAligntab=$inaligntab;
}
// setAdv
function setAdv($inWantAdv) {
$this->mWantAdv=$inWantAdv;
}
// setConfirmInsert
function setConfirmInsert($inConfirmInsert) {
$this->mConfirmInsert=$inConfirmInsert;
}
// setNotifyInsert
function setNotifyInsert($inNotifyInsert) {
$this->mNotifyInsert=$inNotifyInsert;
}
// setNotify
function setNotify($inNotify) {
$this->mNotify=$inNotify;
}
// setNewsLetter
function setNewsLetter($inNewsLetter) {
$this->mNewsLetter=$inNewsLetter;
}
// SetLang
function setLang($inlang) {
$this->mLang=$inlang;
}
// getLang
function getLang() {
return $this->mLang;
}
// setConfirmSound
function setConfirmSound($inConfirmSound) {
$this->mConfirmSound=$inConfirmSound;
}
// getAdv
function getAdv() {
return $this->mWantAdv;
}
// getAutoInsert
function getAutoInsert() {
return $this->mAutoInsert;
}
// getNewsLetter
function getNewsLetter() {
return $this->mNewsLetter;
}
// getNotify
function getNotify() {
return $this->mNotify;
}
// getConfirmSound
function getConfirmSound() {
return $this->mConfirmSound;
}
// getViewComment
function getViewComment() {
return $this->mViewComment;
}
// getConfirmInsert
function getConfirmInsert() {
return $this->mConfirmInsert;
}
// getNotifyInsert
function getNotifyInsert() {
return $this->mNotifyInsert;
}
}
//--------- End class : CPreference() ------------------------------------------------
?>
/*---------------------------------------------------
* Class : CUser
* Date : 23/07/2003
* Purpose : Manage user profile
* Version : 1.0
* Author : J. Pénicaud
* Copyright : Com'onSoft
* required include files/classes :
* /genericdb.php
* /settings.php
* /inc/mail.php
*---------------------------------------------------*/
class CUser
{
var $mUid = 0; // user id
var $mEmail= ""; // Email
var $mFname = ""; // First name
var $mLname= ""; // Last name
var $mSex= 'M'; // Sex
var $mCountry= ""; // Country
var $mAddress= ""; // Address
var $mCity= ""; // City
var $mZip= ""; // Zip code
var $mPhone ; // Phone number
var $mMobile; // Mobile phone
var $mFax; // Fax number
var $mPseudo =""; // Pseudo
var $mPasswd= ""; // Password
var $mCompany= ""; // Company
var $mDatecre= ""; // Account creation date
var $mDateclos= ""; // Date account closed
var $mLastvisit= ""; // Date last visit
var $mAccountstatus= 'A'; // Account status 'O'pen 'C'losed 'L'ocked 'D'eleted 'W'aiting cre'A'ted
var $mAccountype= 'F'; // Account type 'F'ree 'P'ro p'E'rsonnal
var $mAccountPeriod = 3 ; // Account period in months
var $mIdCompany = "NULL" ; // Id of company
var $mDialpasswd ; // Numeric password for phone access
var $mDateEnd; // Date when account ends
var $mAccountPayment ="NULL"; // Account payment type
var $mNewEmail ; // In case of email modification
var $mNewEmailCode; // Idem
var $mId_Oem = "NULL" ; // OEM Id
var $mVisits = 0 ; // Numbers of visits
var $mTbar = 0 ; // Installed toolbar
var $mLoad=false ; // Indicate if datas has been read from RDBMS
// constructor
function CUser($inUid=0, $inReadit=false) {
$this->mUid = $inUid;
if( $inReadit==true )
$this->read() ;
}
//------- end constructor : CUser() ---------------------------------
// lockAccount
function lockAccount( $inStatus='L') {
$this->setAccountStatus($inStatus);
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lQuery="UPDATE adbm_user SET accountstatus='$inStatus'";
if( $inStatus=='D' || $inStatus=='C' )
$lQuery.=", dateclos='".date("YmdHis")."'";
$lDb->query($lQuery." WHERE uid=".$this->mUid);
}
//------- end method : lockAccount() --------------------------------------
// updateVisit
function updateVisit() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query("UPDATE adbm_user SET lastvisit=NULL, visits=visits+1 WHERE uid=".$this->mUid);
}
//------- end method : updateVisit() --------------------------------------
// update toolbar counter
function updateTbar() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query("UPDATE adbm_user SET tbar=tbar+1 WHERE uid=".$this->mUid);
}
//------- end method : updateTbar() --------------------------------------
// removeAccount
// Remove all data concerning this account and change its status
function removeAccount() {
// Remove data and folders
$lDb = new MySql(cDB_DAT_HOST, cDB_DAT_DBNAME, cDB_DAT_USER, cDB_DAT_PSW);
$lDb->query('DELETE FROM adbm_userdata WHERE uid='.$this->mUid);
$lDb->query('DELETE FROM adbm_folders WHERE uid='.$this->mUid);
// remove prefs and delete account
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query('DELETE FROM adbm_preference WHERE uid='.$this->mUid);
$this->lockAccount( 'D');
}
//------- end method : removeAccount() --------------------------------------
// real delete account
// Remove all data concerning this account
function trueDeleteAccount() {
// Remove data and folders
$lDb = new MySql(cDB_DAT_HOST, cDB_DAT_DBNAME, cDB_DAT_USER, cDB_DAT_PSW);
$lDb->query('DELETE FROM adbm_userdata WHERE uid='.$this->mUid);
$lDb->query('DELETE FROM adbm_folders WHERE uid='.$this->mUid);
// remove prefs and account
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query('DELETE FROM adbm_preference WHERE uid='.$this->mUid);
$lDb->query('DELETE FROM adbm_user WHERE uid='.$this->mUid);
// remove CRM
$lDb = new MySql(cDB_CRM_HOST, cDB_CRM_DBNAME, cDB_CRM_USER, cDB_CRM_PSW);
$lDb->query('DELETE FROM crm WHERE uid='.$this->mUid);
}
//------- end method : trueDeleteAccount() --------------------------------------
/* encodeKey
generate a key : AAnAAA
encode64, crypt, CRC32, encode64 and urlencode
*/
function encodeKey() {
$lKey[0] = -1;
$lKey[1] = "";
if( $this->mUid > 0 ) {
mt_srand((float) microtime()*1000000);
$lKey[1]= chr(mt_rand( 58, 126)) ;
$lKey[1].= chr(mt_rand( 58, 126)) ;
$lKey[1].= $this->mUid ;
$lKey[1].= chr(mt_rand( 58, 126)) ;
$lKey[1].= chr(mt_rand( 58, 126)) ;
$lKey[1].= chr(mt_rand( 58, 126)) ;
$lKey[1]=base64_encode($lKey[1]) ;
$lSecretKey = md5("SyF@C1l");
$lVector = mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$lKey[1] = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $lSecretKey, $lKey[1], MCRYPT_MODE_ECB, $lVector);
$lKey[0] = crc32( $lKey[1]);
$lKey[1]=base64_encode($lKey[1]) ;
$lKey[1]=urlencode($lKey[1]) ;
}
return $lKey;
}
//------- end method : encodeKey() --------------------------------------
/* encodePwd
generate a crypted password encode64, crypt
*/
function encodePwd( $inPwd) {
if( $this->mUid > 0 ) {
$lCrypt=base64_encode( $inPwd) ;
$lSecretKey = md5("SyF@C1l");
$lVector = mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$lCrypt = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $lSecretKey, $lCrypt, MCRYPT_MODE_ECB, $lVector);
}
return $lCrypt;
}
//------- end method : encodePwd() --------------------------------------
// decodePwd : see encodePwd() method
function decodePwd( $inCryptedPwd) {
$lRet=-1;
if( strlen($inCryptedPwd) > 0 ) {
$lSecretKey = md5("SyF@C1l");
$lVector = mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$lKey = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $lSecretKey, $inCryptedPwd, MCRYPT_MODE_ECB, $lVector);
$lKey = base64_decode($lKey);
}
return $lKey;
}
//------- end method : decodePwd() --------------------------------------
// put user infos in session
function putInSession() {
if( $this->mLoad ) {
$_SESSION['sUserid']=$this->getUserId();
$_SESSION['sUsername']=$this->getFirstName()." ".$this->getLastName();
$_SESSION['sUseremail']=$this->getEmail();
$_SESSION['sTry']=0;
$_SESSION['sAccountType']=$this->getAccountType();
$_SESSION['sAccountStatus']=$this->getAccountStatus();
}
}
//------- end method : putInSession() --------------------------------------
// decodeKey : see encodeKey() method
function decodeKey( $inKey, $inCrc, $inWithCRC=true) {
$lRet=-1;
if( strlen($inKey) > 0 ) {
$lKey = urldecode($inKey);
$lKey = base64_decode($lKey);
$lcRc = crc32( $lKey);
if( $lcRc==$inCrc || $inWithCRC==false) {
$lSecretKey = md5("SyF@C1l");
$lVector = mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$lKey = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $lSecretKey, $lKey, MCRYPT_MODE_ECB, $lVector);
$lKey = base64_decode($lKey);
$lId = eregi_replace('[^0-9]',"",$lKey); // Get only numbers
$lId = trim($lId); // remove spaces
if( $lId > 0 ) $lRet= $lId;
}
}
return $lRet;
}
//------- end method : decodeKey() --------------------------------------
// User authentification with crypted userid and crypted crc key
// Purpose : decode key to get user id, read user and get account status
// Return : -1 in case of error
// userid if ok
function isValidUserId( $inKey, $inCrc) {
$lRet=-1;
if( strlen($inKey) && strlen($inCrc) ) {
$lUid = $this->decodeKey( $inKey, $inCrc);
if( $lUid > 0 ) {
$this->setUserId($lUid);
if( $this->Read() )
$lRet = ($this->getAccountStatus()!='O') ? -1 : $lUid ;
}
}
return $lRet;
}
//------- end method : isValidUserId() --------------------------------------
function getUserListBySubscriptionDate( &$outNbRec, $inCol='*', $inNbDays=7) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT $inCol FROM adbm_user WHERE (TO_DAYS(NOW())-TO_DAYS(datecre) <= $inNbDays) ORDER BY uid DESC");
if( $lDb->numRows()>0 ) $outNbRec=$lDb->numRows();
else $outNbRec=0;
return $lDatas ;
}
//------- end method : getUserListBySubscriptionDate() --------------------------------------
function getUserListTestimonial( $inLang, $inNbRow=3) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT title,comment FROM adbm_testimonial WHERE lang='$inLang' ORDER BY RAND() LIMIT 0,$inNbRow");
return $lDatas ;
}
//------- end method : getUserListTestimonial() --------------------------------------
function getUserListFromColumn( &$outNbRec, $inCol='*', $inOrder=false) {
$lOrder='';
if( $inOrder )
$lOrder = " ORDER BY ".$inOrder;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT $inCol FROM adbm_user $lOrder");
if( $lDb->numRows()>0 ) $outNbRec=$lDb->numRows();
else $outNbRec=0;
return $lDatas ;
}
//------- end method : getUserListFromColumn() --------------------------------------
function getUserListFromMail( &$outNbRec, $inCol='*', $inOrder=false, $inMail) {
$lOrder='';
if( $inOrder )
$lOrder = " ORDER BY ".$inOrder;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT $inCol FROM adbm_user WHERE email like '%$inMail%' $lOrder");
if( $lDb->numRows()>0 ) $outNbRec=$lDb->numRows();
else $outNbRec=0;
return $lDatas ;
}
//------- end method : getUserListFromMail() --------------------------------------
function getUserListWithPrefs( $inLang='french', $inOrder=false ) {
$lOrder='';
if( $inOrder )
$lOrder = " ORDER BY ".$inOrder;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT adbm_user.uid, email, fname, lname, sex, newsletter, notifyinsert FROM adbm_user , adbm_preference WHERE adbm_user.uid = adbm_preference.uid $lOrder AND adbm_preference.language='$inLang'");
return $lDatas ;
}
//------- end method : getUserListWithPrefs() --------------------------------------
function getPublicUserListCount( $inSearch='', $inSearchIn=1) {
$lRet=0;
if( $inSearch ) {
if( $inSearchIn==1 ) $lSearch=" AND adbm_user.pseudo like '%$inSearch%' ";
else $lSearch=" AND adbm_user.lname like '%$inSearch%' AND adbm_preference.anonymous=0 ";
}
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT count(*) as NbUsr FROM adbm_user INNER JOIN adbm_preference ON adbm_user.uid = adbm_preference.uid WHERE adbm_preference.indirectory=1 $lSearch");
if( $lDb->numRows()==1 ) $lRet=$lDatas[0]["NbUsr"];
return $lRet;
}
//------- end method : getPublicUserListCount() --------------------------------------
function getPublicUserList( $inPage, $inPagesize, $inOrder, $inSearch='', $inSearchIn=1) {
$lRet=0;
switch( $inOrder) {
case 2: $lOrder='lname, fname, zip'; break;
case 3: $lOrder='fname, lname, zip'; break;
case 4: $lOrder='zip, lname, fname'; break;
case 5: $lOrder='sex, fname, lname, zip'; break;
case 6: $lOrder='country, lname, fname, zip'; break;
default: $lOrder='pseudo, zip';
}
if( $inSearch ) {
if( $inSearchIn==1 ) $lSearch=" AND adbm_user.pseudo like '%$inSearch%' ";
else $lSearch=" AND adbm_user.lname like '%$inSearch%' AND adbm_preference.anonymous=0 ";
}
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT adbm_user.uid, pseudo, fname, lname, zip, sex, country, adbm_preference.indirectory, adbm_preference.anonymous FROM adbm_user INNER JOIN adbm_preference ON adbm_user.uid = adbm_preference.uid WHERE adbm_preference.indirectory=1 $lSearch ORDER BY $lOrder LIMIT $inPage,$inPagesize;");
return ( $lDb->numRows()>=1 ) ? $lDatas : $lRet;
}
//------- end method : getPublicUserList() --------------------------------------
function readColumnValue( $inColName) {
$lRet = -1;
if( $inColName!="" && $this->mUid>0 ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT $inColName FROM adbm_user WHERE uid=".$this->mUid);
if( $lDb->numRows()==1 ) $lRet = $lDatas[0][$inColName];
}
return $lRet;
}
//------- end method : readColumnValue() --------------------------------
// Read data
function read() {
$lRet = false;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords('SELECT * FROM adbm_user WHERE uid='.$this->mUid );
if( $lDb->numRows()==1 ) {
$this->mUid = $lDatas[0]["uid"];
$this->mFname = $lDatas[0]["fname"];
$this->mLname = $lDatas[0]["lname"];
$this->mEmail = $lDatas[0]["email"];
$this->mPasswd = $lDatas[0]["passwd"];
$this->mSex = $lDatas[0]["sex"];
$this->mCountry = $lDatas[0]["country"];
$this->mZip = $lDatas[0]["zip"];
$this->mCity = $lDatas[0]["city"];
$this->mAddress = $lDatas[0]["address"];
$this->mCompany = $lDatas[0]["company"];
$this->mPhone = $lDatas[0]["phone"];
$this->mMobile = $lDatas[0]["mobile"];
$this->mFax = $lDatas[0]["fax"];
$this->mDatecre = $lDatas[0]["datecre"];
$this->mDateclos = $lDatas[0]["dateclos"];
$this->mLastvisit = $lDatas[0]["lastvisit"];
$this->mAccountstatus = $lDatas[0]["accountstatus"];
$this->mAccountype = $lDatas[0]["accountype"];
$this->mAccountPeriod = $lDatas[0]["accountperiod"];
$this->mIdCompany = ($lDatas[0]["id_company"]) ? $lDatas[0]["id_company"] :"NULL" ;
$this->mPseudo = $lDatas[0]["pseudo"];
$this->mDialpasswd = $lDatas[0]["dialpasswd"];
$this->mDateEnd = $lDatas[0]["dateend"];
$this->mAccountPayment = $lDatas[0]["accountpayment"];
$this->mNewEmail = $lDatas[0]["newemail"] ;
$this->mNewEmailCode = $lDatas[0]["newemailcode"] ;
$this->mId_Oem = $lDatas[0]["id_oem"] ;
$this->mVisits = $lDatas[0]["visits"] ;
$this->mTbar = $lDatas[0]["tbar"] ;
$this->mLoad=true;
$lRet=true ;
}
return $lRet;
}
//------- end method : read() ----------------------------------------
// Create New user
function create() {
$this->generatePasswords();
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lRet=$lDb->query("INSERT adbm_user SET email='".addslashes($this->mEmail)."', fname='".addslashes($this->mFname)."', lname='".addslashes($this->mLname)."', sex='".$this->mSex."',
country='".$this->mCountry."', city='".addslashes($this->mCity)."', zip='".addslashes($this->mZip)."', accountstatus='".$this->mAccountstatus."',
address='".addslashes($this->mAddress)."', passwd='".addslashes($this->mPasswd)."', dialpasswd='".addslashes($this->mDialpasswd)."', datecre='".date("YmdHis")."',
pseudo='".addslashes($this->mPseudo)."', accountype='".$this->mAccountype."', accountperiod=".$this->mAccountPeriod.", accountpayment=".$this->mAccountPayment.",
phone='".eregi_replace('[^0-9]',"",$this->mPhone)."', mobile='".eregi_replace('[^0-9]',"",$this->mMobile)."', fax='".eregi_replace('[^0-9]',"",$this->mFax)."', company='".addslashes($this->mCompany)."'");
$this->mUid = $lDb->getInsertedId();
return $this->mUid;
}
//------- end method : create() --------------------------------------
// Update
// return true if OK false in case of error
function update() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
if( $this->mAccountype=='F' ) { // Free version only unique email
$lDatas = $lDb->queryAllRecords("SELECT email,uid FROM adbm_user WHERE email='".$this->mEmail."'");
if( $lDb->numRows()==1 && $lDatas[0]['uid']!=$this->mUid) return false;
}
// Verify now if user enter a new email
$lDatas = $lDb->queryAllRecords("SELECT email FROM adbm_user WHERE uid=".$this->mUid);
if( $lDb->numRows()==1 ) {
if( strcasecmp($lDatas[0]['email'],$this->mEmail)!=0 ) {
$this->updateNewMail( $lDatas[0]['email'],$this->mEmail, $lDb) ;
$this->mEmail=$lDatas[0]['email']; // Update with original email
}
}
return $lDb->query("UPDATE adbm_user SET email='".addslashes($this->mEmail)."', fname='".addslashes($this->mFname)."',
lname='".addslashes($this->mLname)."', sex='".$this->mSex."', country='".$this->mCountry."',
address='".addslashes($this->mAddress)."', city='".addslashes($this->mCity)."', zip='".addslashes($this->mZip)."',
phone='".eregi_replace('[^0-9]',"",$this->mPhone)."', mobile='".eregi_replace('[^0-9]',"",$this->mMobile)."', fax='".eregi_replace('[^0-9]',"",$this->mFax)."',
company='".addslashes($this->mCompany)."', id_company=".$this->mIdCompany.",
accountype='".$this->mAccountype."',
pseudo='".addslashes($this->mPseudo)."' WHERE uid=".$this->mUid);
}
//------- end method : update() --------------------------------------
function getDateEndAccount() {
$lDate = "";
if( $this->mAccountype!='F' && $this->mDateEnd!="" ) {
$lDate=date("Ymd", mktime (0,0,0,substr($this->mDateEnd, 4, 2),substr($this->mDateEnd, 6, 2),substr($this->mDateEnd, 0, 4)));
}
return $lDate;
}
//------- end method : getDateEndAccount() --------------------------------
function setDateEndAccount( $inDate, $inWrite) {
if( $inDate!="" ) {
$this->mDateEnd=$inDate ;
if( $inWrite ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query("UPDATE adbm_user SET dateend='".$this->mDateEnd."' WHERE uid=".$this->mUid);
}
}
}
//------- end method : setDateEndAccount() --------------------------------
function isAccountExpired() {
$lRet=false;
if( $this->mAccountype!='F' && $this->mDateEnd!="" )
$lRet=(mktime(0,0,0,date("m"),date("d"),date("Y")) <= mktime (0,0,0,substr($this->mDateEnd, 4, 2),substr($this->mDateEnd, 6, 2),substr($this->mDateEnd, 0, 4)) ) ? false : true ;
return $lRet;
}
//------- end method : isAccountExpired() ---------------------------------
function updateNewMail( $inEmail,$inNewEmail, $inDbcon) {
// generate random code
mt_srand((float) microtime()*1000000);
$lKeyCode= chr(mt_rand( 47, 91)) ;
$lKeyCode.= chr(mt_rand( 97, 126)) ;
$lKeyCode.= chr(mt_rand( 47, 91)) ;
$lKeyCode.= chr(mt_rand( 47, 91)) ;
$lKeyCode.= chr(mt_rand( 47, 91)) ;
$lKeyCode.= chr(mt_rand( 97, 126)) ;
$inDbcon->query("UPDATE adbm_user SET newemail='".$inNewEmail."', newemailcode ='".$lKeyCode."' WHERE uid=".$this->mUid);
$this->sendMailToChange( $inEmail,$inNewEmail, $lKeyCode) ;
}
//------- end method : updateNewMail() --------------------------------------
function sendMailToChange( $inEmail,$inNewEmail, $lKeyCode) {
$lFilename = "lang/mailchangedemail_".$_SESSION['sLang'].".txt";
$lFile = fopen($lFilename, "r");
$lContent = fread($lFile, filesize ($lFilename));
fclose($lFile);
$toChange = "#CODE#";
$by = $lKeyCode;
$lContent=str_replace($toChange,$by, $lContent) ;
return SendMail(cEMAILSENDER, $inNewEmail, cMSG_CHANGEDMAILTOSUBJECT, $lContent, cNormalPriority, cTextFormat);
}
//------- end method : sendMailToChange() --------------------------------------
function sendMailSubscription( $inLang='french') {
$lFilename = "lang/mailsubscription_".$inLang.".txt";
$lFile = fopen($lFilename, "r");
$lContent = fread($lFile, filesize ($lFilename));
fclose($lFile);
$toChange[0] = "#NAME#";
$toChange[1] = "#PSWD#";
$toChange[2] = "#ABO#";
$toChange[3] = "#DPSW#";
$by[0] = $this->mFname." ".$this->mLname;
$by[1] = $this->mPasswd;
$by[2] = $this->mUid;
$by[3] = $this->mDialpasswd;
$lContent=str_replace($toChange,$by, $lContent) ;
return SendMail(cEMAILSENDER, $this->mEmail, cMSG_MAILPASSWDSUBJECT, $lContent, cNormalPriority, cTextFormat);
}
//------- end method : sendMailSubscription() ----------------------------------
function isEmailExist( $inEmail=NULL, $inAccountType=NULL) {
$lRet=false;
if( $inEmail==NULL ) {
$inEmail=$this->mEmail;
$inAccountType=$this->mAccountype;
}
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT uid FROM adbm_user WHERE email='".$inEmail."' AND accountype='".$inAccountType."' AND accountstatus<>'D'");
if( $lDb->numRows()>=1 ) $lRet=true;
return $lRet;
}
//------- end method : isEmailExist() -----------------------------------------
function validateNewMail( $inKeyCode) {
$lRet=false;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
if( strlen($inKeyCode)==6 && strcmp( $inKeyCode, $this->mNewEmailCode)==0 )
$lRet = $lDb->query("UPDATE adbm_user SET email='".$this->mNewEmail."', newemailcode=NULL, newemail=NULL WHERE uid=".$this->mUid);
else // do not validate new email
$lDb->query("UPDATE adbm_user SET newemailcode=NULL, newemail=NULL WHERE uid=".$this->mUid);
return $lRet;
}
//------- end method : validateNewMail() --------------------------------------
// changePassword
// return true if OK false in case of error
function changePassword() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
return $lDb->query("UPDATE adbm_user SET passwd='".$this->mPasswd."' WHERE uid=".$this->mUid);
}
//------- end method : changePassword() --------------------------------------
// changeDialPassword
// return true if OK false in case of error
function changeDialPassword() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
return $lDb->query("UPDATE adbm_user SET dialpasswd='".$this->mDialpasswd."' WHERE uid=".$this->mUid);
}
//------- end method : changeDialPassword() --------------------------------------
// User authentification
// return values : 1 = OK
// -1 invalid user
// -2 invalid password
// -3 account locked
// -4 account closed
// -5 account deleted
// -6 account wainting for payment
// -7 account just created need payment
function login( $inLogon, $inPassword) {
$lRet = 1 ;
if( cLDAPSERVER != "" ) { // Use LDAP authetification
}
else {
if( $this->mLoad==false ) {
if( is_numeric($inLogon)==true ) {
$this->setUserId($inLogon);
if( $this->read()==false )
return -1;
}
else return -1;
}
if( $this->getPassword()!=$inPassword )
return -2;
}
// Verify account
switch( $this->getAccountStatus() ) {
case 'L': $lRet=-3; break;
case 'C': $lRet=-4; break;
case 'D': $lRet=-5; break;
case 'W': $lRet=-6; break;
case 'A': $lRet=-7; break;
}
return $lRet ;
}
//------- end method : login() --------------------------------------
function getAccountMaxSize() {
$lNbRecTab = array ( "F" => cMAXSIZE_FRE_VERSION , "S" => cMAXSIZE_STD_VERSION, "P" => cMAXSIZE_PRE_VERSION, "O" => cMAXSIZE_PRO_VERSION );
return $lNbRecTab[$this->getAccountType()];
}
//------- end method : getAccountMaxSize() --------------------------------------
function isMailboxFull() {
$lNbRecTab = array ( "F" => cMAXSIZE_FRE_VERSION , "S" => cMAXSIZE_STD_VERSION, "P" => cMAXSIZE_PRE_VERSION, "O" => cMAXSIZE_PRO_VERSION );
$lSize = $this->getAccountSize() ;
$lNbMax=$lNbRecTab[$this->getAccountType()];
return ($lSize>=$lNbMax) ? 1 : 0 ;
}
//------- end method : isMailboxFull() --------------------------------------
/*
* Method: generatePasswords()
* generate temporary passwords for user account
* web and dial passwords
*/
function generatePasswords() {
$lKeyCode = $lDialCode= "";
// generate random code for web access, 8 chars
//mt_srand((float) microtime()*1000000);
for($i=0; $i<8; $i++) $lKeyCode.= chr(mt_rand( 40, 91)) ;
// generate random code for dial access, 4 numeric
for($i=0; $i<4; $i++) $lDialCode.= chr(mt_rand( 48, 57)) ;
$this->mDialpasswd = $lDialCode;
$this->mPasswd = $lKeyCode;
}
//------- end method : generatePasswords() ----------------------------------
function setUserId( $inUid) {
$this->mUid = $inUid;
}
function getUserId() {
return $this->mUid ;
}
function getPseudo() {
return $this->mPseudo;
}
function setPseudo( $inStr) {
$this->mPseudo = $inStr ;
}
function getFirstName() {
return $this->mFname ;
}
function setFirstName( $inStr) {
$this->mFname = $inStr ;
}
function getLastName() {
return $this->mLname ;
}
function setLastName( $inStr) {
$this->mLname = $inStr;
}
function getEmail() {
return $this->mEmail ;
}
function setEmail( $inEmail) {
$this->mEmail = $inEmail;
}
function getPassword() {
return $this->mPasswd ;
}
function setPassword( $inStr) {
$this->mPasswd = $inStr ;
}
function getSex() {
return $this->mSex ;
}
function setSex( $inStr) {
$this->mSex = $inStr;
}
function getCountryCode() {
return $this->mCountry ;
}
function setCountryCode( $inStr) {
$this->mCountry = $inStr ;
}
function getZipCode() {
return $this->mZip ;
}
function setZipCode( $inStr) {
$this->mZip = $inStr;
}
function getCity() {
return $this->mCity ;
}
function setCity( $inStr) {
$this->mCity = $inStr;
}
function getVisits() {
return $this->mVisits ;
}
function setVisits( $inValue) {
$this->mVisits = $inValue;
}
function getTbar() {
return $this->mTbar;
}
function setTbar( $inValue) {
$this->mTbar = $inValue;
}
function getAddress() {
return $this->mAddress ;
}
function setAddress( $inStr) {
$this->mAddress = $inStr;
}
function getCompany() {
return $this->mCompany ;
}
function setCompany($inStr) {
$this->mCompany = $inStr ;
}
function getDateCre() {
return $this->mDatecre ;
}
function getDateClos() {
return $this->mDateclos ;
}
function getLastVisit() {
return $this->mLastvisit ;
}
function getAccountStatus() {
return $this->mAccountstatus ;
}
function setAccountStatus( $inStatus) {
$this->mAccountstatus = $inStatus ;
}
function getAccountType() {
return $this->mAccountype ;
}
function setAccountType($inStr) {
$this->mAccountype = $inStr;
}
function getCompanyId() {
return $this->mIdCompany ;
}
function setCompanyId( $inId) {
$this->mIdCompany = $inId ;
}
function getPhone() {
return $this->mPhone ;
}
function setPhone($inStr) {
$this->mPhone = $inStr;
}
function getIdOem() {
return $this->mId_Oem;
}
function getMobile() {
return $this->mMobile ;
}
function setMobile($inStr) {
$this->mMobile = $inStr;
}
function getFax() {
return $this->mFax ;
}
function setFax($inStr) {
$this->mFax = $inStr;
}
function getDialPassword() {
return $this->mDialpasswd;
}
function setDialPassword( $inDialPassword) {
$this->mDialpasswd = $inDialPassword ;
}
function setAccountPeriod( $inPeriod) {
$this->mAccountPeriod = $inPeriod ;
}
function getAccountPeriod() {
return $this->mAccountPeriod ;
}
function setAccountPayment( $inPayment, $inWrite=false) {
$this->mAccountPayment = $inPayment ;
if( $inWrite ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query("UPDATE adbm_user SET dateend='".$this->mDateEnd."' WHERE uid=".$this->mUid);
}
}
function getAccountPayment() {
return $this->mAccountPayment ;
}
function isValidAccount() {
return ($this->mAccountstatus=='O') ;
}
function getNewEmail() {
return $this->mNewEmail;
}
function getNewEmailCode() {
return $this->mNewEmailCode;
}
function isLoaded() {
return $this->mLoad ;
}
function getNbRecords() {
$lDb = new MySql(cDB_DAT_HOST, cDB_DAT_DBNAME, cDB_DAT_USER, cDB_DAT_PSW);
$lDatas = $lDb->queryAllRecords('SELECT count(*) as Nbelt FROM adbm_userdata WHERE uid='.$this->mUid);
return $lDatas[0]["Nbelt"] ;
}
// calculate database size for this user and then add sum of files size
function getAccountSize() {
$lSize=0;
$lDb = new MySql();
$lDatas = $lDb->queryAllRecords('SELECT * FROM adbm_userdata LIMIT 0,1');
$lSql="SELECT SUM(0";
foreach($lDatas[0] as $key => $val){
if( !is_numeric($key)) $lSql.= "+OCTET_LENGTH('$key')";
}
$lSql.= ") AS usize FROM adbm_userdata WHERE uid=".$this->mUid;
$lDatas = $lDb->queryAllRecords($lSql);
$lSize=$lDatas[0]['usize'];
$lDatas = $lDb->queryAllRecords("SELECT SUM(file_size) AS fsize FROM adbm_userdata WHERE (data_type<>'I' OR data_type<>'K') AND uid=".$this->mUid);
$lSize+=$lDatas[0]['fsize'];
return $lSize;
}
function getCountryName() {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords("SELECT name FROM adbm_country WHERE id_country='".$this->mCountry."'");
return $lDatas[0]['name'];
}
}
?>
/*---------------------------------------------------
* Class : CInvoice
* Date : 07/11/2003
* Purpose : Manage customer invoice
* Version : 1.0
* Author : J. Pénicaud
* Copyright : Com'onSoft
* required include files/classes :
* /genericdb.php
* /settings.php
* /inc/mail.php
*---------------------------------------------------*/
class CInvoice
{
var $mUid = 0; // user id
var $mDateCmd; // Date invoice
var $mHT; // HT value
var $mTVA; // TVA Value
var $mTTC; // TTC
var $mTaxPercent; // Percent tax value ex: 19.60
var $mCmdLib; // Cmd label
var $mDatePayment ="NULL"; // Date when invoice payed
var $mTypePayment ='B'; // Invoice payment type
var $mQty; // Qty line
var $mPrice; // Price unit
var $mReadDatas; // Records read
var $mCount=0; // Number of records
var $mCurrent=0; // Record pointer
var $mId=0; // Record Id
var $mPay_card_type="NULL"; // Card type CB, VISA...
var $mPay_certificate="NULL"; // Bank transaction certificate
var $mPay_authorisation_id="NULL"; // Authorisatin number
// constructor
function CInvoice($inUid=0, $inReadit=false) {
$this->mUid = $inUid;
if( $inReadit==true )
$this->read() ;
}
//------- end constructor : CInvoice() ---------------------------------
// Read list
function readAll() {
$lRet = false;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$this->mReadDatas = $lDb->queryAllRecords('SELECT * FROM adbm_invoice WHERE uid='.$this->mUid.' ORDER BY datecmd DESC' );
if( $lDb->numRows()>=1 ) {
$this->mCount=$lDb->numRows();
$lRet=true ;
}
return $lRet;
}
//------- end method : readAll() ----------------------------------------
// Read one record
function read($inId=0) {
$lRet = false;
if( $inId>0 ) $this->mId=$inId;
if( $this->mId=$inId ) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$this->mReadDatas = $lDb->queryAllRecords('SELECT * FROM adbm_invoice WHERE uid='.$this->mUid.' AND id='.$this->mId );
if( $lDb->numRows()==1 ) {
$this->mCount=$lDb->numRows();
$this->mDateCmd= $this->mReadDatas[0]["datecmd"];
$this->mDatePayment= $this->mReadDatas[0]["datepayment"];
$this->mTypePayment= $this->mReadDatas[0]["typepayment"];
$this->mCmdLib= $this->mReadDatas[0]["lib"];
$this->mTaxPercent= $this->mReadDatas[0]["taxpercent"];
$this->mHT= $this->mReadDatas[0]["ht"];
$this->mTVA= $this->mReadDatas[0]["tva"];
$this->mTTC= $this->mReadDatas[0]["ttc"];
$this->mPrice= $this->mReadDatas[0]["price"];
$this->mQty= $this->mReadDatas[0]["qty"];
$this->mPay_card_type= $this->mReadDatas[0]["pay_card_type"];
$this->mPay_authorisation_id= $this->mReadDatas[0]["pay_authorisation_id"];
$lRet=true ;
}
}
return $lRet;
}
//------- end method : read() ----------------------------------------
// Read last record
function readLastInvoice() {
$lRet = false;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$this->mReadDatas = $lDb->queryAllRecords('SELECT * FROM adbm_invoice WHERE uid='.$this->mUid.' ORDER BY datepayment DESC LIMIT 0,1');
if( $lDb->numRows()==1 ) {
$this->mCount=$lDb->numRows();
$this->mId=$this->mReadDatas[0]["id"];
$this->mDateCmd= $this->mReadDatas[0]["datecmd"];
$this->mDatePayment= $this->mReadDatas[0]["datepayment"];
$this->mTypePayment= $this->mReadDatas[0]["typepayment"];
$this->mCmdLib= $this->mReadDatas[0]["lib"];
$this->mTaxPercent= $this->mReadDatas[0]["taxpercent"];
$this->mHT= $this->mReadDatas[0]["ht"];
$this->mTVA= $this->mReadDatas[0]["tva"];
$this->mTTC= $this->mReadDatas[0]["ttc"];
$this->mPrice= $this->mReadDatas[0]["price"];
$this->mQty= $this->mReadDatas[0]["qty"];
$this->mPay_card_type= $this->mReadDatas[0]["pay_card_type"];
$this->mPay_authorisation_id= $this->mReadDatas[0]["pay_authorisation_id"];
$lRet=true ;
}
return $lRet;
}
//------- end method : readLastInvoice() ----------------------------------------
// Check if invoice pending
function isPending(&$outDateCmd, &$outTypePayment) {
$lRet = false;
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDatas = $lDb->queryAllRecords('SELECT datecmd,typepayment FROM adbm_invoice WHERE datepayment IS NULL AND uid='.$this->mUid );
if( $lDb->numRows()>=1 ) {
$outDateCmd=$lDatas[0]['datecmd'];
$outTypePayment=$lDatas[0]['typepayment'];
$lRet=true ;
}
return $lRet;
}
//------- end method : isPending() -----------------------------------
// Create New invoice
function create($inLockAccount=0) {
$lDb = new MySql(cDB_USR_HOST, cDB_USR_DBNAME, cDB_USR_USER, cDB_USR_PSW);
$lDb->query("INSERT adbm_invoice SET uid=".$this->mUid.", datepayment=".$this->mDatePayment.",
typepayment='".$this->mTypePayment."', lib='".$this->mCmdLib."', taxpercent=".$this->mTaxPercent.",
ht=".$this->mHT.", tva=".$this->mTVA.", ttc=".$this->mTTC.", price=".$this->mPrice.",
qty=".$this->mQty.", pay_authorisation_id=".$this->mPay_authorisation_id.",
pay_card_type=".$this->mPay_card_type.", pay_certificate=".$this->mPay_certificate);
$this->mId = $lDb->getInsertedId();
// In payment other than online change and flag to lock account status
if( $this->mTypePayment!='B' ) {
if( $inLockAccount==1 )
$lDb->query("UPDATE adbm_user SET accountstatus='W' WHERE uid=".$this->mUid);
}
else { // Credit card payment update user fields
$lDb->query("UPDATE adbm_user SET accountstatus='O', accountpayment='B',
accountperiod=".$this->mQty.", dateend='".date("YmdHis", mktime (0,0,0,date("m")+$this->mQty,date("d"),date("Y")))."'
WHERE uid=".$this->mUid);
}
return $this->mId;
}
//------- end method : create() --------------------------------------
// calulate row
function calculate() {
$this->mHT=$this->mQty*$this->mPrice;
$this->mTVA=round($this->mHT*$this->mTaxPercent/100,2);
$this->mTTC=$this->mHT+$this->mTVA;
}
//------- end method : calculate() --------------------------------------
function getCount() {
return $this->mCount;
}
function setUserId( $inUid) {
$this->mUid = $inUid;
}
function getUserId() {
return $this->mUid ;
}
function setAuthorisationId( $inId) {
$this->mPay_authorisation_id = $inId;
}
function setCertificate( $inCertificate) {
$this->mPay_certificate = $inCertificate;
}
function setCardType( $inCard) {
$this->mPay_card_type = $inCard;
}
function setLib( $inStr) {
$this->mCmdLib = $inStr ;
}
function getLib($inDice=-1) {
return ( $inDice!=-1 ) ? $this->mReadDatas[$inDice]['lib'] : $this->mCmdLib ;
}
function getId($inDice=-1) {
return ( $inDice!=-1 ) ? $this->mReadDatas[$inDice]['id'] : $this->mId ;
}
function getHT($inDice=-1) {
return ( $inDice!=-1 ) ? $this->mReadDatas[$inDice]['ht'] : $this->mHT ;
}
function getDateCmd($inDice=-1) {
return ( $inDice!=-1 ) ? $this->mReadDatas[$inDice]['datecmd'] : $this->mDateCmd ;
}
function setTaxPercent( $inVal) {
$this->mTaxPercent = $inVal ;
}
function getTaxPercent() {
return $this->mTaxPercent;
}
function setPriceUnit( $inVal) {
$this->mPrice = $inVal ;
}
function getPriceUnit() {
return $this->mPrice ;
}
function setTypePayment( $inVal) {
$this->mTypePayment = $inVal ;
}
function getTypePayment() {
return $this->mTypePayment;
}
function setQty( $inVal) {
$this->mQty = $inVal ;
}
function getQty() {
return $this->mQty;
}
function getTVA() {
return $this->mTVA;
}
function getTTC() {
return $this->mTTC;
}
function setDatePayment( $inDate="") {
if( strlen($inDate)!=14 )
$this->mDatePayment = "'".date("YmdHis")."'" ;
else
$this->mDatePayment = "'".$inDate."'" ;
}
function getDatePayment() {
return $this->mDatePayment ;
}
}
?>
if(session_id()=='') session_start();
require_once('settings.php');
//------------ Functions -----------------------------------------------------
function isPro() {
return ($_SESSION['sAccountType']=='O') ? true : false ;
}
function isPremium() {
return ($_SESSION['sAccountType']=='P') ? true : false ;
}
function isStandard() {
return ($_SESSION['sAccountType']=='S') ? true : false ;
}
function isFree() {
return ($_SESSION['sAccountType']=='F') ? true : false ;
}
//---------------------------------------------------
function getLanguageByHost() {
$lRet="english";
$lHostName=gethostbyaddr($_SERVER['REMOTE_ADDR']);
switch( substr($lHostName,-3, strlen($lHostName)-1) ) {
case ".fr": case ".ch": case ".be": case ".ca":
$lRet="french";
}
return $lRet;
}
//---------------------------------------------------
function getBrowserLanguage() {
$lang=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) ;
switch( $lang ) {
case 'fr':
$lRet="french";
break;
default: // If none found try to determine by gateway
if( strlen($lang)<=0 ) $lRet="french";
else $lRet=getLanguageByHost() ;
}
return $lRet;
}
//---------------------------------------------------
/*
Define GUI language
Take session if present
Else cookie if present
Else default browser language
*/
function setLanguage() {
$lang="french";
if( isset($_SESSION['sLang']) ) $lang=$_SESSION['sLang'];
elseif( isset($_COOKIE["lang"]) ) $lang=$_COOKIE["lang"];
else $lang=getBrowserLanguage();
return $lang;
}
//----------------------------------------------------------------------------
// Function : HiliteText()
// Purpose : Hilite matching text
//
//----------------------------------------------------------------------------
function HiliteText( $inString, $inPattern) {
$inPattern = trim($inPattern);
if ( $inPattern!="" ) {
$toChange[0] = htmlentities($inPattern);
$toChange[1] = htmlentities(ucfirst($inPattern));
$toChange[2] = ucfirst($inPattern);
$toChange[3] = strtoupper($inPattern);
$toChange[4] = $inPattern;
/*
if( $toChange[0] == $toChange[1] ) {
$toChange[1]=$toChange[2];
$toChange[2]=$toChange[3];
$toChange[3]="";
if( $toChange[0] == $toChange[1] ) {
$toChange[1] = $toChange[2] = "";
}
}
*/
$by[0] = "".htmlentities($inPattern)."";
$by[1] = "".ucfirst($inPattern)."";
$by[2] = "".ucfirst($inPattern)."";
$by[3] = "".strtoupper($inPattern)."" ;
$by[4] = "".$inPattern."" ;
$inString=str_replace($toChange,$by, $inString) ;
} // endif
return $inString;
}
//----------------------------------------------------------------------------
//--- Check session ---------------------------------
if( !isset($home) ) {
if( !isset($_SESSION['sUserid']) || $_SESSION['sUserid']<=0 || $_SESSION['sUserid']=="" ) {
header("Location: /index.php");
exit();
}
else {
switch( $_SESSION['sAccountStatus'] ) {
case 'O':
if( $_SESSION['sExp']==1 ) {
header("Location: /payment.php");
exit();
}
break;
case 'A': case 'W':
header("Location: /payment.php");
exit();
break;
default:
header("Location: /closed.php?k=".$_SESSION['sAccountStatus'] );
exit();
}
}
$uid=$_SESSION['sUserid'];
}
// Check browser, to set specific values for HTML classes
if( ((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || (ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT"))) ) && (!ereg("MSIE", getenv("HTTP_USER_AGENT"))) && ereg("illa/4.", getenv("HTTP_USER_AGENT")))
$gCl = "l"; // Netscape browser
else $gCl = "bo";
$sLang=setLanguage() ; // Set default value language if no user preferences
switch( $sLang ) {
case "french": $lg='fr'; break ;
default: $lg='en';
}
if( isset($_SESSION['sOEM']) ) $lOEM=$_SESSION['sOEM'];
else $lOEM="";
// Set default GUI color if no user preferences
if( !isset($_SESSION['sStyle']) ) $gStyle="yellow" ;
else $gStyle=$lOEM.$_SESSION['sStyle'];
if( !isset($_GET['s']) ) $s="" ;
if( !isset($_GET['see']) ) $see=0 ;
else $see=$_GET['see'];
if (!isset($_GET['page']) || $_GET['page']<=0) $page = 1;
else $page=$_GET['page'];
if( strstr($gStyle,"3D")==false ) $gLogo=$lOEM."logo.gif";
else $gLogo=$gStyle."_logo.jpg";
define("cCOPYRIGHT","© ".date("Y")." Com'onSoft");
define("cDOMAIN","syfacil");
define("cDELCONFIRM",1);
define("cDELNEVER",2);
define("cDELNOTVISITED",3);
/*
if( $_SERVER['HTTP_REFERER'] && substr($_SERVER['HTTP_REFERER'], 0, 19)!="http://www.syfacil.") {
$fp=fopen( "/data/syfacil/logs/".date("Ymd")."_ref.txt", "a");
fwrite($fp, date("YmdHis").";".$_SERVER['REMOTE_ADDR'].";".gethostbyaddr($_SERVER['REMOTE_ADDR']).";".$_SERVER['HTTP_REFERER']."\r\n");
fclose($fp);
}
*/
?>