Пример #1
0
 public function initFor(WOOOF $wo)
 {
     $wooofUserId = $wo->userData['id'];
     if (!$wo->hasContent($wooofUserId)) {
         $wo->logError(self::_ECP . "0010 No value found for 'wooofUserId'");
         return false;
     }
     if ($wooofUserId === '0123456789') {
         return true;
     }
     $movieRamaPersonRow = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_userId', $wooofUserId);
     if ($movieRamaPersonRow === FALSE) {
         return FALSE;
     }
     if ($movieRamaPersonRow === NULL) {
         $wo->logError(self::_ECP . "0020 User [{$wooofUserId}] should not be logged-in");
         return false;
     }
     $this->userId = $movieRamaPersonRow['VUS_id'];
     $this->personProfileId = $movieRamaPersonRow['VUS_personProfileId'];
     $this->userSlug = $movieRamaPersonRow['PROF_firstName'] . ' ' . $movieRamaPersonRow['PROF_lastName'];
     $this->movieRamaPersonRow = $movieRamaPersonRow;
     $this->isUserRegistered = $movieRamaPersonRow['VUS_isVerified'] == '1';
     return $this->userId;
 }
Пример #2
0
function showStopperErrorRoutineDev(WOOOF $wo, $errorInput, $uri = NULL)
{
    var_dump($errorInput, $_SERVER['REQUEST_URI']);
    // die();
    if (!$wo->hasContent($uri)) {
        $uri = $_SERVER['REQUEST_URI'];
    }
    showStopperErrorRoutineProd($wo, $errorInput, $uri);
    die;
}
Пример #3
0
 /**
  *
  * @param WOOOF $wo
  * @param VO_TblFlagItems $obj
  * @param char $action
  * @param bool $fetchBack
  * @return false | type of reported object
  * Returns actually saved $obj if $fetchBack is set to true
  */
 public static function save(WOOOF $wo, VO_TblFlagItems &$obj, $action = 'I', $fetchBack = true)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ");
     if (!$wo->hasContent($obj->flaggedByUserId)) {
         $wo->logError(self::_ECP . "3011 No value provided for [flaggedByUserId]");
         return false;
     }
     if (!$wo->hasContent($obj->whatId)) {
         $wo->logError(self::_ECP . "3012 No value provided for [whatId]");
         return false;
     }
     if (!$wo->hasContent($obj->whatType)) {
         $wo->logError(self::_ECP . "3013 No value provided for [whatType]");
         return false;
     }
     if ($obj->flaggedByUserId === $obj->whatId) {
         $wo->logError(self::_ECP . "3014 Id's cannot be the same");
         return false;
     }
     $tblFlagItems = new WOOOF_dataBaseTable($wo->db, 'flag_items');
     if ($tblFlagItems === FALSE) {
         return false;
     }
     //insert
     if ($action === 'I') {
         $obj->flaggedDateTime = WOOOF::currentGMTDateTime();
         $newId = $tblFlagItems->insertRowFromArraySimple($obj->toArray());
         if ($newId === FALSE) {
             return false;
         }
     } else {
         $obj->flaggedDateTime = $wo->currentGMTDateTime();
         $res = $tblFlagItems->updateRowFromArraySimple($obj->toArray());
         if ($res === FALSE) {
             return false;
         }
     }
     return $obj->whatType;
 }
 /**
  *
  * @param WOOOF $wo
  * @param string $fieldValue
  * @return false | array ['externalFileId', 'fileName', 'originalFileName']	// return contents of file
  */
 public static function getFileObject(WOOOF $wo, $fieldValue)
 {
     $fileObject = ['externalFileId' => $fieldValue, 'fileName' => '', 'originalFileName' => ''];
     if ($wo->hasContent($fieldValue)) {
         $externalFileData = self::getExternalFileDataById($wo, $fieldValue);
         if ($externalFileData === FALSE) {
             return false;
         }
         if ($externalFileData !== NULL) {
             $fileObject['fileName'] = $externalFileData['fileName'];
             $fileObject['originalFileName'] = $externalFileData['originalFileName'];
         }
     }
     return $fileObject;
 }
