getConnection(); $conference = new Conferencia($db); $stmt = $conference->lgccctv_list( LOCALE ); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $date = ''; $no_activity = ''; $city = ''; $state = ''; $country = ''; $response_item=array( "title" => $title ); $translations = unserialize($translationmeta); $translations[LOCALE] = (int)$ID; if(LOCALE=='es_ES'){ $original_id = $ID; } else { $original_id = $translations['es_ES']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $response_item['date'] = $date; $response_item['activity'] = $no_activity; $dt = new DateTime($date); $formatter = new IntlDateFormatter(LOCALE, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $formatter->setPattern( datePattern( $date ) ); $response_item['nicedate'] = ucfirst($formatter->format($dt)); $response_item['location'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); array_push($conferences_arr, $response_item); } } //Add activities data as well $activities_json = json_decode(file_get_contents('https://www.carpa.com/wp-admin/admin-ajax.php?action=processQueue'), JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK ); $all_data = array_merge($conferences_arr,$activities_json); $data = array( 'count' => count($all_data), 'result' => array ( 'conferencias' => $all_data ) ); send_response( $data ); } /** * Create conference list with cache option */ function conferences_list( $year, $month, $last_update, $text, $cache ){ if( $cache==false ){ //Cache directory $dir = '/var/www/html/v3/cache'; //Define filename $filen = 'conferencias_' . LOCALE; //Set filename for relevant conferences if( RELEVANT ){ $filen .= '_relevant'; } else { //If year if($year != ''){ $filen .= '_' . $year; if($month != ''){ $filen .= '_' . $month; } } } if($text){ $filen .= '_texts'; } $file = $dir . '/' . $filen . '.json'; if(!file_exists( $file ) || $_REQUEST['forceupdate']==true ){ $data = build_conferences_list( $year, $month, $last_update, $text ); $data['cache'] = time(); $data['filename'] = $filen; $res = file_put_contents( $file , json_encode($data) ); $data['res'] = $res; } else { readfile( $file ); die(); } } else { $data = build_conferences_list( $year, $month, $last_update, $text ); $data['cache'] = $cache; } send_response( $data ); } /** * Generate conference list */ function build_conferences_list( $year, $month, $last_update, $text ){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); if( EXPORT ){ $gettext = true; } else { $gettext = $text; } if( RELEVANT ){ $stmt = $conference->translation_list( $year, $month, $last_update, $gettext, LOCALE, 'relevantes' ); } else { $stmt = $conference->translation_list( $year, $month, $last_update, $gettext, LOCALE ); } $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $date = ''; $no_activity = ''; $city = ''; $state = ''; $country = ''; $thumbnail = ''; if(!$text){ $response_item=array( "_id" => $ID, "title" => $title, "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']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $response_item['date'] = $date; $response_item['activity'] = $no_activity; $response_item['city'] = $city; $response_item['state'] = $state; $response_item['country'] = $country; $response_item['private'] = $private; $response_item['thumbnail'] = $thumbnail; $dt = new DateTime($date); $formatter = new IntlDateFormatter(LOCALE, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $formatter->setPattern( datePattern( $date ) ); $response_item['nicedate'] = ucfirst($formatter->format($dt)); $response_item['location'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $response_item['duration'] = gmdate("H:i:s", (int)$duration); if( !EXPORT ){ $fileData = $conference->get_post_files( $ID, LOCALE ); $files = $fileData->fetch(PDO::FETCH_ASSOC); $response_item['files'] = []; $response_item['files']['youtube'] = str_replace( 'http://', 'https://', $files['youtube']); if($files['videofile'] != ''){ $response_item['files']['video'] = $conference->get_post_file($files['videofile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['video'] = str_replace( 'http://', 'https://',$files['video']); } if($files['audiofile'] != ''){ $response_item['files']['audio'] = $conference->get_post_file($files['audiofile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['audio'] = str_replace( 'http://', 'https://',$files['audio']); } if($files['pdffile'] != ''){ $response_item['files']['pdf'] = $conference->get_post_file($files['pdffile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['pdf'] = str_replace( 'http://', 'https://',$files['pdf']); } if($files['pdfsimplefile'] != ''){ $response_item['files']['pdf_simple'] = $conference->get_post_file($files['pdfsimplefile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['pdf_simple'] = str_replace( 'http://', 'https://',$files['pdf_simple']); } //Image metadata for thumbnail use. TODO: Optimize this return array $response_item['meta'] = unserialize($meta); $imeta = unserialize($meta); $images = []; $images['small'] = explode('.',$imeta['file'])[0].'-'.$imeta['sizes']['medium']['width'].'x'.$imeta['sizes']['medium']['height'].'.'.explode('.',$imeta['file'])[1]; $images['medium'] = explode('.',$imeta['file'])[0].'-'.$imeta['sizes']['medium_large']['width'].'x'.$imeta['sizes']['medium_large']['height'].'.'.explode('.',$imeta['file'])[1]; $images['large'] = explode('.',$imeta['file'])[0].'-'.$imeta['sizes']['large']['width'].'x'.$imeta['sizes']['large']['height'].'.'.explode('.',$imeta['file'])[1]; $images['original'] = $imeta['file']; $response_item['images'] = $images; } else { $response_item['body'] = wpautop( $content ); } $response_item['translations'] = $translations; } else { $response_item=array( "_id" => $ID, "b" => wpautop( $content ) ); } array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'result' => array ( 'conferencias' => $conferences_arr ) ); $data['year'] = $year; $data['month'] = $month; return $data; } function datePattern( $date ){ $format = ''; switch( LOCALE ){ case "en_US": $format = "EEEE, MMMM d, yyyy"; break; case "fr": case "pt_BR": case "es_ES": default: $format = "EEEE, d 'de' MMMM 'de' yyyy"; break; } return $format; } function conference_detail( $id ){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); if(is_numeric($id)){ $stmt = $conference->detail($id,LOCALE); } else { $stmt = $conference->detailBySlug($id,LOCALE); } $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $date = ''; $no_activity = ''; $city = ''; $state = ''; $country = ''; $thumbnail = ''; extract($row); $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']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $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 ) ); $response_item['nicedate'] = ucfirst($formatter->format($dt)); $response_item['location'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $response_item['duration'] = gmdate("H:i:s", (int)$duration); $fileData = $conference->get_post_files( $ID, LOCALE ); $files = $fileData->fetch(PDO::FETCH_ASSOC); $response_item['files'] = []; $response_item['files']['youtube'] = str_replace( 'http://', 'https://', $files['youtube']); if($files['videofile'] != ''){ $response_item['files']['video'] = $conference->get_post_file($files['videofile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['video'] = str_replace( 'http://', 'https://',$files['video']); } if($files['audiofile'] != ''){ $response_item['files']['audio'] = $conference->get_post_file($files['audiofile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['audio'] = str_replace( 'http://', 'https://',$files['audio']); } if($files['pdffile'] != ''){ $response_item['files']['pdf'] = $conference->get_post_file($files['pdffile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['pdf'] = str_replace( 'http://', 'https://',$files['pdf']); } if($files['pdfsimplefile'] != ''){ $response_item['files']['pdf_simple'] = $conference->get_post_file($files['pdfsimplefile'], LOCALE)->fetch(PDO::FETCH_ASSOC)['url']; } else { $response_item['files']['pdf_simple'] = str_replace( 'http://', 'https://',$files['pdf_simple']); } $response_item['translations'] = $translations; //Image metadata for thumbnail use. TODO: Optimize this return array $response_item['meta'] = unserialize($meta); array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'result' => array ( 'conferences' => $conferences_arr ) ); send_response( $data ); } function send_response( $data ){ // set response code - 200 OK header('Content-Type: application/json; charset=utf-8'); http_response_code(200); echo json_encode( $data, JSON_UNESCAPED_UNICODE ); } function conference_search( $q ){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->title_search($q, LOCALE); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $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']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $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 ) ); $response_item['nicedate'] = ucfirst($formatter->format($dt)); $response_item['location'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $response_item['duration'] = gmdate("H:i:s", (int)$duration); $fileData = $conference->get_post_files( $ID, LOCALE ); $files = $fileData->fetch(PDO::FETCH_ASSOC); $response_item['files'] = []; $response_item['files']['youtube'] = str_replace( 'http://', 'https://', $files['youtube']); $response_item['files']['video'] = str_replace( 'http://', 'https://',$files['video']); $response_item['files']['audio'] = str_replace( 'http://', 'https://',$files['audio']); $response_item['files']['pdf'] = str_replace( 'http://', 'https://',$files['pdf']); $response_item['files']['pdf_simple'] = str_replace( 'http://', 'https://',$files['pdf_simple']); $response_item['translations'] = $translations; //Image metadata for thumbnail use. TODO: Optimize this return array $response_item['meta'] = unserialize($meta); array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'query' => $q, 'result' => array ( 'conferencias' => $conferences_arr ) ); send_response( $data ); } function conference_content_search( $q ){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->content_search($q); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $response_item=array( "_id" => $ID, "ty" => 'conferencia', "d" => date("Y-m-d", strtotime( $creation_date ) ), "t" => $title, "a" => $no_activity, "c" => $city, "st" => $state, "co" => $country, "s" => $duration, "sl" => $slug, "th" => $thumbnail, "ex" => "..." . preg_replace("/\w*?$q\w*/i", '$0', better_strip_tags($excerpt)) . "..." ); $dt = new DateTime($date); $formatter = new IntlDateFormatter(LOCALE, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); $formatter->setPattern("EEEE, d 'de' MMMM 'de' yyyy"); $response_item['date'] = ucfirst($formatter->format($dt)); $response_item['lo'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $response_item['dur'] = gmdate("H:i:s", (int)$duration); $response_item['slug'] = 'https://conferencias.carpa.com/conferencias/'.$slug; $fileData = $conference->get_post_files( $ID ); $files = $fileData->fetch(PDO::FETCH_ASSOC); $response_item['yt'] = str_replace( 'http://', 'https://', $files['youtube']); $response_item['v'] = str_replace( 'http://', 'https://',$files['video']); $response_item['au'] = str_replace( 'http://', 'https://',$files['audio']); $response_item['p'] = str_replace( 'http://', 'https://',$files['pdf']); $response_item['ps'] = str_replace( 'http://', 'https://',$files['pdf_simple']); array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'query' => $q, 'result' => array ( 'conferencias' => $conferences_arr ) ); send_response( $data ); } function countries_list(){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->country_summary(); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $response_item=array( 'code' => $row['country_code'], 'country' => $row['country'], 'total' => $row['total'] ); array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'countries' => $conferences_arr ); send_response( $data ); } function country_conferences($co){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->country_list($co,LOCALE); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $date = ''; $no_activity = ''; $city = ''; $state = ''; $country = ''; $thumbnail = ''; $response_item=array( "_id" => $ID, "title" => $title, "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']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $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 ) ); $response_item['nicedate'] = ucfirst($formatter->format($dt)); $response_item['location'] = implode(', ',array_filter(array($city,$state,Locale::getDisplayRegion('-'.strtoupper($country), LOCALE )))); $response_item['duration'] = gmdate("H:i:s", (int)$duration); $fileData = $conference->get_post_files( $ID, LOCALE ); $files = $fileData->fetch(PDO::FETCH_ASSOC); $response_item['files'] = []; $response_item['files']['youtube'] = str_replace( 'http://', 'https://', $files['youtube']); $response_item['files']['video'] = str_replace( 'http://', 'https://',$files['video']); $response_item['files']['audio'] = str_replace( 'http://', 'https://',$files['audio']); $response_item['files']['pdf'] = str_replace( 'http://', 'https://',$files['pdf']); $response_item['files']['pdf_simple'] = str_replace( 'http://', 'https://',$files['pdf_simple']); //Image metadata for thumbnail use. TODO: Optimize this return array $response_item['meta'] = unserialize($meta); $response_item['translations'] = $translations; array_push($conferences_arr, $response_item); } } $data = array( 'count' => $num, 'result' => array ( 'conferencias' => $conferences_arr ) ); $data['country'] = Locale::getDisplayRegion('-'.strtoupper($country), LOCALE ); send_response( $data ); } 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( "%^(\"'/]++|/+?|\"[^\"]*\"|'[^']*')*?(/?>)%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){ 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'); $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->detail($id,LOCALE); $num = $stmt->rowCount(); if($num>0){ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $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']; } $confmeta = $conference->conference_meta( $original_id ); extract($confmeta); $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("Dr. William Soto Santiago","Dr. William Soto Santiago"); $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" . "". $title ."\n" . "\n" . "\n"; $svgData = ''; $book->addFile("logo_lgccc_epub.svg", "logo_svg", $svgData, "image/svg+xml"); $cover = $content_start . "
".$code."

