private function set_application() { $application = session_read('application'); if (!isset($application)) { $application = factory::create('application'); } $this->application = $application; }
private function set_application() { $application = session_read('application'); if (!isset($application)) { $application = factory::create('application'); } $this->application = $application; $election_id = get_http_var('election_id'); if ($election_id != 0) { session_write('election_id', $election_id); } }
function process() { //get rate types $search = factory::create("search"); $rate_types = $search->search("rate_type", array(array("1", "=", "1"))); $rate_values = array(); //get leaflet_id $leaflet_id = $this->data['hidLeafletId']; if (isset($leaflet_id) && $leaflet_id > 0 && $leaflet_id != '') { $name = session_read('analysis_name'); $email = session_read('analysis_email'); //loop through types foreach ($rate_types as $rate_type) { if (isset($this->data['hidRateValue_' . $rate_type->rate_type_id])) { $rate_value = factory::create('rate_value'); $rate_value->rate_type_id = $rate_type->rate_type_id; $rate_value->leaflet_id = $leaflet_id; $rate_value->value = $this->data['hidRateValue_' . $rate_type->rate_type_id]; $rate_value->user_name = $name; $rate_value->user_email = $email; array_push($rate_values, $rate_value); } else { trigger_error("Unknown rate type on rate page"); } } } else { trigger_error("No leaflet ID set on rate page"); } //save rate values foreach ($rate_values as $rate_value) { $rate_value->insert(); } //anything interesting? $interesting = trim($this->data['txtInteresting']); if (isset($interesting) && $interesting != '' && strlen($interesting) > 30) { $rate_interesting = factory::create('rate_interesting'); $rate_interesting->leaflet_id = $leaflet_id; $rate_interesting->description = $interesting; $rate_interesting->user_name = $name; $rate_interesting->user_email = $email; $rate_interesting->insert(); } redirect(WWW_SERVER . "/rate.php"); }
if (empty($_SESSION)) { //if there isn't a session, start one startSession(); //get feed data $request = 'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&q=' . $query . '&output=rss'; $data = file_get_contents($request); //create Feed object $today = date("Y-m-d H:i:s"); $myFeed = new Feed($id, $today, $data); $xml = simplexml_load_string($myFeed->Data); //create session with Feed data session_write($myFeed->ID, $myFeed->Data); } else { //if session already set //get session data and load it it $xml variable $data = session_read($id); $xml = simplexml_load_string($data); } //output feed data echo '<div class="panel panel-primary"><div class="panel-heading">'; echo '<h3 class="panel-title">' . $xml->channel->title . '</h3></div>'; echo '<div class="panel-body">' . $subCatDescp . '</div></div>'; foreach ($xml->channel->item as $story) { echo '<div class="panel panel-primary"><div class="panel-heading">'; echo '<h3 class="panel-title"><a href="' . $story->link . '">' . $story->title . '</a></h3></div>'; echo '<div class="panel-body">' . $story->description . '</div></div>'; } echo '<p><a href="index.php">BACK</a></p>'; //close session session_close(); get_footer();
function process() { if ($this->validate()) { //create & save leaflet $leaflet = factory::create('leaflet'); $leaflet->title = $this->data['txtTitle']; $leaflet->description = $this->data['txtDescription']; $leaflet->publisher_party_id = $this->data['ddlPartyBy']; $leaflet->postcode = $this->data['txtPostcode']; $leaflet->lng = $this->lng; $leaflet->lat = $this->lat; $leaflet->name = $this->data['txtName']; $leaflet->email = $this->data['txtEmail']; //date delivered $days = $this->data['ddlDelivered']; if ((int) $days > 30) { $days = 30; } $date = mktime(0, 0, 0, date("m"), date("d") - $days, date("Y")); $leaflet->date_delivered = mysql_date($date); if ($leaflet->insert()) { //save images $image_ids = session_read("image_ids"); $sequence = 1; foreach ($image_ids as $image_id) { $leaflet_image = factory::create("leaflet_image"); $leaflet_image->leaflet_id = $leaflet->leaflet_id; $leaflet_image->image_key = $image_id; $leaflet_image->sequence = $sequence; if (!$leaflet_image->insert()) { trigger_error("Unable to save leaflet image"); } $sequence++; } //TODO: move the code below into the leaflet object //save party attack foreach ($this->selected_party_attack_ids as $selected_party_attack_id) { $leaflet_party_attack = factory::create("leaflet_party_attack"); $leaflet_party_attack->leaflet_id = $leaflet->leaflet_id; $leaflet_party_attack->party_id = $selected_party_attack_id; if (!$leaflet_party_attack->insert()) { trigger_error("Unable to save leaflet party attack"); } } //save categories foreach ($this->selected_category_ids as $selected_category_id) { $leaflet_category = factory::create("leaflet_category"); $leaflet_category->leaflet_id = $leaflet->leaflet_id; $leaflet_category->category_id = $selected_category_id; if (!$leaflet_category->insert()) { trigger_error("Unable to save leaflet category"); } } //save tags $tag_string = trim($this->data['txtTags']); $tags = split(",", $tag_string); if ($tag_string != '' && isset($tag_string) && count($tags) > 0) { foreach ($tags as $tag) { $new_tag = factory::create('tag'); $new_tag->tag = $tag; if (!$new_tag->insert()) { trigger_error("Unable to save new tag"); } $leaflet_tag = factory::create('leaflet_tag'); $leaflet_tag->leaflet_id = $leaflet->leaflet_id; $leaflet_tag->tag_id = $new_tag->tag_id; if (!$leaflet_tag->insert()) { trigger_error("Unable to save leaflet/tag bridge"); } } } } else { trigger_error("Unable to save leaflet"); } //clear session session_delete('image_ids'); //redirect with callback provided if ($this->viewstate['callback']) { redirect($this->viewstate['callback'] . "?v1=" . WWW_SERVER . "/leaflet.php?q=" . $leaflet->leaflet_id); } else { redirect("leaflet.php?q=" . $leaflet->leaflet_id . "&m=1"); } } else { $this->bind(); $this->render(); } }
private function get_images_from_que() { $upload_key = session_read("upload_key"); $search = factory::create('search'); $image_que_items = $search->search("image_que", array(array("upload_key", "=", $upload_key)), "AND", null, array(array("uploaded_date", "DESC"))); return $image_que_items; }
function load() { if (!session_read('analysis_name') || !session_read('analysis_email')) { redirect(WWW_SERVER . '/analyze.php'); } }