/** * Execute a query at the database. * * @param string $sql Query to run. * @return RS_Base Returns a RecordSet object if there is a result to the query or TRUE if it was successfull, FALSE if a error occurred. */ function Query($sql) { if (!empty($GLOBALS['debug'])) { dv(5, 'QUERY SQL', $sql); } $rs = pg_query($this->link, $sql); if ($rs === FALSE) { return FALSE; } return new RS_PostgreSQL($this, $rs); }
/** * Output the field as a HTML Form or just for display. * * @param array $data Array containing the field values as 'field' => 'value'. * @param bool $form Show field as a INPUT object? */ function Show(&$data, $form = TRUE, $origin = FT_OR_DB) { global $vortex_msgs; if (!$form) { return; } echo "<tr class='ft_{$this->name}'><th>" . $this->label . '</th><td>'; $selected = array(); if (!empty($data)) { $sel = array('fields' => array($this->multi_rel), 'from' => array($this->multi_table)); $where = ''; $p = explode(',', $this->multi_key); foreach ($p as $f) { $where .= (empty($where) ? '' : ' AND ') . "({$f} = '{$data[$f]}')"; } if (!empty($where)) { $sel['where'] = $where; } if (!($rs = $this->db->Select($sel))) { return; } while ($row = $rs->Row()) { $selected[] = implode($this->separator, $row); } $rs->Close(); dv(5, 'Selected', $selected); } $sel = array('fields' => array($this->rel_key, $this->rel_label), 'from' => array($this->rel_table)); if (!empty($this->rel_order)) { $sel['order'] = $this->rel_order; } if (!($rs = $this->db->Select($sel))) { return; } echo "<select multiple name='{$this->name_form}[]'>\n"; while ($row = $rs->Row()) { echo "\t<option value='{$row[$this->rel_key]}'" . (in_array($row[$this->rel_key], $selected) ? ' selected' : '') . ">{$row[$this->rel_label]}</option>\n"; } echo "</select>\n"; echo "</td></tr>\n"; $rs->Close(); }
</div> <div class="inputblock"> <label for="body">Body</label> <br> <textarea cols="80" rows="10" name="body" id="body"><?php dv('body'); ?> </textarea> </div> <div class="inputblock"> <label for="analysis">Analysis / Remarks (optional)</label> <br> <textarea cols="80" rows="10" name="analysis" id="analysis"><?php dv('analysis'); ?> </textarea> </div> <div class="inputblock"> <input type="submit" value="Add Follow-up" name="submit"> <input type="hidden" value="<?php echo htmlentities($_REQUEST['i']); ?> " name="i"> </div> </fieldset> </form>
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die; } switch ($this->GetTemplateName()) { case 'ajax': if ($_REQUEST['time'] >= MIN_TIME) { try { $form = new \Domino\Forms\Feedback($_REQUEST, IBLOCK_FORM_FEEDBACK); $form->process(); $arResult['ERROR'] = 0; } catch (Exception $ex) { $arResult['ERROR'] = 1; } } $this->IncludeComponentTemplate(); break; default: try { if ($this->StartResultCache(COMPONENTS_CACHE_TTL)) { $this->SetResultCacheKeys(); $this->IncludeComponentTemplate(); } } catch (Exception $e) { dv($e->getMessage()); } break; }
function dm($object) { if (!is_object($object)) { dv($object); return; } dv(get_class($object) . ':'); $methods = get_class_methods($object); sort($methods); dv($methods); }
/** * Extract the field from $vars, test the field consistency and return it ready for database insertion. * * @param array $vars Array containing the FORM data (usually $_POST). * @return string Returns a string containing the parsed field data, or FALSE if the field is invalid. */ function Consist(&$vars) { if (!isset($_FILES[$this->name_form])) { if ($this->required) { return FALSE; } else { return "'" . $this->default . "'"; } } $file =& $_FILES[$this->name_form]; if (empty($file['name'])) { return "'" . $vars[$this->name_form . '_old_name'] . "'"; } $ext = substr(strrchr($file['name'], "."), 1); $fn = substr($file['name'], 0, -1 * (strlen($ext) + 1)); if (!empty($this->allowed_extensions)) { $ae = explode(':', $this->allowed_extensions); if (!in_array($ext, $ae)) { return FALSE; } } if (!empty($this->denied_extensions)) { $de = explode(':', $this->denied_extensions); if (in_array($ext, $de)) { return FALSE; } } $path = realpath($this->path); if ($this->delete_old && !empty($var[$this->name_form . '_old_name']) && file_exists($path . DIRECTORY_SEPARATOR . $var[$this->name_form . '_old_name'])) { unlink($path . DIRECTORY_SEPARATOR . $var[$this->name_form . '_old_name']); } $name = $file['name']; if ($this->rename || file_exists($path . DIRECTORY_SEPARATOR . $name) && !$this->overwrite) { $ra = array('%name%' => $fn, '%ext%' => $ext, '%r%' => rand(0, 9999)); list($ra['%d%'], $ra['%m%'], $ra['%y%'], $ra['%h%'], $ra['%i%'], $ra['%s%']) = explode(':', date('d:m:Y:H:i:s')); $name = strtr($this->rename_mask, $ra); if (file_exists($path . DIRECTORY_SEPARATOR . $name) && !$this->overwrite) { if (strpos($this->rename_mask, '%r%') !== FALSE) { while (file_exists($path . DIRECTORY_SEPARATOR . $name)) { $ra = array('%name%' => $fn, '%ext%' => $ext, '%r%' => rand(0, 9999)); list($ra['%d%'], $ra['%m%'], $ra['%y%'], $ra['%h%'], $ra['%i%'], $ra['%s%']) = explode(':', date('d:m:Y:H:i:s')); $name = strtr($this->rename_mask, $ra); } } else { return FALSE; } } } if (!move_uploaded_file($file['tmp_name'], $path . DIRECTORY_SEPARATOR . $name)) { return FALSE; } chmod($path . DIRECTORY_SEPARATOR . $name, $this->mode); if (!empty($GLOBALS['debug'])) { dv(1, 'PATH', $path); dv(1, 'NAME', $name); } return "'{$name}'"; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Infotic</title> <link rel="stylesheet" type="text/css" href="../css/menu.css"> <link rel="stylesheet" type="text/css" href="../css/administracion.css"> <?php include_once "properties/propiedades.php"; ?> <script type="text/javascript" src="validacion/validaciones.js"></script> </head> <?php if (isset($_POST['guardar'])) { include_once 'validacion/validaciones.php'; if (dv($_POST['rutAux']) == $_POST['dv']) { $a[0] = $_POST['rutAux'] . $_POST['dv']; $a[1] = $_POST['nombres']; $a[2] = $_POST['apellido_paterno']; $a[3] = $_POST['apellido_materno']; $a[4] = $_POST['sexo']; $a[5] = $_POST['insotec_escolaridad_id']; include_once '../controller/class_trabajador.php'; $trabajadores = new trabajador(); if ($trabajadores->addTrabajador($a)) { echo "<script>alert('Se han registrado correctamente los datos del trabajador.')</script>"; } else { echo "<script>alert('Se ha generado un problema al registrar el trabajador.')</script>"; } } else { echo "<script>alert('Rut no valido.')</script>";
/** * INSERT or UPDATE the data to the database. * * @param array $data Array containing all the data to save as 'field' => 'value'. * @return bool Returns TRUE on success, FALSE on error. */ function Save($data) { if (empty($data)) { $this->error = TB_ERR_EMPTY; return FALSE; } $values = array(); $where = ''; foreach ($this->fields as $field) { if (($value = $field->Consist($data)) === FALSE) { if (!empty($GLOBALS['debug'])) { dv(1, 'INCONSISTENT FIELD', $field); dv(1, 'DATA', $data); } $this->error = TB_ERR_INCONSIST; return FALSE; } if ($field->pkey) { $where .= (strlen($where) ? ' AND ' : '') . $field->Where($value); } else { isset($data[$field->name_form]) and !empty($field->name_db) and $values[$field->name_db] = $value; } } if (empty($where)) { if (empty($values)) { $this->error = TB_ERR_EMPTY; return FALSE; } if (!$this->db->Insert($this->name_db, $values)) { $this->error = TB_ERR_DB; return FALSE; } return TRUE; } if (empty($values)) { $this->error = TB_ERR_EMPTY; return FALSE; } if (!($rs = $this->db->Select(array('fields' => array('cnt' => 'COUNT(*)'), 'from' => array($this->name_db), 'where' => $where)))) { $this->error = TB_ERR_DB; return FALSE; } if (($row = $rs->Row()) === FALSE) { $this->error = TB_ERR_DB; return FALSE; } $rs->Close(); if ($row['cnt'] > 0) { if (!$this->db->Update($this->name_db, $values, $where)) { $this->error = TB_ERR_DB; return FALSE; } } else { if (!($rs = $this->db->Insert($this->name_db, $values))) { $this->error = TB_ERR_DB; return FALSE; } $id = $rs->LastId(); return $id > 0 ? $id : TRUE; } return TRUE; }
/** * Execute a DELETE query at the database. * * @param string $table Table to update. * @param string $where Where clause to the query. * @return RS_Base Returns a RecordSet object if there is a result to the query or FALSE if a error occurred. */ function Delete($table, $where = '') { $sw = ''; if (!empty($where)) { $sw = "WHERE {$where}"; } $sql = "DELETE FROM {$table} {$sw}"; if (!empty($GLOBALS['debug'])) { dv(3, 'DELETE SQL', $sql); } return $this->Query($sql); }
<div class="inputblock"> <label for="status">Status (ex: Still looking at logs)</label> <br> <input type="text" size="80" name="status" id="status" value="<?php dv('status'); ?> "> </div> <div class="inputblock"> <label for="hotlist">Hotlist (stuff to watch for + short desc) - one item per line, optional</label> <br> <textarea cols="80" rows="10" name="hotlist" id="hotlist" wrap="off"><?php dv('hotlist'); ?> </textarea> </div> </fieldset> <div class="inputblock"> <input type="submit" value="Add Incident" name="submit"> </div> </form> </body> </html>
function parseTitle($title) { $title = trim($title); preg_match('#^([^\\(]+)(\\([^\\)]+\\))?$#isxu', $title, $m); if (empty($m[2])) { $m[2] = ''; } $m[2] = trim($m[2]); $m[2] = trim($m[2], ')'); $m[2] = trim($m[2], '('); if (empty($m[1])) { dv($title); } return array(trim($m[1]), $m[2]); }
<?php dv(); ?> </tr> <tr> <td><p class="heading_copy"><a name="Requirements" id="Requirements"></a>Requirements:</p> <p class="body_Copy_Blue"> <a href="need_to_know.php">Click here</a> to see a list of requirements for participation. </p> <p><span class="body_Copy_Blue">To see the official rules for the challenge, <a href="offrules.php">click here</a>.</span></p> <p><a href="#Top" class="bodyCopy_list">Back to the Top</a> </p></td> </tr> <tr> <?php dv(); ?> </tr> <tr> <td><p class="heading_copy"><a name="OtherRules" id="OtherRules"></a>Other Important Rules:</p> <p class="body_Copy_Blue">As in real business, you will be expected to manage your responsibilities to your client and the Virtual Team Challenge. The simulation is structured to reward teams who work together so you should decide as a team the best way to tackle the Challenge. Also, as in the real business world, you are expected to behave in an appropriate and adult way while you are in the Challenge.<br/> <br /> If you have any questions about the rules, please refer to the "Frequently Asked Questions" (<a href="faq.php">FAQ</a>) section of this website.<br/> <br /> <!-- Questions about the rules of the simulation, or about the Virtual High School Team Challenge program, may also be directed to Deloitte advisors at <a href="mailto:teamchallenge@scholastic.com" title="mailto:teamchallenge@scholastic.com">teamchallenge@scholastic.com</a>.<br/>--> <br /> Technical questions should be emailed to <a href="mailto:<?php echo $support_email; ?> "><?php
// validar consistencia $error_consistencia = ""; if ($nombres == null || $nombres == "") { $error_consistencia .= "- Debes ingresar tus Nombres. \\n"; } if ($apellidos == null || $apellidos == "") { $error_consistencia .= "- Debes ingresar tus Apellidos. \\n"; } if (empty($rut)) { $error_consistencia .= "- Debes ingresar tu Rut. \\n"; } $stopchars = array(".", ","); $rut_sinpuntos = str_replace($stopchars, "", $rut); $rut = $rut_sinpuntos; $rut_separated = explode("-", $rut_sinpuntos); if ($rut == "" || strlen($rut) < 9 || dv($rut) != $rut_separated[1]) { $error_consistencia .= "- Rut inv\\u00e1lido.\\nRecuerda ingresarlo con gui\\u00f3n (ej: 12345678-9)\\n"; } if ($direccion == null || $direccion == "") { $error_consistencia .= "- Debes ingresar tu Direcci\\u00f3n. \\n"; } if ($comuna == null || $comuna == "") { $error_consistencia .= "- Debes ingresar tu Comuna. \\n"; } if ($ciudad == null || $ciudad == "") { $error_consistencia .= "- Debes ingresar tu Ciudad. \\n"; } if ($region == null || $region == "") { $error_consistencia .= "- Debes ingresar tu Regi\\u00f3n. \\n"; } if (!empty($error_consistencia)) {
/** * Get input from User Input * */ public static function guin($t = NULL, $fn = NULL, $ft = '', $fd = NULL, $opt = array()) { global $_GET, $_POST, $_REQUEST, $_PUT; // Get Input Field value from input Array $r = NULL; $av_t = array('post', 'get', 'request', 'put'); $av_ft = array('null', 'int', 'float', 'str', 'bool', 'array'); if (!empty($t) && in_array($t, $av_t) && !empty($fn) && !empty($ft) && in_array($ft, $av_ft)) { // $in= ($t == 'post')? $_POST : (($t == 'get')? $_GET : $_REQUEST); $in = $t == 'post' ? $_POST : ($t == 'get' ? $_GET : ($t == 'put' ? $_PUT : $_REQUEST)); $ex = array_key_exists($fn, $in); if ($ex) { $r = $in[$fn]; } else { $r = $fd; } if ($ft == 'null') { $r = NULL; } else { if ($ft == 'int') { $r = $ex && is_numeric($r) ? intval($r) : $r; } else { if ($ft == 'float') { $r = $ex && is_numeric($r) ? floatval($r) : $r; } else { if ($ft == 'str') { $r = $ex ? isset($r) && !is_array($r) ? trim(strval($r)) : $r : $r; } else { if ($ft == 'bool') { $r = $ex ? (bool) $r : $r; } else { if ($ft == 'array') { if (!is_array($r)) { $r = $fd; } } else { $r = NULL; } } } } } } if (!empty($opt) && is_array($opt)) { if (array_key_exists('mfunc', $opt) && count($opt['mfunc']) > 0) { foreach ($opt['mfunc'] as $cf) { $r = $cf($r); } } } dv($in); } dvs($av_t, $av_ft, $fn, $ft, $fd, $opt); return $r; }