} } //todo complete valid like pseudo $valid = $new_item->form_validation(); if (empty($valid->errors)) { if ($new_item->save()) { $session->message($class_name . $new_item->pseudo . " " . "has been {$text_post} with ID (" . $new_item->id . ")"); $session->ok(true); redirect_to($class_name::$page_manage); } else { $message($class_name . $new_item->pseudo . " " . "{$text_post1} failed"); } } } } else { if (request_is_get()) { if (isset($_GET['id'])) { $id = $_GET['id']; $get_item = $class_name::find_by_id($id); } } } ?> <?php $layout_context = "admin"; $active_menu = "admin"; $stylesheets = ""; $fluid_view = true; $javascript = ""; $incl_message_error = true;
function check_request() { // echo $_POST['project_id'][0]."<br>"; // echo $_POST['project_id'][1]."<br>"; // echo array_count_values($_POST['project_id']); if (request_is_post() && $_POST) { echo "<p>POST Request Value</p>" . "<br>"; echo "<pre>"; print_r($_POST); echo "</pre>"; } if (request_is_get() && $_GET) { echo "<p>GET Request Value</p>" . "<br>"; echo "<pre>"; print_r($_GET); echo "</pre>"; } }
public static function Create_form() { // $is_data=false // if($is_data){ // // $qr_str="?class_name=".get_called_class()."&"; // } else { // $qr_str='?'; // } if (isset($_GET['id'])) { // $post_link=$_SERVER["PHP_SELF"]."?id=".urldecode($_GET['id'].$qr_str); // $post_link=$_SERVER["PHP_SELF"].$qr_str."id=".urldecode($_GET['id']); $post_link = clean_query_string(static::$page_edit . "?id=" . urldecode($_GET['id'])); $page = "Update"; $page1 = "Update "; $text_post = "Updated"; $text_post1 = "update"; } else { $post_link = clean_query_string(static::$page_new); $page = "New"; $page1 = "Add New "; $text_post = "created"; $text_post1 = "creation"; } // var_dump($post_link); // echo "<pre>"; // // print_r($_SERVER['QUERY_STRING']); // echo BR; // print_r($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']); // echo BR; // print_r($_SERVER); // // echo "</pre>"; $output = ""; $link = "<a href='" . $_SERVER["PHP_SELF"] . " '>" . ' ' . $page1 . "' " . clean_query_string(static::$page_name) . "</a>"; $h4 = "<h4 class='text-center'>{$link} </h4>"; // $output.= $h4; $output .= "<div class =\"background_light_blue\">"; $output .= "<form name='form_ToDo' class='form-horizontal' method='post' action='{$post_link}'> "; $output .= "<fieldset id=\"login\" title=\"Client\"><legend class=\"text-center\" style=\"color: #0000ff\">" . $link . "</legend>"; if (request_is_get()) { if (isset($_GET['id'])) { $id = $_GET['id']; $get_item = static::find_by_id($id); $output .= static::construct_form($get_item, $_GET); } else { $output .= static::construct_form(false, $_GET); } } $output .= Form::form_id(); $output .= csrf_token_tag(); $output .= "</fieldset>"; $output .= " <div class=\"col-sm-offset-3 col-sm-7 col-xs-3\">\n <button type=\"submit\" name=\"submit\" class=\"btn btn-primary\">" . $page . ' ' . get_called_class() . "</button></div>"; $output .= "<div class=\"text-right \" ><a href=\"" . clean_query_string(static::$page_manage) . "\"" . " class=\"btn btn-info \" role=\"button\">Cancel</a></div>"; $output .= ""; $output .= " </form>"; $output .= "</div>"; return $output; }
$tmp_post = $_POST; //escape POST array; can be more complex foreach ($tmp_post as $key => $value) { $tmp_post[$key] = strip_tags($value); } //checking checkbox. if it's not checked then there is no value in POST array if (!isset($tmp_post['allow_mails'])) { $tmp_post['allow_mails'] = ""; } $ad = Ad::build($tmp_post); //create new object $ad->save(); //save object in database $object_storage[$ad->id] = $ad; //add object to storage } elseif (request_is_get()) { //пришло из ссылок if (isset($_GET['id']) && isset($_GET['mode'])) { $id = (int) $_GET['id']; $mode = strip_tags($_GET['mode']); if ($mode == "show") { $ad = $object_storage[$id]; $smarty->assign('ad_object', $ad); $smarty->assign('is_allow_mail', $ad->allow_mails == 1 ? 'checked' : ''); $smarty->assign('city_selected_id', $ad->location_id); $smarty->assign('category_selected_id', $ad->category_id); $edit_id = $ad->id; } elseif ($mode == "delete") { if (array_key_exists($id, $object_storage)) { $object_storage[$id]->delete(); unset($object_storage[$id]);