From 08f09666f7028463bfd9b69ac5fb9e8e06aa79ad Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 4 Sep 2021 16:09:07 +0200 Subject: Remove obsolete shortcodes. These are no longer in use, and have been replaced by the admin screens. --- giglogadmin.php | 11 - includes/public/shortcodes/giglog_bands.php | 118 ------- .../shortcodes/giglog_display_unprocessed.php | 145 -------- .../public/shortcodes/giglog_photographers.php | 385 --------------------- .../public/shortcodes/giglog_process_files.php | 72 ---- 5 files changed, 731 deletions(-) delete mode 100644 includes/public/shortcodes/giglog_bands.php delete mode 100644 includes/public/shortcodes/giglog_display_unprocessed.php delete mode 100644 includes/public/shortcodes/giglog_photographers.php delete mode 100644 includes/public/shortcodes/giglog_process_files.php diff --git a/giglogadmin.php b/giglogadmin.php index 2db1f3b..e9adbe2 100644 --- a/giglogadmin.php +++ b/giglogadmin.php @@ -26,10 +26,6 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { require_once __DIR__ . '/includes/admin/register_db_tables.php'; - require_once __DIR__ . '/includes/public/shortcodes/giglog_bands.php'; - require_once __DIR__ . '/includes/public/shortcodes/giglog_display_unprocessed.php'; - require_once __DIR__ . '/includes/public/shortcodes/giglog_photographers.php'; - require_once __DIR__ . '/includes/public/shortcodes/giglog_process_files.php'; require_once __DIR__ . '/includes/admin/views/giglog_admin_page.php'; require_once __DIR__ . '/includes/admin/views/giglog_import_gigs.php'; require_once __DIR__ . '/includes/admin/helpfiles/instrunctions.php'; @@ -41,12 +37,6 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { class GiglogAdmin_Plugin { static public function init(): void { - add_shortcode('giglog_cities', 'giglogadmin_getfilters'); - add_shortcode('giglog_bands', 'giglogadmin_getconcerts'); - add_shortcode('giglog_unprocessed', 'giglogadmin_display_unprocessed'); - add_shortcode('giglog_upload', 'giglogadmin_upload_files'); - add_shortcode('giglog_photog', 'giglogadmin_photographers'); - add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_admin_pages' )); add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_help_pages' )); @@ -143,7 +133,6 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { register_activation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'activate' )); register_deactivation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'deactivate' )); - GiglogAdmin_Plugin::init(); } ?> diff --git a/includes/public/shortcodes/giglog_bands.php b/includes/public/shortcodes/giglog_bands.php deleted file mode 100644 index e4fe71d..0000000 --- a/includes/public/shortcodes/giglog_bands.php +++ /dev/null @@ -1,118 +0,0 @@ - -// SPDX-FileCopyrightText: 2021 Harald Eilertsen -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -/* - * 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(): string -{ - global $wpdb; - - //echo (var_dump($_POST["selectvenue"])); - - $results = $wpdb->get_results('select distinct wpgvenue_city from wpg_venues'); - $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 .= '
'; - return $select; -} - - -function giglogadmin_getconcerts(): string -{ - global $wpdb; - // Shortcodes RETURN content, so store in a variable to return - $content = ''; - // $content .= ''; - $content .= ''; - // 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, wpgc.wpgconcert_name ,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_venues wpgv -where 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 .= ''; - - if ($lastType != '' && $lastType != $row->wpgvenue_city) { - $content .= ''; - } - - if ($lastType == '') { - $content .= ''; - } - // Modify these to match the database structure - // $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $fdate = strtotime($row->wpgconcert_date); - $newformat = date('d.M.Y', $fdate); - - //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $lastType = $row->wpgvenue_city; - } - $content .= '
CITYIDBANDVENUEDATETICKETSEVENT
CITYTITLEVENUEDATETICKETSEVENT
' . $row->wpgvenue_city . '
' . $row->wpgvenue_city . '
' . $row->id. '' . $row->wpgconcert_name . '' . $row->venue . '' . $newformat . 'TicketsEvent link
'; - // return the table - return $content; -} diff --git a/includes/public/shortcodes/giglog_display_unprocessed.php b/includes/public/shortcodes/giglog_display_unprocessed.php deleted file mode 100644 index 90ef69f..0000000 --- a/includes/public/shortcodes/giglog_display_unprocessed.php +++ /dev/null @@ -1,145 +0,0 @@ - -// SPDX-FileCopyrightText: 2021 Harald Eilertsen -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -/* - * 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(): string -{ - global $wpdb; - - $content = '

