getConnection(); $activity = new Actividad($db); $stmt = $activity->activities_list('2023', '05', false, false, 'es'); echo json_encode(print_r($stmt->fetch(PDO:FETCH_ASSOC,true))); /*$num = $stmt->rowCount(); if($num>0){ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ } }*/ } function better_strip_tags( $str, $allowable_tags = '', $strip_attrs = false, $preserve_comments = false, callable $callback = null ) { $allowable_tags = array_map( 'strtolower', array_filter( // lowercase preg_split( '/(?:>|^)\\s*(?:<|$)/', $allowable_tags, -1, PREG_SPLIT_NO_EMPTY ), // get tag names function( $tag ) { return preg_match( '/^[a-z][a-z0-9_]*$/i', $tag ); } // filter broken ) ); $comments_and_stuff = preg_split( '/(|$))/', $str, -1, PREG_SPLIT_DELIM_CAPTURE ); foreach ( $comments_and_stuff as $i => $comment_or_stuff ) { if ( $i % 2 ) { // html comment if ( !( $preserve_comments && preg_match( '//', $comment_or_stuff ) ) ) { $comments_and_stuff[$i] = ''; } } else { // stuff between comments $tags_and_text = preg_split( "/(<(?:[^>\"']++|\"[^\"]*+(?:\"|$)|'[^']*+(?:'|$))*(?:>|$))/", $comment_or_stuff, -1, PREG_SPLIT_DELIM_CAPTURE ); foreach ( $tags_and_text as $j => $tag_or_text ) { $is_broken = false; $is_allowable = true; $result = $tag_or_text; if ( $j % 2 ) { // tag if ( preg_match( "%^(?)([a-z][a-z0-9_]*)\\b(?:[^>\"'/]++|/+?|\"[^\"]*\"|'[^']*')*?(/?>)%i", $tag_or_text, $matches ) ) { $tag = strtolower( $matches[2] ); if ( in_array( $tag, $allowable_tags ) ) { if ( $strip_attrs ) { $opening = $matches[1]; $closing = ( $opening === '' ) ? '>' : $closing; $result = $opening . $tag . $closing; } } else { $is_allowable = false; $result = ''; } } else { $is_broken = true; $result = ''; } } else { // text $tag = false; } if ( !$is_broken && isset( $callback ) ) { // allow result modification call_user_func_array( $callback, array( &$result, $tag_or_text, $tag, $is_allowable ) ); } $tags_and_text[$j] = $result; } $comments_and_stuff[$i] = implode( '', $tags_and_text ); } } $str = implode( '', $comments_and_stuff ); return $str; } function getFilePrefix(){ switch (LOCALE){ case "pt_BR": case "pt": $prefix = "POR"; break; case "en_US": case "en": $prefix = "ENG"; break; case "fr_FR": case "fr": $prefix = "FRA"; break; case "es_ES": case "es": default: $prefix = "SPA"; break; } return $prefix; } function conference_epub($id,$return,$overwrite){ if(!$id){ echo json_encode("No id!"); wp_die(); } require_once( '/var/www/html/v3/inc/epub/EPub.php'); require_once( '/var/www/html/v3/inc/epub/EPubChapterSplitter.class.php'); require_once( '/var/www/html/v3/inc/epub/Zip.class.php'); /*require_once( 'c:/laragon/www/conferencias/v3/inc/epub/EPub.php'); require_once( 'c:/laragon/www/conferencias/v3/inc/epub/EPubChapterSplitter.class.php'); require_once( 'c:/laragon/www/conferencias/v3/inc/epub/Zip.class.php');*/ $database = new Database(); $db = $database->getConnection(); $activity = new Actividad($db); $count = $activity->get_post_interventions($id); $row = $count->fetch(PDO::FETCH_ASSOC); $interventions = $row['meta_value']; $interventionData = $activity->get_interventions($id,$interventions); $stmt = $activity->detail($id,LOCALE); $num = $stmt->rowCount(); if($num>0){ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ //echo json_encode($row); //die(); extract($row); $date = $creation_date; $no_activity = ''; $city = ''; $state = ''; $country = ''; $thumbnail = ''; $response_item=array( "_id" => $ID, "title" => $title, "body" => wpautop($content), "slug" => $slug, "hasText" => ($bodylength>0?true:false) ); $translations = unserialize($translationmeta); $translations[LOCALE] = (int)$ID; if(LOCALE=='es_ES'){ $original_id = $ID; } else { $original_id = $translations['es_ES']; } $count = $activity->get_post_interventions($id); //Get interventions //$intervention_count = "SELECT * FROM `wp_postmeta` WHERE `post_id` = " . $id . " AND `meta_key` = 'intervenciones'"; /*$response_item['date'] = $date; $response_item['activity'] = $no_activity; $response_item['city'] = $city; $response_item['state'] = $state; $response_item['country'] = $country; $response_item['thumbnail'] = $thumbnail;*/ $dt = new DateTime($date); $formatter = new IntlDateFormatter(LOCALE, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $formatter->setPattern( datePattern( $date ) ); $nicedate = ucfirst($formatter->format($dt)); $lo = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $code = getFilePrefix() . '-' . date("Y-m-d", strtotime( $date ) ) . '-' . $no_activity; //Title $newTitle = sanitize_title( $title ); $fixedNewTitle = str_replace( '-','_',$newTitle ); $newFilename = $code . "-" . $fixedNewTitle . "-" . strtoupper( substr( $city , 0 , 3 ) ) . strtoupper( $country ) . ".epub"; $file = $newFilename; $generate = 'true'; if(file_exists( $file )){ $generate = 'false'; } if($generate == 'true' || $overwrite == 'true'){ $book = new EPub(); // Title and Identifier are mandatory! $book->setTitle( $title ); $book->setIdentifier( $code , EPub::IDENTIFIER_URI); // Could also be the ISBN number, prefered for published books, or a UUID. $book->setLanguage( LOCALE ); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. $book->setDescription( $t . ', predicado el ' . $nicedate . ', en ' . $lo ); $book->setAuthor("Rev. José Benjamín Pérez","Rev. José Benjamín Pérez"); $book->setPublisher("La Gran Carpa Catedral, Corp.", "https://www.carpa.com/"); // I hope this is a non existant address :) $book->setDate(time()); // Strictly not needed as the book date defaults to time(). $book->setRights("Copyright and licence information specific for the book."); $book->setSourceURL( $u ); $cssData = " h1 {\n text-transform : uppercase;\n text-align : center;\n}\n h2 {\n text-align : center;\n text-transform : capitalize;\n}"; $book->addCSSFile("styles.css", "css1", $cssData); // ePub uses XHTML 1.1, preferably strict. $content_start = "\n" . "\n" . "\n" . "
" . "\n" . "\n" . "