Example #1
0
 /**
  *
  * @param WOOOF $wo
  * @param array $in
  * @return false | flagged item type
  */
 public static function saveFlagItem(WOOOF $wo, $movieramaUserId, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ");
     //find if user has already flagged the movie once before
     $tblFlagItems = new WOOOF_dataBaseTable($wo->db, 'flag_items');
     if (!$tblFlagItems->constructedOk) {
         return false;
     }
     $res = $tblFlagItems->getResult(['whatId' => $in['whatId'], 'whatType' => $in['whatType'], 'flaggedByUserId' => $movieramaUserId, 'flagStatus' => 'P', 'isDeleted' => '0'], '', '', '', '', false, true);
     if ($res === FALSE) {
         return false;
     }
     foreach ($tblFlagItems->resultRows as $aFlagItem) {
         $tblFlagItemUpdate = new VO_TblFlagItems($aFlagItem);
         $tblFlagItemUpdate->flagText = $in['flagText'];
         $res = self::save($wo, $tblFlagItemUpdate, 'U');
         if ($res === FALSE) {
             return false;
         }
         return $res;
     }
     $tblFlagItemInsert = new VO_TblFlagItems();
     $tblFlagItemInsert->whatType = $in['whatType'];
     $tblFlagItemInsert->whatId = $in['whatId'];
     $tblFlagItemInsert->flaggedByUserId = $movieramaUserId;
     $tblFlagItemInsert->flagText = $in['flagText'];
     $tblFlagItemInsert->flagStatus = 'P';
     $res = self::save($wo, $tblFlagItemInsert, 'I');
     if ($res === FALSE) {
         return false;
     }
     return $res;
 }
Example #2
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;
 }
Example #3
0
 public static function get(WOOOF $wo, $paramCode, $evenDeleted = false)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $p_param = trim(strtoupper($paramCode));
     if (isset(self::$params[$paramCode])) {
         return self::$params[$paramCode][0];
     }
     $t1 = new WOOOF_dataBaseTable($wo->db, 'sys_params');
     if (!$t1->constructedOk) {
         return false;
     }
     $wheres = ['code' => $paramCode];
     if (!$evenDeleted) {
         $wheres['isDeleted'] = 0;
     }
     $res = $t1->getResult($wheres, 'code');
     if ($res === FALSE) {
         return false;
     }
     if ($res['rowsFetched'] !== 1) {
         $wo->logError(self::_ECP . "0010 {$res['rowsFetched']} records found for [{$paramCode}]");
         return false;
     }
     $paramRec = $t1->resultRows[0];
     $l_val = self::convertToType($paramRec['paramValue'], $paramRec['paramDataType']);
     self::$params[$paramCode] = array($l_val, $paramRec['paramDataType']);
     return $l_val;
 }
 /**
  *
  * @param WOOOF $wo
  * @param id $movieRamaUserId
  * @return false | array[ ]
  */
 public static function getMainInfo(WOOOF $wo, $movieRamaUserId)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  [{$movieRamaUserId}]");
     $main = [];
     if ($movieRamaUserId == $wo->app->userId) {
         $ramaUser = $wo->app->movieRamaPersonRow;
         $main['isSelf'] = true;
     } else {
         $ramaUser = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_id', $movieRamaUserId);
         if ($ramaUser === FALSE || $ramaUser === NULL) {
             return false;
         }
         $main['isSelf'] = false;
     }
     $main['personProfileId'] = $ramaUser['VUS_personProfileId'];
     $main['movieRamaUserId'] = $ramaUser['VUS_id'];
     $main['isActive'] = $ramaUser['VUS_isActive'];
     $main['isLoggedIn'] = true;
     $main['isType'] = 'PRS';
     $main['avatarImg'] = $ramaUser['VUS_avatarImg'];
     $mainElems = ['PROF_firstName', 'PROF_lastName'];
     WOOOF_Util::filterOnKeys($main, $mainElems, $ramaUser, 'PROF_');
     return $main;
 }
 /**
  * 
  * @param WOOOF $wo
  * @param string $messageText
  * @param string $messageType
  * @param number $fadeInSeconds
  * @return bool
  */
 public static function addMessage(WOOOF $wo, $messageText, $messageType = 'I', $fadeInSeconds = 0)
 {
     $newId = $wo->db->getNewId('session_messages');
     $sid = $wo->sid;
     if ($messageType != 'I' and $messageType != 'E' and $messageType != 'S' and $messageType != 'W') {
         $wo->log(WOOOF_loggingLevels::WOOOF_LOG_WARNINGS, "Invalid messageType [{$messageType}] for Message: [{$messageText}]");
         $messageType = 'E';
     }
     $fadeInSeconds = (int) $fadeInSeconds;
     $sql = "insert into session_messages( id, sessionId, messageType, messageText, whenMicrotime, fadeInSeconds ) " . "values ( '{$newId}', '{$sid}', '{$messageType}', '{$messageText}', " . microtime(true) . ", {$fadeInSeconds} )";
     $succ = $wo->db->query($sql);
     return $succ;
 }