".$title."

\n

Dr. William Soto Santiago
".$nicedate."
" . $lo . "


\"La
\n" . "\n\n"; $book->addChapter("Cover", "Cover.html", $cover); $content = autop($content); $content = preg_replace('/[\x00-\x1F\x7F]/u', '', $content); $contenido = $content_start . "

".$title."

\n

Dr. William Soto Santiago
".$nicedate."
" . $lo . "

\n" . $content . "\n\n";; $book->addChapter("Contenido: " . $title, "Chapter001.html", $contenido); $book->finalize(); // Finalize the book, and build the archive. //save file $fp = fopen( $file , 'w'); fwrite( $fp , $book->getBook() ); fclose( $fp ); if($return=='true'){ $zipData = $book->sendBook( $newFilename ); } //die(); } else { if($return=='true'){ $newTitle = sanitize_title( $title ); $fixedNewTitle = str_replace( '-','_',$newTitle ); $newFilename = $code . "-" . $fixedNewTitle . "-" . strtoupper( substr( $city , 0 , 3 ) ) . strtoupper( $country ) . ".epub"; //Send current file header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); header("Cache-Control: public"); // needed for internet explorer header("Content-Type: application/epub+zip"); header("Content-Transfer-Encoding: Binary"); header("Content-Length:".filesize($file)); header("Content-Disposition: attachment; filename=".$newFilename); readfile($file); } } } } } function sanitize_title($text, string $divider = '-') { // replace non letter or digits by divider $text = preg_replace('~[^\pL\d]+~u', $divider, $text); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); // trim $text = trim($text, $divider); // remove duplicate divider $text = preg_replace('~-+~', $divider, $text); // lowercase $text = strtolower($text); if (empty($text)) { return 'n-a'; } return $text; } function nl2p($string, $line_breaks = false, $xml = true) { $string = str_replace(array('

