public function setPassword($value) { if (Val::requerido($value)) { $this->password = $value; } else { $this->Util()->setError(0, 'error', 'Contraseña :: Campo requerido'); } }
public function update() { global $database; if (!empty($_POST['id']) && ctype_digit($_POST['id'])) { $id = $_POST["id"]; $article = RJ_News::find_by_id($id); $val = new Val(); $error = ""; if ($val->maxlength($_POST['topic'], 500)) { $article->news_topic = htmlspecialchars($_POST['topic']); } else { $error .= "Topic Incorrect, "; } $article->news_content = htmlspecialchars($_POST['content']); $article->news_visible = $_POST['visible']; if (!empty($_FILES['image']['name'])) { $result = $this->upload; if ($result) { $article->news_image = $result; } else { $error .= "Image Incorrect"; } } if ($error == "") { if ($article->update()) { $_SESSION['adminmessage'] = "News successfully updated"; return true; } else { $_SESSION['adminmessage'] = "An error occured while connecting with database, please try again"; return false; } } else { $_SESSION['adminmessage'] = $error; return false; } } else { return false; } }
public static function initMulti($array, $keys) { foreach ($keys as $key => &$definition) { if (isset($definition[0])) { list($type, $default) = $definition; } else { $type = $definition; $default = false; } $definition = Val::init(isset($array[$key]) ? $array[$key] : null, $type, $default); } return $keys; }
public function setRepetirPassword($value, $passwd) { if (Val::requerido($value)) { if ($value != $passwd) { $this->Util()->setError(0, 'error', 'Las contraseñas no coinciden.'); } $this->repetirPassword = $value; } else { $this->Util()->setError(0, 'error', 'Has olvidado confirmar la contraseña.'); } }
/** * Count value occurrences in array * * @param array $arr * @param string $search * * @return int */ public static function occurrences(array $arr, $search) { $count = 0; $test = Val::hash($search); foreach ($arr as $val) { $compare = Val::hash($val); if ($test == $compare) { $count++; } } return $count; }
public function updateProduct() { if (isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['editor2']) && !empty($_POST['editor2']) && isset($_POST['prod_id'])) { $error = ""; $product = Product::find_by_id($_POST['prod_id']); $val = new Val(); if ($val->minlength($_POST['name'], 3) && $val->maxlength($_POST['name'], 255)) { $product->prod_name = strip_tags($_POST['name']); } else { $error .= "Name, "; } $product->prod_web_content = htmlspecialchars($_POST['editor2']); $product->prod_visible = $_POST['display']; if (isset($_POST['desc']) && !empty($_POST['desc'])) { $product->prod_desc = $_POST['desc']; } if (isset($_POST['series']) && !empty($_POST['series'])) { $product->prod_series = $_POST['series']; } if (isset($_POST['company']) && !empty($_POST['company'])) { $product->prod_company = $_POST['company']; } if (!empty($_FILES['image']['name'])) { $filepath = $this->upload_pix(); if ($filepath) { $product->prod_image = $filepath; } else { $error .= "Image, "; } } if (!empty($_FILES['pdf']['name'])) { $filepath = $this->upload_document(); if ($filepath) { $product->prod_pdf = $filepath; } else { $error .= "File, "; } } $product->prod_cat_id = $this->getCatID(); if ($error == "") { if ($product->update()) { $_SESSION['adminmessage'] = "Product updated successfully"; } else { $error = "An error occured please try again"; } } } else { $error = "Please fill all the required spaces"; } if ($error == "") { return true; } else { $_SESSION['adminmessage'] = $error; return false; } }