Пример #5
0
 /**
  *
  * @param WOOOF $wo
  * @param string $id for record to be deleted
  * @param string $action ('unLike' | 'unHate')
  * @return id of row deleted
  */
 public static function deleteOpinion(WOOOF $wo, $id, $action)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  Delete Movie Opinion");
     if (!$wo->hasContent($id)) {
         $wo->logError(self::_ECP . "1909 No value provided for [id]");
         return false;
     }
     $tblUserMovieOpinions = new WOOOF_dataBaseTable($wo->db, 'movierama_user_movies_opinions');
     if (!$tblUserMovieOpinions->constructedOk) {
         return false;
     }
     //find movie id to update counter
     $movieOpinionRec = $wo->db->getRow('movierama_user_movies_opinions', $id);
     if ($movieOpinionRec === FALSE) {
         return false;
     }
     $res = $tblUserMovieOpinions->deleteRow($id);
     if ($res === FALSE) {
         return false;
     }
     if ($action === 'unLike') {
         $decreaseLike = self::updateCounter($wo, $movieOpinionRec['movieId'], 'noOfLikes', '-1');
         if ($decreaseLike === FALSE) {
             return false;
         }
     } else {
         if ($action === 'unHate') {
             $decreaseHate = self::updateCounter($wo, $movieOpinionRec['movieId'], 'noOfHates', '-1');
             if ($decreaseHate === FALSE) {
                 return false;
             }
         }
     }
     return $id;
 }
Пример #6
0
 /**
  *
  * @param WOOOF $wo
  * @param string $evaluationId
  * @param string $requestorUserId
  * return [] if none | [ criteria1, criteria2, ... ]
  */
 public static function getCriteria(WOOOF $wo, $evaluationId, $requestorUserId)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if (!$wo->hasContent($evaluationId)) {
         $wo->logError(self::_ECP . "5099 No value for evaluation id to find criteria");
         return false;
     }
     $criterias = [];
     $criteriaElems = ['id', 'evaluationId', 'evalTemplateId', 'label', 'description', 'evaluationTypeDVCode', 'isOptional', 'weight'];
     $tblEvaluationCriteria = new WOOOF_dataBaseTable($wo->db, 'evaluation_criteria');
     if (!$tblEvaluationCriteria->constructedOk) {
         return false;
     }
     $safeEvaluationId = $wo->db->escape($evaluationId);
     $result = $wo->db->query("SELECT * FROM evaluation_criteria WHERE evaluationId='{$safeEvaluationId}' AND isDeleted='0'");
     if ($result === FALSE) {
         return false;
     }
     if (!$wo->db->getNumRows($result)) {
         //no error no results
         return [];
     } else {
         //no error results
         while ($row = $wo->db->fetchAssoc($result)) {
             $tblEvaluationCriteria->resultRows[] = $row;
         }
     }
     foreach ($tblEvaluationCriteria->resultRows as $aCriteria) {
         $criteria = [];
         WOOOF_Util::filterOnKeys($criteria, $criteriaElems, $aCriteria);
         $criterias[] = $criteria;
     }
     return $criterias;
 }