Example #6
0
function initAppMOVIERAMA(WOOOF $wo)
{
    $wo->debug("Initialising MOVIERAMA App...");
    $appObject = new VO_App();
    $userId = $appObject->initFor($wo);
    if ($userId === FALSE) {
        return FALSE;
    }
    $wo->app = $appObject;
    spl_autoload_register(function ($className) {
        VO_App::handleClassAutoloader($className, WOOOF::$instance);
    });
    return TRUE;
}
 /**
  *
  * @param WOOOF $wo
  * @param array $in
  * @return [ 'changeOk' => bool, 'changePass' => boolean, 'errors' => array ]
  */
 public static function changePassword(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if ($wo->userData['id'] == '0123456789') {
         $wo->handleShowStopperError('505');
     }
     $errors = [];
     if ($in['newPass'] !== $in['newPassConfirm']) {
         $errors[] = "Passwords given do not match.";
         $out = ['changeOk' => false, 'errors' => $errors];
         return $out;
     }
     $res = VO_Users::passwordChange($wo, $in);
     if ($res === FALSE) {
         $out = ['changeOk' => false, 'errors' => $wo->getErrorsAsArrayAndClear()];
         $wo->db->rollback();
     } else {
         $out = ['changeOk' => true, 'changePass' => $res];
         $wo->db->commit();
     }
     return $out;
 }
 public static function checkFilesMissingFromDB(WOOOF $wo, $doDelete = false, $viewName = '__v_files')
 {
     $sql = "select * from {$viewName} order by tableName, rowId, columnName";
     $dbRes = $wo->db->query($sql);
     if ($dbRes === FALSE) {
         return FALSE;
     }
     $out = array();
     $paths = array(0 => $wo->getConfigurationFor('absoluteFilesRepositoryPath'), 1 => $wo->getConfigurationFor('siteBasePath') . $wo->getConfigurationFor('imagesRelativePath'));
     foreach ($paths as $isImage => $aPath) {
         // Assume the two types are in distinct paths!
         $actualContents = scandir($aPath);
         foreach ($actualContents as $aContent) {
             if (is_dir($aContent)) {
                 continue;
             }
             $sql = "select count(*) from {$viewName} where filename = '{$aContent}'";
             $c = $wo->db->getSingleValueResult($sql, true, true);
             if ($c === FALSE) {
                 return FALSE;
             }
             if ($c === '0') {
                 $out[] = array($aContent, $isImage);
             }
             if ($doDelete) {
                 echo "del {$aPath}{$aContent}<br>";
             }
         }
         // foreach file in path
     }
     // foreach path
     return $out;
 }
Example #9
0
 /**
  *
  * @param WOOOF $wo
  */
 public static function logout(WOOOF $wo)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->invalidateSession();
     header("Location:  " . $wo->assetsURL);
 }
Example #10
0
<?php

/* examples:
 * ...../publicSite/tailLog.php?forceFromStart=1&session=cRw2kGwD34lNmMfFt492g4d6xX1UcChUxCnJtOyD
 * ...../publicSite/tailLog.php?forceFromStart=1&errors
 */
