echo $data; } else { $cache->start_caching(); $pic_settings = array('w' => 80, 'h' => 80); ?> <!-- begin center --> <div id="center"> <div id="home_container"> <!-- start of news box --> <div id="news"><div id="nav1">News</div> <div align="left" style="padding:6px;height:90px;overflow:hidden;"> <?php $sql = yasDB_select("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1", false); $news = $sql->fetch_array(MYSQLI_ASSOC); $text = closeTags(strlen($news['news_text']) > 230 ? substr($news['news_text'], 0, 230) . '...' : $news['news_text']); if ($setting['seo'] == 'yes') { $news_url = $setting['siteurl'] . 'news.html'; } else { $news_url = $setting['siteurl'] . 'index.php?act=news'; } echo '<center><b>' . $news['date'] . '</center></b> <left>' . $text . '</left> <div style="position:absolute;bottom:0px;right:70px;"><a href="' . $news_url . '">Read All News</a></div>'; $sql->close(); ?> </div> </div> <!-- end of news box --> <!-- start of banner box --> <div id="banner2"><div id="nav2">Banner</div>
<div class="navh3"><div align="center">News</div></div> <div class="cont"> <div class="inner"> <?php $sql = yasDB_select("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1", false); $news = $sql->fetch_array(MYSQLI_ASSOC); $text = closeTags(substr($news['news_text'], 0, 350) . '...'); if ($setting['seo'] == 'yes') { echo '<center>Date:<br><b>' . $news['date'] . '</center></b><br> <left>' . $text . '</left><br /> <center><a href="' . $setting['siteurl'] . 'news.html">Read All News</a></center>'; } else { echo '<center>Date:<br><b>' . $news['date'] . '</center></b><br> <left>' . $text . '</left><br /> <center><a href="' . $setting['siteurl'] . 'index.php?act=news" class="linkset">Read All News</a></center>'; } $sql->close(); ?> </div>
function buildEpub() { // Do stuff // $toc_ncx_content = "" . $_POST['toc_ncx'] . ""; // toc_ncx (epub 2.0) $nav_end_content = "" . $_POST['nav_end'] . ""; // nav_end (epub 3.0) $cover_page_content = "" . $_POST['cover_page'] . ""; // XML Cover(epub 2.0) $content_opf_a = "" . $_POST['content_opf_a'] . ""; // content_opf_a $content_opf_b = "" . $_POST['content_opf_b'] . ""; $title_page = "" . $_POST['title_page'] . ""; $toc_page = "" . $_POST['toc_page'] . ""; $epub_html = ""; // epub_pages $images_folder = ""; // imagefolder_name $styles_name = ""; $myCSSfile = 0; // no custom file $myCSSname = ""; $manifest = ""; $m = 0; function manifest_Build($type, $file, $media_type, $m) { return "\t<item id=\"" . $type . $m . "\"\thref=\"" . $file . "\"\tmedia-type=\"" . $media_type . "\"/>\r\n"; } if ($_POST['epub_pages'] == "" || $_POST['epub_pages'] == "undefined") { echo '<span style="color:red;">ERROR: File Content Missing!</span><br/>'; return; } else { $epub_html = json_decode($_POST['epub_pages']); } if ($_POST['cssfile_name'] == "") { $styles_name = 'thisissue.css'; } else { $styles_name = "" . $_POST['cssfile_name'] . ""; } // Allows no image folder to be included with empty set. $images_folder = $_POST['imagefolder_name']; if ($_POST['add_customCSS'] != "") { $myCSSfile = 1; $myCSSname = "" . $_POST['add_customCSS'] . ""; } // Now that variables are set let's build some stuff! // // check if temp directory exists or not, if not create it // $MY_PATH = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']; $MY_PATH = explode('ryuzinewriter/', $MY_PATH); if (is_writable($MY_PATH[0])) { $tmp = $MY_PATH[0] . 'tmp'; if (!file_exists($tmp)) { mkdir($tmp, 0777); } else { deleteAll($tmp, true); } // If Flush was checked, get rid of all old epub files // if ($_POST['epub_flush'] == '1') { foreach (glob($MY_PATH[0] . "*.epub*") as $file) { unlink($file); // Delete only .epub files through the loop } echo '<span style="color:yellow;">WARNING: All older .epub files were permanently deleted! To prevent this in the future uncheck the "Delete Old ePub Files" option.</span><br/>'; } } else { echo '<script type="text/javascript">alert(\'ERROR: Dev Folder is not writable!\\nePub COULD NOT BE BUILT\\nCheck folder permissions and try again.\');</script>'; return; } // Now populate tmp folder with standard Ryuzine Folders // $_css = $MY_PATH[0] . 'tmp/css'; $_images = $MY_PATH[0] . 'tmp/images'; echo 'Building Package file structure. . .'; if (!file_exists($_css)) { mkdir($_css, 0777); } if (!file_exists($_images)) { mkdir($_images, 0777); } echo 'DONE<br/>'; // Copy Core Files to Package // echo 'Copying Core Files to Package. . .'; // copy($MY_PATH[0].'ryuzinewriter/addons/epub/assets/mimetype',$MY_PATH[0].'tmp/mimetype'); // use template instead! recurse_copy($MY_PATH[0] . 'ryuzinewriter/addons/epub/assets/META-INF', $MY_PATH[0] . 'tmp/META-INF'); if ($_POST['epub_fonts'] == '1') { recurse_copy($MY_PATH[0] . 'fonts', $MY_PATH[0] . 'tmp/fonts'); echo 'DONE<br/>'; // Now get the list of fonts and types for manifest // foreach (ListFiles('../../../fonts') as $key => $file) { $file = preg_replace("~../../../~", "", $file); if (preg_match("~\\.otf~i", $file)) { $media_type = 'application/x-font-otf'; // possible 1: application/opentype // possible 2: application/vnd.ms-opentype } else { if (preg_match("~\\.ttf~i", $file)) { $media_type = 'application/x-font-ttf'; // possibly: application/truetype } else { if (preg_match("~\\.eot~i", $file)) { $media_type = 'application/x-font-eot'; // possibly: application/embedded-opentype } else { if (preg_match("~\\.svg~i", $file)) { $media_type = 'image/svg+xml'; // possibly: application/x-font-svg } else { if (preg_match("~\\.woff~i", $file)) { $media_type = 'application/x-font-woff'; // possibly: application/font-woff' // Now check for other kinds of files in case they are there } else { if (preg_match("~\\.htm~i", $file) || preg_match("~\\.html~i", $file)) { $media_type = 'application/xhtml+xml'; } else { if (preg_match("~\\.css~i", $file)) { $media_type = 'text/css'; } else { if (preg_match("~\\.txt~i", $file)) { $media_type = 'text/plain'; } else { if (preg_match("~\\.rtf~i", $file)) { $media_type = 'text/richtext'; } else { if (preg_match("~\\.xml~i", $file)) { $media_type = 'text/xml'; } else { if (preg_match("~\\.zip~i", $file)) { echo '<span style="color:yellow;">WARNING: There is a ZIP archive (' . $file . ') in your /fonts folder. Consider removing it and run build again.</span><br/>'; $media_type = 'application/zip'; } else { $media_type = 'unknown'; echo '<span style="color:red;">ERROR: ' . $file . ' in the fonts folder unknown media-type. This invalidates the ePub. Please fix it and try again!</span><br/>'; return; } } } } } } } } } } } $manifest = $manifest . "" . manifest_Build('font', $file, $media_type, $m) . ""; $m++; } } else { if (file_exists($tmp . 'fonts')) { deleteAll($tmp . 'fonts', true); } } echo '<span style="font-weight:bold;color:limegreen;">**** BUILDING ePUB ****</span><br/>'; ePubFiles('', 'nav.xhtml', $nav_end_content); ePubFiles('', 'toc.ncx', $toc_ncx_content); if ($cover_page_content != "") { ePubFiles('', 'cover.xhtml', $cover_page_content); } if ($title_page != "") { ePubFiles('', 'title.xhtml', $title_page); } if ($toc_page != "") { ePubFiles('', 'contents.xhtml', $toc_page); } $epub_html = closeTags($epub_html); for ($e = 0; $e < count($epub_html); $e++) { ePubFiles('', 'page' . $e . '.xhtml', $epub_html[$e]); } if ($images_folder != "") { if (!file_exists($MY_PATH[0] . 'images/' . $images_folder)) { echo '<span style="color:red;">ERROR: Images sub-folder does not exist! No images are included in this ePub.</span><br/>'; } else { // File exists, yay! echo 'DONE<br/>Copying issue-specific images subdirectory ' . $images_folder . '. . .'; recurse_copy($MY_PATH[0] . 'images/' . $images_folder, $MY_PATH[0] . 'tmp/images/' . $images_folder); echo 'DONE<br/>'; $m = 0; foreach (ListFiles('../../../images/' . $images_folder . '') as $key => $file) { $file = preg_replace("~../../../~", "", $file); if (preg_match("~\\.jpg~i", $file) || preg_match("~\\.jpeg~i", $file)) { $media_type = 'image/jpeg'; } else { if (preg_match("~\\.png~i", $file)) { $media_type = 'image/png'; } else { if (preg_match("~\\.gif~i", $file)) { $media_type = 'image/gif'; } else { if (preg_match("~\\.svg~i", $file)) { $media_type = 'image/svg+xml'; } else { if (preg_match("~\\.htm~i", $file) || preg_match("~\\.html~i", $file)) { $media_type = 'application/xhtml+xml'; } else { if (preg_match("~\\.css~i", $file)) { $media_type = 'text/css'; } else { if (preg_match("~\\.txt~i", $file)) { $media_type = 'text/plain'; } else { if (preg_match("~\\.rtf~i", $file)) { $media_type = 'text/richtext'; } else { if (preg_match("~\\.xml~i", $file)) { $media_type = 'text/xml'; } else { $media_type = 'unknown'; echo '<span style="color:red;">ERROR: ' . $file . ' in the images folder unknown media-type. This invalidates the ePub. Please fix it and try again!</span><br/>'; return; } } } } } } } } } $manifest = $manifest . manifest_Build('image', $file, $media_type, $m); $m++; } } } else { if (file_exists($tmp . 'images')) { deleteAll($tmp . 'images', true); } echo '<span style="color:yellow;">WARNING: No images sub-folder set! No images are included in this ePub.</span><br/>'; } if ($styles_name != "") { echo 'Copying ' . $styles_name . ' to ePub Package<br/>'; copy($MY_PATH[0] . 'css/' . $styles_name, $MY_PATH[0] . 'tmp/css/' . $styles_name); } if ($myCSSfile == '1') { echo 'Copying ' . $myCSSname . ' file into package /css</br/>'; if (!copy($MY_PATH[0] . 'js/' . $myCSSname, $MY_PATH[0] . 'tmp/css/' . $myCSSname)) { echo 'File could not be copied (either missing, wrong name, or destination is not writable)'; } } ePubFiles('', 'content.opf', $content_opf_a . $manifest . $content_opf_b); $epubname = $_POST['mytitle']; $epubname = preg_replace("/[^\\w\\.-]/", "-", strtolower($epubname)); $epubname = $epubname . '_ops_' . date_timestamp_get(date_create()) . '.epub'; createArchive($MY_PATH[0], 'tmp/', $epubname); }
function word_limiter_html($str, $n = 100, $end_char = '…') { if (strlen($str) < $n) { return closeTags($str); } $words = explode(' ', preg_replace("/\\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str))); if (count($words) <= $n) { return closeTags($str); } $str = ''; for ($i = 0; $i < $n; $i++) { $str .= $words[$i] . ' '; } $str = closeTags($str); return trim($str) . $end_char; }