Пример #7
0
 /**
  *
  * @param WOOOF $wo
  * @param string $databaseName
  * @param string $tableName
  * @param bool $execute		// Optional, default is false. Set to true to actually execute the statements
  * @return false|true|array	// true on successful execution of statements. array if execute=false
  */
 public static function buildIndexesForTable(WOOOF $wo, $databaseName, $tableName, $execute = false)
 {
     $lc_legalPattern = '/^([piuts])([A-Z])([1-9])([ad])?$/';
     // Type of index: p -> primary, i -> index, u -> unique, t -> fullText, s -> spatial
     // 'Name' of index: just a different letter for each index
     // Position: of column to the specified index
     // Collation: (optional) a -> ASC, d -> DESC (not implemented in MySQL!!)
     //echo '<h2>'.__CLASS__.'.'.__FUNCTION__.'</h2>';
     $sql = "\n\t\t\tselect c.name, c.indexParticipation\n\t\t\tfrom __tableMetaData t, __columnMetaData c\n\t\t\twhere t.tableName = '{$tableName}' and c.tableId = t.id and c.indexParticipation is not null and c.indexParticipation != ''\n\t\t";
     $ipResults = $wo->db->query($sql);
     if ($ipResults === FALSE) {
         $wo->logError(self::_ECP . "0135 You may need to WOOOF_MetaData:selfUpgradeMetaData your db first!");
         return FALSE;
     }
     $indexesArray = array();
     // hold the columns: array( iName => array( [0] => array( colName, collation ), ... ), ... )
     $indexesArray2 = array();
     // hold the type: array( iName => iType )
     $dbIndexesArray = array();
     $dbIndexesArray2 = array();
     while (($aResult = $wo->db->fetchAssoc($ipResults)) !== NULL) {
         // $aResult: array( name, indexParticipation )
         //var_dump($aResult);
         $colName = $aResult['name'];
         $indexParticipationsArray = explode(',', $aResult['indexParticipation']);
         foreach ($indexParticipationsArray as $anIndexParticipationString) {
             $anIndexParticipationString = trim($anIndexParticipationString);
             if (!$wo->hasContent($anIndexParticipationString)) {
                 continue;
             }
             $matches = null;
             $matchOk = preg_match($lc_legalPattern, $anIndexParticipationString, $matches);
             if ($matchOk === 0 or $matchOk === FALSE) {
                 $wo->logError(self::_ECP . "0100 Bad IndexParticipation value [{$anIndexParticipationString}] for column [{$tableName}.{$colName}]");
                 return FALSE;
             }
             // var_dump($matches);
             list($dummy, $iType, $iName, $iSeq) = $matches;
             $iCollation = $wo->getFromArray($matches, 4);
             if (isset($indexesArray[$iName][$iSeq])) {
                 $wo->logError(self::_ECP . "0105 Multiple columns ([{$colName}], [{$indexesArray[$iName][$iSeq][0]}]) with same sequence number [{$iSeq}] for index [{$iName}] on column [{$tableName}.{$colName}]");
                 return FALSE;
             }
             $indexesArray[$iName][$iSeq] = array($colName, $iCollation);
             if (!isset($indexesArray2[$iName])) {
                 $indexesArray2[$iName] = $iType;
             } else {
                 if ($indexesArray2[$iName] != $iType) {
                     $wo->logError(self::_ECP . "0110 Index [{$iName}] of column [{$tableName}.{$colName}] defined with multiple types: [{$iType}] and [{$indexesArray2[$iName]}]");
                     return false;
                 }
             }
         }
         // foreach one of the column's participations
     }
     // foreach column with indexParticipation(s)
     //var_dump($indexesArray);
     if (count($indexesArray) == 0) {
         return $execute ? true : array();
     }
     // Load existing indexes
     //
     $dbIndTemp = self::getDBIndexesForTable($wo, $databaseName, $tableName);
     if ($dbIndTemp === FALSE) {
         return FALSE;
     }
     list($dbIndexesArray2, $dbIndexesArray) = $dbIndTemp;
     $sqlStatements = array();
     foreach ($indexesArray as $anIndexCode => &$anIndexColumns) {
         //echo "$anIndexCode<br>";
         $sqlOut = '';
         $indexName = $tableName . '_idx' . $anIndexCode;
         ksort($anIndexColumns);
         // sort according to specified position and not leave according to order of entry in the array
         // Check if already built/exists in DB
         //
         $needToRecreateIndex = false;
         $needToCreateIndex = false;
         if (isset($dbIndexesArray2[$anIndexCode])) {
             if ($dbIndexesArray2[$anIndexCode] == $indexesArray2[$anIndexCode]) {
                 if (count($dbIndexesArray[$anIndexCode]) == count($indexesArray[$anIndexCode])) {
                     $i = 1;
                     foreach ($anIndexColumns as $aColumn) {
                         if ($aColumn[0] == $dbIndexesArray[$anIndexCode][$i][0]) {
                             // ignore collation differences as collation is a joke (ASC only) in MySQL
                         } else {
                             $needToRecreateIndex = true;
                             break;
                         }
                         // same column or not in that position
                         $i++;
                     }
                     // foreach column in index
                 } else {
                     $needToRecreateIndex = true;
                 }
                 // count of cols same or not
             } else {
                 $needToRecreateIndex = true;
             }
             // index type same or not
         } else {
             $needToCreateIndex = true;
         }
         // var_dump($needToRecreateIndex, $needToCreateIndex);
         if ($needToRecreateIndex) {
             $sqlStatements[] = "ALTER TABLE `{$tableName}` DROP INDEX `{$indexName}`;";
         }
         if ($needToCreateIndex or $needToRecreateIndex) {
             $sqlOut .= "ALTER TABLE `{$tableName}` ADD ";
             switch ($indexesArray2[$anIndexCode]) {
                 case 'p':
                     $sqlOut .= "CONSTRAINT PRIMARY KEY ";
                     break;
                 case 'u':
                     $sqlOut .= "UNIQUE KEY `{$indexName}` ";
                     break;
                 case 'i':
                     $sqlOut .= "INDEX `{$indexName}` ";
                     break;
                 case 's':
                     $sqlOut .= "SPATIAL INDEX `{$indexName}` ";
                     break;
                 case 't':
                     $sqlOut .= "FULLTEXT INDEX `{$indexName}` ";
                     break;
                 default:
                     $sqlOut .= " " . $indexesArray2[$anIndexCode] . " ***not implemented*** ";
             }
             $sqlOut .= '( ';
             foreach ($anIndexColumns as $aColumn) {
                 $sqlOut .= "`" . $aColumn[0] . "` ";
                 if (isset($aColumn[1])) {
                     $sqlOut .= ' ' . ($aColumn[1] == 'd' ? 'DESC' : 'ASC');
                 }
                 $sqlOut .= ', ';
             }
             // foreach column
             $sqlOut = substr($sqlOut, 0, -2);
             $sqlOut .= ' ) ';
             $sqlOut .= ';';
             $sqlStatements[] = $sqlOut;
         }
         // create index
     }
     // foreach index
     // var_dump($sqlStatements);
     if ($execute) {
         if (count($sqlStatements) > 0) {
             $succ = $wo->db->queryMultiple($sqlStatements);
             return $succ;
         } else {
             return true;
         }
     }
     return $sqlStatements;
 }
 /**
  *
  * @param WOOOF $wo
  * @param array $in	// [ 'email' ]
  * @return array [ 'resendOk', 'errors' ]
  */
 public static function resendToken(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $requestedAction = 'resendToken';
     $pageLocation = '3';
     $browserTitle = 'MovieRama User Verification Token Resend';
     if ($wo->userData['id'] != '0123456789') {
         $wo->handleShowStopperError("505 {$place}: " . $wo->userData['id']);
     }
     if (!$wo->hasContent($in['email'])) {
         $wo->logError(self::_ECP . "2359 You must provide your email in order to resend your verification token.");
         return false;
     }
     $movieramaUserRec = $wo->db->getRowByColumn('movierama_users', 'username', $in['email']);
     if ($movieramaUserRec === FALSE) {
         return false;
     }
     if ($movieramaUserRec === NULL) {
         $wo->logError(self::_ECP . "2360 I am sorry it seems you are not a registered MovieRama user.");
         return false;
     }
     $res = VO_Registration::tokenResend($wo, $in);
     if ($res === FALSE) {
         $out = ['resendOk' => false, 'errors' => $wo->getErrorsAsArrayAndClear()];
         $wo->db->rollback();
     } else {
         $out = ['resendOk' => true, 'resend' => $res];
         $wo->db->commit();
     }
     return $out;
 }