require_once '../setup.inc.php';
$__isAdminPage = true;
$requestedAction = 'read';
$pageLocation = '1';
$browserTitle = 'Tail Log';
$timers = array();
$wooofConfigCustomOptions['debug'] = array();
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
if (isset($_GET['currentSession'])) {
    $l_filename = $wo->getConfigurationFor('debugLogPath') . $wo->getConfigurationFor('siteName') . '_debugMessages_' . $wo->sid . '.log';
} elseif (isset($_GET['session'])) {
    $l_filename = $wo->getConfigurationFor('debugLogPath') . $wo->getConfigurationFor('siteName') . '_debugMessages_' . $_GET['session'] . '.log';
} elseif (isset($_GET['errors'])) {
    $l_filename = $wo->getConfigurationFor('debugLogPath') . $wo->getConfigurationFor('siteName') . '_errorMessages.log';
} elseif (isset($_GET['filename'])) {
    $l_filename = $_GET['filename'];
    // full path is expected
} else {
    echo "ERROR: Either a 'session=....' or a 'errors' or a 'filename=...' is required. 'forceFromStart' is optional.";
    die('Aborting._');
}
$l_textType = true;
<?php

require_once '../setup.inc.php';
header('Content-Type: text/html; charset=utf-8');
$__isAdminPage = true;
$pageLocation = '1';
$requestedAction = 'users';
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
// PLEASE, SET THE FOLLOWING
// just an example
$users['loginName'] = 'newPassword';
$users['loginName2'] = 'newPassword2';
var_dump($wo->sid);
$database = $wo->db->getDatabaseName();
$dbString = "{$database}@" . $wo->getConfigurationFor('databaseHost')[$wo->getConfigurationFor('defaultDBIndex')];
echo "<h1>Change user passwords</h1>";
echo "<h2>Db: {$dbString}</h2>";
foreach ($users as $key => $value) {
    echo "Changing [{$key}] ...";
    /*
    $cUser = $wo->db->getRowByColumn('__users','loginName', $key);
    
    if ( $cUser === NULL ) {
    	echo " user not found!<br>";
    	continue;
    }
    
    $thePassword = $wo->getPasswordHash($wo->cleanUserInput($value), $cUser['id']);
 /**
  *
  * @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;
 }
Example #13
0
<?php

$__isSiteBuilderPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'edit';
$pageLocation = '1';
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
$tm = WOOOF::getCurrentDateTime();
$metaDataDBVersion = WOOOF_MetaData::versionReadFromDB($wo, $wo->db);
if ($metaDataDBVersion !== NULL) {
    if ($metaDataDBVersion === 'UNDEFINED' or substr($metaDataDBVersion, 0, 2) < substr(WOOOF_MetaData::$version, 0, 2)) {
        echo "\n\t\t\tNeed to upgradre DB MetaData: DB version [{$metaDataDBVersion}] is behind Code Version [" . WOOOF_MetaData::$version . "]\n\t\t\t<br>\n\t\t\t<a href=\"mdSynch.php?what=selfUpgradeMetaData\">Click here to upgrade right now...</a>\n\t\t";
        die;
    }
}
if (!isset($_COOKIE["allTablesVisible"])) {
    setcookie("allTablesVisible", "no");
    header("Location: dbManager.php?tm=" . $tm);
    exit;
}
if ($_COOKIE["allTablesVisible"] == "no") {
    $switchText = "Make system tables visible";
    $showSystemTables = FALSE;
} else {
    $switchText = "Hide system tables";
    $showSystemTables = TRUE;
Example #14
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;
 }
Example #15
0
 /**
  *
  * @param WOOOF $wo
  * @param array $in
  * @return boolean
  */
 public static function passwordChange(WOOOF $wo, $in)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  ChangePassword");
     $movieRamaPerson = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_id', $in['movieRamaUserId']);
     if ($movieRamaPerson === FALSE) {
         return false;
     }
     if ($movieRamaPerson === NULL) {
         $wo->logError(self::_ECP . "3352 No MovieRama person found.");
         return false;
     }
     $user = $wo->db->getRow('__users', $movieRamaPerson['VUS_userId']);
     if ($user === FALSE) {
         return false;
     }
     if ($user === NULL) {
         $wo->logError(self::_ECP . "3357 No user found.");
         return false;
     }
     //change password here
     $passwordErrors = [];
     $res = WOOOF_User::changePassword($wo, $user['loginName'], $in['newPass'], $passwordErrors, $in['oldPass']);
     if ($res === FALSE) {
         return false;
     }
     return $res;
 }
Example #16
0
<?php

