Beispiel #1
0
 public function export($language)
 {
     $language_path = $this->language_path . $language->code . '/';
     if (File::exists($language_path)) {
         $file_name = "doptor_translation_{$language->code}";
         $this->export_temp_path = temp_path() . '/translations_export/' . $file_name;
         if (File::exists($this->export_temp_path) && !is_file($this->export_temp_path)) {
             // delete old exported files
             File::deleteDirectory($this->export_temp_path);
         }
         $temp_lang_path = $this->export_temp_path . '/lang';
         File::copyDirectory($language_path, $temp_lang_path);
         $this->writeConfig($language);
         $zip_file = $this->export_temp_path . ".zip";
         Zip($this->export_temp_path, $zip_file, false);
         return $zip_file;
     }
 }
}
$queryAllFloorPlanLabelsResult = $DBConnect->executeQueryResult($sqlList->queryAllFloorPlanLabels);
while ($queryAllFloorPlanLabelsResultRecord = mysql_fetch_array($queryAllFloorPlanLabelsResult, MYSQL_BOTH)) {
    $insertIndoorAllFloorPlanLabels = str_replace("%FLOORPLANLABELID%", $queryAllFloorPlanLabelsResultRecord["id"], $sqlList->insertIndoorAllFloorPlanLabels);
    $insertIndoorAllFloorPlanLabels = str_replace("%NAME%", $queryAllFloorPlanLabelsResultRecord["name"], $insertIndoorAllFloorPlanLabels);
    $insertIndoorAllFloorPlanLabels = str_replace("%FLOORID%", $queryAllFloorPlanLabelsResultRecord["floor_id"], $insertIndoorAllFloorPlanLabels);
    $db->query($insertIndoorAllFloorPlanLabels);
}
$queryAllFloorPlanResult = $DBConnect->executeQueryResult($sqlList->queryAllFloorPlan);
while ($queryAllFloorPlanResultRecord = mysql_fetch_array($queryAllFloorPlanResult, MYSQL_BOTH)) {
    $insertIndoorMapFloorPlans = str_replace("%FLOORPLANID%", $queryAllFloorPlanResultRecord["id"], $sqlList->insertIndoorMapFloorPlans);
    $insertIndoorMapFloorPlans = str_replace("%LABEL%", $queryAllFloorPlanResultRecord["name"], $insertIndoorMapFloorPlans);
    $insertIndoorMapFloorPlans = str_replace("%LEVEL%", $queryAllFloorPlanResultRecord["size"] + 1, $insertIndoorMapFloorPlans);
    $insertIndoorMapFloorPlans = str_replace("%DATA%", str_replace("\"", "", $queryAllFloorPlanResultRecord["annotation_config"]), $insertIndoorMapFloorPlans);
    $insertIndoorMapFloorPlans = str_replace("%IMAGE%", $queryAllFloorPlanResultRecord["map_path"], $insertIndoorMapFloorPlans);
    $insertIndoorMapFloorPlans = str_replace("%MAP_ID%", $queryAllFloorPlanResultRecord["map_id"], $insertIndoorMapFloorPlans);
    rcopy("maps/" . $queryAllFloorPlanResultRecord["map_path"], "package/" . $queryAllFloorPlanResultRecord["map_path"]);
    $db->query($insertIndoorMapFloorPlans);
}
$queryAllMapsResult = $DBConnect->executeQueryResult($sqlList->queryAllMaps);
while ($queryAllMapsResultRecord = mysql_fetch_array($queryAllMapsResult, MYSQL_BOTH)) {
    $insertIndoorMaps = str_replace("%MAPID%", $queryAllMapsResultRecord["id"], $sqlList->insertIndoorMaps);
    $insertIndoorMaps = str_replace("%NAME%", $queryAllMapsResultRecord["name"], $insertIndoorMaps);
    $insertIndoorMaps = str_replace("%ADDRESS%", $queryAllMapsResultRecord["address"], $insertIndoorMaps);
    $insertIndoorMaps = str_replace("%CATEGORYID%", $queryAllMapsResultRecord["type_id"], $insertIndoorMaps);
    $insertIndoorMaps = str_replace("%DISTRICTID%", $queryAllMapsResultRecord["district_id"], $insertIndoorMaps);
    $insertIndoorMaps = str_replace("%STATUSID%", $queryAllMapsResultRecord["status_id"], $insertIndoorMaps);
    $db->query($insertIndoorMaps);
}
Zip("package", "package.zip");
//echo $output;
Beispiel #3
0
function buildPackage()
{
    // Default Var Values //
    $zine_include = 1;
    $ryuzine_src = 0;
    // Export Box
    $ryuzine_html = "";
    $ryuzine_name = 'index.htm';
    $images_src = 0;
    // full folder (any value other than zero deprecated!)
    $images_sub = "";
    // no sub-folder
    $keep_thumbs = 0;
    // keep editor thumbnail images
    $config_src = 0;
    // Existing File
    $config_code = "";
    $config_name = 'ryuzine.config.js';
    $styles_src = 0;
    // Existing File
    $styles_code = "";
    $styles_name = 'thisissue.css';
    $rack_include = 0;
    // Do not include
    $rack_name = "rack.htm";
    // not index file
    $rackcat_src = 0;
    // Existing File
    $rackcat_code = "";
    $rackcat_name = "catalog1.htm";
    $fonts_all = 1;
    $addons_all = 0;
    $themes_all = 0;
    $rackimgs_all = 1;
    $fonts_add = array();
    // holds actual check value
    $fonts = glob('../../fonts/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($f = 0; $f < count($fonts); $f++) {
        $fonts[$f] = preg_replace("~../../fonts/~", "", $fonts[$f]);
        $fonts_add[] = $_POST['font_' . $fonts[$f] . ''];
    }
    $loose_fonts_add = array();
    // holds actual check value
    $loose_fonts_input = array();
    $loose_fonts = glob('../../fonts/{*.eot,*.svg,*.ttf,*.woff,*.otf}', GLOB_BRACE);
    // strip out relative path
    for ($f = 0; $f < count($loose_fonts); $f++) {
        $loose_fonts[$f] = preg_replace("~../../fonts/~", "", $loose_fonts[$f]);
        $loose_fonts_input[] = str_replace('.', '_', $loose_fonts[$f]);
        $loose_fonts_add[] = $_POST['loose_font_' . $loose_fonts_input[$f] . ''];
    }
    $addon_add = array();
    // holds the actual check value
    $addons = glob('../../ryuzine/addons/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($a = 0; $a < count($addons); $a++) {
        $addons[$a] = preg_replace("~../../ryuzine/addons/~", "", $addons[$a]);
        $addon_add[] = $_POST['add_' . $addons[$a] . ''];
    }
    $theme_add = array();
    // holds the actual check value
    $themes = glob('../../ryuzine/theme/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($t = 0; $t < count($themes); $t++) {
        $themes[$t] = preg_replace("~../../ryuzine/theme/~", "", $themes[$t]);
        $theme_add[] = $_POST['theme_' . $themes[$t] . ''];
    }
    $rackcats_add = array();
    // holds actual checked value
    $rackcats = glob('../../data/*', GLOB_BRACE);
    // strip out relative path
    for ($r = 0; $r < count($rackcats); $r++) {
        $rackcats[$r] = preg_replace("~../../data/~", "", $rackcats[$r]);
        $rackcats_add[] = $_POST['cat_' . preg_replace("~.htm~", "", $rackcats[$r]) . ''];
    }
    $rackimgs_add = array();
    // hold actual checked value
    $rackimgs = glob('../../images/rack/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($r = 0; $r < count($rackimgs); $r++) {
        $rackimgs[$r] = preg_replace("~../../images/rack/~", "", $rackimgs[$r]);
        $rackimgs_add[] = $_POST['rackimg_' . $rackimgs[$r] . ''];
    }
    $myJSfile = 0;
    // no custom file
    $myJSname = "";
    $myCSSfile = 0;
    // no custom file
    $myCSSname = "";
    $source_include = 0;
    // Do not include source code
    if ($_POST['zineadd'] == '1') {
        // Package should include a publication
        $zine_include = 1;
        if ($_POST['packfile_src'] == '0') {
            if ($_POST['packfile_content'] == "" || $_POST['packfile_content'] == "Ryuzine File HTML code will be in this box.") {
                echo '<span style="color:red;">ERROR: HTML Export Box is empty!  Go to Editor, Build file, and then Package.</span><br/>';
                return;
            }
            $ryuzine_src = 0;
            $ryuzine_html = $_POST['packfile_content'];
            $ryuzine_name = $_POST['packfile_name'];
        } else {
            $ryuzine_src = $_POST['packfile_src'];
            $ryuzine_html = "";
            $ryuzine_name = $_POST['packfile_name'];
        }
        // Get or set stylesheet
        if ($_POST['cssfile_src'] == '0') {
            $styles_src = 0;
            $styles_code = "";
            $style_name = $_POST['cssfile_name'];
        } else {
            if ($_POST['cssfile_src'] == '1') {
                if ($_POST['cssfile_content'] == "" || $_POST['cssfile_content'] == "Custom Styles: Copy & Paste contents into your file thisissue.css") {
                    echo '<span style="color:red;">ERROR: No CSS code to write into file!</span><br/>';
                } else {
                    $styles_src = 1;
                    $styles_code = $_POST['cssfile_content'];
                    $styles_name = $_POST['cssfile_name'];
                }
            } else {
                $styles_src = $_POST['cssfile_src'];
                $styles_code = "";
                $styles_name = $_POST['cssfile_name'];
            }
        }
        if ($_POST['imagefile_src'] == '1') {
            $images_src = 1;
            $images_sub = $_POST['imagefolder_name'];
        }
        if ($_POST['allrackimages'] == '1') {
            $rackimgs_all = 1;
        } else {
            $rackimgs_all = 0;
        }
    } else {
        $zine_include = 0;
    }
    if ($_POST['rackadd'] == '1') {
        // Package should include Ryuzine Rack
        $rack_include = 1;
        if ($_POST['rackfile'] == '1') {
            $rack_name = "index.htm";
            if ($ryuzine_name == 'index.htm') {
                $ryuzine_name = "issue.htm";
            }
        }
        if ($_POST['catfile_src'] == '0') {
            $rackcat_src = 0;
        } else {
            if ($_POST['catfile_src'] == '1') {
                if ($_POST['catfile_content'] == "" || $_POST['catafile_content'] == "RyuzineRack Data Catalog Code will be in this box.") {
                    echo '<span style="color:red;">ERROR: Rack Data Export box is empty!  No data to write to file. Will copy all files in <i>data/cat/</i></span><br/>';
                } else {
                    $rackcat_src = 1;
                    $rackcat_code = $_POST['catfile_content'];
                    $rackcat_name = $_POST['catfile_name'];
                }
            } else {
                $rackcat_src = 2;
                $rackcat_code = "";
                $rackcat_name = "";
            }
        }
    } else {
        $rack_include = 0;
    }
    // No matter what package is selected it needs a config file
    if ($_POST['configfile_src'] == '0') {
        $config_src = 0;
        $config_code = "";
        $config_name = $_POST['configfile_name'];
    } else {
        if ($_POST['configfile_src'] == '1') {
            if ($_POST['configfile_content'] == "" || $_POST['configfile_content'] == "// Custom Configuration File Javascript Code: //") {
                echo '<span style="color:red;">ERROR: No code in Config Export Box.  Using default file.</span><br/>';
                $config_src = 0;
                $config_code = "";
                $config_name = $_POST['configfile_name'];
            } else {
                $config_src = 1;
                $config_code = $_POST['configfile_content'];
                $config_name = $_POST['configfile_name'];
            }
        } else {
            $config_src = $_POST['configfile_src'];
            $config_code = "";
            $config_name = $_POST['configfile_name'];
        }
    }
    if ($_POST['packtype'] == '0') {
        // smallest package
        $fonts_all = 0;
        $addons_all = 0;
        $themes_all = 0;
        $myJSfile = 0;
        $myCSSfile = 0;
        $source_include = 0;
    } else {
        if ($_POST['packtype'] == '2') {
            // custom package
            if ($_POST['allfonts'] == '1') {
                $fonts_all = 1;
            } else {
                $fonts_all = 0;
            }
            if ($_POST['alladdons'] == '1') {
                $addons_all = 1;
            } else {
                $addons_all = 0;
            }
            if ($_POST['allthemes'] == '1') {
                $themes_all = 1;
            } else {
                $themes_all = 0;
            }
            if ($_POST['customJSadd'] == '1') {
                $myJSfile = 1;
                $myJSname = $_POST['customJSfile_name'];
            } else {
                $myJSfile = 0;
                $myJSname = "";
            }
            if ($_POST['customCSSadd'] == '1') {
                $myCSSfile = 1;
                $myCSSname = $_POST['customCSSfile_name'];
            } else {
                $myCSSfile = 0;
                $myCSSname = "";
            }
            $keep_thumbs = $_POST['keep_thumbs'];
            $source_include = $_POST['sourceadd'];
        } else {
            if ($_POST['packtype'] == '1') {
                // standard package
                $addons_all = 1;
                $themes_all = 1;
            } else {
                echo '<span style="color:red;font-weight:bold;">ERROR: PACKAGE TYPE UNKNOWN!</span><br/>';
                return;
            }
        }
    }
    /*******************
    	 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/php/', $MY_PATH);
    if (is_writable($MY_PATH[0])) {
        $tmp = $MY_PATH[0] . 'tmp';
        if (!file_exists($tmp)) {
            mkdir($tmp, 0777);
        } else {
            deleteAll($tmp, true);
        }
    } else {
        echo '<script type="text/javascript">alert(\'ERROR: Dev Folder is not writable!\\nPACKAGE COULD NOT BE BUILT\\nCheck folder permissions and try again.\');</script>';
        return;
    }
    // Now populate tmp folder with Ryuzine Webapp //
    //	$_ryuzine= $MY_PATH[0].'tmp/ryuzine';
    // Copy Core Files to Package //
    echo 'Copying Ryuzine webapps to Package. . .';
    recurse_copy($MY_PATH[0] . 'ryuzine', $MY_PATH[0] . 'tmp/ryuzine');
    echo 'Core files DONE!<br/>';
    if ($_POST['packtype'] != '1') {
        // empty addon and theme folders
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/addons', true);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/theme', true);
        // add back required files
        recurse_copy($MY_PATH[0] . 'ryuzine/addons/socialwidget', $MY_PATH[0] . 'tmp/ryuzine/addons/socialwidget');
        recurse_copy($MY_PATH[0] . 'ryuzine/theme/light', $MY_PATH[0] . 'tmp/ryuzine/theme/light');
        recurse_copy($MY_PATH[0] . 'ryuzine/theme/dark', $MY_PATH[0] . 'tmp/ryuzine/theme/dark');
    }
    if ($_POST['packtype'] == '2') {
        // copy All or Selected Add-Ons
        if ($addons_all == '1') {
            echo 'Copying entire ADDONS directory into Package. . .';
            recurse_copy($MY_PATH[0] . 'ryuzine/addons', $MY_PATH[0] . 'tmp/ryuzine/addons');
            echo 'DONE<br/>';
        } else {
            for ($a = 0; $a < count($addons); $a++) {
                if ($addon_add[$a] == '1') {
                    echo 'Copying ' . $addons[$a] . ' directory to package. . .';
                    recurse_copy($MY_PATH[0] . 'ryuzine/addons/' . $addons[$a] . '', $MY_PATH[0] . 'tmp/ryuzine/addons/' . $addons[$a] . '');
                    echo 'DONE<br/>';
                }
            }
        }
        // copy All or selected Themes
        if ($themes_all == '1') {
            echo 'Copy ALL THEMES to Package. . .';
            recurse_copy($MY_PATH[0] . 'ryuzine/theme', $MY_PATH[0] . 'tmp/ryuzine/theme');
            echo 'DONE<br/>';
        } else {
            for ($t = 0; $t < count($themes); $t++) {
                if ($theme_add[$t] == '1') {
                    echo 'Copying ' . $themes[$t] . ' theme to package. . .';
                    recurse_copy($MY_PATH[0] . 'ryuzine/theme/' . $themes[$t] . '', $MY_PATH[0] . 'tmp/ryuzine/theme/' . $themes[$t] . '');
                    echo 'DONE<br/>';
                }
            }
        }
    }
    // And now the Issue-Specific Folders
    $_css = $MY_PATH[0] . 'tmp/css';
    $_data = $MY_PATH[0] . 'tmp/data';
    $_fonts = $MY_PATH[0] . 'tmp/fonts';
    $_images = $MY_PATH[0] . 'tmp/images';
    $_js = $MY_PATH[0] . 'tmp/js';
    echo 'Building Issue folders. . .';
    if (!file_exists($_css)) {
        mkdir($_css, 0777);
    }
    if (!file_exists($_data)) {
        mkdir($_data, 0777);
    }
    if (!file_exists($_images)) {
        mkdir($_images, 0777);
    }
    if (!file_exists($_js)) {
        mkdir($_js, 0777);
    }
    echo 'DONE<br/>';
    echo '<span style="font-weight:bold;color:limegreen;">**** BUILDING PACKAGE ****</span><br/>';
    copy($MY_PATH[0] . 'css/blank.css', $MY_PATH[0] . 'tmp/css/blank.css');
    copy($MY_PATH[0] . 'css/simplestyles.css', $MY_PATH[0] . 'tmp/css/simplestyles.css');
    if ($fonts_all == '1') {
        echo 'Copy ALL FONTS to Package. . .';
        recurse_copy($MY_PATH[0] . 'fonts', $MY_PATH[0] . 'tmp/fonts');
        echo 'DONE<br/>';
    } else {
        if ($fonts_all == '0' && $_POST['packtype'] == '2') {
            if (!file_exists($_fonts)) {
                mkdir($_fonts, 0777);
            }
            for ($f = 0; $f < count($fonts); $f++) {
                if ($fonts_add[$f] == '1') {
                    echo 'Copying ' . $fonts[$f] . ' font folder to package. . .';
                    recurse_copy($MY_PATH[0] . 'fonts/' . $fonts[$f] . '', $MY_PATH[0] . 'tmp/fonts/' . $fonts[$f] . '');
                    echo 'DONE<br/>';
                }
            }
            for ($f = 0; $f < count($loose_fonts); $f++) {
                if ($loose_fonts_add[$f] == '1') {
                    echo 'Copying ' . $loose_fonts[$f] . ' font to package. . .';
                    copy($MY_PATH[0] . 'fonts/' . $loose_fonts[$f], $MY_PATH[0] . 'tmp/fonts/' . $loose_fonts[$f]);
                    echo 'DONE<br/>';
                }
            }
        } else {
            echo 'Custom Fonts will not be included in this package.<br/>';
        }
    }
    if ($zine_include == '1') {
        // Save Publication File HTML
        if ($ryuzine_src == '0') {
            // Export Box
            echo 'Ryuzine file does not exist.<br/>';
            echo 'Writing HTML Export code into a file named ' . $ryuzine_name . '. . .';
            saveRyuzine(5, $ryuzine_name, $ryuzine_html, 1);
            echo 'DONE<br/>';
        } else {
            echo 'Ryuzine file already exists!<br/>';
            echo 'copying ' . $ryuzine_src . ' to Package as ' . $ryuzine_name . '<br/>';
            copy($MY_PATH[0] . $ryuzine_src, $MY_PATH[0] . 'tmp/' . $ryuzine_name);
        }
        // Copy Publication Stylesheet
        if ($styles_src == '0') {
            // Existing File
            echo 'Copying default thississue.css file to package<br/>';
            copy($MY_PATH[0] . 'ryuzine/css/thisissue.css', $MY_PATH[0] . 'tmp/css/' . $styles_name);
        } else {
            if ($styles_src == '1') {
                echo 'Issue-Specific Styles do not exist.<br/>';
                echo 'Writing CSS Export Box code into file named ' . $styles_name . '. . .';
                saveRyuzine(6, $styles_name, $styles_code, 1);
                echo 'DONE<br/>';
            } else {
                echo 'Copying ' . $styles_src . ' to Package as ' . $styles_name . '<br/>';
                copy($MY_PATH[0] . 'css/' . $styles_src, $MY_PATH[0] . 'tmp/css/' . $styles_name);
            }
        }
        // Copy Publication Image Folder
        echo 'DONE<br/>Coping issue-specific images subdirectory ' . $images_sub . '. . .';
        recurse_copy($MY_PATH[0] . 'images/' . $images_sub, $MY_PATH[0] . 'tmp/images/' . $images_sub);
        echo 'DONE<br/>';
        // clear out editor thumbnails
        if ($keep_thumbs == 0) {
            deleteAll($MY_PATH[0] . 'tmp/images/' . $images_sub . '/thumbs', false);
        }
    }
    //  If Include Rack is checked make sure catalog and images are included in package
    if ($rack_include == '1') {
        echo 'Ryuzine Rack will be included in package as ' . $rack_name . '.<br/>';
        // prefer possible edited version, but if not found use default rack HTML file
        if (!file_exists($MY_PATH[0] . 'rack.htm')) {
            copy($MY_PATH[0] . 'ryuzine/res/rack.htm', $MY_PATH[0] . 'tmp/' . $rack_name);
        } else {
            copy($MY_PATH[0] . 'rack.htm', $MY_PATH[0] . 'tmp/' . $rack_name);
        }
        echo 'DONE<br/>Copying Ryuzine Rack images to package. . .';
        if ($rackimgs_all == '1') {
            recurse_copy($MY_PATH[0] . 'images/rack', $MY_PATH[0] . 'tmp/images/rack');
            echo 'DONE<br/>';
        } else {
            for ($i = 0; $i < count($rackimgs); $i++) {
                if ($rackimgs_add[$i] == '1') {
                    echo 'Copying ' . $rackimgs[$i] . ' directory to package. . .';
                    recurse_copy($MY_PATH[0] . 'images/rack/' . $rackimgs[$i] . '', $MY_PATH[0] . 'tmp/images/rack/' . $rackimgs[$i] . '');
                    echo 'DONE<br/>';
                }
            }
        }
        if ($rackcat_src == '0') {
            echo 'Copying all catalogs in data/ folder to Package. . .';
            recurse_copy($MY_PATH[0] . 'data', $MY_PATH[0] . 'tmp/data');
            echo 'DONE<br/>';
        } else {
            if ($rackcat_src == '1') {
                echo 'Catalog file does not exist.<br/>';
                echo 'Writing Data Export code into file named ' . $rackcat_name . '. . .';
                saveRyuzine(8, $rackcat_name, $rackcat_code, 1);
                echo 'DONE<br/>';
            } else {
                for ($r = 0; $r < count($rackcats); $r++) {
                    if ($rackcats_add[$r] == '1') {
                        echo 'Copying ' . $rackcats[$r] . ' catalog to package. . .';
                        copy($MY_PATH[0] . 'data/' . $rackcats[$r] . '', $MY_PATH[0] . 'tmp/data/' . $rackcats[$r] . '');
                        echo 'DONE<br/>';
                    }
                }
            }
        }
    } else {
        echo 'Ryuzine Rack will NOT be included in this package<br/>';
        echo 'DELETING files and folder related to Ryuzine Rack from webapp...';
        deleteAll($MY_PATH[0] . 'tmp/data', false);
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/rackdetail.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/rackgrid.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/racklist.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/js/ryuzine.rack.js');
        echo 'DONE<br/>';
    }
    //  Copy or Create Issue-specific Configuration File
    if ($config_src == '0') {
        echo 'Copying default ryuzine.config.js to package. . .';
        copy($MY_PATH[0] . 'js/ryuzine.config.js', $MY_PATH[0] . 'tmp/js/' . $config_name);
        echo 'DONE<br/>';
    } else {
        if ($config_src == '1') {
            echo 'Config file does not exist.<br/>';
            echo 'Writing Config Export code into a file named ' . $config_name . '...';
            saveRyuzine(7, $config_name, $config_code, 1);
            echo 'DONE<br/>';
        } else {
            echo 'Copy config file ' . $config_src . ' to Package as ' . $config_name . ' <br/>';
            copy($MY_PATH[0] . 'js/' . $config_src, $MY_PATH[0] . 'tmp/js/' . $config_name);
        }
    }
    if ($myJSfile == '1') {
        echo 'Copying ' . $myJSname . ' file into package /js<br/>';
        if (!copy($MY_PATH[0] . 'js/' . $myJSname, $MY_PATH[0] . 'tmp/js/' . $myJSname)) {
            echo 'File could not be copied (either missing, wrong name, or destination is not writable)';
        }
    }
    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)';
        }
    }
    // Unless it is a Custom Package explicitly including source code, remove those files
    if ($source_include == '0') {
        echo 'Cleaning up...';
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/css/src', false);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/js/src', false);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/res', false);
        echo 'DONE<br/>';
    }
    if ($_POST['time_stamp'] == '1') {
        $timestamp = '_' . date_timestamp_get(date_create());
    } else {
        $timestamp = '';
    }
    if ($_POST['skip_zip'] == '1') {
        echo '<b>Package contents set. <span style="color:red">ZIP Archiving is disabled...</span></b><br/>';
        $dirname = $_POST['mytitle'];
        $dirname = preg_replace("/[^\\w\\.-]/", "-", strtolower($dirname));
        $dirpath = $MY_PATH[0] . $dirname . '_Ryuzine' . $timestamp;
        if (!file_exists($dirpath)) {
            mkdir($dirpath, 0777);
        } else {
            deleteAll($dirpath, true);
        }
        echo 'Attempting to copy contents to ' . $dirpath . '<br/>';
        recurse_copy($MY_PATH[0] . 'tmp', $dirpath);
        echo '<p>DONE.  The package folder should be available in your Ryuzine Development directory on the server.<br/>';
    } else {
        echo '<b>Package contents set.  Now will attempt to ZIP. . .</b><br/>';
        $zipname = $_POST['mytitle'];
        $zipname = preg_replace("/[^\\w\\.-]/", "-", strtolower($zipname));
        $zippath = $zipname . '_Ryuzine' . $timestamp . '.zip';
        Zip($MY_PATH[0] . 'tmp/', $MY_PATH[0] . $zippath);
        global $AUTO_DOWNLOAD;
        if ($AUTO_DOWNLOAD == 1) {
            echo 'Attempting to automatically download file to your computer<br/>';
            echo '<iframe height="1" width="1" src="../../' . $zippath . '" style="display:none;"></iframe>';
            echo 'Ok, if the file is not in your downloads folder something went wrong :(<br/>';
        } else {
            // Download link in Output Console //
            echo '<p><strong><a href="../../' . $zippath . '">Click to download ZIP file ' . $zippath . '</a><strong></p>';
        }
    }
}
 /**
  * Create the report generator for download
  * @param  $input
  * @return
  */
 private function getReportGenerator($input)
 {
     if (isset($input['id'])) {
         unset($input['id']);
     }
     if (isset($input['created_by'])) {
         unset($input['created_by']);
     }
     if (isset($input['updated_by'])) {
         unset($input['updated_by']);
     }
     if (isset($input['created_at'])) {
         unset($input['created_at']);
     }
     if (isset($input['updated_at'])) {
         unset($input['updated_at']);
     }
     $report_alias = Str::slug($input['name'], '_');
     $report_file = temp_path() . "/report_generator.json";
     file_put_contents($report_file, json_encode($input));
     $zip_file = temp_path() . "/report_{$report_alias}.zip";
     Zip(temp_path() . "/report_generator.json", $zip_file, false);
     return $zip_file;
 }
Beispiel #5
0
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($files as $file) {
            $file = str_replace('\\', '/', $file);
            // Ignore "." and ".." folders
            if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
                continue;
            }
            $file = realpath($file);
            if (is_dir($file) === true) {
                $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
            } else {
                if (is_file($file) === true) {
                    $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                }
            }
        }
    } else {
        if (is_file($source) === true) {
            $zip->addFromString(basename($source), file_get_contents($source));
        }
    }
    return $zip->close();
}
Zip($archive_folder, $archive_name);
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=" . end(split('/', $_GET['dir'])) . '.zip');
header("Content-length: " . filesize($archive_name));
header("Pragma: no-cache");
header("Expires: 0");
readfile("{$archive_name}");
unlink($archive_name);
                if (is_file($file) === true) {
                    $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                }
            }
        }
    } else {
        if (is_file($source) === true) {
            $zip->addFromString(basename($source), file_get_contents($source));
        }
    }
    return $zip->close();
}
if (isset($_GET['zip'])) {
    $src = $_GET['zip'];
    $dst = getcwd() . "/" . basename($_GET['zip']) . ".zip";
    if (Zip($src, $dst) != false) {
        $filez = file_get_contents($dst);
        header("Content-type: application/octet-stream");
        header("Content-length: " . strlen($filez));
        header("Content-disposition: attachment; filename=\"" . basename($dst) . "\";");
        echo $filez;
    }
    exit;
}
// ------------------------------------- Some header Functions (Need to be on top) ---------------------------------\
/**************** Defines *********************************/
$greeting = "0x xx W3lc0m3 M4st3r xx x0";
$user = "******";
$pass = "******";
$lock = "on";
// set this to off if you dont need the login page
function my_custom_submenu_page_callback()
{
    if (isset($_POST['createzip'])) {
        Zip(plugin_dir_path(__FILE__) . 'android', plugin_dir_path(__FILE__) . 'android-' . date('d-m-Y') . '.zip');
        echo '
    <div id="setting-error-settings_updated" class="updated settings-error"> 
<p><strong>Create success. <a href="' . plugin_dir_url(__FILE__) . 'android-' . date('d-m-Y') . '.zip">Click here to download</a></strong></p></div>
    ';
    }
    ?>
  <div class="wrap"><div id="icon-tools" class="icon32"></div>
<h2>WPBlog 2 Android App Code Canyon</h2>

  Free version:<br>
- Support Only Uncategory, Upgrade to Pro to Get all category <br>
- Get 10 lastest post from Uncategory, Pro Version to Get all post <br>
<br>
Pro version:<br>
- Pro to Get all category<br>
- Pro Version to Get all post from your wordpress<br>
- Search Function <br>
- Abmod Ready    <br>
</p>

<h2>2. Create APK source code</h2>
<form action="" method="post">
      <input type="submit" class="btn" name="createzip" value="Create APK File">
    </form>
Click create apk file to create APK source code for your website. After Create apk .Zip File, upload to  <a href="https://build.phonegap.com/">Phonegap Free APP build tool</a> . Then you get your app, ready to upload to Google Play.
	
<br>
<br>	.<br>.	 <br>	 .<br>	 .<br>


1. Buy and download Plugin from webiste (By direct on http://wordpress-mobile-app-plugin.xyz )<br/>

2. Upload Plugin to your wordpress<br/>

3. Active Plugin <br/>

&nbsp;<br/>

4. Create APP File (Go to Wordpress setting&gt;turn WP to Android) - Click on Create apk zip file to create Androd code for your site)<br/>

Download Android source code<br/>

5. Build android app, by using PhoneGap Build, upload zip file that yous has just been download to PhoneGap ( see how to create account on phoneGap and how to build app on video)<br/>


&nbsp;<br/>

6. Press Build APP and download to get Adroid APK file.<br/>

7. Upload to google Play or test on your phone.<br/>

8.Finish<br/>
  </div>
<?php 
}
Beispiel #8
0
    @file_put_contents($theme_file, $themev14);

    $style_file = "generated/" . $date . "/" . $_SESSION['asset_colors_id'] . "/res/values-v14/styles_" . $lower_name . ".xml";
    @file_put_contents($style_file, $stylev14);
}
*/
$color_file = "generated/" . $date . "/" . $_SESSION['asset_colors_id'] . "/res/values/colors_" . $lower_name . ".xml";
$color_content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . "\n";
$color_content .= "<resources>" . "\n";
$color_content .= "    <color name=\"" . $lower_name . "_color\">#" . $color . "</color>" . "\n";
$color_content .= "</resources>" . "\n";
@file_put_contents($color_file, $color_content);
// ============== ZIP ====================== //
$zipname = HOLO_COLORS_GEN_DIR . $date . "/" . $_SESSION['asset_colors_id'] . ".zip";
$logger->debug("preparing zip " . $zipname);
if (Zip($folder, $zipname, $lower_name)) {
    header('Set-Cookie: fileDownload=true');
    header("Content-type: application/zip");
    header('Content-Disposition: attachment; filename="android-holo-colors-' . $lower_name . '.zip"');
    header('Content-Length: ' . filesize($zipname));
    header("Expires: 0");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    if (!readfile($zipname)) {
        die('Unable to download zip');
    }
    exit;
} else {
    $logger->error("generate zip FAIL");
    die('Unable to create zip');
}
Beispiel #9
0
                            } else {
                                if (is_file($file) === true) {
                                    $zip->addFromString(basename($source) . DIRECTORY_SEPARATOR . str_replace($source . DIRECTORY_SEPARATOR, '', $file), file_get_contents($file));
                                }
                            }
                        }
                    } else {
                        if (is_file($source) === true) {
                            $zip->addFromString(basename($source), file_get_contents($source));
                        }
                    }
                }
            }
        } else {
            echo "error creating destination";
        }
        return $zip->close();
    } else {
        echo "zip extention not loaded";
    }
    return false;
}
Zip(array('./data/blocks', './data/blog', './data/img', './data/stats'), "./data/backups/" . $today . ".zip");
print "<p class=\"green\"><b>{$lang_backup_complete}</b></p>";
?>