', '

', '
', '
'), '', $string); // It is conceivable that people might still want single line-breaks // without breaking into a new paragraph. if ($line_breaks == true) return '

'.preg_replace(array("/([\n]{2,})/i", "/([^>])\n([^<])/i"), array("

\n

", '$1$2'), trim($string)).'

'; else return '

'.preg_replace( array("/([\n]{2,})/i", "/([\r\n]{3,})/i","/([^>])\n([^<])/i"), array("

\n

", "

\n

", '$1$2'), trim($string)).'

'; } function autop($pee, $br = false) { $pre_tags = array(); if ( trim($pee) === '' ) return ''; $pee = $pee . "\n"; // just to make things a little easier, pad the end if ( strpos($pee, '', $pee ); $last_pee = array_pop($pee_parts); $pee = ''; $i = 0; foreach ( $pee_parts as $pee_part ) { $start = strpos($pee_part, ''; $pee .= substr( $pee_part, 0, $start ) . $name; $i++; } $pee .= $last_pee; } $pee = preg_replace('|
\s*
|', "\n\n", $pee); // Space things out a little $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|samp|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); $pee = preg_replace('!()!', "$1\n\n", $pee); $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines if ( strpos($pee, ']*)>\s*|', "", $pee); // no pee inside object/embed $pee = preg_replace('|\s*\s*|', '', $pee); } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates // make paragraphs, including one at the end $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); $pee = ''; foreach ( $pees as $tinkle ) $pee .= '