require_once '../setup.inc.php';
$requestedAction = 'viewUncontroled';
$pageLocation = '3';
$pageTitle = 'Download File.';
$wo = new WOOOF();
$pageLocation = '6_' . $wo->cleanUserInput($_GET['location']);
$pieces = explode('_', $pageLocation);
if (count($pieces) != 4) {
    die('Malformed file location. Please try again !');
}
// antonis ???? The specific field is ignored?
$pageLocationTrue = '6_' . $pieces[1] . '_' . $pieces[3];
$permitions = $wo->db->getSecurityPermitionsForLocationAndUser($pageLocationTrue, $userData['id']);
//antonis. TODO: Fix and uncomment!!!
/*
if (!isset($permitions['download']) || $permitions['download']!='1')
{
    die('Security failure: you don\'t have permission to perform the requested action.');
}
*/
$result = $wo->db->query('select * from __tableMetaData where id=\'' . $pieces[1] . '\'');
if (mysqli_num_rows($result) != 1) {
    die('Malformed file location. Specified HEAD location is invalid!');
}
$tMD = $wo->db->fetchAssoc($result);
$result = $wo->db->query('select * from __columnMetaData where id=\'' . $pieces[2] . '\'');
if (mysqli_num_rows($result) != 1) {
    die('Malformed file location. Specified BODY location is invalid!');
}
Example #17
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;
 }
Example #18
0
{
    $menuOutput .= fetchSubmenus($mI);
}
*/
$menuOutput .= '      </ul>
';
if (isset($activateFirstMenu) && $activateFirstMenu == true) {
    $menuAClass = 'selected';
} else {
    $menuAClass = 'menuLink';
}
$menuOutput = '        <div class="menuItem"><a href="administration.php?tm=' . WOOOF::getCurrentDateTime() . '" class="' . $menuAClass . '">Home</a></div>
';
$mR = $wo->db->query('select * from __tableMetaData where appearsInAdminMenu=\'1\' and tableName not in (\'__tableMetaData\', \'__columnMetaData\') ');
while ($m = $wo->db->fetchAssoc($mR)) {
    if (isset($addressItems[1]) && $addressItems[1] == $m['id']) {
        $menuAClass = 'selected';
    } else {
        $menuAClass = 'menuLink';
    }
    $menuOutput .= '<div class="menuItem"><a href="administration.php?__address=1_' . $m['id'] . '&action=read" class="' . $menuAClass . '">' . $m['description'] . '</a></div>';
}
if (basename($_SERVER['SCRIPT_FILENAME']) == 'optionManagement.php') {
    $optClass = 'selected';
} else {
    $optClass = 'menuLink';
}
$menuOutput .= '        <div class="menuItem"><a href="optionManagement.php?tm=' . WOOOF::getCurrentDateTime() . '" class="' . $optClass . '">Options</a></div>
        <div class="menuItem"><a href="backUpDataBase.php?tm=' . WOOOF::getCurrentDateTime() . '" class="menuLink">DB Backup</a></div>
        <div class="menuItem"><a href="logOut.php?tm=' . WOOOF::getCurrentDateTime() . '" class="menuLink">Log Out</a></div>
';
Example #19
0
<?php

require_once '../setup.inc.php';
$__isAdminPage = true;
$requestedAction = 'read';
$pageLocation = '1';
$browserTitle = 'Tail Log Files';
$timers = array();
$wooofConfigCustomOptions['debug'] = array();
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
if (isset($_GET['filename'])) {
    $l_filename = urldecode($_GET['filename']);
    //echo json_encode(array("size" => 0, "data" => array($l_filename)));
    //return;
} else {
    echo json_encode(array("size" => 0, "data" => array()));
    return;
}
$l_textType = isset($_GET['textType']);
$tail = new Tail($l_filename, $l_textType);
/**
 * We're getting an AJAX call
 */
