diff options
author | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-04-13 19:23:59 +0200 |
---|---|---|
committer | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-04-13 19:23:59 +0200 |
commit | 0c437c746a8f964bf59ae9808a2b990d144bc39e (patch) | |
tree | f3fb6fd929ccfe834880c8430a939d105cc9109c /includes | |
parent | 512511df29423fc943b566bc20d997cd20ee9e03 (diff) | |
download | gigologadmin-0c437c746a8f964bf59ae9808a2b990d144bc39e.tar.gz gigologadmin-0c437c746a8f964bf59ae9808a2b990d144bc39e.tar.bz2 gigologadmin-0c437c746a8f964bf59ae9808a2b990d144bc39e.zip |
Fixes of LF and extra spaces done by ATOM
Diffstat (limited to 'includes')
-rw-r--r-- | includes/admin/helpfiles/instr_photog.php | 2 | ||||
-rw-r--r-- | includes/admin/helpfiles/instr_reviewers.php | 2 | ||||
-rw-r--r-- | includes/admin/helpfiles/instrunctions.php | 2 | ||||
-rw-r--r-- | includes/admin/views/giglog_admin_page.php | 64 | ||||
-rw-r--r-- | includes/admin/views/giglog_import_gigs.php | 10 | ||||
-rw-r--r-- | includes/concert.php | 314 | ||||
-rw-r--r-- | includes/public/shortcodes/giglog_bands.php | 228 | ||||
-rw-r--r-- | includes/public/shortcodes/giglog_display_unprocessed.php | 306 | ||||
-rw-r--r-- | includes/public/shortcodes/giglog_process_files.php | 134 |
9 files changed, 531 insertions, 531 deletions
diff --git a/includes/admin/helpfiles/instr_photog.php b/includes/admin/helpfiles/instr_photog.php index 34af4dd..510b95d 100644 --- a/includes/admin/helpfiles/instr_photog.php +++ b/includes/admin/helpfiles/instr_photog.php @@ -294,4 +294,4 @@ if ( !class_exists( 'Instructions_Photogs' ) ) { -?>
\ No newline at end of file +?> diff --git a/includes/admin/helpfiles/instr_reviewers.php b/includes/admin/helpfiles/instr_reviewers.php index 51c2c48..b8d43d5 100644 --- a/includes/admin/helpfiles/instr_reviewers.php +++ b/includes/admin/helpfiles/instr_reviewers.php @@ -113,4 +113,4 @@ if ( !class_exists( 'Instructions_Reviewers' ) ) { } -?>
\ No newline at end of file +?> diff --git a/includes/admin/helpfiles/instrunctions.php b/includes/admin/helpfiles/instrunctions.php index 3f5c49b..52019b5 100644 --- a/includes/admin/helpfiles/instrunctions.php +++ b/includes/admin/helpfiles/instrunctions.php @@ -55,4 +55,4 @@ Pick a help file to go through } -?>
\ No newline at end of file +?> diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 8deba81..3f43873 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -41,8 +41,8 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { <p><?php echo GiglogAdmin_AdminPage::get_filters() ?></p> <p><?php echo GiglogAdmin_AdminPage::get_concerts() ?></p> - </div> - <?php + </div> + <?php if (current_user_can('administrator')) echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo? } @@ -84,7 +84,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $select .= '</select>'; return($select); } - + static function get_filters() { $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); @@ -133,12 +133,12 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $select; } - + static function editforms() { global $wpdb; - $cid = filter_input(INPUT_POST, "cid"); - $c = GiglogAdmin_Concert::find_or_create($cid,'','','','',''); - + $cid = filter_input(INPUT_POST, "cid"); + $c = GiglogAdmin_Concert::find_or_create($cid,'','','','',''); + $content='<form method="POST" action="" class="concedit" > Form to create/edit concerts, bands, venues<br>' .'<input type="hidden" name="pid" value="' .$c->id(). '" />' .'<label for="band">Band:</label>'.GiglogAdmin_AdminPage::get_allbands($c->band()).'<br>' @@ -148,21 +148,21 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { .'<label for="eventurl">Event link:</label><input type="text" id="eventurl" name="eventurl" value="'.$c->eventlink().'"><br>'; if ($c->band()=='') //actions differ if we update or create a concert, hence two buttons needed $content.='<p><input type="submit" name="newconcert" value="Create New Concert"></p>'; - else + else $content.='<p><input type="submit" name="editconcert" value="Edit Concert"></p>'; $content.='</form>'; - + $content.='<form method="POST" action="" class="bandedit" ><br>' .'<label for="bandname">Band Name:</label><input type="text" id="bandname" name="bandname"><br>' .'<label for="eventurl">Band Country:</label>'.GiglogAdmin_AdminPage::get_countries().'<br>' .'<p><input type="submit" name="newband" value="Create New Band"></p>' .'</form>'; - + $content.='<form method="POST" action="" class="bandedit" ><br>' .'<label for="bandname">Venue Name:</label><input type="text" id="venuename" name="venuename"><br>' .'<label for="eventurl">Venue City:</label><input type="text" id="venuecity" name="venuecity"><br>' .'<p><input type="submit" name="newvenue" value="Create New Venue"></p>' - .'</form>'; + .'</form>'; return $content; } @@ -290,7 +290,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { // return the table return $content; } - + static function update() { @@ -330,49 +330,49 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { //$url2=$_SERVER['REQUEST_URI']; //doesn't seem to be needed actually, leaving here just in case //header("Refresh: 1; URL=$url2"); //reload page } - + if(isset($_POST['newconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo '<script language="javascript">alert("You are missing a value, concert was not created"); </script>'; - else - { + else + { GiglogAdmin_Concert::create($_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo '<script language="javascript">alert("Yey, concert created"); </script>'; - } + } } if(isset($_POST['editconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo '<script language="javascript">alert("You are missing a value, concert was not updated"); </script>'; - else - { + else + { GiglogAdmin_Concert::updatec($_POST['pid'],$_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo '<script language="javascript">alert("Yey, concert updated"); </script>'; - } - } - + } + } + if(isset($_POST['newband'])) { - IF (empty($_POST['bandname'])) //country is not checked as it is set to Norway by default + IF (empty($_POST['bandname'])) //country is not checked as it is set to Norway by default echo '<script language="javascript">alert("You are missing a value, band was not created"); </script>'; - else - { - GiglogAdmin_Band::create($_POST['bandname'],$_POST['selectcountry']); + else + { + GiglogAdmin_Band::create($_POST['bandname'],$_POST['selectcountry']); echo '<script language="javascript">alert("Yey, band created"); </script>'; - } + } } - + if(isset($_POST['newvenue'])) { IF (empty($_POST['venuename']) || empty($_POST['venuecity'])) echo '<script language="javascript">alert("You are missing a value, venue was not created"); </script>'; - else - { - GiglogAdmin_Venue::create($_POST['venuename'],$_POST['venuecity']); + else + { + GiglogAdmin_Venue::create($_POST['venuename'],$_POST['venuecity']); echo '<script language="javascript">alert("Yey, venue created"); </script>'; - } - } + } + } } static function assignconcert($p1, $c) diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php index d0520e7..ae34c2d 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -104,8 +104,8 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { $newconcert[1], $condate, $ticketlink, - $eventlink); - + $eventlink); + error_log( 'NEW CONCERT ADDED: ' . ' ID: ' . $id->id() . ' BAND ' . $band . ' with band ID ' . $newconcert[0] @@ -115,14 +115,14 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { . ', Event LINK ' . $eventlink); GiglogAdmin_Concertlogs::add($id->id()); - - /*the last line can be replaced by a trigger + + /*the last line can be replaced by a trigger CREATE TRIGGER `insertIntoPhotoLogs` AFTER INSERT ON `wpg_concerts` FOR EACH ROW INSERT INTO wpg_concertlogs ( wpg_concertlogs.id, wpg_concertlogs.wpgcl_concertid, wpg_concertlogs.wpgcl_status) - + VALUES (null, new.id, 1) */ diff --git a/includes/concert.php b/includes/concert.php index 5c50d43..e7165cc 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -1,157 +1,157 @@ -<?php
-/*
- * Copyright (C) 2021 Harald Eilertsen, Andrea Chirulescu
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-if ( !class_exists('GiglogAdmin_Concert') ) {
- class GiglogAdmin_Concert
- {
- private $id;
- private $band;
- private $venue;
- private $cdate;
- private $tickets;
- private $eventlink;
-
- /*
- * Constructs a new venue object from an array of attributes.
- * The attributes are expected to be named as in the database,
- * so this constructor can be used to construct the object
- * directly from the database row.
- */
- private function __construct($attrs)
- {
- $this->id = isset($attrs->id) ? $attrs->id : NULL;
- $this->band = isset($attrs->band) ? $attrs->band : NULL;
- $this->venue = isset($attrs->venue) ? $attrs->venue : NULL;
- $this->cdate = isset($attrs->wpgconcert_date) ? $attrs->wpgconcert_date : NULL;
- $this->tickets = isset($attrs->wpgconcert_tickets) ? $attrs->wpgconcert_tickets : NULL;
- $this->eventlink = isset($attrs->wpgconcert_event) ? $attrs->wpgconcert_event : NULL;
- }
-
- static function find_or_create($id,$band, $venue, $cdate, $ticketlink, $eventlink)
- {
- global $wpdb;
- if($id)
- {
- $csql = 'SELECT * FROM wpg_concerts WHERE id="' . $id . '"';
- $results = $wpdb->get_results($csql);
-
- if ($results)
- return new GiglogAdmin_Concert($results[0]);
- }
- else {
-
- return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink);
- }
- }
-
- public static function create($band, $venue, $cdate, $ticketlink, $eventlink)
- {
- $attrs = new stdClass();
- $attrs->id = '';
- $attrs->band = $band;
- $attrs->venue = $venue;
- $attrs->wpgconcert_date = $cdate;
- $attrs->wpgconcert_tickets = $ticketlink;
- $attrs->wpgconcert_event = $eventlink;
- $cid = new GiglogAdmin_Concert($attrs);
- $cid->save();
-
- return $cid;
- }
-
-
- public static function updatec($id, $band, $venue, $cdate, $ticketlink, $eventlink)
- {
- global $wpdb;
-
- $res = $wpdb->update('wpg_concerts', array(
- 'band' => $band,
- 'venue' => $venue,
- 'wpgconcert_date' => $cdate,
- 'wpgconcert_tickets' => $ticketlink,
- 'wpgconcert_event' => $eventlink
- ),
- array('id' => $id)
- );
-
- if ( !$res ) {
- // exit( var_dump( $wpdb->last_query ) ); //for onscreen debugging when needed
- error_log( __CLASS__ . '::' . __FUNCTION__ . ": {$wpdb->last_error}");
- die;
- }
-
- return ($wpdb->last_error); //not sure what to return here?
- }
-
- public static function get($band, $venue, $date)
- {
- global $wpdb;
-
- $sql = 'SELECT id from wpg_concerts'
- . ' where band = ' . $band
- . ' and venue = ' . $venue
- . ' and wpgconcert_date ="' . $date . '"';
-
- error_log(__CLASS__ . '::' . __FUNCTION__ . ": {$sql}");
- return $wpdb->get_results($sql);
- }
-
- public function save()
- {
- global $wpdb;
-
- $wpdb->insert('wpg_concerts', array(
- 'id' => '',
- 'band' => $this->band,
- 'venue' => $this->venue,
- 'wpgconcert_date' => $this->cdate,
- 'wpgconcert_tickets' => $this->tickets,
- 'wpgconcert_event' => $this->eventlink
- ));
-
- $this->id = $wpdb->insert_id;
- }
-
- public function id()
- {
- return $this->id;
- }
-
- public function band()
- {
- return $this->band;
- }
- public function venue()
- {
- return $this->venue;
- }
- public function cdate()
- {
- return $this->cdate;
- }
- public function tickets()
- {
- return $this->tickets;
- }
- public function eventlink()
- {
- return $this->eventlink;
- }
- }
-}
-?>
\ No newline at end of file +<?php +/* + * Copyright (C) 2021 Harald Eilertsen, Andrea Chirulescu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +if ( !class_exists('GiglogAdmin_Concert') ) { + class GiglogAdmin_Concert + { + private $id; + private $band; + private $venue; + private $cdate; + private $tickets; + private $eventlink; + + /* + * Constructs a new venue object from an array of attributes. + * The attributes are expected to be named as in the database, + * so this constructor can be used to construct the object + * directly from the database row. + */ + private function __construct($attrs) + { + $this->id = isset($attrs->id) ? $attrs->id : NULL; + $this->band = isset($attrs->band) ? $attrs->band : NULL; + $this->venue = isset($attrs->venue) ? $attrs->venue : NULL; + $this->cdate = isset($attrs->wpgconcert_date) ? $attrs->wpgconcert_date : NULL; + $this->tickets = isset($attrs->wpgconcert_tickets) ? $attrs->wpgconcert_tickets : NULL; + $this->eventlink = isset($attrs->wpgconcert_event) ? $attrs->wpgconcert_event : NULL; + } + + static function find_or_create($id,$band, $venue, $cdate, $ticketlink, $eventlink) + { + global $wpdb; + if($id) + { + $csql = 'SELECT * FROM wpg_concerts WHERE id="' . $id . '"'; + $results = $wpdb->get_results($csql); + + if ($results) + return new GiglogAdmin_Concert($results[0]); + } + else { + + return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink); + } + } + + public static function create($band, $venue, $cdate, $ticketlink, $eventlink) + { + $attrs = new stdClass(); + $attrs->id = ''; + $attrs->band = $band; + $attrs->venue = $venue; + $attrs->wpgconcert_date = $cdate; + $attrs->wpgconcert_tickets = $ticketlink; + $attrs->wpgconcert_event = $eventlink; + $cid = new GiglogAdmin_Concert($attrs); + $cid->save(); + + return $cid; + } + + + public static function updatec($id, $band, $venue, $cdate, $ticketlink, $eventlink) + { + global $wpdb; + + $res = $wpdb->update('wpg_concerts', array( + 'band' => $band, + 'venue' => $venue, + 'wpgconcert_date' => $cdate, + 'wpgconcert_tickets' => $ticketlink, + 'wpgconcert_event' => $eventlink + ), + array('id' => $id) + ); + + if ( !$res ) { + // exit( var_dump( $wpdb->last_query ) ); //for onscreen debugging when needed + error_log( __CLASS__ . '::' . __FUNCTION__ . ": {$wpdb->last_error}"); + die; + } + + return ($wpdb->last_error); //not sure what to return here? + } + + public static function get($band, $venue, $date) + { + global $wpdb; + + $sql = 'SELECT id from wpg_concerts' + . ' where band = ' . $band + . ' and venue = ' . $venue + . ' and wpgconcert_date ="' . $date . '"'; + + error_log(__CLASS__ . '::' . __FUNCTION__ . ": {$sql}"); + return $wpdb->get_results($sql); + } + + public function save() + { + global $wpdb; + + $wpdb->insert('wpg_concerts', array( + 'id' => '', + 'band' => $this->band, + 'venue' => $this->venue, + 'wpgconcert_date' => $this->cdate, + 'wpgconcert_tickets' => $this->tickets, + 'wpgconcert_event' => $this->eventlink + )); + + $this->id = $wpdb->insert_id; + } + + public function id() + { + return $this->id; + } + + public function band() + { + return $this->band; + } + public function venue() + { + return $this->venue; + } + public function cdate() + { + return $this->cdate; + } + public function tickets() + { + return $this->tickets; + } + public function eventlink() + { + return $this->eventlink; + } + } +} +?> diff --git a/includes/public/shortcodes/giglog_bands.php b/includes/public/shortcodes/giglog_bands.php index 76187ab..b299644 100644 --- a/includes/public/shortcodes/giglog_bands.php +++ b/includes/public/shortcodes/giglog_bands.php @@ -1,114 +1,114 @@ -<?php
-/*
- * code used for giglogadmin for the open page where everyone sees the list of
- * concerts. First function displays filters by city, venue and the second one
- * builds the table with concerts
- */
-
-function giglogadmin_getfilters()
-{
- global $wpdb;
-
- //echo (var_dump($_POST["selectvenue"]));
-
- $results = $wpdb->get_results('select distinct wpgvenue_city from wpg_venues');
- $select = '<form method="POST" action=""><select name="selectcity">';
- $select .= '<option value="ALL" ';
- if (isset($_POST["selectcity"]) && $_POST["selectcity"] == "ALL") {
- $select .= ' selected = "selected"';
- }
- $select .= '> All cities</option>';
- foreach ($results AS $row) {
- $select .= '<option value="' . $row->wpgvenue_city . '"';
- if (isset($_POST["selectcity"]) && $_POST["selectcity"] == $row->wpgvenue_city) {
- $select .= ' selected = "selected"';
- }
- $select .= ' >' . $row->wpgvenue_city . '</option>';
- }
-
- if (isset($_POST["selectcity"]) && $_POST["selectcity"] != "ALL") {
- $select .= '</select>';
- //second drop down for venue
-
- $vquery = "select id, wpgvenue_name from wpg_venues";
- $vquery .= " where wpgvenue_city='" . $_POST["selectcity"] . "'";
- $resultsv = $wpdb->get_results($vquery);
- $select .= '<select name="selectvenue">';
- $select .= '<option value="0" ';
- if (isset($_POST["selectvenue"]) && $_POST["selectvenue"] == "0") {
- $select .= ' selected = "selected"';
- }
- $select .= '> All venues</option>';
-
- foreach ($resultsv AS $rowv) {
- $select .= '<option value="' . $rowv->id . '"';
- if (isset($_POST["selectvenue"]) && $_POST["selectvenue"] == $rowv->id) {
- $select .= ' selected = "selected"';
- }
- $select .= ' >' . $rowv->wpgvenue_name . '</option>';
- }
- //end IF that checks if city was selected
- }
- $select .= '</select><input type="submit" value="Filter"></form>';
- return $select;
-}
-
-
-function giglogadmin_getconcerts()
-{
- global $wpdb;
- // Shortcodes RETURN content, so store in a variable to return
- $content = '<table class="concertstb">';
- // $content .= '</tr><th>CITY</th><th>ID</th><th>BAND</th><th>VENUE</th><th>DATE</th><th>TICKETS</th><th>EVENT</th></tr>';
- $content .= '<tr class="concertshrow"><th>CITY</th><th>BAND</th><th>VENUE</th><th>DATE</th><th>TICKETS</th><th>EVENT</th></tr>';
- // Use the submitted "city" if any. Otherwise, use the default/static value.
- $cty = filter_input(INPUT_POST, 'selectcity');
- $cty = $cty ? $cty : 'ALL';
-
- $venue = filter_input(INPUT_POST, 'selectvenue');
- //echo($_POST['selectvenue']);
- $venue = $venue ? $venue : '0';
-
-
- $query = "SELECT wpgc.id, wpgb.wpgband_name as band ,wpgv.wpgvenue_name as venue ,wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage
- FROM wpg_concerts wpgc, wpg_bands wpgb, wpg_venues wpgv
-where wpgc.band=wpgb.id
-and wpgc.venue = wpgv.id
-and wpgconcert_date >= CURDATE()";
- $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" . $cty . "'";
- $query .= ($venue == "0") ? "" : " and wpgv.id='" . $venue . "'";
- $query .= " order by wpgv.wpgvenue_city, wpgconcert_date, wpgc.id";
- //echo($query);
- $results = $wpdb->get_results($query);
-
-
- $lastType = '';
- foreach ($results AS $row) {
- $content .= '<tr class="concertsrow">';
-
- if ($lastType != '' && $lastType != $row->wpgvenue_city) {
- $content .= '<td class="concertstd">' . $row->wpgvenue_city . '</td></tr><tr>';
- }
-
- if ($lastType == '') {
- $content .= '<td>' . $row->wpgvenue_city . '</td></tr><tr>';
- }
- // Modify these to match the database structure
- // $content .= '<td>' . $row->id. '</td>';
- $content .= '<td></td>';
- $content .= '<td>' . $row->band . '</td>';
- $content .= '<td>' . $row->venue . '</td>';
- $fdate = strtotime($row->wpgconcert_date);
- $newformat = date('d.M.Y', $fdate);
-
- //$content .= DATE_FORMAT($fdate,'%d.%b.%Y');
- $content .= '<td>' . $newformat . '</td>';
- $content .= '<td><a href="' . $row->wpgconcert_tickets . '" target="_blank">Tickets</a></td>';
- $content .= '<td><a href="' . $row->wpgconcert_event . '" target="_blank">Event link</a></td>';
- $content .= '</tr>';
- $lastType = $row->wpgvenue_city;
- }
- $content .= '</table>';
- // return the table
- return $content;
-}
+<?php +/* + * code used for giglogadmin for the open page where everyone sees the list of + * concerts. First function displays filters by city, venue and the second one + * builds the table with concerts + */ + +function giglogadmin_getfilters() +{ + global $wpdb; + + //echo (var_dump($_POST["selectvenue"])); + + $results = $wpdb->get_results('select distinct wpgvenue_city from wpg_venues'); + $select = '<form method="POST" action=""><select name="selectcity">'; + $select .= '<option value="ALL" '; + if (isset($_POST["selectcity"]) && $_POST["selectcity"] == "ALL") { + $select .= ' selected = "selected"'; + } + $select .= '> All cities</option>'; + foreach ($results AS $row) { + $select .= '<option value="' . $row->wpgvenue_city . '"'; + if (isset($_POST["selectcity"]) && $_POST["selectcity"] == $row->wpgvenue_city) { + $select .= ' selected = "selected"'; + } + $select .= ' >' . $row->wpgvenue_city . '</option>'; + } + + if (isset($_POST["selectcity"]) && $_POST["selectcity"] != "ALL") { + $select .= '</select>'; + //second drop down for venue + + $vquery = "select id, wpgvenue_name from wpg_venues"; + $vquery .= " where wpgvenue_city='" . $_POST["selectcity"] . "'"; + $resultsv = $wpdb->get_results($vquery); + $select .= '<select name="selectvenue">'; + $select .= '<option value="0" '; + if (isset($_POST["selectvenue"]) && $_POST["selectvenue"] == "0") { + $select .= ' selected = "selected"'; + } + $select .= '> All venues</option>'; + + foreach ($resultsv AS $rowv) { + $select .= '<option value="' . $rowv->id . '"'; + if (isset($_POST["selectvenue"]) && $_POST["selectvenue"] == $rowv->id) { + $select .= ' selected = "selected"'; + } + $select .= ' >' . $rowv->wpgvenue_name . '</option>'; + } + //end IF that checks if city was selected + } + $select .= '</select><input type="submit" value="Filter"></form>'; + return $select; +} + + +function giglogadmin_getconcerts() +{ + global $wpdb; + // Shortcodes RETURN content, so store in a variable to return + $content = '<table class="concertstb">'; + // $content .= '</tr><th>CITY</th><th>ID</th><th>BAND</th><th>VENUE</th><th>DATE</th><th>TICKETS</th><th>EVENT</th></tr>'; + $content .= '<tr class="concertshrow"><th>CITY</th><th>BAND</th><th>VENUE</th><th>DATE</th><th>TICKETS</th><th>EVENT</th></tr>'; + // Use the submitted "city" if any. Otherwise, use the default/static value. + $cty = filter_input(INPUT_POST, 'selectcity'); + $cty = $cty ? $cty : 'ALL'; + + $venue = filter_input(INPUT_POST, 'selectvenue'); + //echo($_POST['selectvenue']); + $venue = $venue ? $venue : '0'; + + + $query = "SELECT wpgc.id, wpgb.wpgband_name as band ,wpgv.wpgvenue_name as venue ,wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage + FROM wpg_concerts wpgc, wpg_bands wpgb, wpg_venues wpgv +where wpgc.band=wpgb.id +and wpgc.venue = wpgv.id +and wpgconcert_date >= CURDATE()"; + $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" . $cty . "'"; + $query .= ($venue == "0") ? "" : " and wpgv.id='" . $venue . "'"; + $query .= " order by wpgv.wpgvenue_city, wpgconcert_date, wpgc.id"; + //echo($query); + $results = $wpdb->get_results($query); + + + $lastType = ''; + foreach ($results AS $row) { + $content .= '<tr class="concertsrow">'; + + if ($lastType != '' && $lastType != $row->wpgvenue_city) { + $content .= '<td class="concertstd">' . $row->wpgvenue_city . '</td></tr><tr>'; + } + + if ($lastType == '') { + $content .= '<td>' . $row->wpgvenue_city . '</td></tr><tr>'; + } + // Modify these to match the database structure + // $content .= '<td>' . $row->id. '</td>'; + $content .= '<td></td>'; + $content .= '<td>' . $row->band . '</td>'; + $content .= '<td>' . $row->venue . '</td>'; + $fdate = strtotime($row->wpgconcert_date); + $newformat = date('d.M.Y', $fdate); + + //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); + $content .= '<td>' . $newformat . '</td>'; + $content .= '<td><a href="' . $row->wpgconcert_tickets . '" target="_blank">Tickets</a></td>'; + $content .= '<td><a href="' . $row->wpgconcert_event . '" target="_blank">Event link</a></td>'; + $content .= '</tr>'; + $lastType = $row->wpgvenue_city; + } + $content .= '</table>'; + // return the table + return $content; +} diff --git a/includes/public/shortcodes/giglog_display_unprocessed.php b/includes/public/shortcodes/giglog_display_unprocessed.php index 05fbb97..dad05f2 100644 --- a/includes/public/shortcodes/giglog_display_unprocessed.php +++ b/includes/public/shortcodes/giglog_display_unprocessed.php @@ -1,153 +1,153 @@ -<?php
-/*
- * I kinda overloaded this snippet. Added comments for each function. But this
- * is used in the giglog admin page, which should only be available to admin
- * users. After the file is being uploaded into the concertlists folder, its
- * content is written into wpg_files. Then the content is split into lines and
- * each line is transformed intoa concert
- */
-
-/* this checks th wpg_files table to see if any file is uploaded but hasn't
- * gone through the processing process - aka fetching each line and
- * transforming it into a concert line
- */
-function giglogadmin_getunprocessed()
-{
- global $wpdb;
-
- $content = '<br /><h3> UNPROCESSED ROWS</h3><table class="concertstable">';
- $content .= '<tr class="concertsheaderrow"><th>Filerow</th><th>FILENAME</th><th>DATE</TH><th>UploadedContent</th>';
- $query = 'SELECT rowid,filename,filedate,rowcontent from wpg_files where processed="N"';
- $results = $wpdb->get_results($query);
- foreach ($results AS $row) {
- $content .= '<tr>';
- $content .= '<td>' . $row->rowid . '</td>';
- $content .= '<td>' . $row->filename . '</td>';
- $content .= '<td>' . $row->filedate . '</td>';
- $content .= '<td>' . $row->rowcontent . '</td>';
- $content .= '</tr>';
- }
- $content .= '</table>';
- return $content;
-}
-
-/* function that goes through each line of the unprocessed file. Each line is
- * checked against the concerts table. if it exists - concert and date and
- * venue - it does nothing with it. If it doesn't exist, it checks if band or
- * venue exists. If they don't, they get created, if they do, their ID from
- * their table is fetchd and used in concerts table
- */
-function giglogadmin_insertconcerts()
-{
- global $wpdb;
- $concertlist = '<p>Inserted the following:</p>';
- $newconcert= [];
- $query1 = 'SELECT id,rowid,filename,filedate,rowcontent from wpg_files where processed="N"';
- $cresults = $wpdb->get_results($query1);
- foreach ($cresults AS $row) {
- $rowfileid = $row->id;
- $resultArray = explode("\t", $row->rowcontent);
- $band = $resultArray[0];
- $venue = $resultArray[1];
- $condate = date('Y-m-d', strtotime($resultArray[2]));
- $ticketlink = $resultArray[3];
- $eventlink = $resultArray[4];
- //first item in the row should be band $resultArray[0]; second should be venue $resultArray[1]; third should be concert date $resultArray[2];
- //fourth item is ticketlink $resultArray[3]; fifth item is eventlink $resultArray[4];
-
- //processing band
- $bandsql = 'SELECT id FROM wpg_bands WHERE upper(wpgband_name)="' . $band . '"';
- $results = $wpdb->get_results($bandsql);
- if ($results)
- $newconcert[0] = $results[0]->id;
- else {
- $wpdb->insert('wpg_bands', array(
- 'id' => '',
- 'wpgband_name' => $band
- ));
- echo ($wpdb->last_error);
- $newconcert[0] = $wpdb->insert_id;
- }
- //done processing band
-
- //processing venue
- if (is_numeric($venue))
- $newconcert[1] = $venue;
- else {
- $venuesql = 'SELECT id FROM wpg_venues WHERE upper(wpgvenue_name)="' . $venue . '"';
- $results = $wpdb->get_results($venuesql);
- if ($results)
- $newconcert[1] = $results[0]->id;
- else {
- $wpdb->insert('wpg_venues', array(
- 'id' => '',
- 'wpgvenue_name' => $venue
- ));
- echo ($wpdb->last_error);
- $newconcert[1] = $wpdb->insert_id;
- }
- }
- //done processing venue
-
- //not sure how to check dates, hopefully manual verification of files will take care of it
-
- //check if concert already exists and return ID if it does. Not checking by date, to be considered
- $csql = 'SELECT id from wpg_concerts where band = ' . $newconcert[0] . ' and venue = ' . $newconcert[1] . ' and wpgconcert_date ="' . $condate . '"';
-
- $cresults = $wpdb->get_results($csql);
- if ($cresults) {
- $usql = 'UPDATE wpg_files SET processed="D", wpgc_id = ' . $cresults[0]->id . ' WHERE id = ' . $rowfileid;
-
- $uresults = $wpdb->get_results($usql);
- $concertlist .= 'DUPLICATE ROW detected BAND ' . $band . ' with band ID ' . $newconcert[0];
- $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1];
- $concertlist .= ', CONCERTDATE ' . $condate;
- $concertlist .= ' <br />';
- } else {
- $wpdb->insert('wpg_concerts', array(
- 'id' => '',
- 'band' => $newconcert[0],
- 'venue' => $newconcert[1],
- 'wpgconcert_date' => $condate,
- 'wpgconcert_tickets' => $ticketlink,
- 'wpgconcert_event' => $eventlink
- ));
- echo ($wpdb->last_error);
- $newconcertid = $wpdb->insert_id;
-
- $usql = 'UPDATE wpg_files SET processed="Y", wpgc_id = ' . $newconcertid . ' WHERE id = ' . $rowfileid;
-
- $uresults = $wpdb->get_results($usql);
- $concertlist .= 'BAND ' . $band . ' with band ID ' . $newconcert[0];
- $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1];
- $concertlist .= ', CONCERTDATE ' . $condate . ', Ticket LINK ' . $ticketlink . ', event LINK' . $eventlink;
- $concertlist .= ' <br />';
-
- }
-
- //end check if concert exists
-
-
- //remember to add the concert ID when displaying
-
-
- } //end looping through unprocessed rows
-
- return $concertlist;
-}
-
-function giglogadmin_display_unprocessed() {
- $output = giglogadmin_getunprocessed();
-
- $output .= '<form method="POST" action=""><input type="submit" name="ProcessConcerts" value="ProcessConcerts"/></form>';
-
-
- if (isset($_POST['ProcessConcerts'])) {
- $output .= giglogadmin_insertconcerts();
-
- //$url2 = $_SERVER['REQUEST_URI'];
- //header("Refresh: 5; URL=$url2"); //reload page
- } //end if button for process concerts is pressed
-
- return $output;
-}
+<?php +/* + * I kinda overloaded this snippet. Added comments for each function. But this + * is used in the giglog admin page, which should only be available to admin + * users. After the file is being uploaded into the concertlists folder, its + * content is written into wpg_files. Then the content is split into lines and + * each line is transformed intoa concert + */ + +/* this checks th wpg_files table to see if any file is uploaded but hasn't + * gone through the processing process - aka fetching each line and + * transforming it into a concert line + */ +function giglogadmin_getunprocessed() +{ + global $wpdb; + + $content = '<br /><h3> UNPROCESSED ROWS</h3><table class="concertstable">'; + $content .= '<tr class="concertsheaderrow"><th>Filerow</th><th>FILENAME</th><th>DATE</TH><th>UploadedContent</th>'; + $query = 'SELECT rowid,filename,filedate,rowcontent from wpg_files where processed="N"'; + $results = $wpdb->get_results($query); + foreach ($results AS $row) { + $content .= '<tr>'; + $content .= '<td>' . $row->rowid . '</td>'; + $content .= '<td>' . $row->filename . '</td>'; + $content .= '<td>' . $row->filedate . '</td>'; + $content .= '<td>' . $row->rowcontent . '</td>'; + $content .= '</tr>'; + } + $content .= '</table>'; + return $content; +} + +/* function that goes through each line of the unprocessed file. Each line is + * checked against the concerts table. if it exists - concert and date and + * venue - it does nothing with it. If it doesn't exist, it checks if band or + * venue exists. If they don't, they get created, if they do, their ID from + * their table is fetchd and used in concerts table + */ +function giglogadmin_insertconcerts() +{ + global $wpdb; + $concertlist = '<p>Inserted the following:</p>'; + $newconcert= []; + $query1 = 'SELECT id,rowid,filename,filedate,rowcontent from wpg_files where processed="N"'; + $cresults = $wpdb->get_results($query1); + foreach ($cresults AS $row) { + $rowfileid = $row->id; + $resultArray = explode("\t", $row->rowcontent); + $band = $resultArray[0]; + $venue = $resultArray[1]; + $condate = date('Y-m-d', strtotime($resultArray[2])); + $ticketlink = $resultArray[3]; + $eventlink = $resultArray[4]; + //first item in the row should be band $resultArray[0]; second should be venue $resultArray[1]; third should be concert date $resultArray[2]; + //fourth item is ticketlink $resultArray[3]; fifth item is eventlink $resultArray[4]; + + //processing band + $bandsql = 'SELECT id FROM wpg_bands WHERE upper(wpgband_name)="' . $band . '"'; + $results = $wpdb->get_results($bandsql); + if ($results) + $newconcert[0] = $results[0]->id; + else { + $wpdb->insert('wpg_bands', array( + 'id' => '', + 'wpgband_name' => $band + )); + echo ($wpdb->last_error); + $newconcert[0] = $wpdb->insert_id; + } + //done processing band + + //processing venue + if (is_numeric($venue)) + $newconcert[1] = $venue; + else { + $venuesql = 'SELECT id FROM wpg_venues WHERE upper(wpgvenue_name)="' . $venue . '"'; + $results = $wpdb->get_results($venuesql); + if ($results) + $newconcert[1] = $results[0]->id; + else { + $wpdb->insert('wpg_venues', array( + 'id' => '', + 'wpgvenue_name' => $venue + )); + echo ($wpdb->last_error); + $newconcert[1] = $wpdb->insert_id; + } + } + //done processing venue + + //not sure how to check dates, hopefully manual verification of files will take care of it + + //check if concert already exists and return ID if it does. Not checking by date, to be considered + $csql = 'SELECT id from wpg_concerts where band = ' . $newconcert[0] . ' and venue = ' . $newconcert[1] . ' and wpgconcert_date ="' . $condate . '"'; + + $cresults = $wpdb->get_results($csql); + if ($cresults) { + $usql = 'UPDATE wpg_files SET processed="D", wpgc_id = ' . $cresults[0]->id . ' WHERE id = ' . $rowfileid; + + $uresults = $wpdb->get_results($usql); + $concertlist .= 'DUPLICATE ROW detected BAND ' . $band . ' with band ID ' . $newconcert[0]; + $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]; + $concertlist .= ', CONCERTDATE ' . $condate; + $concertlist .= ' <br />'; + } else { + $wpdb->insert('wpg_concerts', array( + 'id' => '', + 'band' => $newconcert[0], + 'venue' => $newconcert[1], + 'wpgconcert_date' => $condate, + 'wpgconcert_tickets' => $ticketlink, + 'wpgconcert_event' => $eventlink + )); + echo ($wpdb->last_error); + $newconcertid = $wpdb->insert_id; + + $usql = 'UPDATE wpg_files SET processed="Y", wpgc_id = ' . $newconcertid . ' WHERE id = ' . $rowfileid; + + $uresults = $wpdb->get_results($usql); + $concertlist .= 'BAND ' . $band . ' with band ID ' . $newconcert[0]; + $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]; + $concertlist .= ', CONCERTDATE ' . $condate . ', Ticket LINK ' . $ticketlink . ', event LINK' . $eventlink; + $concertlist .= ' <br />'; + + } + + //end check if concert exists + + + //remember to add the concert ID when displaying + + + } //end looping through unprocessed rows + + return $concertlist; +} + +function giglogadmin_display_unprocessed() { + $output = giglogadmin_getunprocessed(); + + $output .= '<form method="POST" action=""><input type="submit" name="ProcessConcerts" value="ProcessConcerts"/></form>'; + + + if (isset($_POST['ProcessConcerts'])) { + $output .= giglogadmin_insertconcerts(); + + //$url2 = $_SERVER['REQUEST_URI']; + //header("Refresh: 5; URL=$url2"); //reload page + } //end if button for process concerts is pressed + + return $output; +} diff --git a/includes/public/shortcodes/giglog_process_files.php b/includes/public/shortcodes/giglog_process_files.php index c3e3427..69a9a26 100644 --- a/includes/public/shortcodes/giglog_process_files.php +++ b/includes/public/shortcodes/giglog_process_files.php @@ -1,67 +1,67 @@ -<?php
-/*
- * snippet used to upload files with concerts. File is tab delimited file.
- * Band Venue Date TicketLink Eventlink. The form is at the end of this snippet
- */
-
-function giglogadmin_upload_files() {
- global $wpdb;
- $output = "";
- $dir = wp_upload_dir()['basedir'].'/concertlists/'; //the basedir is from file uploader plugin, namely the uploads folder in which I created a concertlist folder
- if ( !file_exists($dir) ) {
- mkdir( $dir );
- }
-
- $cfiles = scandir($dir);
- foreach ($cfiles as $value) { //list all files in directory
- $my_id = 0; //reset my_id which is used to check if anything was inserted
- if (strlen($value) > 3 and (is_dir($dir . '/' . $value) == false)) {
- $output .= 'Filename: ' . $value . '<br />';
- $filecontent = file_get_contents($dir . '/' . $value);
- $listcontent = str_replace(array(
- "\r",
- "\n"
- ), '<br />', $filecontent); //tring to replace end of lines with brs for html
-
- $output .= '<b>FILE CONTENT</b><br />';
- $r = 1;
- //processing each line of the file into a new row in wpg_files table
- if (isset($_POST['InsertFileContent'])) {
- $lines = new SplFileObject($dir . '/' . $value);
- //and then execute a sql query here
- $table = 'wpg_files';
- foreach ($lines as $newconcert) {
- $output .= '<li> ' . $newconcert . '</li>';
- $wpdb->insert($table, array(
- 'id' => '',
- 'filename' => $value,
- 'rowid' => $r,
- 'rowcontent' => $newconcert
- ));
- $r++;
- //$wpdb->print_error();
- $output .= $wpdb->last_error;
- $my_id = $wpdb->insert_id;
- $output .= '<br />---------------<br />Inserted rowID ' . $my_id . '<br />';
- } //end processing each line
- } //end file processing
-
-
- } //end if that checks whether filename is longer than 3 and is actually a file
-
- if ($my_id > 0) //if anything was inserted, move file to handled
- {
- $output .= '<br />File <b><i> ' . $value . ' </i></b> will be movedto handled folder';
- rename($dir . '/' . $value, $dir . '/handled/' . $value);
- }
-
- } //end looping through all folder content
-
- if ($my_id > 0) {
- $url1 = $_SERVER['REQUEST_URI'];
- header("Refresh: 5; URL=$url1");
- } //reload page
-
- $output .= '<form method="POST" action=""><input type="submit" name="InsertFileContent" value="InsertFileContent"/></form>';
- return $output;
-}
+<?php +/* + * snippet used to upload files with concerts. File is tab delimited file. + * Band Venue Date TicketLink Eventlink. The form is at the end of this snippet + */ + +function giglogadmin_upload_files() { + global $wpdb; + $output = ""; + $dir = wp_upload_dir()['basedir'].'/concertlists/'; //the basedir is from file uploader plugin, namely the uploads folder in which I created a concertlist folder + if ( !file_exists($dir) ) { + mkdir( $dir ); + } + + $cfiles = scandir($dir); + foreach ($cfiles as $value) { //list all files in directory + $my_id = 0; //reset my_id which is used to check if anything was inserted + if (strlen($value) > 3 and (is_dir($dir . '/' . $value) == false)) { + $output .= 'Filename: ' . $value . '<br />'; + $filecontent = file_get_contents($dir . '/' . $value); + $listcontent = str_replace(array( + "\r", + "\n" + ), '<br />', $filecontent); //tring to replace end of lines with brs for html + + $output .= '<b>FILE CONTENT</b><br />'; + $r = 1; + //processing each line of the file into a new row in wpg_files table + if (isset($_POST['InsertFileContent'])) { + $lines = new SplFileObject($dir . '/' . $value); + //and then execute a sql query here + $table = 'wpg_files'; + foreach ($lines as $newconcert) { + $output .= '<li> ' . $newconcert . '</li>'; + $wpdb->insert($table, array( + 'id' => '', + 'filename' => $value, + 'rowid' => $r, + 'rowcontent' => $newconcert + )); + $r++; + //$wpdb->print_error(); + $output .= $wpdb->last_error; + $my_id = $wpdb->insert_id; + $output .= '<br />---------------<br />Inserted rowID ' . $my_id . '<br />'; + } //end processing each line + } //end file processing + + + } //end if that checks whether filename is longer than 3 and is actually a file + + if ($my_id > 0) //if anything was inserted, move file to handled + { + $output .= '<br />File <b><i> ' . $value . ' </i></b> will be movedto handled folder'; + rename($dir . '/' . $value, $dir . '/handled/' . $value); + } + + } //end looping through all folder content + + if ($my_id > 0) { + $url1 = $_SERVER['REQUEST_URI']; + header("Refresh: 5; URL=$url1"); + } //reload page + + $output .= '<form method="POST" action=""><input type="submit" name="InsertFileContent" value="InsertFileContent"/></form>'; + return $output; +} |