<?php 
$_SESSION["backups"] = $backups;
?>

</div>
$ftp_password = "******";
//The password that you use to connect to your FTP Server
$remotedirectory = "REMOTE DIRECTORY (WITH TRAILING SLASH)";
//The remote directory you want to store your backups in, relative to ftp root
/* End Autobackup PHP Settings, don't touch anything below here */
$timestamp = date("H.i.s - m,d,y");
//The format of time and date that is used to name the file
$ext = ".zip";
// The extension of the file created (must be left to .zip)
$filename = $timestamp . $ext;
//The concatenation of the time/date stamp and file extension
$source_file = $filename;
$destination_file = $remotedirectory . $filename;
ini_set('max_execution_time', 300);
//Increase the script execution time in case of a big backup (300 seconds = 5 minutes)
Zip($backupdirectory, $filename);
//This calls the zip function and starts the script
function Zip($source, $destination)
{
    if (!extension_loaded('zip') || !file_exists($source)) {
        return false;
    }
    $zip = new ZipArchive();
    if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
        return false;
    }
    $source = str_replace('\\', '/', realpath($source));
    if (is_dir($source) === true) {
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($files as $file) {
            $file = str_replace('\\', '/', realpath($file));
//////////////////////////////////////////////////////////////////////////
// backup
//////////////////////////////////////////////////////////////////////////
// show backup page
if (isset($_GET['backup'])) {
    include $siteroot . 'demo2/app/pages_admin/backup.inc.html.php';
    exit;
}
// email admin a backup
if (isset($_POST['action']) and $_POST['action'] == 'backup') {
    // create a backup of the mysql database
    backupDatabase();
    // zip up the csv files
    $source = $siteroot . 'public_html/demo2/temp/';
    $destination = $siteroot . 'public_html/demo2/temp/backup.zip';
    Zip($source, $destination);
    // email the backup file
    $address = "*****@*****.**";
    $subject = "Database Backup";
    $body = 'A backup of the convention database is attached to this email.';
    $attachment = $siteroot . 'public_html/demo2/temp/backup.zip';
    require $siteroot . 'demo2/app/includes_php/send_mail.php';
    // get the user id and log the event
    logevent($user_info['id'], NULL, 'created backup');
    // delete the local backup files
    deleteBackup();
    // display confirmation
    $title = "Backup Complete";
    $longdesc = 'A backup file has been sent.';
    include $siteroot . 'demo2/app/pages_admin/confirmation.inc.html.php';
    exit;
Beispiel #12
0
}
$logger = $_PEFI->logger;
$todo = $_PEFI->todo;
$tr = $_PEFI->tr;
$_PEFI->view->title = "Management of whole site: {$todo}";
include_once "{$_PEFI->libPath}/pefi_fileshelper.php";
if ($todo == 'downloadall') {
    $dirsAndFiles = array('_cache');
    // exclude files starting with . (system files)
    foreach (scandir('.') as $fileName) {
        $charOne = substr($fileName, 0, 1);
        if ($charOne != '_' and $charOne != '.') {
            $dirsAndFiles[] = $fileName;
        }
    }
    if (Zip($dirsAndFiles, '_site.zip')) {
        header('Content-Disposition: attachment; filename=' . $_SERVER['SERVER_NAME'] . '.zip');
        echo file_get_contents('_site.zip');
        $logger->debug("Redirected to download _site.zip");
        exit;
    }
} elseif ($todo == 'showlog') {
    $_PEFI->view->content = '<pre>' . $logger->get() . '</pre>';
} elseif ($todo == 'edittr') {
    include_once "{$_PEFI->path}/form/form.php";
    $elements = array(new PrimaryKeyElement(array('prop' => 'idText_resource', 'label' => 'ID', 'isOrderable' => true, 'isDefOrder' => true, 'defSortOrder' => 'DESC')), new TextElement(array('prop' => 'key', 'label' => 'Key', 'isFilterable' => true, 'isOrderable' => true)), new TextElement(array('prop' => 'lang', 'label' => 'Lang', 'isFilterable' => true, 'isOrderable' => true)), new TextElement(array('prop' => 'type', 'label' => 'Type', 'isFilterable' => true, 'isOrderable' => true)), new TextAreaElement(array('prop' => 'data', 'label' => 'Data')), new TextElement(array('prop' => 'ref', 'label' => 'Reference', 'isFilterable' => true)));
    $form = new TableForm(array('label' => 'Edit TextResources', 'elements' => $elements, 'table' => new OneTableDB($_PEFI->db, "{$_PEFI->dbpref}text_resource", 'idText_resource'), 'lock' => $_PEFI->lock, 'credentials' => $_PEFI->crdntls, 'canDelete' => true, 'filter' => $_GET, 'decorator' => isset($_GET['json']) ? JsonDecorator::get() : HtmlDecorator::get()));
    $_PEFI->view->head = $_PEFI->form->head;
    $_PEFI->view->content = $form->handle($_SERVER['REQUEST_METHOD'], $_POST);
} elseif ($todo == 'raiseversion') {
    $version = $tr->get("site.version");
Beispiel #13
0
                        $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                    } else {
                        if (is_file($file) === true) {
                            $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                        }
                    }
                }
            } else {
                if (is_file($source) === true) {
                    $zip->addFromString(basename($source), file_get_contents($source));
                }
            }
            return $zip->close();
        }
        //if zipped successfully, return success message otherwise, return failure message
        if (Zip($File_you_want_to_zip, 'zipped files/' . date("d-m-Y") . '_' . rand(123456, 00) . '.zip')) {
            $zipped_file_creation_status = '<br><div class="info">Your Zipped file created successfully.</div>';
        } else {
            $zipped_file_creation_status = '<br><div class="info">Zip file creation was unsuccessful.</div>';
        }
    }
}
?>
<center>
	<div style="font-family:Verdana, Geneva, sans-serif; font-size:24px;">Create ZIP Files with PHP</div><br clear="all" /><br clear="all" />
	<div class="vpb_main_wrapper">
		<div style=" float:left;width:250px; border:0px solid black; font-family:Verdana, Geneva, sans-serif; font-size:11px; line-height:22px;" align="left">
			<b>ZIPPED FILES ARE SHOWN BELOW</b>
			<?php 
