Compare commits

..

15 Commits

Author SHA1 Message Date
Matt Pass
2237c91067 Version number, Zip It! plugin & tabWidth
Version number now v 0.7.3
Zip It! is new plugin instead of backupOpenFiles
tabWidth now set to 4 chars by default
2012-06-17 16:34:37 +01:00
Matt Pass
98a08fddf8 tabWidth option and plugins tooltip
tabWidth option now saved as a setting
Plugins show tooltip now on hover via title attribute
2012-06-17 16:33:14 +01:00
Matt Pass
21cdcb20b4 New tabWidth option
tabWidth option now shown in 'style' section
On change, this affects editor demo instance
2012-06-17 16:27:59 +01:00
Matt Pass
47547b2ae8 Dark active line & dynamic tab widths
Config file included so we can use vars
Active line is now black rather than dark blue
(This is a bit experimental and unusual, so we'll see how it works out)
indentUnit & tabSize params in CM now uses JS var, so updateable
2012-06-17 16:26:43 +01:00
Matt Pass
6e9af92471 tabWidth var & Zip It! file manager option
New tabWidth var available to use
New Zip It! option added to file manager menu
(allowing users to zip anything on demand)
2012-06-17 16:21:53 +01:00
Matt Pass
cc7df4222a Removed unneeded for loop
Completely unneeded for loop controlling tabWidth's removed
2012-06-17 16:20:35 +01:00
Matt Pass
25b5af50c2 tabWidth changable & Zip It! on Demand
useNewSettings now takes a tabWidth param
This changes the width of all open documents in CM instance
New function to call Zip It! plugin on demand with target
(This means you can zip anything up from the file manager menu)
2012-06-17 16:17:31 +01:00
Matt Pass
7c8c728ad4 Darker file manager menu
Was same colour as file manager and didn't stand out
Now slightly darker to help visual appearance
2012-06-17 16:15:02 +01:00
Matt Pass
655fef4baa Zip It! Plugin Added
This replaces backupOpenFiles
Now zips up whole website be default, but also can zip up targets
This plugin is also now available from the file manager menu
2012-06-17 16:13:22 +01:00
Matt Pass
a27db58031 Removed backupOpenFiles Plugin
Plugin which backs up open files now removed
This is because the rest of your site isn't being backed up, just open
files
Now the whole site being backed up instead
Devs are used to saving regularly and so this is a better setup
2012-06-17 16:12:08 +01:00
Matt Pass
7c0cb2d1c3 goToLine now takes number as a param
You can optionally pass through a param to goToLine
It will go to this given line instead of textfield value
This makes it more usable via API calls
2012-06-11 07:48:46 +01:00
Matt Pass
229a089d45 Now checks for updates of ICEcoder & CodeMirror
Extended this process to check for firstly ICEcoder updates and then
CodeMirror
Both working via their own remotely sourced latest-version.txt files
If ICEcoder is up to date, if performs a check on CodeMirrors version
no.
2012-06-11 07:46:43 +01:00
Matt Pass
49ca9d75f9 testcMVersion var now checkUpdates
Repurposed this var to both check for newer ICEcoder and CodeMirror
versions
Renamed to checkUpdates
2012-06-11 07:43:46 +01:00
Matt Pass
745903d133 Move file/folder count & last 10 files clickable
File & folder count moved into files section
Last 10 files is now clickable to open file
Also shows [none] if there aren't any files to display
Couple of bytes saved in server DT display process
Will also only update server DT if it's visible
2012-06-10 11:46:23 +01:00
Matt Pass
54bf805548 openFile function now takes a file as param
You can now pass through a file link to this function
If passed through, it'll be set as the file to open
2012-06-10 11:36:54 +01:00
10 changed files with 153 additions and 115 deletions

View File

@@ -1,3 +1,4 @@
<?php include("lib/config.php");?>
<!DOCTYPE html>
<html style="margin: 0">
@@ -28,7 +29,7 @@ if ($theme=="default") {
.CodeMirror-scroll {width: 100px; height: 100px;}
.cm-s-visible {display: block; top: 0}
.cm-s-hidden {display: none; top: 4000px}
.cm-s-activeLine {background: #002 !important;}
.cm-s-activeLine {background: #000 !important;}
// Make sure this next one remains the 5th item, updated with JS
.cm-tab:after {position: relative; display: inline-block; width: 0; left: -1.4em; overflow: visible; color: #aaa; content: "<?php if ($visibleTabs) {?>\21e5<?;};?>";}
span.CodeMirror-matchhighlight {background: #555}
@@ -48,8 +49,6 @@ span.CodeMirror-matchhighlight {background: #555}
echo $_SERVER['DOCUMENT_ROOT'].'<br><br>'.PHP_EOL;
echo '<span style="color:#888">PHP version:</span><br>'.PHP_EOL;
echo phpversion().'<br><br>'.PHP_EOL;
echo '<span style="color:#888">File & folder count:</span><br>'.PHP_EOL;
echo '<div id="fileFolderCounts"></div><br>'.PHP_EOL;
echo '<span style="color:#888">Date & time:</span><br>'.PHP_EOL;
echo '<span id="serverDT"></span><br><br><br>'.PHP_EOL;
echo '</div>'.PHP_EOL;
@@ -57,7 +56,19 @@ span.CodeMirror-matchhighlight {background: #555}
echo '<div style="float: left">'.PHP_EOL;
echo '<h2 style="color: rgba(0,198,255,0.7)">files</h2>'.PHP_EOL;
echo '<span style="color:#888">Last 10 files opened:</span><br>'.PHP_EOL;
echo str_replace("|","/",str_replace(",","<br>",$last10Files)).'<br><br><br>'.PHP_EOL;
$last10FilesArray = explode(",",$last10Files);
for ($i=0;$i<count($last10FilesArray);$i++) {
if ($last10Files=="") {
echo '[none]<br><br>';
} else {
echo '<a style="cursor:pointer" onClick="top.ICEcoder.openFile(top.fullPath+\''.str_replace("|","/",$last10FilesArray[$i]).'\')">';
echo str_replace("|","/",$last10FilesArray[$i]);
echo '</a><br>'.PHP_EOL;
if ($i==count($last10FilesArray)-1) {echo '<br>'.PHP_EOL;};
}
}
echo '<span style="color:#888">File & folder count:</span><br>'.PHP_EOL;
echo '<div id="fileFolderCounts"></div><br><br><br>'.PHP_EOL;
echo '</div>'.PHP_EOL;
echo '<div style="clear: both">'.PHP_EOL;
@@ -71,13 +82,15 @@ span.CodeMirror-matchhighlight {background: #555}
<script>
var nDT=<?php echo time()*1000;?>;
setInterval(function(){
var s=(new Date(nDT+=1000)+'').split(' '),
var s=(new Date(nDT+=1e3)+'').split(' '),
d=s[2]*1,
t=s[4].split(':'),
p=t[0]>11?'pm':'am',
e=d%20==1|d==31?'st':d%20==2?'nd':d%20==3?'rd':'th';
e=d%20==1|d>30?'st':d%20==2?'nd':d%20==3?'rd':'th';
t[0]=--t[0]%12+1;
document.getElementById('serverDT').innerHTML=[s[0],d+e,s[1],s[3],t.join(':')+p].join(' ');
if (document.getElementById('serverDT')) {
document.getElementById('serverDT').innerHTML=[s[0],d+e,s[1],s[3],t.join(':')+p].join(' ');
}
},1000);
</script>
</div>
@@ -92,8 +105,8 @@ function createNewCMInstance(num) {
mode: "application/x-httpd-php",
lineNumbers: true,
lineWrapping: true,
indentUnit: 4,
tabSize: 4,
indentUnit: top.tabWidth,
tabSize: top.tabWidth,
indentWithTabs: true,
electricChars: false,
onCursorActivity: function() {

View File

Before

Width:  |  Height:  |  Size: 551 B

After

Width:  |  Height:  |  Size: 551 B

View File

@@ -10,12 +10,18 @@ if (!$allowedIP) {
header('Location: /');
};
// Test for latest CodeMirror version
if ($testcMVersion) {
$cMLatestVer = json_encode(file_get_contents("http://codemirror.net/latest-version.txt"));
$cMLatestVer = rtrim(ltrim($cMLatestVer,"\""),"\"\\n");
if ($cMThisVer<$cMLatestVer) {
echo '<script>alert(\'Code Mirror '.$cMLatestVer.' now released\n\nPlease upgrade\');</script>';
// Check for updates of ICEcoder & CodeMirror
if ($checkUpdates) {
$ICEcoderLatestVer = json_encode(file_get_contents("http://icecoder.net/latest-version.txt"));
$ICEcoderLatestVer = rtrim(ltrim($ICEcoderLatestVer,"\""),"\"\\n");
if (ltrim($versionNo,"v ")<ltrim($ICEcoderLatestVer,"v ")) {
echo '<script>alert(\'ICEcoder '.$ICEcoderLatestVer.' now released\n\nPlease upgrade\');</script>';
} else {
$cMLatestVer = json_encode(file_get_contents("http://codemirror.net/latest-version.txt"));
$cMLatestVer = rtrim(ltrim($cMLatestVer,"\""),"\"\\n");
if ($cMThisVer<$cMLatestVer) {
echo '<script>alert(\'Code Mirror '.$cMLatestVer.' now released\n\nPlease upgrade\');</script>';
}
}
}
?>
@@ -30,6 +36,7 @@ if ($testcMVersion) {
shortURLStarts = "<?php echo $shortURLStarts;?>";
theme = "<?php if ($theme=="default") {echo 'icecoder';} else {echo $theme;};?>";
tabsIndent = <?php if ($tabsIndent) {echo 'true';} else {echo 'false';};?>;
tabWidth = <?php echo $tabWidth; ?>;
<?
$docRoot = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']);
if (strrpos($docRoot,"/")==strlen($docRoot)-1) {$docRoot = substr($docRoot,0,strlen($docRoot)-1);};
@@ -86,6 +93,7 @@ previousFiles = [<?php
<a href="javascript:top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Rename</a>
<a href="javascript:window.open(top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length))" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">View Webpage</a>
</span>
<a href="javascript:top.ICEcoder.zipIt(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Zip It!</a>
</div>
<div id="header" class="header" onContextMenu="return false">

View File

@@ -154,7 +154,7 @@ h2 {font-size: 18px; font-weight: normal; color: #fff}
}
.fileMenu {position: absolute; display: none; left: 0; top: 0; background-color: #333; z-index: 10}
.fileMenu a {display: block; padding: 2px 5px; background-color: #444; color: #eee; text-decoration: none}
.fileMenu a {display: block; padding: 2px 5px; background-color: #333; color: #eee; text-decoration: none}
.fileMenu a:hover {background-color: #666}
.screenContainer {position: absolute; display: table; width: 100%; height: 100%; top: 0; left: 0; text-align: center}

View File

@@ -734,7 +734,11 @@ var ICEcoder = {
},
// Open a file on demand
openFile: function() {
openFile: function(fileLink) {
if (fileLink) {
top.ICEcoder.thisFileFolderLink=fileLink;
top.ICEcoder.thisFileFolderType="file";
}
if (top.ICEcoder.thisFileFolderLink!="" && top.ICEcoder.thisFileFolderType=="file") {
var shortURL, canOpenFile;
@@ -977,11 +981,11 @@ var ICEcoder = {
},
// Go to a specific line number
goToLine: function() {
goToLine: function(lineNo) {
var cM;
cM = ICEcoder.getcMInstance();
cM.setCursor(document.getElementById('goToLineNo').value-1);
cM.setCursor(lineNo ? lineNo-1 : document.getElementById('goToLineNo').value-1);
cM.focus();
return false;
},
@@ -1475,7 +1479,7 @@ var ICEcoder = {
},
// Update the settings used when we make a change to them
useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,refreshFM) {
useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,tabWidth,refreshFM) {
var styleNode, strCSS, cMCSS;
// Add new stylesheet for selected theme
@@ -1506,6 +1510,12 @@ var ICEcoder = {
cMCSS = ICEcoder.content.contentWindow.document;
visibleTabs ? cMCSS.styleSheets[2][strCSS][5].style['content'] = '"\\21e5"' : cMCSS.styleSheets[2][strCSS][5].style['content'] = '" "';
top.tabWidth = tabWidth;
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.tabWidth);
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.tabWidth);
}
// Finally, refresh the file manager if we need to
if (refreshFM) {top.ICEcoder.refreshFileManager()};
},
@@ -1556,5 +1566,11 @@ var ICEcoder = {
screenIcon.src.indexOf("images/full-screen.gif") > -1 ? screenIcon.src = "images/restored-screen.gif" : screenIcon.src = "images/full-screen.gif";
},
// Pass target file/folder to Zip It!
zipIt: function(tgt) {
tgt=tgt.replace(top.fullPath+"/","").replace(/\//g,"|");
top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href="plugins/zip-it/index.php?zip="+tgt;
}
};

View File

@@ -1,9 +1,9 @@
<?php
$versionNo = "v 0.7.2";
$versionNo = "v 0.7.3";
$codeMirrorDir = "CodeMirror-2.25";
$cMThisVer = 2.25;
$tabsIndent = true;
$testcMVersion = false;
$checkUpdates = false;
$openLastFiles = true;
$findFilesExclude = array("_coder",".doc",".gif",".jpg",".jpeg",".pdf",".png",".swf",".xml",".zip");
$codeAssist = true;
@@ -16,9 +16,10 @@ $allowedIPs = array("*");
$plugins = array(
array("Database Admin","images/database.png","margin-top: 3px","plugins/adminer/adminer-3.3.3-mysql-en.php","_blank",""),
array("Batch Image Processor","images/images.png","margin-top: 5px","http://birme.net","_blank",""),
array("Backup","images/backup-open-files.png","margin-top: 3px","plugins/backupOpenFiles/index.php","fileControl:<b>Zipping Open Files</b>","10")
array("Zip It!","images/zip-it.png","margin-top: 3px","plugins/zip-it/index.php?zip=|","fileControl:<b>Zipping Open Files</b>","10")
);
$theme = "default";
$tabWidth = 4;
$previousFiles = "";
$last10Files = "";
?>

View File

@@ -79,7 +79,7 @@ for ($i=0;$i<count($themeArray)-1;$i++) {
<h1>settings</h1>
<h2>functionality</h2>
<input type="checkbox" onclick="showButton()" name="tabsIndent" value="true"<?php if($tabsIndent) {echo ' checked';};?>> tab indents selection<br>
<input type="checkbox" onclick="showButton()" name="testcMVersion" value="true"<?php if($testcMVersion) {echo ' checked';};?>> test codemirror version on load<br>
<input type="checkbox" onclick="showButton()" name="checkUpdates" value="true"<?php if($checkUpdates) {echo ' checked';};?>> check for updates on load<br>
<input type="checkbox" onclick="showButton()" name="openLastFiles" value="true"<?php if($openLastFiles) {echo ' checked';};?>> auto open last files on login<br>
<br>
when finding in files, exclude:<br>
@@ -156,11 +156,19 @@ function findSequence(goal) {
}
return find(1,"1");
}</textarea>
<br>
<span style="position: absolute; top: 520px">
tab width <span style="font-size: 10px; color: #888">chars</span><br>
<input type="text" name="tabWidth" id="tabWidth" style="width: 30px" onkeydown="showButton()" onkeyup="changeTabWidth()" value="<?php echo $tabWidth;?>">
</span>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
readOnly: "nocursor",
indentUnit: top.tabWidth,
tabSize: top.tabWidth,
theme: "<?php if ($theme=="default") {echo 'icecoder';} else {echo $theme;}; ?>"
});
@@ -171,6 +179,12 @@ function selectTheme() {
editor.setOption("theme", theme);
}
function changeTabWidth() {
var tabWidth = document.getElementById("tabWidth").value;
editor.setOption("indentUnit", tabWidth);
editor.setOption("tabSize", tabWidth);
}
var showButton = function() {
document.getElementById('updateButton').style.opacity = 1;
}

View File

@@ -25,7 +25,7 @@ if (isset($_POST["theme"]) && $_POST["theme"] && $_SESSION['userLevel'] == 10) {
// Prepare all our vars
if ($_POST['tabsIndent']) {$tabsIndent = "true";} else {$tabsIndent = "false";};
if ($_POST['testcMVersion']) {$testcMVersion = "true";} else {$testcMVersion = "false";};
if ($_POST['checkUpdates']) {$checkUpdates = "true";} else {$checkUpdates = "false";};
if ($_POST['openLastFiles']) {$openLastFiles = "true";} else {$openLastFiles = "false";};
$findFilesExclude = 'array("'.str_replace(', ','","',$_POST['findFilesExclude']).'")';
if ($_POST['codeAssist']) {$codeAssist = "true";} else {$codeAssist = "false";};
@@ -37,9 +37,10 @@ if (isset($_POST["theme"]) && $_POST["theme"] && $_SESSION['userLevel'] == 10) {
$allowedIPs = 'array("'.str_replace(', ','","',$_POST['allowedIPs']).'")';
$plugins = 'array('.PHP_EOL.' array('.PHP_EOL.' '.str_replace('====================','),'.PHP_EOL.' array(',$_POST['plugins']).'))';
$theme = $_POST['theme'];
$tabWidth = $_POST['tabWidth']*1;
$settingsNew = '$tabsIndent = '.$tabsIndent.';'.PHP_EOL;
$settingsNew .= '$testcMVersion = '.$testcMVersion.';'.PHP_EOL;
$settingsNew .= '$checkUpdates = '.$checkUpdates.';'.PHP_EOL;
$settingsNew .= '$openLastFiles = '.$openLastFiles.';'.PHP_EOL;
$settingsNew .= '$findFilesExclude = '.$findFilesExclude.';'.PHP_EOL;
$settingsNew .= '$codeAssist = '.$codeAssist.';'.PHP_EOL;
@@ -51,6 +52,7 @@ if (isset($_POST["theme"]) && $_POST["theme"] && $_SESSION['userLevel'] == 10) {
$settingsNew .= '$allowedIPs = '.$allowedIPs.';'.PHP_EOL;
$settingsNew .= '$plugins = '.$plugins.';'.PHP_EOL;
$settingsNew .= '$theme = "'.$theme.'";'.PHP_EOL;
$settingsNew .= '$tabWidth = '.$tabWidth.';'.PHP_EOL;
// Compile our new settings
$settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,($repPosEnd),strlen($settingsContents));
@@ -69,7 +71,7 @@ if (isset($_POST["theme"]) && $_POST["theme"] && $_SESSION['userLevel'] == 10) {
// Do we need a file manager refresh?
if ($_POST['changedFileSettings']=="true") {$refreshFM="true";} else {$refreshFM="false";};
// With all that worked out, we can now hide the settings screen and apply the new settings
echo "<script>top.ICEcoder.settingsScreen('hide');top.ICEcoder.useNewSettings('".$themeURL."',".$tabsIndent.",".$codeAssist.",".$lockedNav.",".$visibleTabs.",".$refreshFM.");</script>";
echo "<script>top.ICEcoder.settingsScreen('hide');top.ICEcoder.useNewSettings('".$themeURL."',".$tabsIndent.",".$codeAssist.",".$lockedNav.",".$visibleTabs.",".$tabWidth.",".$refreshFM.");</script>";
}
// Save the currently opened files for next time
@@ -154,7 +156,7 @@ if ((isset($_POST["theme"]) && $_POST["theme"] && $_SESSION['userLevel'] == 10)
$pluginsDisplay = "";
for ($i=0;$i<count($plugins);$i++) {
$target = explode(":",$plugins[$i][4]);
$pluginsDisplay .= '<a href="'.$plugins[$i][3].'" target="'.$target[0].'"><img src="'.$plugins[$i][1].'" style="'.$plugins[$i][2].'" alt="'.$plugins[$i][0].'"></a>';
$pluginsDisplay .= '<a href="'.$plugins[$i][3].'" title="'.$plugins[$i][0].'" target="'.$target[0].'"><img src="'.$plugins[$i][1].'" style="'.$plugins[$i][2].'" alt="'.$plugins[$i][0].'"></a>';
};
// If we're updating, replace the plugin display with our newly established one

View File

@@ -1,87 +0,0 @@
<!DOCTYPE html>
<body>
<script>
top.ICEcoder.serverMessage("<b>Zipping Open Files</b>");
</script>
<?php
// ------------------------------------
// backupOpenFiles by Matt Pass
// Will backups open files in ICE coder
// ------------------------------------
// If we have no post data for the 1st item, set a form up ready to post back
if (!isset($_POST['fileName1'])) {
echo '<form name="zipFiles" id="zipFiles" action="index.php" method="POST">'.PHP_EOL;
for ($i=1;$i<=10;$i++) {
echo '<input type="hidden" name="fileName'.$i.'" id="fName'.$i.'" value="" style="display: none">'.PHP_EOL;
echo '<textarea name="fileContent'.$i.'" id="fContent'.$i.'" style="display: none"></textarea>'.PHP_EOL;
}
echo '</form>'.PHP_EOL;
?>
<script>
// Populate values for file names & contents
for (i=1;i<=top.ICEcoder.openFiles.length;i++) {
document.getElementById('fName'+i).value = top.ICEcoder.openFiles[i-1];
document.getElementById('fContent'+i).value = top.ICEcoder.content.contentWindow['cM'+i].getValue();
}
if (top.ICEcoder.openFiles.length>0) {
document.zipFiles.submit();
}
</script>
<?php
;} else {
// Folder name & filename of the zip
$zipItSaveLocation = '../../backups/';
$zipItFileName = time().'.zip';
// Make the dir if it doesn't exist
if (!is_dir($zipItSaveLocation)) {
mkdir($zipItSaveLocation, 0777);
}
// Start a class
Class zipIt {
public function zipFilesUp($zipName='') {
// OK, if we've got at least one file to add
if($_POST['fileName1']!=="") {
$zip = new ZipArchive();
// Return if we have a problem creating/overwriting our zip
if($zip->open($zipName,$overwriteZip ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
// Otherwise, we're OK to add our string into a new file (incl dirs) in the zip, so do that
for($i=1;$i<=10;$i++) {
$fName = 'fileName'.$i;
if($_POST[$fName]!=="") {
$zip->addFromString(ltrim($_POST[$fName],"/"), $_POST['fileContent'.$i]);
}
}
$zip->close();
// We've been successful, so return with a positive response
return file_exists($zipName);
} else {
// If we had 0 files, return
return false;
}
}
}
// Trigger the class
$zipItDoZip = new zipIt();
$zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation.$zipItFileName);
if (!$zipItAddToZip) {echo '<script>alert("Could not zip files up!");</script>';};
;};
?>
<script>
top.ICEcoder.serverMessage();
top.ICEcoder.serverQueue("del",0);
</script>
</body>
</html>

71
plugins/zip-it/index.php Normal file
View File

@@ -0,0 +1,71 @@
<?php
// -----------------------------------------------
// Zip-It! for ICEcoder v0.9.0 by Matt Pass
// Will backup requested files/folders in ICEcoder
// -----------------------------------------------
include("../../lib/settings.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>Zip It! for ICEcoder</title>
</head>
<body>
<?
$zipItSaveLocation = '../../backups/';
if ($_GET['zip']=="|") {$zipItFileName = "root";} else {$zipItFileName = str_replace("|","_",$_GET['zip']);};
$zipItFileName .= '-'.time().'.zip';
if (!is_dir($zipItSaveLocation)) {mkdir($zipItSaveLocation, 0777);}
Class zipIt {
public function zipFilesUp($zipName='') {
$zipFiles = array();
$zipTgt = str_replace("|","/",$_GET['zip']);
if (strpos($_GET['zip'],"/")!==0) {$zipTgt = "/".$zipTgt;};
$addItem = $_SERVER['DOCUMENT_ROOT'].$zipTgt;
if (is_dir($addItem)) {
$dirStack = array($addItem);
while (!empty($dirStack)) {
$currentDir = array_pop($dirStack);
$dir = dir($currentDir);
while (false !== ($node = $dir->read())) {
if (($node == '.') || ($node == '..')) {continue;}
if (is_dir($currentDir.$node) && !strpos($currentDir.$node,"_coder")) {
array_push($dirStack,$currentDir.$node.'/');
}
if (is_file($currentDir.$node)) {$zipFiles[] = $currentDir.$node;}
}
}
} else {
if(file_exists($addItem)) {$zipFiles[] = $addItem;}
}
if(count($zipFiles)) {
$zip = new ZipArchive();
if($zip->open($zipName,ZIPARCHIVE::CREATE)!== true) {return false;}
foreach($zipFiles as $file) {
$zip->addFile($file,str_replace($_SERVER['DOCUMENT_ROOT']."/","",$file));
}
$zip->close();
return file_exists($zipName);
} else {
return false;
}
}
}
if($_SESSION['userLevel']==10) {
$zipItDoZip = new zipIt();
echo '<script>top.ICEcoder.serverMessage("<b>Zipping Files</b>");</script>';
$zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation.$zipItFileName);
if (!$zipItAddToZip) {
echo '<script>alert("Could not zip files up!");</script>';
} else {
echo '<script>setTimeout(function(){top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);},500);</script>';
}
}
?>
</body>
</html>