UNPROCESSED ROWS

'; - $content .= ''; - $query = 'SELECT rowid,filename,filedate,rowcontent from wpg_files where processed="N"'; - $results = $wpdb->get_results($query); - foreach ($results AS $row) { - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - } - $content .= '
FilerowFILENAMEDATEUploadedContent
' . $row->rowid . '' . $row->filename . '' . $row->filedate . '' . $row->rowcontent . '
'; - 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(): string -{ - global $wpdb; - $concertlist = '

Inserted the following:

'; - $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); - $cname = $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 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 wpgconcert_name = ' . $cname . ' 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 Title ' . $cname . ' with band ID ' . $newconcert[0]; - $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]; - $concertlist .= ', CONCERTDATE ' . $condate; - $concertlist .= '
'; - } else { - $wpdb->insert('wpg_concerts', array( - 'id' => '', - 'wpgconcert_name' => cname, - '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 .= 'name ' . $cname ; - $concertlist .= ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]; - $concertlist .= ', CONCERTDATE ' . $condate . ', Ticket LINK ' . $ticketlink . ', event LINK' . $eventlink; - $concertlist .= '
'; - - } - - //end check if concert exists - - - //remember to add the concert ID when displaying - - - } //end looping through unprocessed rows - - return $concertlist; -} - -function giglogadmin_display_unprocessed(): string { - $output = giglogadmin_getunprocessed(); - - $output .= '
'; - - - 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_photographers.php b/includes/public/shortcodes/giglog_photographers.php deleted file mode 100644 index 829c53e..0000000 --- a/includes/public/shortcodes/giglog_photographers.php +++ /dev/null @@ -1,385 +0,0 @@ - -// SPDX-FileCopyrightText: 2021 Harald Eilertsen -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -/* - * code used for giglogadmin for the page where users such as photographers/concert reviewers - * check what gigs are available and show interest for them - * Admin users also control concert statuses here - */ - -function giglogadmin_assignconcert($p1, $c): void -{ - global $wpdb; - - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; - $to = 'live@eternal-terror.com'; - $subject = $hf_username.' has taken '.$p1. 'for a concert with id '.$c; - $body = 'The email body content'; - $headers = array('Content-Type: text/html; charset=UTF-8'); - - - - if ($p1 == 'photo1') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo1='".$hf_username."' WHERE wpgcl_concertid=".$c; - if ($p1 == 'photo2') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo2='".$hf_username."' WHERE wpgcl_concertid=".$c; - if ($p1 == 'rev1') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev1='".$hf_username."' WHERE wpgcl_concertid=".$c; - if ($p1 == 'rev2') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev2='".$hf_username."' WHERE wpgcl_concertid=".$c; - - $uresults = $wpdb->get_results($usql); - $wpdb->insert( 'wpg_logchanges', array ( - 'id' => '', - 'userid' => $hf_username, - 'action' => 'assigned '.$p1, - 'concertid' => $c)); - echo ($wpdb->last_error ); - wp_mail( $to, $subject, $body, $headers ); - - -} - -function giglogadmin_unassignconcert($p1, $c): void -{ - global $wpdb; - - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; - $to = 'live@eternal-terror.com'; - $subject = $hf_username.' has UNASSINED '.$p1. 'for a concert with id '.$c; - $body = 'The email body content'; - $headers = array('Content-Type: text/html; charset=UTF-8'); - - - - if ($p1 == 'photo1') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo1='' WHERE wpgcl_concertid=".$c; - if ($p1 == 'photo2') $usql = "UPDATE wpg_concertlogs SET wpgcl_photo2='' WHERE wpgcl_concertid=".$c; - if ($p1 == 'rev1') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev1='' WHERE wpgcl_concertid=".$c; - if ($p1 == 'rev2') $usql = "UPDATE wpg_concertlogs SET wpgcl_rev2='' WHERE wpgcl_concertid=".$c; - - - $uresults = $wpdb->get_results($usql); - $wpdb->insert( 'wpg_logchanges', array ( - 'id' => '', - 'userid' => $hf_username, - 'action' => 'unassigned '.$p1, - 'concertid' => $c)); - echo ($wpdb->last_error ); - wp_mail( $to, $subject, $body, $headers ); - - -} - -/** - * @return null|string - */ -function giglogadmin_getpublishstatus ($c) -{ - global $wpdb; - $date1 = new DateTime("now"); - $dsql = "select filedate from wpg_files where wpgc_id=".$c; - $results = $wpdb->get_results($dsql); - foreach ( $results AS $row ) - { //$x = strtotime($row -> filedate); - $x= date('Y-m-d H:i:s', strtotime($row -> filedate)); - $date2 = new DateTime($x, new DateTimeZone('Europe/London')); - $dd = date_diff ($date1, $date2); - $datediff = $dd ->format('%d'); - } - if ($datediff <= 10) return ('NEW'); -} - - -/** - * @return null|string - */ -function giglogadmin_returnuser($p1, $c) -{ - global $wpdb; - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; - - //PHOTO1 - if ($p1 == 'photo1') - { - //checking if taken - $vquery0 = "select wpgcl_photo1 from wpg_concertlogs where wpgcl_concertid=".$c ; - $results = $wpdb->get_results($vquery0); - foreach ( $results AS $row ) $x= $row -> wpgcl_photo1; - if ($x !='' and $x!=$hf_username) { return ('Taken
Taken by '.$x.'
'); } - else - if ($x==$hf_username) //if current user - return ('
-
'); - else //not taken by anyone - return ('
-
'); - } - //PHOTO2 - if ($p1 == 'photo2') - { - $vquery0 = "select wpgcl_photo2 from wpg_concertlogs where wpgcl_concertid=".$c ; - $results = $wpdb->get_results($vquery0); - foreach ( $results AS $row ) $x= $row -> wpgcl_photo2; - if ($x !='' and $x!=$hf_username) { return ('Taken
Taken by '.$x.'
'); } - else - if ($x==$hf_username) //if current user - return ('
-
'); - - else //not taken by anyone - return ('
-
'); - - } - //TEXT1 - if ($p1 == 'rev1') - { - $vquery0 = "select wpgcl_rev1 from wpg_concertlogs where wpgcl_concertid=".$c ; - $results = $wpdb->get_results($vquery0); - foreach ( $results AS $row ) $x= $row -> wpgcl_rev1; - if ($x !='' and $x!=$hf_username) { ('Taken
Taken by '.$x.'
'); } - else - if ($x==$hf_username) //if current user - return ('
-
'); - else //not taken by anyone - return ('
-
'); - - } - //TEXT2 - if ($p1 == 'rev2') - { - $vquery0 = "select wpgcl_rev2 from wpg_concertlogs where wpgcl_concertid=".$c ; - $results = $wpdb->get_results($vquery0); - foreach ( $results AS $row ) $x= $row -> wpgcl_rev2; - if ($x !='' and $x!=$hf_username) { ('Taken
Taken by '.$x.'
'); } - else - if ($x==$hf_username) //if current user - return ('
-
'); - else //not taken by anyone - return ('
-
'); - - } - - -} - - -function giglogadmin_getfiltersphotog(): string { - global $wpdb; - - //echo (var_dump($_POST["selectvenue"])); - - $results = $wpdb->get_results('select distinct wpgvenue_city from wpg_venues'); - $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.= '
'; - return $select; -} - - -function giglogadmin_getconcertsphotog ( ): string { - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; - $roles = ( array ) $hf_user->roles; - global $wpdb; - - // Shortcodes RETURN content, so store in a variable to return - $content = '

