htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
insert link doc with group mysql


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


marco76tv
Novice

Mar 18, 2004, 5:32 AM

Post #1 of 1 (4073 views)
Shortcut
insert link doc with group mysql Can't Post

<!-- add into editor.js -->

else if (cmdID.toLowerCase() == 'insertdoc'){
if(config.CanUpload) {
editdoc.RootFolder = config.RootFolder
editdoc.ScriptLang = config.ScriptLang
editdoc.SizeLimit = config.SizeLimit
var myText = showModalDialog(_editor_url + "popups/php/insert_doc.php", editdoc, "resizable: no; help: no; status: no; scroll: no; ");
if (myText) {
editor_insertHTML(objname, unescape( myText));
}
}
// insert doc
}





<!--- insert_doc.php --->

<html style="font: 9 pt 'MS Shell Dlg', Helvetica, sans-serif; width: 470px; height: 475px; "> <!-- ALL features enabled -->
<!-- <html style="font: 9 pt 'MS Shell Dlg', Helvetica, sans-serif; width: 470px; height: 432px; "> <!-- CREATE disabled -->
<!-- <html style="font: 9 pt 'MS Shell Dlg', Helvetica, sans-serif; width: 470px; height: 410px; "> <!-- UPLOAD disabled -->
<!-- <html style="font: 9 pt 'MS Shell Dlg', Helvetica, sans-serif; width: 470px; height: 368px; "> <!-- CREATE & UPLOAD disabled -->

<head>
<title>Insert Document</title>
<style type="text/css">
BODY { background: threedface; color: windowtext; font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; }

<!-- frame styles -->
IFRAME.lister { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 36em; height:13em; }
IFRAME.viewer { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 18em; height:13em; }