Пример #9
0
 /**
  * 
  * @param WOOOF $wo
  * @param string $loginName
  * @param string $newPassword
  * @param string[] &$passwordErrors	// return possible new password problems
  * @param string $oldPassword		// Optional, default '', do not verify old pass validity
  * @param string $checkPassword		// Optional, default true. Check new pass is ok
  * @return boolean
  */
 public static function changePassword(WOOOF $wo, $loginName, $newPassword, &$passwordErrors, $oldPassword = '', $checkPassword = true)
 {
     $passwordErrors = array();
     if (!$wo->hasContent($loginName) or !$wo->hasContent($newPassword)) {
         $wo->logError('7055 Both loginName and mew Password must be provided');
         return false;
     }
     $userRes = $wo->db->query("select * from __users where loginName='{$loginName}'");
     if ($userRes === FALSE) {
         return FALSE;
     }
     $userRow = $wo->db->fetchAssoc($userRes);
     if ($userRow === NULL) {
         $wo->logError(self::_ECP . "0057 User with loginName [{$loginName}] was not found");
         return FALSE;
     }
     if ($userRow['id'] == self::ID_OF_NOT_LOGGED_IN) {
         $wo->logError(self::_ECP . "0059 Cannot changePassword of this user");
         return FALSE;
     }
     if ($wo->hasContent($oldPassword)) {
         $oldPassHashed = $wo->getPasswordHash($oldPassword, $userRow['id']);
         if ($oldPassHashed === FALSE or $oldPassHashed != $userRow['loginPass']) {
             $wo->logError(self::_ECP . "0060 Bad old password was given");
             return false;
         }
     }
     if ($checkPassword) {
         if ($wo->evaluatePassword($newPassword, $newPassword, $passwordErrors) === FALSE) {
             $wo->logError(self::_ECP . "0063 Password is not accepted");
             return FALSE;
         }
     }
     $newPassHashed = $wo->getPasswordHash($newPassword, $userRow['id']);
     if ($newPassHashed === FALSE) {
         return FALSE;
     }
     $newPassHashed = $wo->db->escape($newPassHashed);
     $succ = $wo->db->query("update __users set loginPass = '******' where id = '{$userRow['id']}'");
     if ($succ === FALSE) {
         return FALSE;
     }
     return true;
 }
