private function validate_presence($instance, $check) { if ($check && blank($this->value($instance))) { return tr("%1 is a required field!", $this->readable_attribute()); } return null; }
function missing($var_name) { if (blank($var_name) || !received($var_name)) { return TRUE; } return FALSE; }
/** * Store the page's title * * @param Doku_Event $event * @param $param */ public function handle_meta(Doku_Event $event, $param) { $id = $event->data['current']['last_change']['id']; $title = new Title($id); if (!blank($event->data['current']['title'])) { $title->setTitle($event->data['current']['title']); } else { $title->setTitle(null); } }
function create($map, $set, $xSize) { foreach ($map as $k => $value) { if (in_array($value, $set)) { spot(); list($n) = explode('-', $value); if ($n == $xSize - 1) { enter(); } } else { blank(); if ($value[0] == $xSize - 1) { enter(); } } } }
/** * Check the input variables and run the AJAX call * * @throws StructException * @return mixed */ protected function executeTypeAjax() { global $INPUT; $col = $INPUT->str('column'); if (blank($col)) { throw new StructException('No column provided'); } list($schema, $colname) = explode('.', $col, 2); if (blank($schema) || blank($colname)) { throw new StructException('Column format is wrong'); } $schema = new Schema($schema); if (!$schema->getId()) { throw new StructException('Unknown Schema'); } $column = $schema->findColumn($colname); if ($column === false) { throw new StructException('Column not found'); } return $column->getType()->handleAjax(); }
/** * Should carry out any processing required by the plugin. */ public function handle() { global $INPUT; global $ID; $assignments = new Assignments(); if ($INPUT->str('action') && $INPUT->arr('assignment') && checkSecurityToken()) { $assignment = $INPUT->arr('assignment'); if (!blank($assignment['assign']) && !blank($assignment['tbl'])) { if ($INPUT->str('action') === 'delete') { $ok = $assignments->removePattern($assignment['assign'], $assignment['tbl']); if (!$ok) { msg('failed to remove pattern', -1); } } else { if ($INPUT->str('action') === 'add') { if ($assignment['assign'][0] == '/') { if (@preg_match($assignment['assign'], null) === false) { msg('Invalid regular expression. Pattern not saved', -1); } else { $ok = $assignments->addPattern($assignment['assign'], $assignment['tbl']); if (!$ok) { msg('failed to add pattern', -1); } } } else { $ok = $assignments->addPattern($assignment['assign'], $assignment['tbl']); if (!$ok) { msg('failed to add pattern', -1); } } } } } send_redirect(wl($ID, array('do' => 'admin', 'page' => 'struct_assignments'), true, '&')); } }
function SqlClean($s) { if (gettype($s) != "string") { return $s; } $okay_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789"; $okay_chars .= "~`!@#\$%^&*()-_=+[]{}\\|;:,.<>/? "; $out = ""; while (!blank($s) && $s !== false) { $c = substr($s, 0, 1); $s = substr($s, 1); $w = stripos($okay_chars, $c); if ($w === FALSE) { $out .= ' '; } else { $out .= $c; } } return $out; }
$err = $err . "" . alert_m("Lastname field is blank", "yellow"); } if (blank($residence)) { $err = $err . "" . alert_m("Residence field is blank", "yellow"); } if (count($r1) >= 1) { $err = $err . "" . alert_m("Person already exists", "red"); } if (count($r2) >= 1) { //username $err = $err . "" . alert_m("Username is already been used", "red"); } if ($password != $repass) { $err = $err . "" . alert_m("Password does not match", "red"); } if (blank($err)) { $q1 = "insert into person(fname,mname,lname,gender,residence)values('{$fname}','{$mname}','{$lname}','{$sex}','{$residence}')"; query($conn, $q1); $q2 = "insert into employee(username,password,person_id)values('{$username}','{$password}',(select person_id from person where fname ='{$fname}' and mname='{$mname}' and lname = '{$lname}'))"; query($conn, $q2); header('Location: create_personnel_form.php'); } else { $title = "Register a new Personnel"; $desc = ""; $fname = input_form("Firstname", "fname", "text"); $mname = input_form("Middlename", "mname", "text"); $lname = input_form("Lastname", "lname", "text"); $sex = multi("Sex", "sex", array("Male", "Female"), array("male", "female"), "radio"); $residence = input_form("Residence", "residence", "area"); $username = input_form("Username", "username", "text"); $password = input_form("Password", "password", "password");
/** * Returns the translated hint for this type * * Uses the current language as determined by $conf['lang']. Falls back to english. * Returns empty string if no hint is configured * * @return string */ public function getTranslatedHint() { global $conf; $lang = $conf['lang']; if (!blank($this->config['hint'][$lang])) { return $this->config['hint'][$lang]; } if (!blank($this->config['hint']['en'])) { return $this->config['hint']['en']; } return ''; }
function VerifyBadgeFormat($BadgeID) { if (blank($BadgeID)) { return true; } if (strlen($BadgeID) != 4) { return false; } if (!is_alpha(substr($BadgeID, 0, 1))) { return false; } if (!is_digit(substr($BadgeID, 1, 1))) { return false; } if (!is_digit(substr($BadgeID, 2, 1))) { return false; } if (!is_digit(substr($BadgeID, 3, 1))) { return false; } return true; }
/** * Saves a wikitext by calling io_writeWikiPage. * Also directs changelog and attic updates. * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> * * @param string $id page id * @param string $text wikitext being saved * @param string $summary summary of text update * @param bool $minor mark this saved version as minor update */ function saveWikiText($id, $text, $summary, $minor = false) { /* Note to developers: This code is subtle and delicate. Test the behavior of the attic and changelog with dokuwiki and external edits after any changes. External edits change the wiki page directly without using php or dokuwiki. */ global $conf; global $lang; global $REV; /* @var Input $INPUT */ global $INPUT; // prepare data for event $svdta = array(); $svdta['id'] = $id; $svdta['file'] = wikiFN($id); $svdta['revertFrom'] = $REV; $svdta['oldRevision'] = @filemtime($svdta['file']); $svdta['newRevision'] = 0; $svdta['newContent'] = $text; $svdta['oldContent'] = rawWiki($id); $svdta['summary'] = $summary; $svdta['contentChanged'] = $svdta['newContent'] != $svdta['oldContent']; $svdta['changeInfo'] = ''; $svdta['changeType'] = DOKU_CHANGE_TYPE_EDIT; $svdta['sizechange'] = null; // select changelog line type if ($REV) { $svdta['changeType'] = DOKU_CHANGE_TYPE_REVERT; $svdta['changeInfo'] = $REV; } else { if (!file_exists($svdta['file'])) { $svdta['changeType'] = DOKU_CHANGE_TYPE_CREATE; } else { if (trim($text) == '') { // empty or whitespace only content deletes $svdta['changeType'] = DOKU_CHANGE_TYPE_DELETE; // autoset summary on deletion if (blank($svdta['summary'])) { $svdta['summary'] = $lang['deleted']; } } else { if ($minor && $conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { //minor edits only for logged in users $svdta['changeType'] = DOKU_CHANGE_TYPE_MINOR_EDIT; } } } } $event = new Doku_Event('COMMON_WIKIPAGE_SAVE', $svdta); if (!$event->advise_before()) { return; } // if the content has not been changed, no save happens (plugins may override this) if (!$svdta['contentChanged']) { return; } detectExternalEdit($id); if ($svdta['changeType'] == DOKU_CHANGE_TYPE_CREATE || $svdta['changeType'] == DOKU_CHANGE_TYPE_REVERT && !file_exists($svdta['file'])) { $filesize_old = 0; } else { $filesize_old = filesize($svdta['file']); } if ($svdta['changeType'] == DOKU_CHANGE_TYPE_DELETE) { // Send "update" event with empty data, so plugins can react to page deletion $data = array(array($svdta['file'], '', false), getNS($id), noNS($id), false); trigger_event('IO_WIKIPAGE_WRITE', $data); // pre-save deleted revision @touch($svdta['file']); clearstatcache(); $data['newRevision'] = saveOldRevision($id); // remove empty file @unlink($svdta['file']); $filesize_new = 0; // don't remove old meta info as it should be saved, plugins can use IO_WIKIPAGE_WRITE for removing their metadata... // purge non-persistant meta data p_purge_metadata($id); // remove empty namespaces io_sweepNS($id, 'datadir'); io_sweepNS($id, 'mediadir'); } else { // save file (namespace dir is created in io_writeWikiPage) io_writeWikiPage($svdta['file'], $svdta['newContent'], $id); // pre-save the revision, to keep the attic in sync $svdta['newRevision'] = saveOldRevision($id); $filesize_new = filesize($svdta['file']); } $svdta['sizechange'] = $filesize_new - $filesize_old; $event->advise_after(); addLogEntry($svdta['newRevision'], $svdta['id'], $svdta['changeType'], $svdta['summary'], $svdta['changeInfo'], null, $svdta['sizechange']); // send notify mails notify($svdta['id'], 'admin', $svdta['oldRevision'], $svdta['summary'], $minor); notify($svdta['id'], 'subscribers', $svdta['oldRevision'], $svdta['summary'], $minor); // update the purgefile (timestamp of the last time anything within the wiki was changed) io_saveFile($conf['cachedir'] . '/purgefile', time()); // if useheading is enabled, purge the cache of all linking pages if (useHeading('content')) { $pages = ft_backlinks($id, true); foreach ($pages as $page) { $cache = new cache_renderer($page, wikiFN($page), 'xhtml'); $cache->removeCache(); } } }
/** * Write the latest value from an entry in a data_ table to the corresponding multi_table * * @param string $table * @param int $colref */ protected function migrateSingleToMulti($table, $colref) { /** @noinspection SqlResolve */ $sqlSelect = "SELECT pid, rev, col{$colref} AS value FROM data_{$table} WHERE latest = 1"; $res = $this->sqlite->query($sqlSelect); $valueSet = $this->sqlite->res2arr($res); $this->sqlite->res_close($res); $valueString = array(); $arguments = array(); foreach ($valueSet as $values) { if (blank($values['value']) || trim($values['value']) == '') { continue; } $valueString[] = "(?, ?, ?, ?, ?)"; $arguments = array_merge($arguments, array($colref, $values['pid'], $values['rev'], 1, $values['value'])); } if (empty($valueString)) { return; } $valueString = join(',', $valueString); /** @noinspection SqlResolve */ $sqlInsert = "INSERT OR REPLACE INTO multi_{$table} (colref, pid, rev, row, value) VALUES {$valueString}"; $this->sqlite->query($sqlInsert, $arguments); }
protected function redirect_back($url = array(), $params = array()) { if (blank($_SERVER['HTTP_REFERER'])) { $this->redirect_to($url, $params); } $this->end_action_output_buffering(); header('Location: ' . $_SERVER['HTTP_REFERER']); exit; }
function coverage_summary($file, $array) { global $global_lines, $global_hits; $lines = explode("\n", file_get_contents($file)); foreach ($array as $linenum => $hits) { if ($hits == -1 && blank($lines[$linenum - 1])) { $array[$linenum] = 0; } } $hit = 0; $miss = 0; $blank = 0; foreach ($array as $value) { if ($value == -2) { $blank++; } if ($value == -1) { $miss++; } if ($value == 0) { $blank++; } if ($value >= 1) { $hit++; } } $global_lines += $hit + $miss; $global_hits += $hit; return $hit / ($hit + $miss); }
define('STEP_INSTRUCTIONS', 1); define('STEP_CSV', 2); $step = empty($_REQUEST['step']) ? STEP_INSTRUCTIONS : $_REQUEST['step']; switch ($step) { case STEP_CSV: try { $account = empty($_REQUEST['account']) ? 1 : $_REQUEST['account']; if (empty($_REQUEST['account'])) { $toolbox->smarty_addMessage('No Account', 'No account specified, all users included in CSV file.', NotificationMessage::WARNING); } $data = $toolbox->cache_get("{$account}/users"); if ($data === false) { $users = $toolbox->api_get("accounts/{$account}/users"); $data[] = array('id', 'user_id', 'login_id', 'full_name', 'sortable_name', 'short_name', 'email', 'status'); foreach ($users as $user) { $data[] = array(blank($user, 'id'), blank($user, 'sis_user_id'), blank($user, 'login_id'), blank($user, 'name'), blank($user, 'sortable_name'), blank($user, 'short_name'), blank($user, 'email'), 'active'); } $toolbox->cache_set("{$account}/users", $data, 15 * 60); } $toolbox->smarty_assign('csv', $toolbox->getCache()->getHierarchicalKey("{$account}/users")); $toolbox->smarty_assign('filename', date('Y-m-d_H-i-s') . "_account-{$account}_users"); $toolbox->smarty_addMessage('Ready for Download', '<code>users.csv</code> is ready and download should start automatically in a few seconds. Click the link below if the download does not start automatically.', NotificationMessage::GOOD); } catch (Exception $e) { $toolbox->exceptionErrorMessage($e); } /* flows into STEP_INSTRUCTIONS */ /* flows into STEP_INSTRUCTIONS */ case STEP_INSTRUCTIONS: default: $toolbox->smarty_assign('accounts', $toolbox->getAccountList()); $toolbox->smarty_assign('formHidden', array('step' => STEP_CSV));
function coalesce_blank_with_closure($value, $closure) { if (blank($value)) { return $closure(); } return $value; }
switch ($step) { case STEP_CSV: try { $account = empty($_REQUEST['account']) ? 1 : $_REQUEST['account']; if (empty($_REQUEST['account'])) { $toolbox->smarty_addMessage('No Account', 'No account specified, all users included in CSV file.', NotificationMessage::WARNING); } $data = $toolbox->cache_get("{$account}/users"); if ($data === false) { $users = $toolbox->api_get("accounts/{$account}/users", ['search_term' => '-advisor']); $data[] = ['id', 'user_id', 'login_id', 'password', 'full_name', 'sortable_name', 'short_name', 'email', 'status']; foreach ($users as $user) { $response = $toolbox->mysql_query("\n SELECT *\n FROM `observers`\n WHERE\n `id` = '{$user['id']}'\n LIMIT 1\n "); $row = $response->fetch_assoc(); if ($row) { $data[] = [blank($user, 'id'), blank($user, 'sis_user_id'), blank($user, 'login_id'), blank($row, 'password'), blank($user, 'name'), blank($user, 'sortable_name'), blank($user, 'short_name'), blank($user, 'email'), 'active']; } } $toolbox->cache_set("{$account}/users", $data); } $toolbox->smarty_assign(['csv' => basename(__FILE__, '.php') . "/{$account}/users", 'filename' => date('Y-m-d_H-i-s') . "_account-{$account}_observers"]); $toolbox->smarty_addMessage('Ready for Download', '<code>users.csv</code> is ready and download should start automatically " . "in a few seconds. Click the link below if the download does not start automatically.', NotificationMessage::SUCCESS); } catch (Exception $e) { $toolbox->smarty_addMessage('Error ' . $e->getCode(), $e->getMessage(), NotificationMessage::DANGER); } /* flows into STEP_INSTRUCTIONS */ /* flows into STEP_INSTRUCTIONS */ case STEP_INSTRUCTIONS: default: $toolbox->smarty_assign('formHidden', ['step' => STEP_CSV, 'account' => $_SESSION[ACCOUNT_ID]]);
public function save($returning = '', $set_where = false) { if (array_value($this->query, 'command', 'SELECT') == 'SELECT') { if (count(array_value($this->query, 'where', array()))) { $this->query['command'] = 'UPDATE'; } else { $this->query['command'] = 'INSERT'; } } if (blank($returning)) { $returning = array(); } else { $returning = preg_split('/[\\s"]*,[\\s"]*/', trim($returning, " \t\n\r\v\"")); } $returning_special = array(); if (in_array('*', $returning)) { $this->query['returning'] = '*'; } else { $update_special = array_keys(array_value($this->query, 'update_special', array())); foreach ($update_special as $name) { if (!in_array($name, $returning)) { $returning_special[] = $name; } } $this->query['returning'] = implode(', ', array_walk_copy(array_merge($returning, $returning_special), function (&$value, $key) { if (!preg_match('/[\\s\\(\\)]/', $value)) { $value = "\"{$value}\""; } })); } $result = $this->execute(); $this->query['returning'] = ''; if ($result && (count($returning) || count($returning_special))) { $returned = pg_fetch_assoc($this->result); if (is_array($returned)) { $this->data = array_merge($this->data ?: [], $returned); if ($set_where) { foreach ($returned as $field => $value) { if (in_array($field, $returning)) { $this->where("\"{$field}\" = ?", $value); } } } } } if (count(array_value($this->query, 'where', array()))) { $this->query['command'] = 'SELECT'; } return $result; }
function GetLogEvents($lines) { $output_events = array(); $current_event = array(); foreach ($lines as $line) { if (blank($line)) { continue; } $col1 = substr($line, 0, 1); if ($col1 != '+') { if (count($current_event) > 0) { $output_events[] = $current_event; } $current_event = array($line); continue; } $current_event[] = $line; } if (count($current_event) > 0) { $output_events[] = $current_event; } return $output_events; }
?> /delete/<?php echo $board['b_idx']; ?> ">글삭제</a> <br /> <ul class="c_list"> <?php foreach ($comment_list as $comment) { ?> <li class="<?php echo $comment['p_idx'] != 0 ? 'reply' : ''; ?> " style="padding-left:<?php echo blank($comment['c_depth']); ?> px;"> <?php if ($comment['deleted']) { ?> <p class="deleted">삭제된 댓글입니다.</p> <?php } else { ?> <div class="cmt_info"> <span class="name"><?php echo $comment['m_name']; ?> </span> <span class="date"><?php
/** * Import a schema. If a schema with the given name already exists, then it will be overwritten. Otherwise a new * schema will be created. * * @param string $schemaName The name of the schema * @param string $schemaJSON The structure of the schema as exportet by structs export functionality * @param string $user optional, the user that should be set in the schemas history. If blank, the current user is used. * @return bool|int the id of the new schema version or false on error. * * @throws dokuwiki\plugin\struct\meta\StructException */ public function importSchema($schemaName, $schemaJSON, $user = null) { $importer = new \dokuwiki\plugin\struct\meta\SchemaImporter($schemaName, $schemaJSON); if (!blank($user)) { $importer->setUser($user); } $ok = $importer->build(); return $ok; }
/** * Simple filter to remove blank values * * @param string $val * @return bool */ public function filter($val) { return !blank($val); }
/** * Checks if the current user may edit data in this schema * * @return bool */ public function isEditable() { global $USERINFO; if ($this->editors == '') { return true; } if (blank($_SERVER['REMOTE_USER'])) { return false; } if (auth_isadmin()) { return true; } return auth_isMember($this->editors, $_SERVER['REMOTE_USER'], $USERINFO['grps']); }
/** * Initialize internal state based on input variables * * @return bool if initialization was successfull */ protected function initFromInput() { global $INPUT; $this->schemadata = null; $this->column = null; $pid = $INPUT->str('pid'); list($table, $field) = explode('.', $INPUT->str('field')); if (blank($pid)) { return false; } if (blank($table)) { return false; } if (blank($field)) { return false; } $this->pid = $pid; try { $this->schemadata = AccessTable::byTableName($table, $pid); } catch (StructException $ignore) { return false; } $this->column = $this->schemadata->getSchema()->findColumn($field); if (!$this->column || !$this->column->isVisibleInEditor()) { $this->schemadata = null; $this->column = null; return false; } return true; }
/** * List matching namespaces and pages for the link wizard * * @author Andreas Gohr <*****@*****.**> */ function ajax_linkwiz() { global $conf; global $lang; global $INPUT; $q = ltrim(trim($INPUT->post->str('q')), ':'); $id = noNS($q); $ns = getNS($q); $ns = cleanID($ns); $id = cleanID($id); $nsd = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); if ($q && !$ns) { // use index to lookup matching pages $pages = ft_pageLookup($id, true); // result contains matches in pages and namespaces // we now extract the matching namespaces to show // them seperately $dirs = array(); foreach ($pages as $pid => $title) { if (strpos(noNS($pid), $id) === false) { // match was in the namespace $dirs[getNS($pid)] = 1; // assoc array avoids dupes } else { // it is a matching page, add it to the result $data[] = array('id' => $pid, 'title' => $title, 'type' => 'f'); } unset($pages[$pid]); } foreach ($dirs as $dir => $junk) { $data[] = array('id' => $dir, 'type' => 'd'); } } else { $opts = array('depth' => 1, 'listfiles' => true, 'listdirs' => true, 'pagesonly' => true, 'firsthead' => true, 'sneakyacl' => $conf['sneaky_index']); if ($id) { $opts['filematch'] = '^.*\\/' . $id; } if ($id) { $opts['dirmatch'] = '^.*\\/' . $id; } search($data, $conf['datadir'], 'search_universal', $opts, $nsd); // add back to upper if ($ns) { array_unshift($data, array('id' => getNS($ns), 'type' => 'u')); } } // fixme sort results in a useful way ? if (!count($data)) { echo $lang['nothingfound']; exit; } // output the found data $even = 1; foreach ($data as $item) { $even *= -1; //zebra if (($item['type'] == 'd' || $item['type'] == 'u') && $item['id']) { $item['id'] .= ':'; } $link = wl($item['id']); echo '<div class="' . ($even > 0 ? 'even' : 'odd') . ' type_' . $item['type'] . '">'; if ($item['type'] == 'u') { $name = $lang['upperns']; } else { $name = htmlspecialchars($item['id']); } echo '<a href="' . $link . '" title="' . htmlspecialchars($item['id']) . '" class="wikilink1">' . $name . '</a>'; if (!blank($item['title'])) { echo '<span>' . htmlspecialchars($item['title']) . '</span>'; } echo '</div>'; } }
/** * Shows the column headers with links to sort by column */ protected function renderColumnHeaders() { $this->renderer->tablerow_open(); // additional column for row numbers if ($this->data['rownumbers']) { $this->renderer->tableheader_open(); $this->renderer->cdata('#'); $this->renderer->tableheader_close(); } // show all headers foreach ($this->columns as $num => $column) { $header = ''; if (isset($this->data['headers'][$num])) { $header = $this->data['headers'][$num]; } // use field label if no header was set if (blank($header)) { if (is_a($column, 'dokuwiki\\plugin\\struct\\meta\\Column')) { $header = $column->getTranslatedLabel(); } else { $header = 'column ' . $num; // this should never happen } } // simple mode first if ($this->mode != 'xhtml') { $this->renderer->tableheader_open(); $this->renderer->cdata($header); $this->renderer->tableheader_close(); continue; } // still here? create custom header for more flexibility // width setting $width = ''; if (isset($data['widths'][$num]) && $data['widths'][$num] != '-') { $width = ' style="width: ' . $data['widths'][$num] . ';"'; // widths are prevalidated, no escape needed } // prepare data attribute for inline edits if (!is_a($column, '\\dokuwiki\\plugin\\struct\\meta\\PageColumn') && !is_a($column, '\\dokuwiki\\plugin\\struct\\meta\\RevisionColumn')) { $data = 'data-field="' . hsc($column->getFullQualifiedLabel()) . '"'; } else { $data = ''; } // sort indicator and link $sortclass = ''; $sorts = $this->searchConfig->getSorts(); $dynamic = $this->searchConfig->getDynamicParameters(); $dynamic->setSort($column, true); if (isset($sorts[$column->getFullQualifiedLabel()])) { list(, $currentSort) = $sorts[$column->getFullQualifiedLabel()]; if ($currentSort) { $sortclass = 'sort-down'; $dynamic->setSort($column, false); } else { $sortclass = 'sort-up'; } } $link = wl($this->id, $dynamic->getURLParameters()); // output XHTML header $this->renderer->doc .= "<th {$width} {$data}>"; $this->renderer->doc .= '<a href="' . $link . '" class="' . $sortclass . '" title="' . $this->helper->getLang('sort') . '">' . hsc($header) . '</a>'; $this->renderer->doc .= '</th>'; } $this->renderer->tablerow_close(); }
/** * @return bool is this dropdown configured to use a lookup? */ protected function usesLookup() { return !blank($this->config['schema']) && !blank($this->config['field']); }