mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-15 12:57:10 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2237c91067 | ||
|
|
98a08fddf8 | ||
|
|
21cdcb20b4 | ||
|
|
47547b2ae8 | ||
|
|
6e9af92471 | ||
|
|
cc7df4222a | ||
|
|
25b5af50c2 | ||
|
|
7c8c728ad4 | ||
|
|
655fef4baa | ||
|
|
a27db58031 | ||
|
|
7c0cb2d1c3 | ||
|
|
229a089d45 | ||
|
|
49ca9d75f9 | ||
|
|
745903d133 | ||
|
|
54bf805548 |
31
editor.php
31
editor.php
@@ -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() {
|
||||
|
||||
|
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 551 B |
20
index.php
20
index.php
@@ -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">
|
||||
|
||||
@@ -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}
|
||||
|
||||
24
lib/coder.js
24
lib/coder.js
@@ -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;
|
||||
}
|
||||
};
|
||||
@@ -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 = "";
|
||||
?>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
71
plugins/zip-it/index.php
Normal 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>
|
||||
Reference in New Issue
Block a user