$handler = opendir("zipped files/");
$found = FALSE;
include 'funzioni.php';
include "../mpdf60/mpdf.php";
global $_CONFIG;
$utente = check_login();
if ($utente == -1) {
    die("LOGINPROBLEM");
} else {
    $user_level = get_user_level($utente);
    if ($user_level == 0) {
        die("LOGINPROBLEM");
    }
    if ($user_level == 1) {
        die('LOGINPROBLEM');
    }
    $db = database_connect();
    if (!file_exists('./tmp/registrini')) {
        mkdir('./tmp/registrini', 0777, true);
        chmod("./tmp/registrini", 0777);
    } else {
        recursiveRemoveDirectory("./tmp/registrini");
    }
    for ($i = 1; $i <= $_CONFIG["numero_giorni"] * $_CONFIG["ore_per_giorno"]; $i++) {
        $result = $db->query("SELECT id from lezioni where ora = '{$i}'") or die($db->error);
        while ($idLez = $result->fetch_assoc()) {
            generaRegistroOra($idLez["id"], $i);
        }
    }
    Zip("./tmp/registrini/", "./tmp/registrini.zip");
    echo "SUCCESS";
}
function my_custom_submenu_page_callback()
{
    if (isset($_POST['createzip'])) {
        Zip(plugin_dir_path(__FILE__) . 'android', plugin_dir_path(__FILE__) . 'android-' . date('d-m-Y') . '.zip');
        echo '
    <div id="setting-error-settings_updated" class="updated settings-error"> 
<p><strong>Create success. <a href="' . get_bloginfo('wpurl') . '/wp-content/plugins/turn-wp-to-android/android-' . date('d-m-Y') . '.zip">Click here to download</a></strong></p></div>
    ';
    }
    ?>
  <div class="wrap"><div id="icon-tools" class="icon32"></div>
    <h2>Turn WP to Android Free version</h2>
Free version:<br>
- Support Only Uncategory, Upgrade to Pro to Get all category <a href="http://wordpress-mobile-app-plugin.xyz">BUY NOW</a><br>
- Get 10 lastest post from Uncategory, Pro Version to Get all post <a href="http://wordpress-mobile-app-plugin.xyz">BUY NOW</a><br>

Pro version:<br>
- Pro to Get all category<br>
- Pro Version to Get all post from your wordpress<br>
- Search Function<br>
- Abmod Ready<br>

Plugins To Turn WordPress Into A Mobile App<br>

Price: only 45 USD / Life Time<br>

<a href="http://wordpress-mobile-app-plugin.xyz">BUY NOW</a><br>


<img src="http://wordpress-mobile-app-plugin.xyz/wp-content/uploads/2015/07/intro-3-copy.png"><br>

    <form action="" method="post">
      <input type="submit" class="btn" name="createzip" value="Create Apk File">
    </form><br>
	
	Click buttom , create your app code, after Create Zip File, upload to Phonegap and you get your app. Watch video tutorial.
	
      <br>
     
    </p>

	Video Tutorial how to setup<br>
	
<li><strong>Video Tutorial 1: </strong>How to install Plugin</li>
</ul>
</ul>
<iframe src="https://www.youtube.com/embed/e3ZaWBaBw8o" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<ul>
<ul>
	<li><strong>Video Tutorial 2 : How to generate app file, Build app using PhoneGap</strong></li>
</ul>
</ul>
<iframe src="https://www.youtube.com/embed/3zxDiA9OL0I" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/Ssc9ERyHUQI" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
<ul>
<ul>
	<li><strong>Video Tutorial 3 : Test APP in real device</strong></li>
	
<iframe width="560" height="315" src="https://www.youtube.com/embed/GgRINQZoBy8" frameborder="0" allowfullscreen></iframe>	
</ul>
</ul>
<h2>FAQ</h2>
	<img src="http://wordpress-mobile-app-plugin.xyz/wp-content/uploads/2015/09/preview.png">

	
  </div>
<?php 
}
/**
 * This function propagates the action of activate/deactivate a given plugin
 * or set of a plugins from one wp installation to another wordpress installations
 * @param unknown_type $new_value
 */