Пример #10
0
 /**
  *
  * @param WOOOF $wo
  * @param array $in [array of user answers to eval criteria]
  * @return false | [ 'evaluationSavedOk' => bool, 'evaluationSavedForEvalId' => string ]
  */
 public static function submitEvaluation(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if ($wo->userData['id'] == '0123456789') {
         $wo->handleShowStopperError('505');
     }
     if (!$wo->hasContent($in)) {
         $wo->logError(self::_ECP . "1226 You must provide data to submit an evaluation");
         return false;
     }
     $res = VO_Evaluation::submitEval($wo, $in, $wo->app->userId);
     if ($res === FALSE) {
         $out = ['evaluationSavedOk' => false, 'errors' => $wo->getErrorsAsArrayAndClear()];
         $wo->db->rollback();
     } else {
         $out = ['evaluationSavedOk' => true, 'evaluationSavedForEvalId' => $res];
         $wo->db->commit();
     }
     return $out;
 }
Пример #11
0
 public function view($in)
 {
     $wo = $this->wo;
     $tableName = $this->tableName;
     if (!WOOOF::hasContent($tableName)) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1000 No value for tableName");
         return false;
     }
     $showDetails = $wo->getFromArray($in, '_showDetails', true);
     $tplContentTop = '';
     $tplContent = '';
     $tplErrorMessage = '';
     $tplMessage = '';
     $wo->debug("Generic.show for '{$tableName}'.");
     $table = new WOOOF_dataBaseTable($wo->db, $tableName);
     if (!$table->constructedOk) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1010 Failed to init '{$tableName}'!");
         return false;
     }
     // form html
     // $htmlFragment = '';
     $id = $wo->getFromArray($in, '_id');
     $tplContentTop .= "<h1>'{$tableName}' View for [{$id}]</h1>";
     // Show the data
     //
     $formBody = $table->presentRowReadOnly($id);
     if ($formBody === FALSE) {
         $tplContent .= "Failed to perform 'view'!";
         $tplErrorMessage .= $wo->getLastErrorAsStringAndClear() . '<br>';
     } else {
         $tplContent .= $formBody;
     }
     return array('contentTop' => $tplContentTop, 'content' => $tplContent, 'errorMessage' => $tplErrorMessage, 'message' => $tplMessage);
 }