' . trim($tinkle, "\n") . "

\n"; $pee = preg_replace('|

\s*

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([^<]+)!', "

$1

", $pee); $pee = preg_replace('!

\s*(]*>)\s*

!', "$1", $pee); // don't pee all over a tag $pee = preg_replace("|

(|", "$1", $pee); // problem with nested lists $pee = preg_replace('|

]*)>|i', "

", $pee); $pee = str_replace('

', '

', $pee); $pee = preg_replace('!

\s*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\s*

!', "$1", $pee); if ( $br ) { $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "", $matches[0]);'), $pee); $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks $pee = str_replace('', "\n", $pee); } $pee = preg_replace('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); $pee = preg_replace( "|\n

$|", '

', $pee ); if ( !empty($pre_tags) ) $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); return $pee; } function conference_download($h,$p,$file){ header_remove(); header("X-Accel-Redirect: /downloadfile/" . $h . $p .'?' . $file); } function last_updated(){ } function conference_years(){ $database = new Database(); $db = $database->getConnection(); $conference = new Conferencia($db); $stmt = $conference->year_list(); $num = $stmt->rowCount(); if($num>0){ $conferences_arr=array(); $years = []; $formattedYears = []; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); /*if(!is_array($years[$year])){ $years[$year] = []; }*/ /*if(!in_array($year,$years)){ array_push($years,$year); }*/ if ($currentYear != $year){ $currentYear = $year; $years[$currentYear] = []; } $format = new IntlDateFormatter(LOCALE, IntlDateFormatter::NONE, IntlDateFormatter::NONE, NULL, NULL, "MMMM"); $monthName = datefmt_format($format, mktime(0, 0, 0, $month)); array_push( $years[$currentYear], array('name'=>$monthName,'month'=>str_pad($month,2,'0',STR_PAD_LEFT),'count' => $total)); /*$months = new StdClass(); $months->$monthName = $total; array_push($years[$year],$months);*/ } //Build the months for the years while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); } //array_push($conferences_arr, $years); } /*$data = array( 'result' => array ( 'years' => $years ) );*/ $newYears = []; foreach($years as $year=>$months){ $totalyear = 0; foreach($months as $month=>$count){ $totalyear += $count['count']; } array_push($newYears, array('year'=>$year, 'count'=>$totalyear, 'months' => $months)); } $data = array( 'result' => array ( 'years' => $newYears ) ); send_response( $data ); }