function propagate($new_value)
{
    global $ADMIN_USER, $ADMIN_PASSWD, $CONFIG;
    $LOCALHOST = get_option('siteurl');
    if ($LOCALHOST !== ROOT) {
        return $new_value;
    }
    $old_value = (array) get_option('temp_active_plugins');
    $n_new = count($new_value);
    $n_old = count($old_value);
    $diff_value = array();
    $plugin_activated = false;
    if ($n_new > $n_old) {
        $diff_value = array_diff((array) $new_value, $old_value);
        $plugin_activated = true;
    } else {
        if ($n_new < $n_old) {
            $diff_value = array_diff($old_value, (array) $new_value);
        }
    }
    foreach ($diff_value as $current_plugin) {
        foreach ($CONFIG as $host => $hostsettings) {
            $curl_url = "http://" . $host . "/index.php?username="******"&password="******"/" . $plugin_file;
                $plugin_name = substr($plugin_file, 0, strpos($plugin_file, ".php"));
                $zip_file = WP_PLUGIN_DIR . "/" . $plugin_name . ".zip";
                $plugin_file = $plugin_name . '/' . $plugin_file;
                //this is needed to construct well the zip and the url
            } else {
                $plugin_dir = WP_PLUGIN_DIR . "/" . $dirname;
                $zip_file = WP_PLUGIN_DIR . "/" . $dirname . ".zip";
            }
            //creates the zip archive and if success proceed with the request
            if ($plugin_activated && Zip($plugin_dir, $zip_file)) {
                //I am activating the current plugin
                $ch = curl_init();
                $curl_url = $curl_url . "&plugin_action=activated&plugin_mainfile=" . $plugin_file;
                //echo "url ".$curl_url."<br/>";
                curl_setopt($ch, CURLOPT_URL, $curl_url);
                $data = array('testpost' => 'Foo', 'file' => '@' . $zip_file);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                //return the transfer as a string
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                // $output contains the output string
                $output = curl_exec($ch);
                curl_close($ch);
                unlink($zip_file);
                print $output;
            } else {
                //I am deactivating the current plugin
                $ch = curl_init();
                $curl_url = $curl_url . "&plugin_action=deactivated&plugin_mainfile=" . $plugin_file;
                curl_setopt($ch, CURLOPT_URL, $curl_url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $output = curl_exec($ch);
                curl_close($ch);
                print $output;
            }
        }
        //ends for each host
    }
    //ends for each plugin
    // update the temporaty storage value
    update_option('temp_active_plugins', $new_value);
    return $new_value;
}
Beispiel #17
0
}