Пример #12
0
 /**
  * getDomainValues get the data values for a requested domain/subdomain
  * 
  * @param WOOOD $wo -- the initialized instance of WOOOF to use
  * @param string $value  -- the value to check
  * @param string $requestedDomain  -- the domain whose values we want to retrieve
  * @param string $requestedSubDomain -- optional -- if the domain is split in subdomains, the requested subdomain should be specified here. If there are subdomains in the domain and no subdomain is specified all the values will be returned regardless of subdomain bu a warning will be written to the debug log. 
  * @param string $mandatory -- optional -- if the given value must have content or not
  * 
  * @return boolean TRUE for valid input.
  */
 public static function validateId(WOOOF $wo, $value, $requestedDomain, $requestedSubDomain = '', $mandatory = TRUE)
 {
     if (!$wo->hasContent($value) && $mandatory) {
         return FALSE;
     }
     $domain = $wo->db->getRowByColumn('__domains', 'code', $requestedDomain);
     if ($domain === FALSE) {
         return FALSE;
     } elseif (!isset($domain['id'])) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0301 Requested domain [' . $wo->cleanUserInput($requestedDomain) . '] doesn\'t exist in the database!');
         return FALSE;
     }
     $domainData = new WOOOF_dataBaseTable($wo->db, '__domain_values');
     if (!$domainData->constructedOk) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0302 Internal failure. Failed to construct instance of __domain_values!');
         return FALSE;
     }
     $whereClauses['domainId'] = $domain['id'];
     if ($wo->hasContent($requestedSubDomain)) {
         $subDomainsR = $wo->db->query('select subDomain from __domain_values where domainId = \'' . $wo->db->escape($domain['id']) . '\' and subDomain = \'' . $wo->db->escape($requestedSubDomain) . '\'');
         if (!$wo->db->getNumRows($subDomainsR)) {
             $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0204 Requested subdomain [' . $wo->cleanUserInput($requestedSubDomain) . '] doesn\'t exist in the database!');
             return FALSE;
         }
         $whereClauses['subDomain'] = $requestedSubDomain;
     }
     $whereClauses['active'] = '1';
     $whereClauses['domainValueCode'] = $value;
     $howManyResults = $domainData->getResult($whereClauses);
     if ($howManyResults === FALSE) {
         $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, self::_ECP . '0303 Operation failed in result retrieval from domain values.');
         return FALSE;
     }
     if ($howManyResults['rowsFetched'] == 0) {
         return FALSE;
     }
     return TRUE;
 }
Пример #13
0
 /**
  *
  * @param WOOOF $wo
  * @param array $in
  * @return false | [ 'flagItemOk' => bool, 'flagItemRecType' => string, 'errors' => array ]
  */
 public static function flagMovie(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if ($wo->userData['id'] == '0123456789') {
         $wo->handleShowStopperError('505');
     }
     if (!$wo->hasContent($in['whatId'])) {
         $wo->logError(self::_ECP . "4196 You must provide a movie ID to report!");
         return false;
     }
     if (!$wo->hasContent($in['whatType'])) {
         $wo->logError(self::_ECP . "4197 You must provide a target type to report!");
         return false;
     }
     if (!$wo->hasContent($in['flagText'])) {
         $wo->logError(self::_ECP . "4198 You must provide flag text!");
         return false;
     }
     $res = VO_FlagItem::saveFlagItem($wo, $wo->app->userId, $in);
     if ($res === FALSE) {
         $out = ['flagItemOk' => false, 'errors' => $wo->getErrorsAsArrayAndClear()];
         $wo->db->rollback();
     } else {
         $out = ['flagItemOk' => true, 'flagItemRecType' => $res];
         $wo->db->commit();
     }
     return $out;
 }
Пример #14
0
 /**
  * 
  * @param WOOOF $wo
  * @param string $domain
  * @param bool $isFullDomain
  * @return false | string
  */
 public static function formFullURL(WOOOF $wo, $domain, $isFullDomain = false)
 {
     if (!$wo->hasContent($domain)) {
         $wo->logError(self::_ECP . "0910 No value provided for [domain]");
         return false;
     }
     $domain = trim($domain);
     $dotParts = explode('.', $domain);
     $noOfParts = count($dotParts);
     $i = $noOfParts;
     while ($i > 2) {
         $i--;
         array_shift($dotParts);
     }
     $domain = implode('.', $dotParts);
     if (substr($domain, 0, 4) === 'http') {
         $fullURL = $domain;
     } else {
         if (!$isFullDomain and substr($domain, 0, 4) != 'www.') {
             $fullURL = 'www.' . $domain;
         }
         $fullURL = 'http://' . $domain;
     }
     return $fullURL;
 }