if (isset($_GET['ajax'])) {
    echo $tail->getNewLines($_GET['lastsize'], $_GET['grep'], $_GET['invert']);
    die;
}
/**
Example #20
0
<?php

$__isSiteBuilderPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'edit';
$pageLocation = '1';
$wo = new WOOOF();
$result = $wo->db->query("select * from __tableMetaData where tableName='" . $wo->cleanUserInput($_GET["table"]) . "'");
// TODO: Update with relevant metadata changes!!!
if (mysqli_num_rows($result)) {
    $row = $wo->db->fetchAssoc($result);
    $tableId = $wo->db->getNewId('__tableMetaData');
    $wo->db->query('insert into __tableMetaData set 
id=\'' . $tableId . '\',
tableName=\'' . $wo->cleanUserInput($row['tableName']) . '_dup\',
orderingColumnForListings=\'' . $wo->cleanUserInput($row['orderingColumnForListings']) . '\',
appearsInAdminMenu=\'' . $wo->cleanUserInput($row['appearsInAdminMenu']) . '\',
adminPresentation=\'' . $wo->cleanUserInput($row['adminPresentation']) . '\',
adminItemsPerPage=\'' . $wo->cleanUserInput($row['adminItemsPerPage']) . '\',
adminListMarkingCondition=\'' . $wo->cleanUserInput($row['adminListMarkingCondition']) . '\',
adminListMarkedStyle=\'' . $wo->cleanUserInput($row['adminListMarkedStyle']) . '\',
groupedByTable=\'' . $wo->cleanUserInput($row['groupedByTable']) . '\',
remoteGroupColumn=\'' . $wo->cleanUserInput($row['remoteGroupColumn']) . '\',
localGroupColumn=\'' . $wo->cleanUserInput($row['localGroupColumn']) . '\',
tablesGroupedByThis=\'' . $wo->cleanUserInput($row['tablesGroupedByThis']) . '\',
hasActivationFlag=\'' . $wo->cleanUserInput($row['hasActivationFlag']) . '\',
availableForSearching=\'' . $wo->cleanUserInput($row['availableForSearching']) . '\',
hasGhostTable=\'' . $wo->cleanUserInput($row['hasGhostTable']) . '\',
hasDeletedColumn=\'' . $wo->cleanUserInput($row['hasDeletedColumn']) . '\',
<?php

// _genericMetaData.php
// CAUTION: TODO: Work in progress
require_once '../setup.inc.php';
$requestedAction = 'read';
$pageLocation = '1';
$browserTitle = 'MetaData';
$timers = array();
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
$paramNames = array('_tableName');
$in = $wo->getMultipleGetPost($paramNames);
//$in['where'] = "region='Greece'";
$tableName = $in['_tableName'];
$table = new Generic($tableName, $wo);
// requires view : __v_columnMetaData
$res = $table->showMetaData($in);
// if ( $tpl === FALSE ) { $wo->handleShowStopperError( print_r($errors,true) ); }
if ($res === FALSE) {
    // $wo->handleShowStopperError( $error );
    $tpl = array('browserTitle' => $browserTitle, 'content' => 'Sorry, smg went wrong', 'errorMessage' => nl2br($wo->getErrorsAsStringAndClear()), 'message' => '');
} else {
    $tpl = array('browserTitle' => $tableName . ' ' . $browserTitle, 'content' => $res, 'message' => '');
}
$wo->fetchApplicationFragment('structural/generic_template.php');
// UNREACHEABLE: As generic_template.php exits at its end!
// End of file _genericMetaData.php
Example #22
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;
 }
<?php

$__isAdminPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'read';
$pageLocation = '1';
$pageTitle = 'Administration Back End';
$tableName = 'pictures';
$columnName = 'picture';
$remoteIdColumn = 'itemId';
$wo = new WOOOF();
if (isset($_GET['itemId'])) {
    $_POST['itemId'] = $wo->cleanUserInput($_GET['itemId']);
} else {
    if (isset($_POST['itemId'])) {
        $_POST['itemId'] = $wo->cleanUserInput($_POST['itemId']);
    } else {
        die('severe error! no ITEM ID!');
    }
}
if (isset($_GET['table'])) {
    $_POST['table'] = $wo->cleanUserInput($_GET['table']);
} else {
    if (isset($_POST['table'])) {
        $_POST['table'] = $wo->cleanUserInput($_POST['table']);
    } else {
        die('severe error! no TABLE ID!');
    }
}
Example #24
0
<?php

$__isAdminPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'signOut';
$pageLocation = '1';
$pageTitle = 'Log out.';
$wo = new WOOOF(FALSE);
$wo->invalidateSession();
$wo->db->commit();
header('Location: index.php?' . $wo->getCurrentDateTime());
exit;
Example #25
0
    $obj->status = 'Error';
    $obj->errorNumber = $errorNumber;
    $obj->errorDescription = $errorDescription;
    echo json_encode($obj);
    exit;
}
if (!isset($_POST['action'])) {
    showErrorAndTerminate('2001', 'No action requested.');
} elseif ($_POST['action'] == 'wsRead' || $_POST['action'] == 'wsUpdate' || $_POST['action'] == 'wsDelete' || $_POST['action'] == 'wsInsert' && (!isset($_POST['__address']) || $_POST['__address'] == '')) {
    showErrorAndTerminate('2002', 'Address required to perform this specific action');
} elseif ((!isset($_POST['wsSessionIdentifier']) || ($_POST['wsSessionIdentifier'] = '')) && $_POST['action'] != 'wsLogin') {
    showErrorAndTerminate('2003', 'Not valid session supplied.');
}
$requestedAction = 'viewUncontroled';
$pageLocation = '3_webService';
$wo = new WOOOF();
if ($_POST['action'] == 'wsLogin') {
    $loginResult = FALSE;
    $rowForTest = $this->db->getRowByColumn('__users', 'loginName', $wo->cleanUserInput($_POST['username']));
    if (isset($rowForTest['id'])) {
        $hash = $wo->getPasswordHash($_POST['password'], $rowForTest['id']);
        $result = $this->db->query('select * from __users where binary loginName=\'' . $wo->cleanUserInput($rowForTest['loginName']) . '\' and binary loginPass=\'' . $hash . '\'');
        if (mysqli_num_rows($result)) {
            $userRow = $this->db->fetchAssoc($result);
            $userRow['loginPass'] = '******';
            $goOn = FALSE;
            do {
                $sid = 'ws' . WOOOF::randomString(38);
                $new_sid_result = $this->db->query("select * from __sessions where sessionId='" . $sid . "'");
                if (!mysqli_num_rows($new_sid_result)) {
                    $goOn = TRUE;
Example #26
0
<?php

$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
header('Content-Type: text/html; charset=utf-8');
$__isAdminPage = true;
$pageLocation = '1';
$requestedAction = 'users';
$wo = new WOOOF();
if (!$wo->constructedOk) {
    $wo->handleShowStopperError("1000 Failed to init WOOOF.");
}
$database = $wo->db->getDatabaseName();
$dbString = "{$database}@" . $wo->getConfigurationFor('databaseHost')[$wo->getConfigurationFor('defaultDBIndex')];
echo "<h1>Create users</h1>";
echo "<h2>Db: {$dbString}</h2>";
// array( array( 0: loginName, 1: password, 2:string[]|string (of role names) 3: id (may be '' ) 4: checkPassword (default true) ), ... )
// The following is an example. Edit as desired.
// PLEASE, SET THE FOLLOWING
$newUsers = array(array('sysJohnL', '12345678A', array('Normal User', 'System Operator')), array('sysApapanto', '12345678A', array('Normal User', 'System Operator')));
$newUsers = array();
// COMMENT AFTER CHANGING $newUsers above
$commitEach = false;
// set to true to save users one by one. set to false to save them all or none!
$succ = WOOOF_User::createMultipleUsers($wo, $newUsers, $newUserIds, $commitEach);
//var_dump($succ, $newUsers, $newUserIds);
echo "<h2>Given Users</h2>";
echo WOOOF_Util::do_dump($newUsers);
echo "<h2>Created Users</h2>";
echo WOOOF_Util::do_dump($newUserIds);
Example #27
0
<?php

$__isAdminPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'read';
$pageLocation = '1_roles';
$pageTitle = 'Administration Back End';
$wo = new WOOOF();
$wo->getResultByQuery('select * from __roles', FALSE);
foreach ($wo->resultRows as $value) {
    $content .= '';
}
require 'template.php';
Example #28
0
<?php

$__isAdminPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
function doTheExit()
{
    global $wo;
    $wo->db->commit();
    exit;
}
$requestedAction = 'read';
$pageLocation = '1';
$pageTitle = 'Administration Back End';
$wo = new WOOOF();
if (isset($_GET['__address'])) {
    $address = $wo->cleanUserInput($_GET['__address']);
} else {
    if (isset($_POST['__address'])) {
        $address = $wo->cleanUserInput($_POST['__address']);
    } else {
        $address = '1';
    }
}
if (isset($_GET['action'])) {
    $action = $wo->cleanUserInput($_GET['action']);
} else {
    if (isset($_POST['action'])) {
        $action = $wo->cleanUserInput($_POST['action']);
    } else {
Example #29
0
<?php

$__isSiteBuilderPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'edit';
$pageLocation = '1';
$wo = new WOOOF();
$table = new WOOOF_dataBaseTable($wo->db, $_GET['table']);
if (isset($_GET['submit']) && $_GET['submit'] == 'Submit') {
    for ($du = 0; $du < count($_GET['chk']); $du++) {
        $desr = $wo->db->query('select * from __columnMetaData where tableId=\'' . $table->getTableId() . '\' and id=\'' . $wo->cleanUserInput($_GET['chk'][$du]) . '\'');
        $de = $wo->db->fetchAssoc($desr);
        $c = '';
        //print_r($de);
        //echo 'INSERT INTO __columnMetaData set
        $wo->db->query('INSERT INTO __columnMetaData set 
id=\'' . $wo->db->getNewId('__columnMetaData') . '\',
tableId=\'' . $table->getTableId() . '\',
name=\'' . $wo->db->escape(trim($de['name' . $c] . $_GET['suplec'])) . '\',
description=\'' . $wo->db->escape(trim($de['description' . $c] . $_GET['suple'])) . '\',
type=\'' . $wo->db->escape(trim($de['type' . $c])) . '\',
length=\'' . $wo->db->escape(trim($de['length' . $c])) . '\',
notNull=\'' . $wo->db->escape(trim($de['notNull' . $c])) . '\',
presentationType=\'' . $wo->db->escape(trim($de['presentationType' . $c])) . '\',
isReadOnly=\'' . $wo->db->escape(trim($de['isReadOnly' . $c])) . '\',
isInvisible=\'' . $wo->db->escape(trim($de['isInvisible' . $c])) . '\',
appearsInLists=\'' . $wo->db->escape(trim($de['appearsInLists' . $c])) . '\',
isASearchableProperty=\'' . $wo->db->escape(trim($de['isASearchableProperty' . $c])) . '\',
isReadOnlyAfterFirstUpdate=\'' . $wo->db->escape(trim($de['isReadOnlyAfterFirstUpdate' . $c])) . '\',
Example #30
0
<?php

$__isSiteBuilderPage = true;
$__actualPath = dirname($_SERVER['SCRIPT_FILENAME']);
$__actualPath = dirname($__actualPath);
require_once $__actualPath . '/setup.inc.php';
$requestedAction = 'edit';
$pageLocation = '1';
$wo = new WOOOF();
$tm = WOOOF::getCurrentDateTime();
$database = $wo->db->getDatabaseName();
$table = trim($wo->db->escape($_GET["table"]));
$content = '<br/><a href="dbManager.php#' . $table . '" class="normalTextCyan">Back to Main Page</a><br/><br/>';
$result = $wo->db->query("show indexes from `{$table}`");
$content .= "<h3>Database Indexes for [{$table}]</h3>";
$content .= "<table width=\"100%\" border=\"0\" cellspacing=\"1\" align=\"left\" bgcolor=\"#FFFFFF\"><tr bgcolor=\"#000000\" class=\"normal_text_yellow\"><td>Table</td><td>Non_unique</td><td>Key_name</td><td>Seq_in_index</td><td>Column_name</td><td>Collation</td><td>Cardinality</td><td>Sub_part</td><td>Packed</td><td>Null</td><td>Index_type</td><td>Comment</td></tr>";
while ($row = $wo->db->fetchAssoc($result)) {
    $content .= "<tr bgcolor=\"#000000\" class=\"normal_text_cyan\"><td>{$row["Table"]}</td><td>{$row["Non_unique"]}</td><td>{$row["Key_name"]}</td><td>{$row["Seq_in_index"]}</td><td>{$row["Column_name"]}</td><td>{$row["Collation"]}</td><td>{$row["Cardinality"]}</td><td>{$row["Sub_part"]}</td><td>{$row["Packed"]}</td><td>{$row["Null"]}</td><td>{$row["Index_type"]}</td><td>{$row["Comment"]}</td></tr>\n";
}
$content .= "</table>";
$content .= "<br><br><br><br>";
$content .= "<h3>Indexes in MetaData not already in the DB for Table [" . $_GET["table"] . "]</h3>";
ob_start();
$res2 = WOOOF_MetaData::buildIndexesForTable($wo, $database, $table, false);
if ($res2 !== FALSE) {
    $content .= '<br>' . implode("<br>", $res2);
} else {
    $content .= '<br>' . '<h2>Error</h2>' . $wo->getErrorsAsStringAndClear();
}
ob_end_clean();
$content .= '