function insert_user($added_name, $password, $gradyear, $email, $type, $status = '') { if (!$password) { srand(time()); $password = rand(0, 999999); } if (!$email) { $email = $added_name . "@grinnell.edu"; } $crpassword = User::hashPassword($password); $dbh = db_connect(); $myrow = array("", $added_name, "", $crpassword, $email, "", "", "", "", "", "", $gradyear, "70", "14", "", "", $type, "", "", 0); add_row($dbh, "accounts", $myrow); mysql_query("UPDATE accounts SET created = NOW() WHERE\n\t\t\tusername = '******'"); $added_id = get_item($dbh, "userid", "accounts", "username", $added_name); mysql_query("INSERT INTO plans (user_id) VALUES ({$added_id})"); add_row($dbh, "display", array($added_id, "6", "7")); foreach (array(2, 4, 6, 8, 14, 15, 16) as $opt_link) { $myrow = array($added_id, $opt_link); add_row($dbh, "opt_links", $myrow); } $myrow = array($added_id, $status); add_row($dbh, "perms", $myrow); return array($password, $email); }
function add_action() { add_row(); $rows = get_all_rows(); $html = render_template("view/admin.php", array('rows' => $rows)); return $html; }
function display_table($name, $phone_number, $age, $address) { echo "<table><tbody>"; add_row("Name", $name); add_row("Phone number", $phone_number); add_row("Age", $age); add_row("Address", $address); echo "</tbody></table>"; }
function add_action() { add_row(); //$row= $sql = "SELECT * FROM pages ORDER BY id DESC"; $rows = get_all_rows($sql); $html = render_template("View/admin.php", array('rows' => $rows)); return $html; //require "View/admin.php"; }
/** * Create a new point node in the database. * This does not create any custom fields, use {@link update_graph_data} afterwards. * @param array $data The new node data * @return int The ID of the inserted WordPress node */ public function create($data) { $id = -1; $choices = get_field_object($this->_fields['node_type']['key'])['choices']; $post_title = $choices[$data['type']]; $post_content = ''; while (have_rows('point_nodes', 'option')) { the_row(); while (have_rows('post_content')) { the_row(); $post_content = get_sub_field($data['type']); } } $id = wp_insert_post(array('post_type' => $this->_postTypeName, 'post_title' => $post_title, 'post_content' => $post_content, 'post_status' => 'publish')); // Create stub graph_data repeater row so it will be ready for update_graph_data, // since that function can't handle creating new rows // @see http://www.advancedcustomfields.com/resources/update_sub_field/ add_row($this->_fields['graph_data']['key'], array('x' => 0, 'y' => 0, 'links' => array()), $id); return $id; }
include '../php/scripts.php'; ?> <?php include '../php/private_header.php'; ?> </head> <body> <div class="table"> <?php switch ($_POST['action']) { case 'add': #Function for add row add_row($connection, $table); break; case 'delete': #Function for delete row del_row($connection, $table, $_GET['id']); break; case 'edit': #Function for edit form print_update_page($connection, $table, $_GET['id']); exit; case 'update': #Function for update row update_row($connection, $table); break; default: break;
function add_row($idx, $CH_this, $level, $id) { global $template, $images, $lang; global $tree, $selected_id; // get data for this level $folder = $images['acp_forum']; $l_folder = $lang['Forum']; if ($tree['data'][$idx]['forum_status'] == FORUM_LOCKED) { $folder = $images['acp_forum_locked']; $l_folder = $lang['Forum_locked']; } if ($tree['type'][$idx] == POST_CAT_URL || !empty($tree['sub'][$CH_this])) { $folder = $images['acp_category']; $l_folder = $lang['Category']; if ($tree['data'][$idx]['forum_status'] == FORUM_LOCKED) { $folder = $images['acp_category_locked']; $l_folder = $lang['Forum_locked']; } } if (!empty($tree['data'][$idx]['forum_link'])) { $folder = $images['acp_link']; $l_folder = $lang['Forum_link']; } $icon = ''; if (!empty($tree['data'][$idx]['icon'])) { $icon = $tree['data'][$idx]['icon']; $icon_img = $icon; if (isset($images[$icon_img])) { $icon_img = $images[$icon_img]; } } $color = !$color; if ($selected_id == '') { $selected_id = 'Root'; } // Fields for javascript collapsing $s_hidden_fields = '<input type="hidden" id="sub-id-' . $tree['main'][$idx] . '-' . $id . '" value="' . $CH_this . '" />'; $s_hidden_fields .= '<input type="hidden" id="nr-sub-' . $CH_this . '" value="' . sizeof($tree['sub'][$CH_this]) . '" />'; $s_hidden_fields .= '<input type="hidden" id="collapsed-' . $CH_this . '" value="0" />'; $template->assign_block_vars('row', array('ID' => $CH_this, 'PARENT_ID' => $tree['main'][$idx], 'COLLAPSE_ID' => $id, 'LEVEL_WIDTH' => $level * 20, 'COLOR' => $color ? 'row1' : 'row2', 'FOLDER' => $folder, 'L_FOLDER' => $l_folder, 'ICON_IMG' => $icon_img != '' ? IP_ROOT_PATH . $icon_img : IP_ROOT_PATH . 'images/spacer.gif', 'ICON' => $icon, 'FORUM_NAME' => get_object_lang($CH_this, 'name', true), 'FORUM_DESC' => get_object_lang($CH_this, 'desc', true), 'TOPICS' => $tree['data'][$idx]['tree.forum_topics'], 'POSTS' => $tree['data'][$idx]['tree.forum_posts'], 'IS_CAT' => $tree['type'][$idx] == POST_CAT_URL, 'U_FORUM' => append_sid('admin_forums_extend.' . PHP_EXT . '?selected_id=' . $CH_this), 'U_ADD' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=create&main=' . $CH_this), 'U_EDIT' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=edit&fid=' . $CH_this), 'U_DELETE' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=delete&fid=' . $CH_this), 'U_RESYNC' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=resync&fid=' . $CH_this), 'U_MOVEUP' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=moveup&fid=' . $CH_this . '&selected_id=' . $selected_id), 'U_MOVEDW' => append_sid('admin_forums_extend.' . PHP_EXT . '?mode=movedw&fid=' . $CH_this . '&selected_id=' . $selected_id), 'U_PERMS' => append_sid('admin_forumauth.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $CH_this), 'S_HIDDEN_FIELDS' => $s_hidden_fields)); if (!empty($icon)) { $template->assign_block_vars('row.forum_icon', array()); } // is there some sub-levels for this level ? if (isset($tree['sub'][$CH_this])) { // build sub-levels links (collapsed) $links = ''; for ($i = 0; $i < sizeof($tree['sub'][$CH_this]); $i++) { $sub_this = $tree['sub'][$CH_this][$i]; $sub_idx = $tree['keys'][$sub_this]; $sub_folder = $images['acp_icon_minipost']; $sub_l_folder = $lang['Forum']; if ($tree['data'][$sub_idx]['forum_status'] == FORUM_LOCKED) { $sub_folder = $images['acp_icon_minipost_lock']; $sub_l_folder = $lang['Forum_locked']; } if ($tree['type'][$sub_idx] == POST_CAT_URL || !empty($tree['sub'][$sub_this])) { $sub_folder = $images['acp_icon_minicat']; $sub_l_folder = $lang['Category']; if ($tree['data'][$sub_idx]['forum_status'] == FORUM_LOCKED) { $sub_folder = $images['acp_icon_minicat_locked']; $sub_l_folder = $lang['Category_locked']; } } if (!empty($tree['data'][$sub_idx]['forum_link'])) { $sub_folder = $images['acp_icon_minilink']; $sub_l_folder = $lang['Forum_link']; } $link = '<a href="' . append_sid('admin_forums_extend.' . PHP_EXT . '?selected_id=' . $sub_this) . '" class="gensmall" style="text-decoration: none;">'; $link .= '<img src="' . $sub_folder . '" alt="' . $sub_l_folder . '" style="vertical-align: middle;" />'; $link .= ' ' . get_object_lang($sub_this, 'name', true) . '</a>'; $links .= (empty($links) ? '' : ', ') . $link; } $template->assign_block_vars('row.has_sublevels', array('LINKS' => $links)); // build sub-levels (expanded) for ($i = 0; $i < sizeof($tree['sub'][$CH_this]); $i++) { $sub_this = $tree['sub'][$CH_this][$i]; $sub_idx = $tree['keys'][$sub_this]; add_row($sub_idx, $sub_this, $level + 1, $i); } } else { $template->assign_block_vars('row.has_no_sublevels', array()); } }
header("Content-type: text/xml"); //encoding may differ in your case echo '<?xml version="1.0" encoding="iso-8859-1"?>'; //output update results echo "<data>"; $ids = explode(",", $_POST["ids"]); //for each row for ($i = 0; $i < sizeof($ids); $i++) { $rowId = $ids[$i]; //id or row which was updated $newId = $rowId; //will be used for insert operation $mode = $_POST[$rowId . "_!nativeeditor_status"]; //get request mode switch ($mode) { case "inserted": //row adding request $action = add_row($rowId); break; case "deleted": //row deleting request $action = delete_row($rowId); break; default: //row updating request $action = update_row($rowId); break; } echo "<action type='" . $action . "' sid='" . $rowId . "' tid='" . $newId . "'/>"; } echo "</data>";
$thispage->append($custom_style_form); $item = new TextInput('urcss', get_item($dbh, "stylesheet", "stylesheet", "userid", $idcookie)); $item->title = 'Custom Stylesheet URL:'; $item->cols = 60; $custom_style_form->append($item); $item = new HiddenInput('style', 'custom'); $custom_style_form->append($item); $item = new HiddenInput('part', '1'); $custom_style_form->append($item); $item = new SubmitInput('Submit'); $custom_style_form->append($item); } else { if (get_item($dbh, "stylesheet", "stylesheet", "userid", $idcookie)) { set_item($dbh, "stylesheet", "stylesheet", $urcss, "userid", $idcookie); } else { add_row($dbh, "stylesheet", array($idcookie, $urcss)); } $message = new InfoText('Style Set', 'Success'); $thispage->append($message); } } else { delete_item($dbh, "stylesheet", "userid", $idcookie); $style = $_POST['style']; set_item($dbh, "display", "style", $style, "userid", $idcookie); //set the style that they selected $message = new InfoText('Style Set', 'Success'); $thispage->append($message); } //if $style=custome, else } populate_page($thispage, $dbh, $idcookie);
$resDel = mysql_query($d_sql); return "delete"; } //include XML Header (as response will be in xml format) header("Content-type: text/xml"); //encoding may differ in your case echo '<?xml version="1.0" encoding="iso-8859-1"?>'; $mode = $_GET["!nativeeditor_status"]; //get request mode $rowId = $_GET["gr_id"]; //id or row which was updated $newId = $_GET["gr_id"]; //will be used for insert operation switch ($mode) { case "inserted": //row adding request $action = add_row(); break; case "deleted": //row deleting request $action = delete_row(); break; default: //row updating request $action = update_row(); break; } //output update results echo "<data>"; echo "<action type='" . $action . "' sid='" . $rowId . "' tid='" . $newId . "'/>"; echo "</data>";
<link rel="stylesheet" type="text/css" href="../css/style.css"> <title>Доходы</title> <?php include '../scripts/header.php'; ?> </head> <body> <div class="table"> <?php switch ($_POST['action']) { case 'add': #Function for add row add_row($connection, $table, $user); break; case 'delete': #Function for delete row del_row($connection, $table, $user, $_GET['id']); break; case 'edit': #Function for edit form print_update_page($connection, $table, $user, $_GET['id']); exit; case 'update': #Function for update row update_row($connection, $table, $user); break; default: break;
if ($json_vars['user'] != $_SERVER['PHP_AUTH_USER']) { $msg = "User name in request body doesn't match user name in authorization header"; throw new MwsAuthorizationException($msg); } } else { throw new MwsErrorCodeException("JSON body must contain a user field."); } list($http_code, $response_body) = submit_job($body); // Success codes are 201 and 202. Errors are 4xx... if ($http_code == 201 || $http_code == 202) { // Add the job id, user and output file to the database $json_vars = json_decode($response_body, true); $jobID = $json_vars['id']; $outfile = $_GET['outfile']; $pdo = open_db(); add_row($pdo, $jobID, $_SERVER['PHP_AUTH_USER'], $outfile); # TODO: Should we enforce the existance of outfile? } if ($http_code == 201) { header('HTTP/1.1 201 Created'); } elseif ($http_code == 202) { header('HTTP/1.1 202 Accepted'); } else { // should never happen... header(sprintf("HTTP/1.1 %d", $http_code)); } echo $response_body; } else { $msg = "Unrecognized request method: " . $_SERVER['REQUEST_METHOD']; throw new MwsErrorCodeException($msg); }
} else { $title = new HeadingText('Optional Links', 1); $thispage->append($title); if (isset($_REQUEST['submit'])) { //if list of available links gets too long, may have to add code in to parse //lists so only adding or deleting changing stuff, but for now easier to just //delete all and start again delete_item($dbh, "opt_links", "userid", $idcookie); //delete current links $mylinks = $_REQUEST['mylinks']; if (count($mylinks)) { //if values to add while (list($key, $items) = each($mylinks)) { $myrow = array($idcookie, $items); //set array to add to database add_row($dbh, "opt_links", $myrow); //add new row in database } } //added values if any //begin valid user display, done later in the page than usual so that the changes will take affect before page is displayed populate_page($thispage, $dbh, $idcookie); $thispage->append(new InfoText('Optional links changed.', 'Success')); } else { populate_page($thispage, $dbh, $idcookie); $selected_links = get_items($dbh, "linknum", "opt_links", "userid", $idcookie); //get the current set of links that the user has selected $o = 0; while ($selected_links[$o][0]) { $myselected[$selected_links[$o][0]] = " checked"; //set up so current links will show up in form as checked
<input type="submit" name="load" value="<?php i18n('rates/CHANGE_LANGUAGE'); ?> " class="submit" /> </div> </div> <?php $ncat = count($categories); foreach ($categories as $category) { $lastCat = !--$ncat; add_row($category, TYPE_CATEGORY, $catId, $catId == 0, $lastCat); $nrates = count($category["rates"]); $rateId = 0; foreach ($category["rates"] as $rate) { $lastRate = !--$nrates; add_row($rate, TYPE_RATE, $catId . '_' . $rateId, $rateId == 0, $lastRate); $rateId++; } //add_row_rate($catId, $rateId, "", ""); $catId++; } ?> <input id="ncat" type="hidden" name="ncat" value="<?php echo count($categories); ?> " /> <div class="submit" style="width:100%"> <input type="submit" name="save" value="<?php i18n('rates/SAVE_RATES'); ?> " class="submit" />
<?php error_reporting(E_ALL); ini_set('display_errors', 1); include "model.php"; $uri = $_SERVER["REQUEST_URI"]; echo "uri={$uri}"; if ('/mysite/index.php' == $uri || '/mysite/' == $uri) { $rows = get_all_rows(); require "view/list.php"; } elseif ('/mysite/index.php/admin' == $uri) { $rows = get_all_rows(); require "view/admin.php"; } elseif ('/mysite/index.php/add' == $uri) { $rows = add_row(); $rows = get_all_rows(); require "view/admin.php"; } ?>