Пример #15
0
 /**
  * 
  * @param WOOOF $wo
  * @param array $in
  * @return false | id
  * Returns actually saved $obj 
  */
 public static function saveMainInfo(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ");
     if (!$wo->hasContent($in['firstName'])) {
         $wo->logError(self::_ECP . "0012 No value for first name");
         return false;
     }
     if (!$wo->hasContent($in['lastName'])) {
         $wo->logError(self::_ECP . "0014 No value for last name");
         return false;
     }
     $movieRamaUser = $wo->db->getRowByColumn('movierama_users', 'userId', $wo->userData['id']);
     //fernei olo to row
     if ($movieRamaUser === FALSE) {
         return false;
     }
     $movieRamaUserProfile = $wo->db->getRow('person_profiles', $movieRamaUser['personProfileId']);
     //fernei olo to row
     if ($movieRamaUserProfile === FALSE) {
         return false;
     }
     $tblProfile = new VO_TblPersonProfile($movieRamaUserProfile);
     $tblProfile->firstName = $in['firstName'];
     $tblProfile->lastName = $in['lastName'];
     $res = VO_Users::savePersonProfile($wo, $tblProfile);
     if ($res === FALSE) {
         return false;
     }
     return $res;
 }
Пример #16
0
 public function __construct($currentMicroTime, $host = 'localhost', $userName = '', $password = '', $dbName = '')
 {
     $wo = WOOOF::$instance;
     $databaseName = $wo->getConfigurationFor('databaseName');
     $databaseUser = $wo->getConfigurationFor('databaseUser');
     $databasePass = $wo->getConfigurationFor('databasePass');
     $databaseHost = $wo->getConfigurationFor('databaseHost');
     $this->resultActive = FALSE;
     $this->currentMicroTime = $currentMicroTime;
     if ($dbName == '') {
         $this->myConnectionSerialNumber = WOOOF_dataBase::$howManyConnections;
         WOOOF_dataBase::$howManyConnections++;
         $host = $databaseHost[$this->myConnectionSerialNumber];
         $userName = $databaseUser[$this->myConnectionSerialNumber];
         $password = $databasePass[$this->myConnectionSerialNumber];
         $dbName = $databaseName[$this->myConnectionSerialNumber];
     }
     $this->dataBaseHost = $host;
     $this->logFileHandle = '';
     $this->connection = mysqli_connect($host, $userName, $password);
     // we are always requesting a new connection so as to avoid two objects having the same actual connection,
     // as this would probably mess query logging, error/exception handling etc
     if ($this->connection === FALSE) {
         $this->constructedOk = false;
         die('Database connection failed with MySQL error :<br/>' . mysqli_connect_error());
     }
     $this->logConnection = $this->connection;
     if ($this->selectDataBase($dbName) === FALSE) {
         $this->constructedOk = false;
         die('Data base selection failed.');
     }
     $this->query('set names utf8');
     $autoCommit = $wo->getConfigurationFor('databaseAutoCommit')[$this->myConnectionSerialNumber];
     $this->query("SET autocommit=" . ($autoCommit ? '1' : '0'));
     // to show in SQL Log
     $this->connection->autocommit($autoCommit);
     // to properly inform possible replication etc services
     $sqlMode = $wo->getConfigurationFor('databaseSQLMode')[$this->myConnectionSerialNumber];
     if (WOOOF::hasContent($sqlMode)) {
         // dev.mysql.com/doc/refman/5.0/en/sql-mode.html
         $succ = $this->query("SET sql_mode='" . $sqlMode . "'");
         if (!$succ) {
             $this->constructedOk = false;
             die("Failed to set sql_mode [{$sqlMode}]<br/>" . $this->error());
         }
     }
     $optionsCheck = $this->query('SELECT * FROM information_schema.tables WHERE table_schema = \'' . $dbName . '\' AND table_name = \'__options\' LIMIT 1');
     if (mysqli_num_rows($optionsCheck)) {
         $optionsR = $this->query('select * From __options');
         while ($o = $this->fetchAssoc($optionsR)) {
             $this->options[$o['id']] = $o;
             $this->refinedOptions[$o['optionName']] = $o['optionValue'];
         }
         // TODO: Check and uncomment!
         /*
                     $metaDataDBVersion = WOOOF_MetaData::versionReadFromDB($wo, $this);
         if ( $metaDataDBVersion !== NULL ) {
         	if ( substr($metaDataDBVersion,0,2) < substr(WOOOF_MetaData::$version,0,2) ) {
         		die("Need to upgradre DB MetaData: DB version [$metaDataDBVersion] is behind Code Version [". WOOOF_MetaData::$version. "]");
         	}
         }
         */
     }
     // options found in DB
     $this->constructedOk = true;
 }
