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; }
if (($_FILES['file']['type'] == 'application/octet' || $_FILES['file']['type'] == 'application/pdf' || $_FILES['file']['type'] == 'application/x-pdf') && $fileInfo['extension'] != 'pdf' && $fileInfo['extension'] != 'PDF') { echo $_FILES['file']['type'] . ' ' . $fileInfo['extension'] . ' BAD file type. File deleted.<br/><br/>'; unlink($_FILES['file']['tmp_name']); exit; } $insertId = $wo->db->getNewId($tableName); $maxR = $wo->db->query('select max(ord) from ' . $tableName); $max = $wo->db->fetchRow($maxR); $max = $max[0] + 10; if (!isset($_POST['entry_date'])) { $entryDate = WOOOF::getCurrentDateTime(); } else { $entryDate = $wo->cleanUserInput($_POST['entry_date']); } if (file_exists($table->getTableName() . '.prePictureUploadOperations.inc.php')) { require $wo->getConfigurationFor($siteBasePath) . $wo->getConfigurationFor('adminIncludesDirectory') . $table->getTableName() . '.prePictureUploadOperations.inc.php'; } if ($_FILES['file']['type'] == 'application/octet' || $_FILES['file']['type'] == 'application/pdf' || $_FILES['file']['type'] == 'application/x-pdf') { $isPDF = ', isPDF=\'1\''; } else { $isPDF = ', isPDF=\'0\''; } move_uploaded_file($_FILES['file']['tmp_name'], $siteBasePath . $imagesRelativePath . $prefix . $_FILES['file']['name']); //WOOOF::cropCenterOfPicture($siteBasePath . $imagesRelativePath . $prefix . $_FILES['file']['name'], $siteBasePath . $imagesRelativePath . $prefix .'thumb_' . $_FILES['file']['name'], 120, 77); WOOOF::cropPictureAndResize($siteBasePath . $imagesRelativePath . $prefix . $_FILES['file']['name'], $siteBasePath . $imagesRelativePath . $prefix . 'thumb_' . $_FILES['file']['name'], 280, 180); $wo->db->query('insert into ' . $tableName . ' set ' . $columnName . '=\'' . $wo->db->escape($prefix . $_FILES['file']['name']) . '\', ' . $remoteIdColumn . ' = \'' . $_POST['itemId'] . '\', objectId=\'' . $_POST['table'] . '\', id = \'' . $insertId . '\', entryDate=\'' . $entryDate . '\', description=\'' . $wo->cleanUserInput($_POST['description']) . '\', description_en=\'' . $wo->cleanUserInput($_POST['description_en']) . '\', ord=\'' . $max . '\', thumbnail=\'' . $wo->cleanUserInput($prefix . 'thumb_' . $_FILES['file']['name']) . '\' ' . $isPDF); if (file_exists($table->getTableName() . '.postPictureUploadOperations.inc.php')) { require $wo->getConfigurationFor($siteBasePath) . $wo->getConfigurationFor('adminIncludesDirectory') . $table->getTableName() . '.postPictureUploadOperations.inc.php'; } if (!$wo->db->error()) { echo "File Upload OK! <br/><br/>";
} } } else { if ($action == 'edit' && count($addressItems) == 3) { $before = ''; $after = ''; $htmlFragment = $table->constructAdministrationFragment(); if ($table->getColumnForMultipleTemplates() != '') { if (trim($addressItems[2]) == '') { $htmlFragment[0] = file_get_contents($table->getTableName() . '.template.inc.php'); } else { $row = $wo->db->getRow($table->getTableName(), $wo->cleanUserInput($addressItems[2])); $htmlFragment[0] = file_get_contents($row[$table->getColumnForMultipleTemplate()] . '_' . $table->getTableName() . '.template.inc.php'); } } else { if (file_exists($wo->getConfigurationFor('siteBasePath') . $wo->getConfigurationFor('adminIncludesDirectory') . $table->getTableName() . '.template.inc.php')) { $htmlFragment[0] = file_get_contents($table->getTableName() . '.template.inc.php'); } } if ($table->getHasEmbededPictures() && trim($addressItems[2]) != '') { $before = '<div id="formHolder">'; $after = '</div><div id="pictureDiv"> <iframe id="resultArea" scroll="auto" frameborder="0" seamless="seamless" src="handlePictureUpload.php?table=' . $table->getTableId() . '&itemId=' . $addressItems[2] . '"></iframe></div>'; } if (trim($table->getAdminListMarkingCondition()) != '' && trim($addressItems[2]) != '') { $htmlFragment[0] = '<div class="previewEye"> <a href="' . $siteBaseURL . $table->getAdminListMarkingCondition() . '"> <img border="0" align="top" alt="Preview item." src="images/preview.png"> </a> </div>' . $htmlFragment[0]; }
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']); if ( $thePassword == FALSE ) {
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!'); } $cMD = $wo->db->fetchAssoc($result); $result = $wo->db->query('select * from ' . $tMD['tableName'] . ' where id=\'' . $pieces[3] . '\''); if (mysqli_num_rows($result) != 1) { die('Malformed file location. Specified FEET location is invalid!'); } $row = $wo->db->fetchAssoc($result); $result = $wo->db->query('select * from __externalFiles where id=\'' . $row[$cMD['name']] . '\''); if (mysqli_num_rows($result) != 1) { die('Malformed file location. Specified PAYLOAD location is invalid!'); } $fileData = $wo->db->fetchAssoc($result); $absoluteFilesRepositoryPath = $wo->getConfigurationFor('absoluteFilesRepositoryPath'); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($fileData['originalFileName'])); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($absoluteFilesRepositoryPath . $fileData['fileName'])); ob_clean(); flush(); readfile($absoluteFilesRepositoryPath . $fileData['fileName']); exit;
* ...../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; //( isset($_GET['textType']); $l_forceFromStart = isset($_GET['forceFromStart']); $tail = new Tail($l_filename, $l_textType, $l_forceFromStart);
public static function importMetaData(WOOOF $wo, $filename, $pathName = '') { echo '<h2>' . __CLASS__ . '.' . __FUNCTION__ . '</h2>'; if ($pathName == '') { $pathName = $wo->getConfigurationFor('debugLogPath'); } $contents = file_get_contents($pathName . $filename); if ($contents === FALSE) { $wo->logError(self::_ECP . "0050 Failed to read from file [{$pathName} . {$filename}]"); return FALSE; } $contentsArray = json_decode($contents, true); //echo WOOOF_Util::do_dump($contentsArray); die(); $version = $contentsArray['version']; if ($version > self::$version) { $wo->logError(self::_ECP . "0000 Version mismatch. Imported file is [{$version}] vs current class [" . self::$version . "]"); return FALSE; } $tables = $contentsArray['tables']; $columns = $contentsArray['columns']; $succ = self::createNewMetaDataTables($wo); if ($succ === FALSE) { return FALSE; } foreach ($tables as $aTableCols) { $sql = 'insert into __tableMetaDataNew set '; foreach ($aTableCols as $aCol => $aVal) { $sql .= "`{$aCol}` = '" . $wo->db->escape($aVal) . "', "; } $sql = substr($sql, 0, -2); $succ = $wo->db->query($sql); if (!$succ) { return FALSE; } } foreach ($columns as $aColumnCols) { $sql = 'insert into __columnMetaDataNew set '; foreach ($aColumnCols as $aCol => $aVal) { $sql .= "`{$aCol}` = '" . $wo->db->escape($aVal) . "', "; } $sql = substr($sql, 0, -2); $succ = $wo->db->query($sql); if (!$succ) { return FALSE; } } return true; }
<?php // index.php $executionTimers['wooof_1'][0] = microtime(true); require_once '../setup.inc.php'; $wo = new WOOOF(true, null, null, false); if (!$wo->constructedOk) { $wo->handleShowStopperError("1000 Failed to init WOOOF."); } wooofTimerStop('wooof_1'); $router = new AltoRouter(); $router->setBasePath(substr($wo->getConfigurationFor('siteBaseURL') . $wo->getConfigurationFor('publicSite'), 0, -1)); /*******************************************************************/ // the start/home // $router->map('GET', '/', function () use($wo) { VO_CtrlSite::home($wo); }, 'home'); require_once 'routes/movies.php'; require_once 'routes/profile.php'; require_once 'routes/registration.php'; require_once 'routes/evaluations.php'; /* ========================================================================== */ // Find and follow route based on URL // Handling of no matches, etc. inside the 'run' function. $router->run($wo); /* End of file index.php */
<?php // WOOOF Version: 0.12.39 // WOOOF MetaData Version: 0.12.39 // June 19, 2015 require_once '../setup.inc.php'; // WARNING !!! Running this script with the 'recreate=1' option // will ELLIMINATE ANY AND ALL DATA in WOOOF's // "system" tables if they already exist. Use With Caution (tm) $wo = new WOOOF(FALSE); if (!$wo->constructedOk) { $wo->handleShowStopperError("1000 Failed to init WOOOF."); } echo "<h1>Initialize DB with WOOOF tables/data</h1>"; if (!is_array($wo->getConfigurationFor('databaseName'))) { echo "No Database defined in the configuration options.<br>"; die('Aborting execution.'); } if ($wo->getConfigurationFor('databaseLog')[0] == true) { echo "Please set the databaseLog config option to false and try again.<br>"; die('Aborting execution.'); } $paramNames = array('recreate'); $in = $wo->getMultipleGetPost($paramNames); $recreate = $in['recreate'] == '1'; $dbName = $wo->getConfigurationFor('databaseName')[0]; $usersArray = null; // set to null to create default users: sysOp, notLoggedIn, admin, user1 /* * // Example. $usersArray = array(