return "<select>{$opts}</select>"; }; $genTextInput = function ($txt) { return "<input type='text' value='{$txt}'>"; }; foreach (Translation::translations() as $t) { //Fields to represent: $tId = $t['TranslationId']; $name = $t['TranslationName']; $bm = $t['BrowserMatch']; $img = $t['ImagePath']; $rfcL = $t['RfcLanguage']; $act = $t['Active']; //Transformations: $sLnk = "<a href='?action=translation&tId={$tId}' class='btn btn-info'>Translate</a>"; $dLnk = session_mayEdit() ? "<a href='query/translation.php?action=deleteTranslation&TranslationId={$tId}' class='btn btn-danger'>Delete</a>" : ''; $name = $genTextInput($name); $bm = $genTextInput($bm); $rfcL = $genRfcLangOptions($rfcL); $chk = $act == 1 ? ' checked="checked"' : ''; $act = "<input type='checkbox'{$chk}>"; //Row output: echo "<tr data-tId='{$tId}'>" . "<td class='name'>{$name}</td>" . "<td class='match'>{$bm}</td>" . "<td><img src='../{$img}' class='btn flag'></td>" . "<td>{$rfcL}</td>" . "<td>{$act}</td>" . "<td>{$sLnk}<input type='button' value='Save' class='btn save'>{$dLnk}</td>" . "</tr>"; } ?> </tbody> <tfoot><?php echo $thead; ?> </tfoot> </table>
/** @param $req @param $desc description */ public static function updateDescription($req, $desc) { //Removing leading/trailing whitespace: $desc = ltrim(rtrim($desc)); //Saving description: $dbConnection = Config::getConnection(); $req = $dbConnection->escape_string($req); $desc = $dbConnection->escape_string($desc); if (!session_mayEdit($dbConnection)) { return; } $q = "UPDATE Page_StaticDescription " . "SET Description = '{$desc}' " . "WHERE Req = '{$req}'"; $dbConnection->query($q); }
<?php require_once 'common.php'; /*Login check and procedure*/ if (!session_validate($dbConnection)) { header('LOCATION: index.php'); } if (!session_mayEdit($dbConnection)) { header('LOCATION: index.php'); } ?> <!DOCTYPE HTML> <html> <?php $title = "Import of .csv files."; $jsFiles = array('dbimport.js'); require_once 'head.php'; //<script type='application/javascript' src='js/main.js'></script> $max = ini_get_all(); $max = $max['max_file_uploads']; $max = __::min(array($max['global_value'], $max['local_value'])); ?> <body><?php require_once 'topmenu.php'; ?> <form class="form-inline"> <label> View the data for a LanguageFamily: <select name="languagefamily" id="select_languagefamily"></select> </label> </form>
require_once 'topmenu.php'; ?> <form class="form-inline" name="updatePassword" method="post" action="index.php?action=updatePassword"> <fieldset> <legend>Update password:</legend> <label> <input name="new" type="password" placeholder="new password"/> </label> <label> <input name="confirm" type="password" placeholder="confirm password"/> </label> <button type="submit" class="btn">Update</button> </fieldset> </form> <?php if (session_mayEdit()) { ?> <form id="addUser" class="form-horizontal"> <legend>Add user:</legend> <div class="control-group"> <label class="control-label" for="username">Username:</label> <div class="controls"> <input name="username" type="text" placeholder="Username"/> </div> </div> <div class="control-group"> <label class="control-label" for="password">Password:</label> <div class="controls"> <input name="password" type="text" placeholder="visible password"/> </div> </div>
<?php /* Setup and session verification */ chdir('..'); require_once 'common.php'; session_validate() or Config::error('403 Forbidden'); session_mayEdit() or Config::error('403 Forbidden'); //Actions: switch ($_GET['action']) { /** @return String html - options for LanguageFamilies to choose, with their Id's as attributes. */ case 'fetchLanguageFamilySelection': $q = 'SELECT CONCAT(StudyIx, FamilyIx, SubFamilyIx), StudyIx, FamilyIx, SubFamilyIx, Name FROM Studies'; $set = $dbConnection->query($q); while ($r = $set->fetch_row()) { $id = $r[0]; $six = $r[1]; $fix = $r[2]; $sfix = $r[3]; $name = $r[4]; echo "<option data-dbid='{$id}' data-studyix='{$six}' data-familyix='{$fix}' data-subfamilyix='{$sfix}'>{$name}</option>"; } break; /** @param studyix String - Interpretation as int @param familyix String - Interpretation as int @param subfamilyix String - Interpretation as int @param name String @return 'FAIL' | String html - new option for LanguageFamilies. */
require_once '../query/cacheProvider.php'; if (php_sapi_name() === 'cli') { //Translating $argv to $_GET,$_POST: if (count($argv) > 1) { $action = $argv[1]; switch ($action) { case 'import': if (count($argv) <= 2) { die('Usage: php -f ' . $argv[0] . " import <file>\n"); } $file = file_get_contents($argv[2]); break; } } } else { $allowed = session_validate() && session_mayEdit(); if (!$allowed) { //Special case for action=export: if (array_key_exists('ch1', $_GET) && array_key_exists('ch2', $_GET)) { $db = Config::getConnection(); $login = $dbConnection->escape_string($_GET['ch1']); $hash = $dbConnection->escape_string($_GET['ch2']); $q = "SELECT AccessEdit FROM Edit_Users" . " WHERE Login = '******' AND Hash = '{$hash}'"; if ($r = $db->query($q)->fetch_row()) { $allowed = $r[0] == 1; } unset($db, $login, $hash, $q, $r); } if (!$allowed) { Config::error('403 Forbidden'); die('403 Forbidden');
<?php chdir('..'); require_once 'common.php'; /* Checking for edit rights: */ if (!session_mayEdit()) { Config::error('You are not allowed to access this feature.'); } /* Ensuring an action is given: */ if (!isset($_GET['action'])) { Config::error('Missing get parameter:action!'); } /* Dealing with the action: */ switch ($_GET['action']) { /* Parameters: username, password, mayTranslate, mayEdit */ case 'create': $username = $dbConnection->escape_string($_POST['username']); $password = password_hash($_POST['password'], PASSWORD_BCRYPT); $mayTranslate = $_POST['mayTranslate'] === '1' ? '1' : '0'; $mayEdit = $_POST['mayEdit'] === '1' ? '1' : '0'; if (!$password) { //Fallback for md5: $password = md5($_POST['password']); } /* Checking that username is not taken: */ $q = "SELECT COUNT(*) FROM Edit_Users WHERE Login = '******'"; $r = $dbConnection->query($q)->fetch_row(); if ($r[0] > 0) { Config::error("Login '{$username}' already taken."); } /* Inserting new user: */
function showTable($tdata) { $head = '<tr><th>Description:</th><th>Original:</th><th>Translation:' . '<input type="button" value="Save all" ' . 'class="btn btn-primary pull-right saveAll"></th></tr>'; echo "<table class='display table table-bordered'>" . "<thead>{$head}</thead><tbody>"; $isAdmin = session_mayEdit() ? ' data-isadmin="1"' : ''; while (count($tdata) > 0) { $newTZ = array(); foreach ($tdata as $key => $field) { if (count($field) === 0) { continue; } echo "<tr>"; //Value to echo as row: $value = array_shift($field); //Description: $desc = $value['Description']; $req = array_key_exists('Req', $desc) ? $desc['Req'] : ''; $desc = array_key_exists('Description', $desc) ? $desc['Description'] : ''; //Shortening: $maxLen = 42; $short = preg_replace('/<[^<>]+>/', '', $desc); if (strlen($short) > $maxLen) { $short = substr($short, 0, $maxLen) . '…'; } //Encoding tooltip contents: $desc = preg_replace("/'/", '"', $desc); $desc = htmlspecialchars($desc); echo "<td class='description'{$isAdmin}' data-req='{$req}' data-html='true' data-container='body' data-title='{$desc}'>{$short}</td>"; //Title in case of search: $title = ''; if (array_key_exists('Match', $value)) { if ($value['Match'] !== $value['Original'] && $value['Match'] !== $value['Translation']) { $title = ' title="' . $value['Match'] . '"'; } } //Original: $orig = $value['Original']; if (array_key_exists('Study', $value)) { //Study in case of search $stud = $value['Study']; $orig = "{$stud}:<code>{$orig}</code>"; } else { $orig = "<code>{$orig}</code>"; } echo '<td class="original"' . $title . '>' . $orig . '<a class="btn pull-right copy-over">' . '<i class="icon-arrow-right"></i></a></td>'; //Translation: $trans = $value['Translation']; $prov = $trans['TranslationProvider']; $tId = $trans['TranslationId']; $pay = $trans['Payload']; $trans = $trans['Translation']; echo "<td data-tId='{$tId}' data-provider='{$prov}' data-payload='{$pay}'>" . "<input type='text' value='{$trans}' class='translation'>" . '<a class="btn save"><i class="icon-hdd"></i>Save</a>' . '</td>'; //Handling the exit condition: if (count($field) > 0) { $newTZ[$key] = $field; } echo "</tr>"; } $tdata = $newTZ; } echo "</tbody><tfoot>{$head}</tfoot></table>"; }