Пример #1
0
<?php

session_start();
include 'config.php';
include 'function.php';
/* creates a compressed zip file */
if (extension_loaded('zip')) {
    $album_ids = explode(',', $_GET['album_ids']);
    if (!file_exists(ABSOLUTE_PATH . "/assets/images/archive")) {
        mkdir(ABSOLUTE_PATH . "/assets/images/archive");
    }
    $filepath = $album_ids[0] . time();
    $zip = new ZipArchive();
    $zip_name = ABSOLUTE_PATH . '/assets/images/archive/' . $filepath . ".zip";
    if ($zip->open($zip_name, ZIPARCHIVE::CREATE) !== TRUE) {
        echo '<p class="bg-danger">Error Occur While Zip Creation ,Please Try After Some Time.</p> ';
        exit;
    }
    foreach ($album_ids as $album_id) {
        createArchive($album_id, $zip);
        // Function to add files to zip and download image from facebook
    }
    $zip->close();
    if (file_exists($zip_name)) {
        echo '<p class="bg-success"><a href="' . BASE_URL . '/assets/images/archive/' . $filepath . '.zip"><strong class="text-uppercase">Download Your Zip File</strong></a></p>';
        exit;
    }
} else {
    echo '<p class="bg-danger">Sorry ,Zip extension is not loaded.</p>';
}
Пример #2
0
} else {
    echo cron_msg("Success reloading dlog_15");
}
$added_partition = false;
foreach ($dates as $date) {
    /* figure out which monthly archive dtransactions data belongs in */
    list($year, $month, $day) = explode('-', $date);
    $dstr = $year . $month;
    $table = 'transArchive' . $dstr;
    /* store monthly archive locally or remotely as needed 
          remote archiving is very beta
       */
    if ($FANNIE_ARCHIVE_REMOTE) {
        $sql = new SQLManager($FANNIE_ARCHIVE_SERVER, $FANNIE_ARCHIVE_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_ARCHIVE_USER, $FANNIE_ARCHIVE_PW);
        if (!$sql->table_exists($table)) {
            createArchive($table, $sql);
            if ($UPDATED_DLOG_SCHEMA) {
                $model = new DTransactionsModel($sql);
                $model->normalizeLog('dlog' . $str, $table, BasicModel::NORMALIZE_MODE_APPLY);
            } else {
                createViews($dstr, $sql);
            }
        }
        $sql->add_connection($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_TRANS_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        $sql->transfer($FANNIE_TRANS_DB, "select * from dtransactions WHERE " . $sql->datediff('datetime', "'{$date}'") . "= 0", $FANNIE_ARCHIVE_DB, "insert into {$table}");
    } else {
        $sql = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_ARCHIVE_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        if ($FANNIE_ARCHIVE_METHOD == "partitions" && strstr($FANNIE_SERVER_DBMS, "MYSQL")) {
            // we're just partitioning
            // make a new partition if it's a new month
            if (date('j') == 1 && !$added_partition) {
Пример #3
0
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);
}
Пример #4
0
function getMyCompile()
{
    if (isset($_POST['confirm']) && $_POST['confirm'] == true && $_SESSION['compile_data']) {
        createArchive($_SESSION['compile_data'], $_POST['ftpLoad'], $_POST['ftpFolder']);
    }
    die;
}