The available slots are marked with the green checkbox. - If you click on it, it will be assigned to you and if you no longer - wish to cover that concert, click on the red icon and you will be - unassigned. A mail should be sent to the admin when this happens, - but in order for the accreditation request to be sent, you have to - mail live@eternal-terror.com with the template containing concert - information. There might be some exceptions, but those are discussed - case by case. So whenever you want a concert, assign yourself and send - the template no later than 3 weeks before the concert.

- -

Admin will try to keep the concert status updated so that you know - what the accreditation status is. You will get personal message if this - is really close to the concert date.

'; - - $content .= ''; - // $content .= ''; - - $content .= ' - - - '; - if (current_user_can('administrator')) //($hf_username == 'etadmin') - $content .= ''; - $content .= ''; - - // 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, wpgc.wpgconcert_name, wpgv.wpgvenue_name as venue, wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage, wpgps.wpgs_name - FROM wpg_concerts wpgc, wpg_venues wpgv, wpg_pressstatus wpgps, wpg_concertlogs wpgcl - where wpgc.venue = wpgv.id - and wpgconcert_date >= CURDATE() - and wpgps.id = wpgcl.wpgcl_status - and wpgcl.wpgcl_concertid=wpgc.id"; - - $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" .$cty ."'"; - $query .= ($venue == "0") ? "" : " and wpgv.id='" .$venue ."'"; - $query .=" order by wpgv.wpgvenue_city, wpgconcert_date" ; - //echo($query); - $results = $wpdb->get_results($query); - - - $lastType = ''; - foreach ( $results AS $row ) { - $content .= ''; - - if($lastType != '' && $lastType != $row->wpgvenue_city) { - $content .= ''; - } - - if ($lastType == '' ) - {$content .= ''; - } - // Modify these to match the database structure - // $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $fdate = strtotime($row->wpgconcert_date); - $newformat = date('d.M.Y',$fdate); - - //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - $content .= ''; - if (current_user_can('administrator')) //($hf_username == 'etadmin') - { $content .= ''; - } - $content .= ''; - $lastType = $row->wpgvenue_city; - } - $content .= '
CITYIDBANDVENUEDATE
CITYTITLEVENUEDATE PHOTO1PHOTO2TEXT1TEXT2STATUSAdminButtons
'.$row->wpgvenue_city.'
'.$row->wpgvenue_city.'
' . $row->id. '' . $row->wpgconcert_name. '' . $row->venue. '' .$newformat. ''.giglogadmin_getpublishstatus($row->id ).''.giglogadmin_returnuser('photo1', $row->id ).''.giglogadmin_returnuser('photo2', $row->id ).''.giglogadmin_returnuser('rev1', $row->id ).''.giglogadmin_returnuser('rev2', $row->id ).''.$row -> wpgs_name; - $content .= ''; - $content .= '
-
'; - $content .= '
'; - - if(isset($_POST['assignitem'])) - { - echo (giglogadmin_assignconcert($_POST['pid'],$_POST['cid'])); - - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - if(isset($_POST['unassignitem'])) - { - echo (giglogadmin_unassignconcert($_POST['pid'],$_POST['cid'])); - - $url3=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url3"); //reload page - } - - if(isset($_POST['reqsent'])) - { - echo (giglogadmin_assignconcert($_POST['pid'],$_POST['cid'])); - $usql = "UPDATE wpg_concertlogs SET wpgcl_status=2 WHERE wpgcl_concertid=".$_POST['cid']; - $uresults = $wpdb->get_results($usql); - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - if(isset($_POST['phok'])) - { - $usql = "UPDATE wpg_concertlogs SET wpgcl_status=3 WHERE wpgcl_concertid=".$_POST['cid']; - $uresults = $wpdb->get_results($usql); - - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - if(isset($_POST['txtok'])) - { - $usql = "UPDATE wpg_concertlogs SET wpgcl_status=4 WHERE wpgcl_concertid=".$_POST['cid']; - $uresults = $wpdb->get_results($usql); - - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - if(isset($_POST['allok'])) - { - $usql = "UPDATE wpg_concertlogs SET wpgcl_status=5 WHERE wpgcl_concertid=".$_POST['cid']; - $uresults = $wpdb->get_results($usql); - - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - if(isset($_POST['rej'])) - { - $usql = "UPDATE wpg_concertlogs SET wpgcl_status=6 WHERE wpgcl_concertid=".$_POST['cid']; - $uresults = $wpdb->get_results($usql); - - $url2=$_SERVER['REQUEST_URI']; - header("Refresh: 1; URL=$url2"); //reload page - } - - // return the table - return $content; -} - -function giglogadmin_photographers(): string -{ - $output = giglogadmin_getfiltersphotog(); - $output .= giglogadmin_getconcertsphotog(); - - return $output; -} diff --git a/includes/public/shortcodes/giglog_process_files.php b/includes/public/shortcodes/giglog_process_files.php deleted file mode 100644 index 9443cda..0000000 --- a/includes/public/shortcodes/giglog_process_files.php +++ /dev/null @@ -1,72 +0,0 @@ - -// SPDX-FileCopyrightText: 2021 Harald Eilertsen -// -// SPDX-License-Identifier: AGPL-3.0-or-later - -/* - * 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(): string { - 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 . '
'; - $filecontent = file_get_contents($dir . '/' . $value); - $listcontent = str_replace(array( - "\r", - "\n" - ), '
', $filecontent); //tring to replace end of lines with brs for html - - $output .= 'FILE CONTENT
'; - $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 .= '
  • ' . $newconcert . '
  • '; - $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 .= '
    ---------------
    Inserted rowID ' . $my_id . '
    '; - } //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 .= '
    File ' . $value . ' 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 .= '
    '; - return $output; -} -- cgit v1.2.3