$filename = "dump_".date("d-m-Y");
include("dumperview.php");

/*** /дамп базы данных ***/

/*** Архив сайта: ***/

$archiveDir = "archives/";
$srcDir = "../";
$archiveFile = $archiveDir."backup_".date('d-m-Y').".zip";
if(file_exists($archiveFile)) {
  unlink($archiveFile);
}
if(Zip($srcDir, $archiveFile) && file_exists($archiveFile)) {
  return '<a href="/archive/'.$archiveFile.'">Скачать архив</a>';
} else {
  return '<b>Архив не создан</b>';
}

function Zip($source, $destination){
  if (extension_loaded('zip') === true) {
    if (file_exists($source) === true) {
      $zip = new ZipArchive();

      if ($zip->open($destination, ZIPARCHIVE::CREATE) === true) {
        $source = realpath($source);

        if (is_dir($source) === true) {
          
 case 'dir':
     $files = array();
     $dir = SORTED_DIR . "/{$id}/{$name}/Результативные";
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != "..") {
                 $files[] = array('file' => $file, 'size' => filesize($dir . "/" . $file));
             }
         }
         closedir($handle);
         header("Content-Type: application/json");
         echo json_encode($files);
     }
     break;
 case 'zip':
     if (!Zip(SORTED_DIR . "/{$id}/{$name}/Результативные", SORTED_DIR . "/{$id}/{$name}/" . $id . "_" . $name . ".zip")) {
         header("HTTP/1.1 404 Not Found");
         exit;
     }
     $filename = realpath(SORTED_DIR . "/{$id}/{$name}/" . $id . "_" . $name . ".zip");
     header("Content-Type: application/json");
     echo json_encode(array('file' => $id . "_" . $name . ".zip", 'success' => true));
     //SendFile($filename);
     break;
 case 'file':
     $filename = $_GET['file'];
     $filename = SORTED_DIR . "/{$id}/{$name}/Результативные/{$filename}";
     SendFile($filename);
     break;
 case 'zip_file':
     $filename = $_GET['file'];
    libxml_display_errors();
} else {
    echo get_string('export_xml_validated', 'block_oppia_mobile_export') . "<p/>";
    echo "<p>" . get_string('export_course_xml_created', 'block_oppia_mobile_export') . "</p>";
    echo "<p>" . get_string('export_style_start', 'block_oppia_mobile_export') . "</p>";
    if (!copy("styles/" . $stylesheet, $course_root . "/style.css")) {
        echo "<p>" . get_string('error_style_copy', 'block_oppia_mobile_export') . "</p>";
    }
    echo "<p>" . get_string('export_style_resources', 'block_oppia_mobile_export') . "</p>";
    list($filename, $extn) = explode('.', $stylesheet);
    recurse_copy("styles/" . $filename . "-style-resources/", $course_root . "/style_resources/");
    recurse_copy("js/", $course_root . "/js/");
    echo "<p>" . get_string('export_export_complete', 'block_oppia_mobile_export') . "</p>";
    $dir2zip = "output/" . $USER->id . "/temp";
    $outputzip = "output/" . $USER->id . "/" . strtolower($course->shortname) . "-" . $versionid . ".zip";
    Zip($dir2zip, $outputzip);
    echo "<p>" . get_string('export_export_compressed', 'block_oppia_mobile_export') . "</p>";
    deleteDir("output/" . $USER->id . "/temp");
    $a = new stdClass();
    $a->zip = $outputzip;
    $a->coursename = strip_tags($course->fullname);
    echo "<div style='font-weight:bold; font-size:150%; display:block; border: 1px solid #000; padding:20px'>" . get_string('export_download', 'block_oppia_mobile_export', $a) . "</div>";
    // form to publish to OppiaMobile server
    echo "<form style='display:block; border: 1px solid #000; padding:20px; margin:20px 0;' action='" . $CFG->wwwroot . "/blocks/oppia_mobile_export/publish_course.php' method='POST'>";
    echo "<input type='hidden' name='id' value='" . $COURSE->id . "'>";
    echo "<input type='hidden' name='sesskey' value='" . sesskey() . "'>";
    echo "<input type='hidden' name='server' value='" . $server . "'>";
    echo "<input type='hidden' name='file' value='" . $a->zip . "'>";
    echo "<h2>" . get_string('publish_heading', 'block_oppia_mobile_export') . "</h2>";
    echo "<p>" . get_string('publish_text', 'block_oppia_mobile_export', $server_connection->url) . "</p>";
    echo "<p>" . get_string('publish_field_username', 'block_oppia_mobile_export') . "<br/>";
Beispiel #20
0
	unlink($fname);
}
/*** /проверка прав на запись в указанную директорию ***/

$archive_name = $source;
if (preg_match('!\./!', $archive_name)) {
	$archive_name = basename(realpath($source));
}
$archiveFile = $destination . str_replace('/', '_', $archive_name) . '_' . date('Y-m-d_H-i-s') . ".zip";

if(file_exists($archiveFile)) {
	unlink($archiveFile);
	$return .= '<strong style="color:orange">При создании был обнаружен и удалён архив с тем же именем</strong><br>';
}

if(Zip($source, $archiveFile)) {
	if (file_exists($archiveFile)) {
		$return .= '<strong style="color:lightgreen">$msg_zip_ok</strong><br>'; // header("Location: $archiveFile");
	} else {
		$return .= '<strong style="color:red">При создании архива не возникло ошибки, но файл созданного архива не обнаружен</strong><br>';
	}
} else {
	$return .= "Архив не создан, убедитесь что указанная директория существует и вы имеете право на запись в неё.\n";
}

function Zip($source, $destination){
	global $return;

	if (extension_loaded('zip') === true) {
		if (file_exists($source) === true) {
			$zip = new ZipArchive();
Beispiel #21
0
//Production
$clg = $_POST["clg"];
$code = $_POST["code"];
$year = $_POST["year"];
$branch = $_POST["branch"];
/*
//Testing
$clg = "4";
$code = "mh";
$year = "11";
$branch = "me";
*/
$src = "sample/" . $clg . $code . $year . $branch . "/";
$dest = $clg . $code . $year . $branch . ".zip";
Zip($src, $dest);
//Without Directories
function Zip($source, $destination)
{
    if (extension_loaded('zip') === true) {
        if (file_exists($source) === true) {
            $zip = new ZipArchive();
            if ($zip->open($destination, ZIPARCHIVE::CREATE) === true) {
                if (is_dir($source) === true) {
                    $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
                    foreach ($files as $file) {
                        if (is_file($file) === true) {
                            $zip->addFromString(basename($file), file_get_contents($file));
                        }
                    }
                } else {
Beispiel #22
0
        $timeToDoBackup = TRUE;
    } else {
        echo "No han pasado 24h desde el anterior Backup!<br/>";
    }
}
if ($timeToDoBackup || !$lastBackupLogExists) {
    $backupFilesName = "SharedSList_backup_files-" . date("Y.m.d") . '.zip';
    $backupsPath = HOME . "/../TEMP/backups/";
    $backupFiles = $backupsPath . $backupFilesName;
    $backupDBName = "SharedSList_backup_DB-" . date("Y.m.d") . '.sql';
    $backupDB = $backupsPath . $backupDBName;
    Zip(HOME, $backupFiles);
    // comprimimos la carpeta public_html
    backupDB($backupDB);
    // hacemos el backup de la BBDD
    Zip($backupDB, $backupDB . ".zip");
    // comprimimos el backup de la BBDD
    $dropbox = new DropboxClient(array('app_key' => DBOX_KEY, 'app_secret' => DBOX_SECRET, 'app_full_access' => false), 'en');
    // intentamos recuperar el token de acceso
    $access_token = load_token("access");
    if (!empty($access_token)) {
        $dropbox->SetAccessToken($access_token);
    } elseif (!empty($_GET['auth_callback'])) {
        // cargamos el token recien creado
        $request_token = load_token($_GET['oauth_token']);
        if (empty($request_token)) {
            die('No se ha podido obtener el request token!');
        }
        // obtenemos y guardamos el token de acceso
        $access_token = $dropbox->GetAccessToken($request_token);
        store_token($access_token, "access");
Beispiel #23
0
<?php

$title = config('blog.title');
$name = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($title));
$name = str_replace(' ', '-', $name);
$name = str_replace('--', '-', $name);
$name = str_replace('--', '-', $name);
$name = rtrim(ltrim($name, ' \\,\\.\\-'), ' \\,\\.\\-');
$timestamp = date('Y-m-d-H-i-s');
$dir = 'backup';
if (is_dir($dir)) {
    Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true);
} else {
    mkdir($dir, 0777, true);
    Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true);
}
$redirect = site_url() . 'admin/backup';
header("Location: {$redirect}");
Beispiel #24
0
            $file = str_replace('\\', '/', $file);
            // Ignore "." and ".." folders
            if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..', '.DS_Store', '.git'))) {
                continue;
            }
            if (strpos($file, $test_dir) > -1) {
                // echo ($file).' is_not_copied<br/>';
                continue;
            }
            $file = realpath($file);
            $fileToPut = getRelativePath($file, $source);
            if (is_file($file) === true && (!strpos($file, '.git') || strpos($file, '.git') == -1)) {
                // echo ($file).' is_file <br/>';
                $zip->addFromString($fileToPut, file_get_contents($file));
            }
        }
    } else {
        if (is_file($source) === true) {
            $zip->addFromString(basename($source), file_get_contents($source));
        }
    }
    return $zip->close();
}
$archive = $tempDir . '/' . $template . '.zip';
Zip($rootDir . '/' . $template, $archive);
header('Content-type: application/zip');
// It will be called test.zip
header('Content-Disposition: attachment; filename="' . $template . '.zip"');
header('Content-Length: ' . filesize($archive));
readfile($archive);
unlink($archive);
Beispiel #25
0
 public function generateVersionFile($branch, $version = null)
 {
     try {
         $fileObj = $this->getFile($branch);
     } catch (Exception $e) {
         echo "failed";
         return;
     }
     echo "is file: " . dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/version.txt<br />';
     if (is_file(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/version.txt')) {
         echo "unlink";
         unlink(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/version.txt');
     }
     if (is_file(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/rtbInfo.txt')) {
         unlink(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/rtbInfo.txt');
     }
     if (is_dir(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/__MACOSX')) {
         $dir = dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/__MACOSX';
         $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
         $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($files as $file) {
             if ($file->isDir()) {
                 rmdir($file->getRealPath());
             } else {
                 unlink($file->getRealPath());
             }
         }
         rmdir($dir);
     }
     if ($version == null) {
         $version = $this->getLatestVersion($branch);
     }
     if ($version == false) {
         $version = 0;
     }
     $channelName[1] = "stable";
     $channelName[2] = "unstable";
     $channelName[3] = "development";
     $verDat = new stdClass();
     $verDat->version = $version;
     $verDat->channel = $channelName[$branch];
     $liveBranch = new stdClass();
     $liveBranch->url = "http://blocklandglass.com/api/support_updater/repo.php";
     $liveBranch->format = "JSON";
     $liveBranch->id = $this->getId();
     $backupRepo = new stdClass();
     $backupRepo->url = "http://cdn.blocklandglass.com/repo.txt";
     $backupRepo->format = "JSON";
     $backupRepo->id = $this->getId();
     $verDat->repositories = array($liveBranch, $backupRepo);
     $file = fopen(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/version.json', "w");
     $content = json_encode($verDat, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     fwrite($file, $content);
     fclose($file);
     //GLASS FILE DATA
     $glassData = new stdClass();
     $glassData->formatVersion = 1;
     $glassData->id = $this->getId();
     $glassData->board = $this->getBoard()->getId();
     $glassData->filename = $this->getFilename();
     $glassData->title = $this->getName();
     $file = fopen(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/glass.json', "w");
     $content = json_encode($glassData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     fwrite($file, $content);
     fclose($file);
     if (is_file(dirname(__DIR__) . '/files/comp/' . $fileObj->getHash() . ".zip")) {
         unlink(dirname(__DIR__) . '/files/comp/' . $fileObj->getHash() . ".zip");
     }
     Zip(dirname(__DIR__) . '/files/decomp/' . $fileObj->getHash() . '/', dirname(__DIR__) . '/files/comp/' . $fileObj->getHash() . ".zip");
 }
Beispiel #26
0
// Cria diretório temporário para o import
mkdir($tmpdir);
chmod($tmpdir, 0777);
// Cria tabelas temporárias
create_temptables($dbcon);
// Realiza a extração
extrair($dbcon);
// Correções de compatibilidade
fix_local_secundario($tmpdir . "/local_secundario.csv");
fix_null_time($tmpdir . "/acao.csv");
fix_null_time($tmpdir . "/aplicativo.csv");
fix_null_time($tmpdir . "/unid_organizacional_nivel2.csv");
fix_rede_grupo_ftp($tmpdir . "/rede_grupo_ftp.csv");
fix_quoted_data($tmpdir . "/usb_device.csv");
/*// Deleta tabelas temporárias
$dbcon->exec("DROP TABLE tmp_redes");
$dbcon->exec("DROP TABLE tmp_computador");
$dbcon->exec("DROP TABLE tmp_uorg");
$dbcon->exec("DROP TABLE tmp_usb");*/
// Gera um arquivo .zip com os dados
$zipfile = $tmproot . "/bases_cacic2_" . date("Y-m-d_H:i:s") . ".zip";
Zip($tmpdir, $zipfile);
chmod($zipfile, 0777);
// Deleta o diretorio temporario
foreach (glob($tmpdir . '/*') as $filename) {
    unlink($filename);
}
rmdir($tmpdir);
echo "O arquivo {$zipfile} foi criado.<br>\n";
// Fecha conexão com o banco
$dbcon = null;
Beispiel #27
0
                         }
                         copy("../files/" . $actFN, "../temp/" . $key . "/" . $fName . "/" . $row['clmnFileName']);
                     }
                 }
             } else {
                 $fActNameResult = dbUtil::SELECT("SELECT clmnActFN FROM tblFiles WHERE clmnUNFile=:uname AND clmnFileName=:fname AND clmnFoldIn=:foldin", array(':uname' => $_SESSION['un'], ':fname' => $fName, ':foldin' => $where));
                 if (count($fActNameResult) != 0) {
                     $actFN = $fActNameResult[0]['clmnActFN'];
                 }
                 copy("../files/" . $actFN, "../temp/" . $key . "/" . $fName);
             }
             break;
         case 'compress':
             $key = $_GET['key'];
             //Zip Folder
             Zip("../temp/" . $key, "../temp/" . $key . "/", $key);
             $filename = $key . ".zip";
             $filepath = "temp/";
             //Remove file
             //unlink("../temp/" . $key . ".zip");
             //Remove Directory
             removeDir("../temp/" . $key . "/");
             break;
         default:
             // not supported
             break;
     }
     break;
 default:
     // not supported
     break;
        }
        $dest = $tmp . "/" . $pid . "/" . $path . "/" . convert_safe_file_dir_name(basename($file['url']));
        if (file_exists($dest)) {
            $x = 1;
            do {
                $dest = $tmp . "/" . $pid . "/" . $path . "/" . $x . "_" . convert_safe_file_dir_name(basename($file['url']));
                $x++;
            } while (file_exists($dest));
        }
        file_put_contents($dest, $document);
    } else {
        echo xlt("Can't find file!") . "<br />";
    }
}
// zip the folder
Zip($tmp . "/" . $pid . "/", $tmp . "/" . $pid . '.zip');
// serve it to the patient
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="patient_documents.zip"');
readfile($tmp . "/" . $pid . '.zip');
// remove the temporary folders and files
recursive_remove_directory($tmp . "/" . $pid);
unlink($tmp . "/" . $pid . '.zip');
function recursive_remove_directory($directory, $empty = FALSE)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return FALSE;
    } elseif (is_readable($directory)) {
                if (is_dir($file) === true) {
                    $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
                } else {
                    if (is_file($file) === true) {
                        $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
                    }
                }
            }
        } else {
            if (is_file($source) === true) {
                $zip->addFromString(basename($source), file_get_contents($source));
            }
        }
        return $zip->close();
    }
    Zip('./', './backup/backup-bsup-' . $rparameters['version'] . '-' . $date . '.zip');
    copy('./connect.php', './backup/connect.php');
    //check backup
    if (file_exists('./backup/backup-bsup-' . $rparameters['version'] . '-' . $date . '.zip')) {
        echo "&nbsp;&nbsp;&nbsp;- Sauvegarde des fichiers: <img src=\"./images/ok_min.png\" border=\"0\" /><br />";
        $step = 5;
    } else {
        echo "&nbsp;&nbsp;&nbsp;- Sauvegarde des fichiers: <img src=\"./images/critical_min.png\" border=\"0\" /><br />";
        $error = 1;
    }
}
//extract last version
if ($step == 5) {
    if (file_exists('./download/tmp')) {
    } else {
        mkdir("./download/tmp");
Beispiel #30
0
                case "PHOTO":
                case "AUDIO":
                case "VIDEO":
                    copy($_POST['game']->backpacks[$i]->notes[$j]->contents[$k]->media_url, $notedir . "/" . $_POST['game']->backpacks[$i]->notes[$j]->contents[$k]->title . " id_" . $_POST['game']->backpacks[$i]->notes[$j]->contents[$k]->media_id . substr($_POST['game']->backpacks[$i]->notes[$j]->contents[$k]->file_name, -4));
                    break;
            }
        }
        $commentsdir = $notedir . "/comments";
        mkdir($commentsdir);
        for ($k = 0; $k < count($_POST['game']->backpacks[$i]->notes[$j]->comments); $k++) {
            $commentdir = $commentsdir . "/" . $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->username . " " . $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->note_id;
            mkdir($commentdir);
            writefile("text.txt", $commentdir, $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->title);
            for ($l = 0; $l < count($_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents); $l++) {
                switch ($_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->type) {
                    case "TEXT":
                        writefile($_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->title . ".txt", $commentdir, $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->text);
                        break;
                    case "PHOTO":
                    case "AUDIO":
                    case "VIDEO":
                        copy($_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->media_url, $commentdir . "/" . $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->title . " id_" . $_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->media_id . substr($_POST['game']->backpacks[$i]->notes[$j]->comments[$k]->contents[$l]->file_name, -4));
                        break;
                }
            }
        }
    }
}
$zippath = "../../gamedata/" . $_GET['gameId'] . "/dumpzip.zip";
Zip($dumpdir, $zippath);
header('Location: ' . $zippath);