Пример #17
0
<?php

$__isAdminPage = true;
$__isSiteBuilderPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'read';
$pageLocation = '1';
$pageTitle = 'Administration Back End';
$wo = new WOOOF();
$in = $wo->getMultipleGetPost(['table', 'class']);
if (!$wo->hasContent($in['table']) or !$wo->hasContent($in['class'])) {
    die("You have to provice 'table' and 'class' parameters");
}
$res = WOOOF_MetaData::createTplCodeForTable($wo, $in['table'], $in['class']);
$res = '<textarea rows="50" cols="100">' . htmlentities($res) . "</textarea>";
echo $res;
exit;
Пример #18
0
midSizeWidth=\'' . $wo->db->escape(trim($de['midSizeWidth' . $c])) . '\',
midSizeHeight=\'' . $wo->db->escape(trim($de['midSizeHeight' . $c])) . '\',
thumbnailColumn=\'' . $wo->db->escape(trim($de['thumbnailColumn' . $c])) . '\',
ordering=\'' . $wo->db->escape(trim($de['ordering' . $c])) . '\',
adminCSS=\'' . $wo->db->escape(trim($_POST['adminCSS' . $c])) . '\',
indexParticipation=\'' . $wo->db->escape(trim($_POST['indexParticipation' . $c])) . '\',
colCollation=\'' . $wo->db->escape(trim($_POST['colCollation' . $c])) . '\'
  ');
        $query = 'ALTER TABLE ' . $table->getTableName() . ' ADD COLUMN ' . $wo->db->escape(trim($de['name'] . $_GET['suplec'])) . ' ' . WOOOF_dataBaseColumnTypes::getColumnTypeLiteral($wo->db->escape(trim($de['type' . $c])));
        if ($wo->db->escape(trim($de['length' . $c])) != '') {
            $query .= '(' . $wo->db->escape(trim($de['length' . $c])) . ')';
        }
        if ($wo->db->escape(trim($de['notNull' . $c])) == '1') {
            $query .= ' NOT NULL ';
        }
        if ($wo->hasContent($wo->db->escape(trim($de['defaultValue' . $c])))) {
            $query .= ' DEFAULT \'' . $wo->db->escape(trim($de['defaultValue' . $c])) . '\'';
        }
        if ($wo->hasContent($wo->db->escape(trim($de['colCollation' . $c])))) {
            $query .= ' COLLATE \'' . $wo->db->escape(trim($de['colCollation' . $c])) . '\'';
        }
        //echo $query .'<br/>';
        $wo->db->query($query);
    }
    $wo->db->commit();
    header('Location: dbManager.php');
    exit;
}
$content = '<form method="GET" action="' . $_SERVER['PHP_SELF'] . '"><input type="hidden" name="table" value="' . $table->getTableName() . '">
';
$pr = $wo->db->query('select * From __columnMetaData where tableId=\'' . $table->getTableId() . '\'');
Пример #19
0
 /**
  *
  * @param WOOOF $wo
  * @param array $in
  * @return boolean
  */
 public static function tokenResend(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ReseendVerificationToken");
     $movieramaUserRec = $wo->db->getRowByColumn('movierama_users', 'username', $in['email']);
     if ($movieramaUserRec === FALSE) {
         return false;
     }
     if ($movieramaUserRec === NULL) {
         $wo->logError(self::_ECP . "2370 No such user found.");
         return false;
     }
     if ($wo->hasContent($movieramaUserRec['verificationToken'])) {
         $succ = VO_Users::handleVerificationToken($wo, $movieramaUserRec['id'], $movieramaUserRec['username'], $movieramaUserRec['verificationToken']);
         if ($succ === FALSE) {
             return FALSE;
         }
     } else {
         $wo->logError(self::_ECP . "2380 It seems you have already been verified.");
         return false;
     }
     return $succ;
 }