<!-- input styles -->
INPUT { border:solid 1px #808080; height: 22px; padding-top: 2px; }

INPUT.folder { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 30em; }
INPUT.image { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 30em; }
INPUT.name { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 30em; }
INPUT.txtAltText { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 31em; }
INPUT.txtBorder { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 3.5em; }
INPUT.txtHorizontal { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 3.5em; }
INPUT.txtFileName { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 31em; }
INPUT.txtVertical { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 3.5em; }

<!-- button styles -->
INPUT.btnCancel { cursor:hand; width:65; height:22; border:none; background-image:url('img/btnBG.jpg'); font: 9pt 'MS Shell Dlg', Helvetica, sans-serif;}
INPUT.btnOK { cursor:hand; width:65; height:22; border:none; background-image:url('img/btnBG.jpg'); font: 9pt 'MS Shell Dlg', Helvetica, sans-serif;}
INPUT.create { cursor:hand; width:65; height:22; border:none; background-image:url('img/btnBG.jpg'); font: 9pt 'MS Shell Dlg', Helvetica, sans-serif;}
INPUT.upload { cursor:hand; width:65; height:22; border:none; background-image:url('img/btnBG.jpg'); font: 9pt 'MS Shell Dlg', Helvetica, sans-serif;}

<!-- drop-down styles -->
SELECT.selAlignment { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 6em; }

<!-- table styles -->
TABLE.dialog { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 36em; }

<!-- cell styles -->
TD.create { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 37em; }
TD.fldLayout { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 13em; }
TD.fldSpacing { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 10em; }
TD.image { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 40em; }
TD.label { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 5em; }
TD.manager { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 37em; }
TD.upload { font: 9pt 'MS Shell Dlg', Helvetica, sans-serif; width: 37em; }
</style>

<!-- script copied from original "insert_image.html" -->
<script defer>
function _CloseOnEsc() {
if(event.keyCode == 27) {
window.close();
return;
}
}

function _getTextRange(elm) {
var r = elm.parentTextEdit.createTextRange();

r.moveToElementText(elm);
return r;
}

window.onerror = HandleError

function HandleError(message, url, line) {
var str = "An error has occurred in this dialog." + "\n\n"
+ "Error: " + line + "\n" + message;

alert(str);
window.close();
return true;
}

function Init() {
var elmSelectedImage;
var htmlSelectionControl = "Control";
var globalDoc = window.dialogArguments;
var grngMaster = globalDoc.selection.createRange();
var dpi = 96;
// var ElemParent = grngMaster.item(0).parentElement;
// alert(ElemParent.tagName);
if(document.all.dpicheck) {
dpi = document.all.dpicheck.width;
}

// -------------------------------------
// Variables for lister with parameters
// -------------------------------------
var RootFolder = '/'
if(typeof(globalDoc.RootFolder) != 'undefined')
RootFolder = globalDoc.RootFolder

var listerURL = 'lister_doc.php'
// var viewerURL = 'viewer.php'

listerURL += '?DPI=' + dpi + '&RootFolder=' + RootFolder
// viewerURL += '?DPI=' + dpi + '&RootFolder=' + RootFolder

document.all.lister.contentWindow.navigate(listerURL);
// document.all.viewer.contentWindow.navigate(viewerURL);
document.all.actions.RootFolder.value = RootFolder;

document.all.actions.DPI.value = dpi;
// -------------------------------------
// End Of trick
// -------------------------------------

if(dpi != 96) {
var xfactor = ((dpi < 96) ? (dpi / 95) : (dpi / 97.5));
var yfactor = ((dpi < 96) ? (dpi / 95) : (dpi / 99.5));
var width = dialogWidth.substr(0, dialogWidth.search(/\D/));
var height = dialogHeight.substr(0, dialogHeight.search(/\D/));

window.dialogWidth = Math.floor((width * xfactor)) + 'px';
window.dialogHeight = Math.floor((height * yfactor)) + 'px';
}

// event handlers
document.body.onkeypress = _CloseOnEsc;
btnOK.onclick = new Function("OKClick()");

txtFileName.fImageLoaded = false;
txtFileName.intImageWidth = 0;
txtFileName.intImageHeight = 0;

if(globalDoc.selection.type == htmlSelectionControl) {
alert(grngMaster.length);
if(grngMaster.length == 1) {
elmSelectedImage = grngMaster.item(0);
alert(elmSelectedImage.tagName);
if(elmSelectedImage.tagName == "IMG") {
txtFileName.fImageLoaded = true;
if(elmSelectedImage.src) {
txtFileName.value = elmSelectedImage.src.replace(/^[^*]*(\*\*\*)/, "$1"); // fix placeholder src values that editor converted to abs paths
txtFileName.intImageHeight = elmSelectedImage.height;
txtFileName.intImageWidth = elmSelectedImage.width;
txtVertical.value = elmSelectedImage.vspace;
txtHorizontal.value = elmSelectedImage.hspace;
txtBorder.value = elmSelectedImage.border;
txtAltText.value = elmSelectedImage.alt;
selAlignment.value = elmSelectedImage.align;
}
}
}
}

txtFileName.value = txtFileName.value || "http://";
txtFileName.focus();
}

function _isValidNumber(txtBox) {
var val = parseInt(txtBox);

if(isNaN(val) || val < 0 || val > 999) {
return false;
}
return true;
}

function OKClick() {
var elmImage;
var intAlignment;
var htmlSelectionControl = "Control";
var globalDoc = window.dialogArguments;
var grngMaster = globalDoc.selection.createRange();
// alert(grngMaster.text);
// error checking

if(!txtAltText.value){
alert("dove scappi?? devi mettere il testo(alt) sotto le immagini !!");
txtAltText.focus();
return;
}
if(!txtFileName.value || txtFileName.value == "http://") {
alert("Image URL must be specified.");
txtFileName.focus();
return;
}
if(txtHorizontal.value && !_isValidNumber(txtHorizontal.value)) {
alert("Horizontal spacing must be a number between 0 and 999.");
txtHorizontal.focus();
return;
}
if(txtBorder.value && !_isValidNumber(txtBorder.value)) {
alert("Border thickness must be a number between 0 and 999.");
txtBorder.focus();
return;
}
if(txtVertical.value && !_isValidNumber(txtVertical.value)) {
alert("Vertical spacing must be a number between 0 and 999.");
txtVertical.focus();
return;
}

// delete selected content and replace with image
if(globalDoc.selection.type == htmlSelectionControl && !txtFileName.fImageLoaded) {
grngMaster.execCommand('Delete');
grngMaster = globalDoc.selection.createRange();
}

var text="<a href=\""+txtFileName.value+"\" title=\""+txtAltText.value+"\">"+grngMaster.text+"</a>";
grngMaster.execCommand('RemoveFormat');
grngMaster.execCommand('unlink');
grngMaster.execCommand('Delete')
window.returnValue = text;

/*
idstr = "\" id=\"556e697175657e537472696e67"; // new image creation ID
if(!txtFileName.fImageLoaded) {
grngMaster.execCommand("InsertImage", false, idstr);
elmImage = globalDoc.all['556e697175657e537472696e67'];
elmImage.removeAttribute("id");
elmImage.removeAttribute("src");
grngMaster.moveStart("character", -1);
}
else {
elmImage = grngMaster.item(0);
if(elmImage.src != txtFileName.value) {
grngMaster.execCommand('Delete');
grngMaster = globalDoc.selection.createRange();
grngMaster.execCommand("InsertImage", false, idstr);
elmImage = globalDoc.all['556e697175657e537472696e67'];
elmImage.removeAttribute("id");
elmImage.removeAttribute("src");
grngMaster.moveStart("character", -1);
txtFileName.fImageLoaded = false;
}
grngMaster = _getTextRange(elmImage);
}

if(txtFileName.fImageLoaded) {
elmImage.style.width = txtFileName.intImageWidth;
elmImage.style.height = txtFileName.intImageHeight;
}

if(txtFileName.value.length > 2040) {
txtFileName.value = txtFileName.value.substring(0,2040);
}

elmImage.src = txtFileName.value;

if(txtHorizontal.value != "") {
elmImage.hspace = parseInt(txtHorizontal.value);
}
else {
elmImage.hspace = 0;
}

if(txtVertical.value != "") {
elmImage.vspace = parseInt(txtVertical.value);
}
else {
elmImage.vspace = 0;
}

elmImage.alt = txtAltText.value;

if(txtBorder.value != "") {
elmImage.border = parseInt(txtBorder.value);
}
else {
elmImage.border = 0;
}

elmImage.align = selAlignment.value;*/
grngMaster.collapse(false);
grngMaster.select();
window.close();
}
</script>
</head>

<body onload="Init()">
<img id="dpicheck" style="position: absolute; left: 1; top: 1; width: 1in; height: 1; visibility: hidden;" src="dpi.gif" width="96" height="9">
<table class="dialog" border="0" cellpadding="0" cellspacing="5">
<tr>
<td>
<table name="manager" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="manager" colspan="3" align="center" valign="middle">
<fieldset>
<legend align="left">Gestione Documenti</legend>
<table name="wrapper" border="0" cellpadding="2" cellspacing="0">
<tr>
<td colspan="2">
<iframe class="lister" name="lister" marginwidth="0" marginheight="0"></iframe>
</td>
</tr>
<tr>
<td colspan="3">
<form name="actions" method="POST" action="lister_doc.php" enctype="multipart/form-data" target="lister">
<table border="0" cellpadding="0" cellspacing="0">
<!-- BEGIN 'UPLOAD' HTML (delete the '>' at the end of this comment to disable the 'UPLOAD' feature) -->
<tr>
<td class="upload" colspan="2">
<fieldset>
<legend align="left">Carica nuovo documento</legend>
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="label" align="left" valign="middle">
<input class="upload" type="submit" value="Carica" onclick="this.form.action.value='upload'">&nbsp;
</td>
<td>
<input Style="cursor:hand;" class="image" type="file" name="image">
</td>
</tr>
<tr>
<td class="label" align="left" valign="middle">
Rinomina:
</td>
<td>
<input class="name" type="input" name="name">
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<!-- END 'UPLOAD' HTML -->
<!-- BEGIN 'CREATE' HTML (delete the '>' at the end of this comment to disable the 'CREATE' feature) -->
<tr>
<td class="create" colspan="2">
<fieldset>
<legend align="left">Nuova cartella</legend>
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="label" align="left" valign="top">
<input class="create" type="submit" value="Crea" onclick="this.form.action.value='create'">&nbsp;
</td>
<td>
<input class="folder" type="input" name="folder">
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<!-- END 'UPLOAD' HTML -->
</table>
<input type="Hidden" name="DPI" value="">
<input type="Hidden" name="action" value="">
<input type="Hidden" name="path" value="">
<input type="Hidden" name="RootFolder" value="/">
</form>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td class="image" colspan="3" valign="middle">
<fieldset>
<legend align="left">Immagine selezionata</legend>
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="label" valign="middle">Indirizzo:</td>
<td valign="middle">
<input class="txtFileName" type="text" name="txtFileName" onfocus="select()">
</td>
</tr>
<tr>
<td class="label" valign="middle">Testo:</td>
<td valign="middle">
<input class="txtAltText" type="text" name="txtAltText" onfocus="select()">
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td class="fldLayout">
<fieldset name="fldLayout">
<legend align="left">Disposizione</legend>
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="label" valign="middle">Allineamento:</td>
<td valign="middle">
<select class="selAlignment" size="1" name="selAlignment">
<OPTION id="optNotSet" value="">(nessuno)</OPTION>
<OPTION id="optAbsBottom" value="absbottom">in basso (assoluto)</OPTION>
<OPTION id="optAbsMiddle" value="absmiddle">al centro (assoluto)</OPTION>
<OPTION id="optBaseline" value="baseline" selected>alla base</OPTION>
<OPTION id="optBottom" value="bottom">in basso</OPTION>
<OPTION id="optLeft" value="left">a sinistra</OPTION>
<OPTION id="optMiddle" value="middle">al centro</OPTION>
<OPTION id="optRight" value="right">a destra</OPTION>
<OPTION id="optTexttop" value="texttop">testo in alto</OPTION>
<OPTION id="optTop" value="top">in alto</OPTION>
</select>
</td>
</tr>
<tr>
<td class="label" valign="middle">Bordo:</td>
<td valign="middle">
<input class="txtBorder" type="text" name="txtBorder" size="3" maxlength="3" onfocus="select()">
</td>
</tr>
</table>
</fieldset>
</td>
<td class="fldSpacing">
<fieldset name="fldSpacing">
<legend align="left">Spaziatura</legend>
<table border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="label" valign="middle">Orizzontale:</td>
<td valign="middle">
<input class="txtHorizontal" type="text" name="txtHorizontal" size="3" maxlength="3" onfocus="select()">
</td>
</tr>
<tr>
<td class="label" valign="middle">Verticale:</td>
<td valign="middle">
<input class="txtVertical" type="text" name="txtVertical" size="3" maxlength="3" onfocus="select()">
</td>
</tr>
</table>
</fieldset>
</td>
<td valign="bottom">
<table align="right" border="0" cellpadding="2" cellspacing="0">
<tr>
<td valign="middle">
<input class="btnOK" type="submit" value="OK" name="btnOK">
</td>
</tr>
<tr>
<td valign="middle">
<input class="btnCancel" type="reset" value="Annulla" name="btnCancel" onClick="window.close();">
</td>
</tr>
</table
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>

</html>


<!--- listener_doc.php -->

<?
if(!session_id()){
session_start();
}
?>
<script>
alert("<?=$_SESSION["db"]?>");
</script>

<html>
<head>
<?php

require("config.inc.php");
require_once("../../../../inc/lib.php");
?>
<style type="text/css">
TD { <?php echo LISTER_STYLE; ?> }
TD.delete { <?php echo LISTER_DELETE; ?> }
</style>
<script language="javascript">

function actionComplete(action, path, error, info) {
var manager = findAncestor(window.frameElement, '<?php echo MANAGER_NAME; ?>', '<?php echo MANAGER_TAG; ?>');
var wrapper = findAncestor(window.frameElement, '<?php echo WRAPPER_NAME; ?>', '<?php echo WRAPPER_TAG; ?>');

if(manager) {
if(error.length < 1) {
manager.all.actions.reset();

<?php
// if UPLOAD is supported ...
if(SUPPORT_UPLOAD) {

// ... emit the JavaScript
echo " if(action == 'upload') {\n";
echo " manager.all.actions.image.value = '';\n";
echo " manager.all.actions.name.value = '';\n";
echo " }\n";
}

// if CREATE is supported ...
if(SUPPORT_CREATE) {

// ... emit the JavaScript
echo " if(action == 'create')\n";
echo " manager.all.actions.folder.value = '';\n";
}

// if DELETE is supported ...
if(SUPPORT_DELETE) {

// ... emit the JavaScript
echo " if(action == 'delete')\n";
echo " manager.all." . MANAGER_SRC . ".value = '';\n";
}
?>
}
manager.all.actions.DPI.value = <?php echo AGENT_DPI; ?>;
manager.all.actions.RootFolder.value = "<?php echo AGENT_ROOT_FOLDER; ?>";
manager.all.actions.path.value = path;
}

if(error.length > 0)
alert(error);
else if(info.length > 0)
alert(info);
}
</script>
</head>
<?php
/*
** Emits the appropriate HTML for the specified Directory.
**
** Params: $value - Directory name
** $key - Array key (undefined)
** $depth - Indent depth
** $icon - Icon filename
** $link - TRUE if Directory should be linked; FALSE otherwise
*/
function dirTag($value, $key, $depth, $icon = ICON_CLOSED, $link = TRUE) {
global $HTTP_SERVER_VARS, $base;

// initialize context
$path = basePath($value, ($depth - 1));

// emit the HTML
echo "<tr><td align=\"left\" valign=\"bottom\" width=\"100%\">\n";

// indent as required
indentTag($depth);

// emit the HTML
echo "<img align=\"bottom\" src=\"" . scriptURL($icon) . "\" alt=\"$value\">";
if($link) {
echo "<a href=\"" . scriptURL(basename($HTTP_SERVER_VARS["PHP_SELF"])) . "?DPI=" . AGENT_DPI . "&RootFolder=" . AGENT_ROOT_FOLDER;
if(strcmp(TEXT_ROOT, $value))
echo "&path=" . urlencode($path);
echo "\">";
}
echo "<b>$value</b>";
echo "</a>";
echo "</td><td class=\"delete\" align=\"right\" valign=\"bottom\">\n";
if(SUPPORT_DELETE) {
if(!(strcmp($icon, ICON_CLOSED)) && isEmpty($path))
echo "<a href=\"javascript:deletePath('" . $path . "')\">" . TEXT_DELETE . "</a>";
}
echo "</td></tr>\n";
}

/*
** Creates a new Folder.
**
** Params: $folder - Folder to create
*/
function doCreate($folder) {
global $error;

// initialize context
$path = basePath($folder);

// if Folder does NOT already exist ...
if(!(file_exists(IMAGE_DIR . $path))) {

// ... if Folder does NOT create ...
if(!(@mkdir(IMAGE_DIR . $path, 0777)))

// ... report the error
$error = "Folder \'" . $path . "\' could not be created";
}

// ... otherwise, report the error
else
$error = "Folder \'" . $path . "\' already exists";
}

/*
** Deletes a Folder/File.
**
** Params: $file - Folder/file to delete
*/
function doDelete($file) {
global $base, $error;

// if Folder/File exists ...
if(file_exists(IMAGE_DIR . $file)) {

// ... if this is a Folder ...
if(is_dir(IMAGE_DIR . $file)) {

// ... if Folder does NOT delete ...
if(!(@rmdir(IMAGE_DIR . $file)))

// ... report the error
$error = "Folder \'" . $file . "\' could not be deleted";
}

// ... otherwise, if File does NOT delete ...
else if(!(@unlink(IMAGE_DIR . $file)))

// ... report the error
$error = "Image \'" . $file . "\' could not be deleted";
}

// ... otherwise, report the error
else
$error = "Folder or file \'" . $file . "\' not found";
}


/*
** Emits the appropriate HTML for the specified File.
**
** Params: $value - File name
** $key - Array key (undefined)
** $depth - Indent depth
*/
function fileTag($value, $key, $depth) {

// initialize context
$file = basePath($value);
/*
if(file_exists(IMAGE_DIR . $file))
if(is_file (IMAGE_DIR . $file))
if(exif_imagetype(IMAGE_DIR . $file)>0 && exif_imagetype(IMAGE_DIR . $file)<16)
$size = @getImageSize(IMAGE_DIR . $file);

// if Image size and type are available ...
if(isset($size)) {
*/
$ext=substr($value, strrpos($value, '.'));

if($ext==".zip" || $ext==".pdf" || $ext==".xls" || $ext==".doc" ){
// ... emit the HTML
echo "<tr><td align=\"left\" valign=\"bottom\" width=\"100%\">\n";

// indent as required
indentTag($depth);

// emit the HTML
echo "<img align=\"bottom\" src=\"";
//echo scriptURL("img/gif.gif");
switch($ext) {
case ".zip":
echo scriptURL("img/zip.gif");
break;
case ".pdf":
echo scriptURL("img/pdf.gif");
break;
case ".doc":
echo scriptURL("img/doc.gif");
break;
case ".xls":
echo scriptURL("img/xls.gif");
break;
}
echo "\" alt=\"" . $value . "\">";
echo '<a href="#" onclick="parent.txtFileName.value=\'' . AGENT_ROOT_FOLDER .$file . '\'">';
echo $value;
echo "</a>\n";
echo "</td><td class=\"delete\" align=\"right\" valign=\"bottom\">\n";
if(SUPPORT_DELETE) {
echo "<a href=\"javascript:deletePath('" . $file . "')\">" . TEXT_DELETE . "</a>";
}
echo "</td></tr>\n";
}
}


/*
** Lists a Path.
*/
function doList() {
global $dirs;

// initialize context
$nodes = 0;
$current = (count($dirs) + 1);

// emit the HTML
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
dirTag(TEXT_ROOT, "", $nodes++, ICON_OPENED);

// for ALL Directories in the Path ...
foreach($dirs as $dir) {

// ... if Directory is exists ...
if(strlen($dir) > 0)

// ... emit the HTML
dirTag($dir, "", $nodes++, ICON_OPENED, ($nodes != $current));
}

// list Directories and emit the HTML
$list = listDirs();
array_walk($list, 'dirTag', $nodes);

// list Image files and emit the HTML
// $list = listFiles(array("gif", "jpg", "jpeg", "png","bmp"));
$db1=new DB();
$strsql1="select * from tbl_images";
$result1=$db1->query($strsql1);
reset($list);
while($row=$db1->fetch_array($result1)){
$list[]=$row["nome"];
}
// var_dump($list);
array_walk($list, 'fileTag', $nodes);

// emit the HTML
echo "</table>\n";
}

/*
** Uploads an Image.
**
** Params: $name - Name for uploaded Image
*/
function doUpload($name) {
global $HTTP_POST_FILES, $error, $info;

// initialize context
$temp = $HTTP_POST_FILES["image"]["tmp_name"];

// if File is a legitimate upload ...
if(is_uploaded_file($temp)) {
$type = $HTTP_POST_FILES["image"]["type"];
$types = array("application/zip" => "[]zip$", "application/pdf" => "[]pdf$", "application/x-zip-compressed" => "[]zip$", "image/pjpeg" => "[]jp[e]?g$", "image/png" => "[]png$", "image/x-png" => "[]png$","image/bmp" => "[]bmp$|[]gif$");


// ... if File is a valid image ...
if(isset($types[$type])) {
$search = (isWindows() ? "eregi" : "ereg");
$replace = (isWindows() ? "eregi" : "ereg");

// ... if Name was NOT specified ...
if(strlen($name) < 1)

// ... use the same Name
$name = $HTTP_POST_FILES["image"]["name"];

// if File has NO or an improper extension ...
if(!($search($types[$type], $name))) {
$exts = array("application/zip" => ".zip", "application/pdf" => ".pdf", "application/x-zip-compressed" => ".zip", "image/pjpeg" => ".jpg", "image/png" => ".png", "image/x-png" => ".png","image/bmp" => ".bmp");

// ... if NO extension exists ...
if(!($search("[].+$", $name)))

// ... append the proper extension
$name .= $exts[$type];

// ... otherwise, force a proper extension
else
$name = $replace("[].*$", $exts[$type], $name);

// notify the user
$info = "Proper extension was added to make \'" . $name . "\' valid for this image type";
}

// if File has the proper extension now ...
if($search($types[$type], $name)) {
$path = basePath($name);

// ... if File does NOT already exist ...
if(file_exists(IMAGE_DIR . $path)) {
for($tmp=0;$tmp<100;$tmp++){
$aaa=substr($path,0,strlen($path)-4)."_".$tmp.substr($path,strlen($path)-4);
if(!(file_exists(IMAGE_DIR . $aaa))) break;
}
$path=$aaa;
}
if(!(file_exists(IMAGE_DIR . $path))) {
// if(true){
$size = $HTTP_POST_FILES["image"]["size"];

// ... if NO size limit exists OR File is NOT over the limit ...
if(UPLOAD_LIMIT == 0 || $size <= UPLOAD_LIMIT) {
//alert_message(IMAGE_DIR . $path);
// ... if File CANNOT be copied ...
if(!(@copy($temp, (IMAGE_DIR . $path)))){

// ... report the error
$error = "File \'" . $path . "\' could not be created";
}else{
//alert_message("copia a buon fine /public/".$path);
?>
<script>
showModalDialog("gruppi.php?path=<?=$path?>",document,"");
</script>
<?
}
}

// ... otherwise, report the error
else
$error = "File \'" . $path . "\' exceeds " . round((UPLOAD_LIMIT / 1024)) . " KByte size limit";
}

// ... otherwise, report the error
else
$error = "File \'" . $path . "\' already exists";
}

// ... otherwise, report the error
else
$error = "Files of type \'" . $type . "\' require a matching extension";
}

// ... otherwise, report the error
else
$error = "File \'" . $HTTP_POST_FILES["image"]["name"] . "\' is not a supported type ($type)";
}

// ... otherwise, report the error
else
$error = "Invalid upload environment";
}


/*
** Emits the appropriate HTML for an Indent.
**
** Params: $depth - Indent depth
*/
function indentTag($depth) {

// if Indent is desired ...
if($depth > 0) {
$ff=SCRIPT_DIR . ICON_INDENT;
if(is_file($ff)){
$size = @getImageSize($ff);
}else{
$size[0]=10;
$size[1]=10;
}

// ... emit the HTML
echo "<img src=\"" . scriptURL(ICON_INDENT) . "\" width=\"" . ($size[0] * $depth) . "\" height=\"" . $size[1] . "\">";
}
}

/*
** Returns the empty status of the specified Directory.
**
** Params: $path - Path to check
**
** Return: TRUE if Directory is empty; FALSE otherwise
*/
function isEmpty($path) {

// initialize context
$empty = TRUE;

// if the Directory opens ...
if(($dir = @opendir(IMAGE_DIR . $path))) {

// ... while Files remain ...
while($empty && FALSE !== ($file = readdir($dir))) {

// ... if NOT hierarchy entries ...
if($file != "." && $file != "..")

// ... indicate NOT empty
$empty = FALSE;
}

// close the Directory
closedir($dir);
}

// return the status
return $empty;
}

/*
** Returns an array of the Directories within the specified path.
**
** Return: Array of Directory names
*/
function listDirs() {
global $base;
$result = array();

// if the Directory opens ...
if(($dir = @opendir(IMAGE_DIR . $base))) {

// ... while Files remain ...
while(FALSE !== ($file = readdir($dir))) {

// ... if NOT hierarchy entries ...
if($file != "." && $file != "..") {

// ... if File is a Directory ...
if(is_dir(IMAGE_DIR . basePath($file)))

// ... return the Directory
$result[] = $file;
}
}

// close the Directory
closedir($dir);
}

// return the Directories
return $result;
}

/*
** Returns an array of the Files within the specified path.
**
** Params: $filter - Extension filter(s)
**
** Return: Array of File names
*/
function listFiles($filter = Array()) {
global $base;
$result = Array();

// if the Directory opens ...
if(($dir = @opendir(IMAGE_DIR . $base))) {
$filters = count($filter);

// ... while Files remain ...
while(FALSE !== ($file = readdir($dir))) {

// ... if File is NOT a Directory ...
if(!(is_dir(IMAGE_DIR . basePath($file)))) {

// ... if Filters were specified ...
if($filters > 0) {
$compare = (isWindows() ? "strcasecmp" : "strcmp");

// ... isolate the Extension
$parts = pathinfo(IMAGE_DIR . basePath($file));
$ext = $parts["extension"];

// for ALL specified Filters ...
for($index = 0; $index < $filters; $index++) {

// ... if this a Filtered extension ...
if(!($compare($ext, $filter[$index])))

// ... get out now!
break;
}

// if File is NOT to be included ...
if($index >= $filters)

// ... continue listing Files
continue;
}

// return the File
$result[] = $file;
}
}

// close the Directory
closedir($dir);
}

// return the Files
//$pii=Array(0 => "pippo.gif", 1 => "gino.gif");
//var_dump($result);
return $result;
// return $result;
}

// process GET/POST parameters
$action = "";
if(isset($HTTP_GET_VARS["action"]))
$action = urldecode($HTTP_GET_VARS["action"]);
else if(isset($HTTP_POST_VARS["action"]))
$action = urldecode($HTTP_POST_VARS["action"]);
$file = "";
if(SUPPORT_DELETE) {
if(isset($HTTP_GET_VARS["file"]))
$file = urldecode($HTTP_GET_VARS["file"]);
else if(isset($HTTP_POST_VARS["file"]))
$file = urldecode($HTTP_POST_VARS["file"]);
}
$folder = "";
if(SUPPORT_CREATE) {
if(isset($HTTP_POST_VARS["folder"]))
$folder = $HTTP_POST_VARS["folder"];
}
$name = "";
if(SUPPORT_UPLOAD) {
if(isset($HTTP_POST_VARS["name"]))
$name = $HTTP_POST_VARS["name"];
}
$path = "";
if(isset($HTTP_GET_VARS["path"]))
$path = urldecode($HTTP_GET_VARS["path"]);
else if(isset($HTTP_POST_VARS["path"]))
$path = urldecode($HTTP_POST_VARS["path"]);

// parse and clean the Path
cleanPath($path);

?>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
// if CREATE is supported AND this is CREATE ...
if(SUPPORT_CREATE && !(strcasecmp($action, "create"))){

// ... create the Folder
doCreate($folder);

// ... otherwise, if DELETE is supported AND this is DELETE ...
}else if(SUPPORT_DELETE && !(strcasecmp($action, "delete"))){

// ... delete the Folder/File
doDelete($file);

// ... otherwise, if UPLOAD is supported AND this is UPLOAD ...
}else if(SUPPORT_UPLOAD && !(strcasecmp($action, "upload"))){

// ... upload the Image
// showdialog();

doUpload(basename($name));
}
// list the Path
doList();

// emit the HTML
echo "<script language=\"javascript\">\n";

// if DELETE is supported ...
if(SUPPORT_DELETE) {

// ... emit the HTML
echo "function deletePath(path) {\n";
echo " var lister = findAncestor(window.frameElement, '" . LISTER_NAME . "', '" . LISTER_TAG . "');\n\n";
echo " if(lister && confirm(\"Delete '\" + path + \"'?\"))\n";
echo " lister.contentWindow.navigate('" . scriptURL("lister.php?DPI=") . AGENT_DPI . "&RootFolder=" . AGENT_ROOT_FOLDER . "&action=delete&path=" . $base . "&file=" . "' + escape(path));\n";
echo "}\n\n";
}
?>
actionComplete("<?php echo $action; ?>", "<?php echo $path; ?>", "<?php echo $error; ?>", "<?php echo $info; ?>");
</script>
</body>
</html>


<!-- gruppi.php -->

<?
if(!session_id()){
session_start();
}
?>
<html>
<head>
<body>
<?php
require_once "../../../../inc/lib.php";
require_once "../../../../inc/tools.php";
$db=new DB();
if(isset($_SESSION['gruppi'])){
$arr=explode(",",$_SESSION['gruppi']);
$n_arr=count($arr);
}else{
$n_arr=-1;
}

$i=0;
$ris='<form action="gruppi.php" target="_self">';
$ris.='<input type="hidden" name="path" value="'.$_REQUEST["path"].'">';
for($i=0;$i<$n_arr;$i++){
$n=$arr[$i];
$strsql="select * from tbl_gruppi where id='".$n."'";
$result=$db->query($strsql);
$row=$db->fetch_array($result);
$ris.='<input type="checkbox" name="gr[]" value="'.$n.'">'.$row["nome"].'<br>';
}
$ris.='<input type="submit" name="azione" value="OK" onclick="window.close()">';
$ris.="</form>";
echo $ris;
switch(request("azione")){
case "OK":
if(isset($_REQUEST["gr"])) $gr=implode(",",$_REQUEST["gr"]);
else $gr="";
$db=new DB();
// $strsql="INSERT INTO tbl_images (id, nome, checkbox_tbl_gruppi) VALUES (NULL, '/public/".$path."', '".$_SESSION["gr"]."')";
$strsql="INSERT INTO tbl_images (id, nome, checkbox_tbl_gruppi) VALUES (NULL, '".$_REQUEST["path"]."', '".$gr."')";
$db->insert_query($strsql);

// alert_message($gr);
//$_SESSION["gr"]=$gr;
//putenv("gr=$gr");
echo "<script>
//window.returnValue='".$gr."';
window.close(); </script>";

break;
}
?>
</body>
</html>

 
 
 


Search for (options)