예제 #1
0
function format_health($up, $mem)
{
    list($up) = explode(" ", $up);
    $ret = '';
    $days = (int) ($up / (24 * 60 * 60));
    $up -= $days * 24 * 60 * 60;
    $hrs = (int) ($up / (60 * 60));
    $up -= $hrs * 60 * 60;
    $mins = (int) ($up / 60);
    $days > 1 ? $d = "s" : ($d = "");
    $hrs > 1 ? $h = "s" : ($h = "");
    $mins > 1 ? $m = "s" : ($m = "");
    $ret .= "<em>" . _("Uptime: ") . "</em>";
    if ($days > 0) {
        $ret .= $days . " " . _("day") . $d . " ";
    }
    if ($days > 0 || $hrs > 0) {
        $ret .= $hrs . " " . _("hour") . $h . " ";
    }
    $ret .= $mins . " " . _("minute") . $m;
    $m = preg_split("/[ ]+/", $mem[1]);
    $ret .= format_mem_bar("<em>" . _("Memory") . "</em> : " . humanSize($m[2] * 1024) . "/" . humanSize(($m[5] + $m[6]) * 1024) . "/" . humanSize($m[1] * 1024), $m[1], $m[2], $m[5] + $m[6]);
    $m = preg_split("/[ ]+/", $mem[3]);
    if ($m[1] > 0) {
        $ret .= format_mem_bar("<em>" . _("Swap") . "</em> : " . humanSize($m[2] * 1024) . "/" . humanSize($m[1] * 1024), $m[1], $m[2]);
    }
    return $ret;
}
예제 #2
0
파일: module.php 프로젝트: Prescia/Prescia
function prepareDataToOutput(&$template, &$params, $data, $processed = false)
{
    // you can prevent auto-running this with ?noOutputParse=true
    # This callback might be called multiple times. The $processed should come as TRUE on all second or more times it's called to prevent performance impact
    # IMPORTANT: DO NOT REMOVE A CONTENT BY SETTING IT AS $data['_somecontent'] = "" OR THIS WILL REMOVE SAID CONTENT FROM ALL FURTHER OCCURENCES OF THE RUNCONTENT LOOP (the object is not instantiated on each iteraction for performance).
    #			 INSTEAD, ADD THE CONTENT TO BE REMOVED ON THE $params['excludes'] array, as: $params['excludes'][] = "_somecontent";
    #			 THIS WILL SIMPLY NOT ECHO THE CONTENT ON THE ITERACTION, WHILE PRESERVING IT INSIDE THE TEMPLATE OBJECT
    $myTitle = isset($data[$params['module']->title]) ? $data[$params['module']->title] : '';
    if ($myTitle != '') {
        $myTitle = str_replace("\"", "", htmlspecialchars($myTitle, ENT_NOQUOTES));
    }
    $keystring = "";
    $havekeys = true;
    foreach ($params['module']->keys as $pkey) {
        if (!isset($data[$pkey])) {
            $havekeys = false;
            break;
        } else {
            $keystring .= "_" . $data[$pkey];
        }
    }
    foreach ($params['module']->fields as $fname => $field) {
        if (isset($data[$fname]) && !$processed) {
            if ($field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) {
                $thumbsettings = isset($field[CONS_XML_THUMBNAILS]) ? $field[CONS_XML_THUMBNAILS] : '';
                if ($thumbsettings != '' && $havekeys) {
                    // image/flash
                    $imgs = count($thumbsettings);
                    for ($c = 1; $c <= $imgs; $c++) {
                        $fnamedata = $fname . "_" . $c;
                        $data[$fnamedata . "w"] = "";
                        $data[$fnamedata . "h"] = "";
                        $data[$fnamedata . "t"] = "";
                        $data[$fnamedata . "tr"] = "";
                        $data[$fnamedata . "s"] = "";
                        $file = CONS_FMANAGER . $params['module']->name . "/" . ($c == 1 ? "" : "t/") . $fname . $keystring . "_{$c}";
                        $fileout = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/" . $params['module']->name . "/" . ($c == 1 ? "" : "t/") . $fname . $keystring . "_{$c}";
                        if ($data[$fname] == 'y' && locateAnyFile($file, $ext, CONS_FILESEARCH_EXTENSIONS)) {
                            $fileout .= "." . $ext;
                            $data[$fnamedata] = $fileout;
                            $popped = explode("/", $file);
                            $data[$fnamedata . "filename"] = array_pop($popped);
                            if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg", "swf"))) {
                                // image/flash
                                $h = getimagesize($file);
                                $data[$fnamedata . "w"] = $h[0];
                                $data[$fnamedata . "h"] = $h[1];
                                $data[$fnamedata . "s"] = humanSize(filesize($file));
                                if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg"))) {
                                    // image
                                    $randomseed = isset($_SESSION[CONS_SESSION_ACCESS_LEVEL]) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 9 ? "?r=" . rand(1000, 9999) . date("YmdHis") : "";
                                    $data[$fnamedata . "t"] = "<img src=\"" . CONS_INSTALL_ROOT . $fileout . $randomseed . "\" width='" . $h[0] . "' title=\"" . $myTitle . "\" height='" . $h[1] . "' alt='' />";
                                    $data[$fnamedata . "tr"] = "<img src=\"" . CONS_INSTALL_ROOT . $fileout . $randomseed . "\" width='100%' title=\"" . $myTitle . "\" height='100%' alt='' />";
                                } else {
                                    if (strtolower($ext) == "swf") {
                                        $data[$fnamedata . "t"] = str_replace("{FILE}", $fileout, str_replace("{H}", $h[1], str_replace("{W}", $h[0], SWF_OBJECT)));
                                        $data[$fnamedata . "tr"] = $data[$fnamedata . "t"];
                                    }
                                }
                            }
                        } else {
                            if (isset($field[CONS_XML_NOIMG])) {
                                $data[$fnamedata] = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/" . $field[CONS_XML_NOIMG];
                                $popped = explode("/", $data[$fnamedata]);
                                $data[$fnamedata . "filename"] = array_pop($popped);
                                $h = getimagesize($data[$fnamedata]);
                                $data[$fnamedata . "w"] = $h[0];
                                $data[$fnamedata . "h"] = $h[1];
                                $data[$fnamedata . "s"] = humanSize(filesize($data[$fnamedata]));
                                $data[$fnamedata . "t"] = "<img src=\"" . CONS_INSTALL_ROOT . $data[$fnamedata] . "\" width='" . $h[0] . "' title=\"" . $myTitle . "\" height='" . $h[1] . "' alt='' />";
                                $data[$fnamedata . "tr"] = "<img src=\"" . CONS_INSTALL_ROOT . $data[$fnamedata] . "\" width='100%' title=\"" . $myTitle . "\" height='100%' alt='' />";
                            } else {
                                $data[$fname] = 'n';
                            }
                        }
                    }
                } else {
                    if ($data[$fname] == 'y') {
                        // file w/o image, present
                        $file = CONS_FMANAGER . $params['module']->name . "/" . $fname . $keystring . "_1";
                        $fileout = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/" . $params['module']->name . "/" . $fname . $keystring . "_1";
                        $fnamedata = $fname . "_1";
                        if (locateAnyFile($file, $ext)) {
                            $data[$fnamedata] = CONS_INSTALL_ROOT . $fileout . $ext;
                            $data[$fnamedata . "s"] = humanSize(filesize($file));
                            $popped = explode("/", $file);
                            $data[$fnamedata . "filename"] = array_pop($popped);
                        } else {
                            $data[$fname] = 'n';
                        }
                    } else {
                        // not uploaded
                        $fnamedata = $fname . "_1";
                        $data[$fnamedata] = "";
                        $data[$fnamedata . "s"] = "";
                        $data[$fnamedata . "filename"] = "";
                    }
                }
            } elseif ($field[CONS_XML_TIPO] == CONS_TIPO_VC && isset($field[CONS_XML_SPECIAL]) && $field[CONS_XML_SPECIAL] == 'onlinevideo') {
                if (preg_match('/^([A-Za-z0-9_\\-]){6,20}$/', $data[$fname]) == 1) {
                    // valid youtube or vimeo ... vimeo are number only
                    if (is_numeric($data[$fname])) {
                        $data[$fname . '_url'] = "http://player.vimeo.com/video/" . $data[$fname];
                        $data[$fname . '_embed'] = "http://player.vimeo.com/video/" . $data[$fname];
                        // <iframe src="//player.vimeo.com/video/107395294?badge=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
                    } else {
                        $data[$fname . '_url'] = "http://www.youtube.com/v/" . $data[$fname];
                        $data[$fname . '_embed'] = "http://www.youtube.com/embed/" . $data[$fname];
                        // <iframe width="560" height="315" src="//www.youtube.com/embed/p6XLNsJ9YrA?list=PLmAut-PjT9-3TIbZascroz-dqP34ohKD5" frameborder="0" allowfullscreen></iframe>
                    }
                } else {
                    $data[$fname . '_url'] = "";
                    $data[$fname . '_embed'] = "";
                }
            } elseif ($field[CONS_XML_TIPO] == CONS_TIPO_SERIALIZED && ($field[CONS_XML_SERIALIZED] == 1 || $field[CONS_XML_SERIALIZED] == 3) && isset($data[$fname])) {
                # serialized field with READ or ALL serialization mode
                $s = @unserialize($data[$fname]);
                if ($s !== false) {
                    foreach ($s as $skey => $scontent) {
                        $data[$fname . "_" . $skey] = $scontent;
                    }
                }
                unset($s);
            }
        }
        switch ($field[CONS_XML_TIPO]) {
            case CONS_TIPO_INT:
            case CONS_TIPO_FLOAT:
            case CONS_TIPO_LINK:
                if (!isset($data[$fname]) || is_null($data[$fname]) || $data[$fname] == 0) {
                    $params['excludes'][] = "_toggle_" . $fname;
                }
                break;
            case CONS_TIPO_VC:
            case CONS_TIPO_TEXT:
                if (!isset($data[$fname]) || is_null($data[$fname]) || trim($data[$fname]) == '') {
                    $params['excludes'][] = "_toggle_" . $fname;
                }
                break;
            case CONS_TIPO_DATE:
            case CONS_TIPO_DATETIME:
                if (!isset($data[$fname]) || is_null($data[$fname]) || trim($data[$fname]) == '' || $data[$fname] == '0000-00-00' || $data[$fname] == '0000-00-00 00:00:00') {
                    $params['excludes'][] = "_toggle_" . $fname;
                }
                break;
            case CONS_TIPO_UPLOAD:
                if (isset($data[$fname]) && $data[$fname] == 'n' && (!isset($field[CONS_XML_NOIMG]) || isset($params[CONS_RUNCONTENT_NOIMGOVERRIDE]))) {
                    $params['excludes'][] = "_toggle_" . $fname;
                }
                break;
            case CONS_TIPO_ENUM:
                if (isset($data[$fname]) && $data[$fname] == 'n') {
                    $params['excludes'][] = "_toggle_" . $fname;
                }
                break;
        }
    }
    return $data;
}
예제 #3
0
function get_space()
{
    //    ini_set("display_errors", 1);
    $data = humanSize(disk_total_space("/"));
    $str = $data[0] . " " . $data[2];
    $data = humanSize(disk_free_space("/"), $data[1]);
    $str = $data[0] . "/" . $str;
    return $str;
}
예제 #4
0
파일: files.php 프로젝트: Prescia/Prescia
            $p = $fm->getPermissions($dir . $file);
            $dados = array('absurl' => CONS_INSTALL_ROOT . CONS_FMANAGER . $dir . $file, 'domain' => $core->domain, 'file' => $file, 'ico' => filetypeIcon($ext), 'CLASS' => $c % 2 == 0 ? "lxmladm_lineeven" : "lxmladm_lineodd", 'size' => humanSize(filesize(CONS_FMANAGER . $dir . $file)), 'id_allowed_group' => $p[0], 'allowed_users' => implode(",", $p[1]), 'expiration_date' => fd($p[2]));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'ico' || $ext == 'bmp') {
                $output .= $tp->techo($dados, !$canchangepermissions || !$isInsideSafePath ? array('_perm') : array());
            } else {
                $output .= $tp->techo($dados, !$canchangepermissions || !$isInsideSafePath ? array('_perm', "_isImage") : array("_isImage"));
            }
        }
    }
} else {
    foreach ($files as $file) {
        $ext = explode(".", $file);
        $ext = strtolower(array_pop($ext));
        if (is_file(CONS_FMANAGER . $dir . $file) && $file[0] != "." && $ext != "php") {
            $c++;
            $dados = array('absurl' => CONS_INSTALL_ROOT . CONS_FMANAGER . $dir . $file, 'domain' => $core->domain, 'file' => $file, 'ico' => filetypeIcon($ext), 'CLASS' => $c % 2 == 0 ? "lxmladm_lineeven" : "lxmladm_lineodd", 'size' => humanSize(filesize(CONS_FMANAGER . $dir . $file)));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'ico' || $ext == 'bmp') {
                $output .= $tp->techo($dados, !$canchangepermissions || !$isInsideSafePath ? array('_perm') : array());
            } else {
                $output .= $tp->techo($dados, !$canchangepermissions || !$isInsideSafePath ? array('_perm', "_isImage") : array("_isImage"));
            }
        }
    }
}
$core->template->assign("_file", $output);
$dir = "/" . $dir;
if (isset($core->storage['error']) || isset($core->storage['dir'])) {
    $core->template->assign('script', "<script type=\"text/javascript\">alert(\"" . $core->storage['error'] . "\");canChange=" . ($canEdit ? "true" : "false") . ";showFolder(\"" . $dir . "\",true);\$('btnPerm').style.display='" . ($isInsideSafePath && $canchangepermissions && $dir != '/' . CONS_FMANAGER_SAFE . "/" ? '' : 'none') . "';lastFolderPermission=[{$permissions}];</script>");
} else {
    $core->template->assign('script', "<script type=\"text/javascript\">canChange=" . ($canEdit ? "true" : "false") . ";showFolder(\"" . $dir . "\",true);\$('btnPerm').style.display='" . ($isInsideSafePath && $canchangepermissions && $dir != '/' . CONS_FMANAGER_SAFE . "/" ? '' : 'none') . "';lastFolderPermission=[{$permissions}];</script>");
}
예제 #5
0
파일: core.php 프로젝트: Prescia/Prescia
 function showTemplate()
 {
     if (count($this->log) > 0) {
         $output = "";
         foreach ($this->log as $saida) {
             $output .= $saida . "\n<br/>";
         }
         $file = $this->debugFile;
         if ($this->debugFile == '' || !is_file($file)) {
             if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_debugarea.html")) {
                 $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_debugarea.html";
             } else {
                 $file = CONS_PATH_SETTINGS . "defaults/_debugarea.html";
             }
         }
         $tp = new CKTemplate($this->template);
         $tp->fetch($file);
         $tp->assign("CORE_DEBUG", $output);
         $tp->assign("CORE_DEBUGWARNING", $this->loglevel);
         // CONS_LOGGING_...
         $this->template->constants['CORE_DEBUG'] = $tp->techo();
         unset($tp);
     }
     if (!is_object($this->template) || get_class($this->template) != "CKTemplate") {
         return;
         // huh, no template? oh well
     }
     # Echo dimconfig if something should be outputed
     $data = $this->cacheControl->getCachedContent('dimconfig_auto');
     if ($data === false) {
         $data = $this->dimconfig;
         $dimconfigMD = unserialize(cReadFile(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/_dimconfig.dat"));
         foreach ($data as $name => $content) {
             if (isset($dimconfigMD[$name])) {
                 if ($dimconfigMD[$name][CONS_XML_TIPO] == CONS_TIPO_UPLOAD) {
                     $FirstfileName = CONS_FMANAGER . $dimconfigMD[$name]['location'];
                     $path = explode("/", $FirstfileName);
                     $fileName = array_pop($path);
                     $path = implode("/", $path) . "/";
                     $hasFile = locateAnyFile($FirstfileName, $ext);
                     if (isset($dimconfigMD[$name][CONS_XML_THUMBNAILS])) {
                         // images
                         $imgs = count($dimconfigMD[$name][CONS_XML_THUMBNAILS]);
                         for ($c = 1; $c <= $imgs; $c++) {
                             $fnamedata = $name . "_" . $c;
                             $data[$fnamedata] = $FirstfileName;
                             $data[$fnamedata . "w"] = "";
                             $data[$fnamedata . "h"] = "";
                             $data[$fnamedata . "t"] = "";
                             $data[$fnamedata . "tr"] = "";
                             $data[$fnamedata . "s"] = "";
                             if ($hasFile) {
                                 $data[$fnamedata] = $FirstfileName;
                                 $popped = explode("/", $FirstfileName);
                                 $data[$fnamedata . "filename"] = array_pop($popped);
                                 if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg", "swf"))) {
                                     // image/flash
                                     $h = getimagesize($FirstfileName);
                                     $data[$fnamedata . "w"] = $h[0];
                                     $data[$fnamedata . "h"] = $h[1];
                                     $data[$fnamedata . "s"] = humanSize(filesize($FirstfileName));
                                     if (in_array(strtolower($ext), array("jpg", "gif", "png", "jpeg"))) {
                                         $data[$fnamedata . "t"] = "<img src=\"" . $FirstfileName . "\" width='" . $h[0] . "' height='" . $h[1] . "' alt='' />";
                                         $data[$fnamedata . "tr"] = "<img src=\"" . $FirstfileName . "\" width='100%' height='100%' alt='' />";
                                     } else {
                                         if (strtolower($ext) == "swf") {
                                             $data[$fnamedata . "t"] = str_replace("{FILE}", $FirstfileName, str_replace("{H}", $h[1], str_replace("{W}", $h[0], SWF_OBJECT)));
                                             $data[$fnamedata . "tr"] = $data[$fnamedata . "t"];
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($hasFile) {
                             $fnamedata = $name . "_1";
                             $data[$fnamedata] = $FirstfileName;
                             $data[$fnamedata . "s"] = humanSize(filesize($FirstfileName));
                             $popped = explode("/", $FirstfileName);
                             $data[$fnamedata . "filename"] = array_pop($popped);
                         } else {
                             $fnamedata = $name . "_1";
                             $data[$fnamedata] = "";
                             $data[$fnamedata . "t"] = "";
                             $data[$fnamedata . "tr"] = "";
                             $data[$fnamedata . "s"] = "";
                         }
                     }
                     $this->template->fill($data);
                 } else {
                     $data[$name] = $content;
                 }
             } else {
                 $data[$name] = $content;
             }
         }
         $this->cacheControl->addCachedContent('dimconfig_auto', $data, true);
     }
     $this->template->fill($data);
     $this->template->constants['CHARSET'] = $this->charset;
     if ($this->doctype == "html" || CONS_BROWSER == "IE" && CONS_BROWSER_VERSION < 9) {
         $this->template->assign("_DOCTYPEXML");
     }
     # metadata - fill default values if not set yet (plugins can set)
     if ($this->layout != 2) {
         if ((!isset($this->template->constants['METAKEYS']) || $this->template->constants['METAKEYS'] == '') && $this->dimconfig['metakeys'] != '') {
             $this->template->constants['METAKEYS'] = $this->dimconfig['metakeys'];
         }
         if ((!isset($this->template->constants['METADESC']) || $this->template->constants['METADESC'] == '') && $this->dimconfig['metadesc'] != '') {
             $this->template->constants['METADESC'] = $this->dimconfig['metadesc'];
         }
         // METAS
         if ($this->template->constants['CANONICAL'] == '') {
             $this->template->constants['CANONICAL'] = "http://" . $_SESSION['CANONICAL'] . $this->context_str . $this->action . ".html";
             if (isset($_REQUEST['id'])) {
                 $this->template->constants['CANONICAL'] .= "?id=" . $_REQUEST['id'];
             }
         }
         $metadata = $this->template->constants['METATAGS'];
         if (CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_meta.xml") {
             $metadata .= cReadFile(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/_meta.xml");
         }
         $metadata .= "\t<link rel=\"canonical\" href=\"" . $this->template->constants['CANONICAL'] . "\" />\n";
         if ($this->template->constants['METAKEYS'] != '') {
             $metadata .= "\t<meta name=\"keywords\" content=\"" . str_replace("\"", "", $this->template->constants['METAKEYS']) . "\"/>\n";
         }
         if ($this->template->constants['METADESC'] != '') {
             $metadata .= "\t<meta name=\"description\" content=\"" . str_replace("\"", "", $this->template->constants['METADESC']) . "\"/>\n";
             $metadata .= "\t<meta property=\"og:description\" content=\"" . str_replace("\"", "", $this->template->constants['METADESC']) . "\"/>\n";
         }
         $metadata .= "\t<meta property=\"og:type\" content=\"website\" />\n";
         $metadata .= "\t<meta property=\"og:title\" content=\"" . str_replace("\"", "", $this->template->constants['PAGE_TITLE']) . "\" />\n";
         $metadata .= "\t<meta property=\"og:url\" content=\"" . $this->template->constants['CANONICAL'] . "\" />\n";
         if (isset($this->template->constants['METAFIGURE']) && $this->template->constants['METAFIGURE'] != "") {
             if ($this->template->constants['METAFIGURE'][0] != '/') {
                 $this->template->constants['METAFIGURE'] = "/" . $this->template->constants['METAFIGURE'];
             }
             $metadata .= "\t<meta property=\"og:image\" content=\"http://" . $_SESSION['CANONICAL'] . $this->template->constants['METAFIGURE'] . "\" />\n";
             $metadata .= "\t<link rel=\"image_src\" href=\"http://" . $_SESSION['CANONICAL'] . $this->template->constants['METAFIGURE'] . "\" />\n";
         }
         $favfile = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/favicon";
         if (locateFile($favfile, $ext)) {
             $favfile = CONS_INSTALL_ROOT . $favfile;
             $metadata .= "\t<link rel=\"shortcut icon\" href=\"/favicon." . $ext . "\" />\n";
         } else {
             if (CONS_DEFAULT_FAVICON) {
                 $favfile = "favicon";
                 if (locateFile($favfile, $ext)) {
                     $favfile = CONS_INSTALL_ROOT . $favfile;
                     $metadata .= "\t<link rel=\"shortcut icon\" href=\"/favicon." . $ext . "\" />\n";
                 }
             }
         }
         // Alternate Language and domains versions (only on root index)
         if ($this->context_str == "/" && $this->action == "index") {
             if (CONS_USE_I18N) {
                 $langs = explode(",", CONS_POSSIBLE_LANGS);
                 foreach ($langs as $lang) {
                     if ($lang != $_SESSION[CONS_SESSION_LANG]) {
                         if (count($this->languageTL) > 0) {
                             foreach ($this->languageTL as $fl => $ln) {
                                 if ($ln == $lang) {
                                     $metadata .= "\t<link rel=\"alternate\" hreflang=\"{$lang}\" href=\"/{$fl}/index.html\"/>\n";
                                     break;
                                 }
                             }
                         } else {
                             $metadata .= "\t<link rel=\"alternate\" hreflang=\"{$lang}\" href=\"" . $this->template->constants['CANONICAL'] . "?lang={$lang}\"/>\n";
                         }
                     }
                 }
             }
             foreach ($this->parseRewrite as $domain => $settings) {
                 if ($domain != $this->domain) {
                     $metadata .= "\t<link rel=\"alternate\" hreflang=\"" . ($settings[0] == '' ? CONS_DEFAULT_LANG : $settings[0]) . "\" href=\"http://" . $domain . "\"/>\n";
                 }
             }
         }
         $this->template->constants['METATAGS'] = $metadata;
     }
     $this->removeAutoTags($this->template);
     // print version
     if ($this->template->get("printver") == '') {
         $printVersion = arrayToString($_GET, array("layout"));
         $printVersion .= "&layout=1";
         $this->template->assign("printver", $this->action . ".html?" . $printVersion);
     }
     return $this->template->techo();
 }
예제 #6
0
         $value = "CHECKED";
     }
     $divid = "disk_div{$disk}";
     $f->push(new DivForModule($msg, "#FFF"));
     $f->push(new Table());
     $f->add(new TrFormElement(_T("Select this hard disk", "imaging"), new CheckboxTpl($inputvar)), array("value" => $value, "extraArg" => 'onclick="jQuery(\'' . $divid . '\').toggle();"'));
     $f->pop();
     $diskdiv = new Div(array("id" => $divid));
     $diskdiv->setVisibility($value == "CHECKED");
     $f->push($diskdiv);
     $f->push(new Table());
     ksort($parts);
     foreach ($parts as $part) {
         $partnum = $part['num'] + 1;
         $ptype = $parttype[$part['type']];
         $length = humanSize($part['length'] * 512);
         $msg = sprintf(_T("Partition number: %d", "imaging"), $partnum);
         $inputvar = "check_disk[{$disk}][{$partnum}]";
         $text = "{$ptype} {$length}";
         if (isset($part["exclude"])) {
             $value = "";
             unset($part["exclude"]);
         } else {
             $value = "CHECKED";
         }
         $f->add(new TrFormElement($msg, new CheckboxTpl($inputvar, $text)), array("value" => $value));
     }
     $f->pop();
     $f->pop();
     $f->pop();
 }
예제 #7
0
파일: grants.php 프로젝트: dg-wfk/dl
echo $class;
?>
"><?php 
echo T_("Upload a file");
?>
</label>
      <div>
	<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
echo $iMaxSize;
?>
"/>
	<input name="file" class="element file" required type="file"/>
      </div>
      <p class="guidelines"><small>
	  <?php 
printf(T_("Choose which file to upload. You can upload up to %s."), humanSize($iMaxSize));
?>
      </small></p>
    </li>

    <li class="buttons">
      <input type="hidden" name="submit" value="<?php 
echo $act;
?>
"/>
      <input id="submit" type="submit" value="<?php 
echo T_("Upload");
?>
"/>
      <div id="uploadprogress"></div>
    </li>
예제 #8
0
파일: options.php 프로젝트: Prescia/Prescia
                     $using->assign("_thumb", $tTemp);
                 } else {
                     $emptyme[] = "_hasThumbs";
                 }
             } else {
                 $emptyme[] = "_hasThumbs";
             }
         } else {
             $emptyme[] = "_isImage";
             $emptyme[] = "_presentable";
         }
     }
     if (isset($dimconfigMD[$data['name']][CONS_XML_THUMBNAILS])) {
         $fillDT['maxres'] = "max " . str_replace(",", "x", $dimconfigMD[$data['name']][CONS_XML_THUMBNAILS][0]);
     }
     $fillDT['maxsize'] = isset($dimconfigMD[$data['name']][CONS_XML_FILEMAXSIZE]) ? humanSize($dimconfigMD[$data['name']][CONS_XML_FILEMAXSIZE]) : ini_get('upload_max_filesize');
     $content = $using->techo($fillDT, $emptyme);
     break;
 case CONS_TIPO_LINK:
     // ############################################### LINK TO ANOTHER MODULE
     $mod = $core->loaded($dimconfigMD[$data['name']][CONS_XML_MODULE]);
     if ($mod !== false) {
         $core->safety = false;
         // <-- in the select, we should always show every item
         $fillDT['rmodule'] = $dimconfigMD[$data['name']][CONS_XML_MODULE];
         if ($mod->options[CONS_MODULE_PARENT]) {
             $field_sel = $core->template->get("_selecttree_field");
             $using = clone $field_sel;
             $sql = $mod->get_base_sql();
             $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data['value'] . "',1,0) as selected";
             $tree = $mod->getContents("", "", "", "\\", $sql);
예제 #9
0
파일: ticketla.php 프로젝트: dg-wfk/dl
  </table>

  <ul>
    <li class="buttons">
      <input type="submit" name="reload" value="<?php 
echo T_("Reload");
?>
"/>
      <input type="reset" value="<?php 
echo T_("Reset");
?>
"/>
      <input type="button" value="<?php 
echo T_("Select all");
?>
" onclick="selectAll();"/>
      <input type="submit" name="purge" value="<?php 
echo T_("Purge selected");
?>
"/>
    </li>
  </ul>
</form>

<p><?php 
printf(T_("Total archive size: %s"), humanSize($totalSize));
?>
</p>

<?php 
pageFooter();
예제 #10
0
파일: users.php 프로젝트: dg-wfk/dl
      </tr>
    </thead>
    <tbody>
<?php 
foreach ($db->query($sql) as $DATA) {
    // selection
    echo "<tr><td><input class=\"element checkbox\" type=\"checkbox\" name=\"sel[]\" value=\"" . htmlEntUTF8($DATA['name']) . "\"/></td>";
    // name/password
    echo "<td>" . htmlEntUTF8($DATA['name']) . "</td>";
    echo "<td><input type=\"hidden\" name=\"user[]\" value=\"" . htmlEntUTF8($DATA['name']) . "\"/><input class=\"element text\"" . " type=\"text\" name=\"pass[]\"></td>";
    // role
    echo '<td data-sort-value="' . $DATA['admin'] . '">' . htmlRole("role[]", $DATA['admin']) . '</td>';
    // tickets/grants
    echo "<td>{$DATA['tickets']}</td><td>{$DATA['grants']}</td>";
    // total size
    echo '<td data-sort-value="' . (int) $DATA['size'] . '">' . humanSize($DATA['size']) . '</td></tr>';
}
?>
    </tbody>
    <tfoot>
      <tr>
        <td></td>
        <td><input class="element text" type="text" name="newUser"></td>
        <td><input class="element text" type="text" name="newPass"></td>
        <td><?php 
echo htmlRole("newRole", 0);
?>
</td>
        <td colspan="3">
          <input class="element button" type="submit" name="create" value="<?php 
echo T_("Create");
예제 #11
0
         }
         if ($gotit == "false") {
             $av_group[$av_groups] = $p_group[$i];
             $av_groups++;
         }
     }
 }
 if ($av_groups < 2 || $group != "") {
     for ($i = 0; $i < $package_count; $i++) {
         if ($p_version[$i] == $version && $p_platform[$i] == $platform && ($av_groups < 2 || $group == $p_group[$i])) {
             echo "<table class=\"pair\">";
             echo "<tr class=\"head\"><td colspan=\"2\">" . $p_description[$i] . "</td></tr>";
             echo "<tr><td class=\"data\">" . $template['custom']['version'] . "</td><td>" . $version_description[$version] . "</td></tr>";
             echo "<tr><td class=\"data\">" . $template['custom']['type'] . "</td><td>" . $platform_description[$platform] . "</td></tr>";
             if ($p_size[$i] != "") {
                 echo "<tr><td class=\"data\">" . $template['custom']['size'] . "</td><td>" . humanSize($p_size[$i]) . "</td></tr>";
             }
             if ($p_author[$i] != "") {
                 echo "<tr><td class=\"data\">" . $template['custom']['author'] . "</td><td>" . $p_author[$i] . "</td></tr>";
             }
             if ($p_details[$i] != "") {
                 echo "<tr><td colspan=\"2\">" . $p_details[$i] . "</td></tr>";
             }
             echo "<tr><td colspan=\"2\">";
             echo "<b>" . $template['releases']['available'] . "</b><br /><br />";
             foreach ($ftp_mirror as $key => $value) {
                 echo "<a href=\"" . $value['url'] . "/" . $p_path[$i] . "/" . $p_filename[$i] . "\">" . $p_filename[$i] . "</a><br />";
                 echo $value['desc'] . ", " . $value['city'] . "<br /><br />";
             }
             echo "</td></tr></table>";
         }
예제 #12
0
파일: preview.php 프로젝트: Prescia/Prescia
 $field_upload = $core->template->get("_upload_field");
 $using = clone $field_upload;
 $emptyme = array();
 $tobjTemp = $core->template->get("_thumb");
 $path = CONS_FMANAGER . $module->name . "/";
 $fileName = $name . "_";
 foreach ($module->keys as $key) {
     $fileName .= $data[$key] . "_";
 }
 $FirstfileName = $path . $fileName . "1";
 $hasFile = locateAnyFile($FirstfileName, $ext);
 if (!$hasFile) {
     $content = false;
     continue;
 } else {
     $fillDT['filesize'] = humanSize(filesize($FirstfileName));
     $ext = strtolower($ext);
     $fillDT['download'] = CONS_INSTALL_ROOT . $FirstfileName;
     $fillDT['ico'] = filetypeIcon($ext);
     if (in_array($ext, array("jpg", "gif", "swf", "png", "jpeg"))) {
         $hasImages = true;
         $h = getimagesize($FirstfileName);
         $fillDT['width'] = $h[0];
         $fillDT['height'] = $h[1];
         $fillDT['dim'] = $h[0] . "x" . $h[1];
         if ($h[0] < $maxWidth && $h[1] < $maxHeight) {
             $emptyme[] = "_downloadable";
             if ($ext != "swf") {
                 $emptyme[] = "_swf";
             } else {
                 $emptyme[] = "_img";
예제 #13
0
파일: edittickets.php 프로젝트: dg-wfk/dl
    $maxDl = $defaults['ticket']['maxdl'];
} else {
    $maxDl = 0;
}
// current ticket details
$ticketUrl = ticketUrl($DATA);
$details = array();
$details[T_('Current expiration')] = ticketExpiration($DATA);
$details[T_('Created on')] = date($dateFmtFull, $DATA["time"]);
// owner
if ($DATA["user_id"] != $auth["id"]) {
    $sql = 'SELECT name FROM "user"' . " WHERE id = " . $db->quote($DATA["user_id"]);
    $user = $db->query($sql)->fetch();
    $details[T_('Created by')] = htmlEntUTF8($user["name"]);
}
$details[T_('File size')] = humanSize($DATA["size"]);
$details[T_('Download link')] = "<a class=\"ticketid\" href=\"{$ticketUrl}\">" . htmlEntUTF8($ticketUrl) . "</a>";
// downloads
if ($DATA["downloads"]) {
    $details[T_("Download count")] = $DATA["downloads"];
    $details[T_("Last download")] = date($dateFmtFull, $DATA["last_stamp"]);
}
// sent-to
if ($DATA["sent_email"]) {
    $addrs = array();
    foreach (getEMailAddrs($DATA['sent_email']) as $email) {
        $addrs[] = '<a href="mailto:' . urlencode($email) . '">' . htmlEntUTF8($email) . '</a>';
    }
    $details[T_("Initially sent to")] = implode(", ", $addrs);
}
infoTable($details);
예제 #14
0
        $dir = "/";
    } else {
        $dir = "/" . $dir;
    }
} else {
    $dir = "/";
}
$core->template->assign("dir", $dir);
$core->template->assign("maxupload", ini_get('upload_max_filesize'));
# Quota:
$usedSpace = quota(CONS_FMANAGER, true) * 1024;
$core->loadDimconfig(true);
$quota = isset($core->dimconfig['quota']) ? $core->dimconfig['quota'] : CONS_MAX_QUOTA;
$percent = $usedSpace / $quota;
$core->template->assign('used', humanSize($usedSpace));
$core->template->assign('quota', humanSize($quota));
$core->template->assign("pct", number_format($percent * 100, 2));
$pbar = ceil($percent * 99);
if ($pbar > 99) {
    $pbar = 99;
}
$core->template->assign("pctd", $pbar);
$core->dimconfig['_usedquota'] = $usedSpace;
$core->saveConfig();
// safe fmanager?
$fm = $core->loaded('bi_fm');
if ($fm !== false) {
    $core->runContent(CONS_AUTH_USERMODULE, $core->template, "", "_permusers", false, "permusersin");
    $core->runContent(CONS_AUTH_GROUPMODULE, $core->template, "", "_permgroup", false, "permgroupsin");
    $core->template->assign("safefolder", CONS_FMANAGER_SAFE);
} else {
예제 #15
0
파일: edit.php 프로젝트: Prescia/Prescia
function fillField(&$core, &$module, $name, &$field, &$data, &$p, $isSerialized = false, $basename = "")
{
    $content = "";
    // load l10n for datetimes
    if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_DATE && isset($data[$name])) {
        $data[$name] = fd($data[$name], $core->intlControl->getDate());
    } else {
        if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_DATETIME && isset($data[$name])) {
            $data[$name] = fd($data[$name], "H:i:s " . $core->intlControl->getDate());
        }
    }
    // format in language mode
    // pre-fill option arrays
    if (!$p['isADD'] && $field[CONS_XML_TIPO] == CONS_TIPO_OPTIONS && isset($data[$name])) {
        if (isset($data[$name])) {
            $l = strlen($data[$name]);
            for ($c = 0; $c < $l; $c++) {
                $data[$name . $c] = isset($data[$name . $c]) || $data[$name][$c] == "1";
            }
            unset($l);
        }
    }
    // If we are adding, check default values
    if ($p['isADD']) {
        if (strpos($field[CONS_XML_SQL], "AUTO_INCREMENT") !== false) {
            return;
        }
        // do not put autoincrement keys on add
        if (isset($field[CONS_XML_DEFAULT]) && !isset($data[$name])) {
            if ($field[CONS_XML_TIPO] == CONS_TIPO_LINK && $field[CONS_XML_DEFAULT] == "%UID%" && defined("CONS_AUTH_USERMODULE") && $field[CONS_XML_MODULE] == CONS_AUTH_USERMODULE && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 0 && isset($_SESSION[CONS_SESSION_ACCESS_USER]['id'])) {
                $data[$name] = $_SESSION[CONS_SESSION_ACCESS_USER]['id'];
            } else {
                if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) {
                    $data[$name] = fd($field[CONS_XML_DEFAULT], $core->intlControl->getDate());
                } else {
                    $data[$name] = $field[CONS_XML_DEFAULT];
                }
            }
        } else {
            if (isset($field[CONS_XML_TIMESTAMP]) || isset($field[CONS_XML_UPDATESTAMP])) {
                if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) {
                    $data[$name] = date($core->intlControl->getDate());
                } else {
                    $data[$name] = date("H:i:s " . $core->intlControl->getDate());
                }
            }
        }
    } else {
        if (isset($field[CONS_XML_UPDATESTAMP])) {
            if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) {
                $data[$name] = date($core->intlControl->getDate());
            } else {
                $data[$name] = date("H:i:s " . $core->intlControl->getDate());
            }
        }
    }
    // ajax exceptions?
    if ($core->layout == 2 && $field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) {
        // ajax mode does not accept uploads
        return;
    }
    // have permission to see this field?
    if ($_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100 && isset($field[CONS_XML_RESTRICT]) && $field[CONS_XML_RESTRICT] > $_SESSION[CONS_SESSION_ACCESS_LEVEL]) {
        return;
    } else {
        // Does this field have a different interface handler? if so use it and continue to the next
        if (in_array($name, $p['cacheCustomFields'])) {
            // detect which plugin has the customHandler and use it. Use the first and leave, if there is more than one, ignore the conflict
            foreach ($module->plugins as $scriptname) {
                // if we didn't have the cache, this would run always, see?
                if (in_array($name, $core->loadedPlugins[$scriptname]->customFields)) {
                    // ok, handle it (if it returns TRUE, ignore this handler)
                    $content = $core->loadedPlugins[$scriptname]->field_interface($name, $p['isADD'], $data);
                    if ($content === false) {
                        return;
                    } else {
                        if ($content !== true) {
                            break;
                            // we will break this foreach plugin search, but continue normally the rest
                        }
                    }
                    $content = "";
                    // if we didn't continue (use the field or ignore), proceed as if this field was normal, thus erase the custom content
                }
            }
        }
        // This field is read-only?
        if (in_array($name, $p['hideKeys']) || isset($field[CONS_XML_READONLY])) {
            if ($p['isADD']) {
                return;
            } else {
                if (!$p['isMultiple']) {
                    $content = isset($data[$name]) ? $data[$name] : ' ';
                } else {
                    return;
                }
            }
        }
        $fillDT = array('field' => $name, 'isADD' => $p['isADD'] ? "true" : "false", 'affreferer' => $module->name, 'affrefererkeys' => implode("_", $p['refererKeys']), 'width' => '99%', 'helper' => '');
        if ($content == '') {
            // format according to type
            $helper = $core->langOut('helper_' . $module->name . "_" . $name);
            if ($helper != 'helper_' . $module->name . "_" . $name) {
                $fillDT['helper'] = $helper;
            }
            switch ($field[CONS_XML_TIPO]) {
                // for each fields ...
                case CONS_TIPO_UPLOAD:
                    // ############################################### FILE(s)
                    if ($p['isMultiple'] || $p['isMup']) {
                        $content = false;
                        continue;
                        // continue will leave only the switch, since switch is considered a loop (??? WHY PHP, WHY ???)
                    }
                    $field_upload = $core->template->get("_upload_field");
                    $using = clone $field_upload;
                    $emptyme = array();
                    if (!$p['isADD']) {
                        $tobjTemp = $core->template->get("_thumb");
                        $path = CONS_FMANAGER . $module->name . "/";
                        $fileName = $name . "_";
                        foreach ($module->keys as $key) {
                            $fileName .= $data[$key] . "_";
                        }
                        $FirstfileName = $path . $fileName . "1";
                        $hasFile = locateAnyFile($FirstfileName, $ext);
                        if (!$hasFile) {
                            $emptyme[] = "_hasFile";
                            if (isset($module->fields[$name][CONS_XML_THUMBNAILS])) {
                                $p['hasImages'] = true;
                                $fillDT['maxres'] = "max " . str_replace(",", "x", $module->fields[$name][CONS_XML_THUMBNAILS][0]);
                            }
                        } else {
                            $fillDT['filesize'] = humanSize(filesize($FirstfileName));
                            $ext = strtolower($ext);
                            $fillDT['download'] = CONS_INSTALL_ROOT . $FirstfileName . "?r=" . rand(0, 9990);
                            $fillDT['ico'] = filetypeIcon($ext);
                            if (in_array($ext, array("jpg", "gif", "swf", "png", "jpeg"))) {
                                $p['hasImages'] = true;
                                $h = getimagesize($FirstfileName);
                                $fillDT['width'] = $h[0];
                                $fillDT['height'] = $h[1];
                                $fillDT['dim'] = $h[0] . "x" . $h[1];
                                if ($h[0] < $p['maxWidth'] && $h[1] < $p['maxHeight']) {
                                    $emptyme[] = "_downloadable";
                                    if ($ext != "swf") {
                                        $emptyme[] = "_swf";
                                    } else {
                                        $emptyme[] = "_img";
                                    }
                                } else {
                                    $emptyme[] = "_presentable";
                                }
                                if (isset($field[CONS_XML_THUMBNAILS])) {
                                    $thumbVersions = count($field[CONS_XML_THUMBNAILS]);
                                    if ($thumbVersions > 1) {
                                        $tObj = clone $tobjTemp;
                                        $tTemp = "";
                                        for ($tv = 2; $tv <= $thumbVersions; $tv++) {
                                            $thumbFile = $path . "t/" . $fileName . $tv;
                                            locateFile($thumbFile, $ext);
                                            $h = getimagesize($thumbFile);
                                            $tTemp .= $tObj->techo(array('tdownload' => CONS_INSTALL_ROOT . $thumbFile));
                                        }
                                        $using->assign("_thumb", $tTemp);
                                    } else {
                                        $emptyme[] = "_hasThumbs";
                                    }
                                } else {
                                    $emptyme[] = "_hasThumbs";
                                }
                            } else {
                                $emptyme[] = "_isImage";
                                $emptyme[] = "_presentable";
                            }
                        }
                    } else {
                        $emptyme[] = "_hasFile";
                    }
                    if (isset($field[CONS_XML_THUMBNAILS])) {
                        $fillDT['maxres'] = "max " . str_replace(",", "x", $field[CONS_XML_THUMBNAILS][0]);
                    }
                    if (isset($field[CONS_XML_FILETYPES])) {
                        $fillDT['exts'] = "(" . $field[CONS_XML_FILETYPES] . ")";
                    }
                    $fillDT['maxsize'] = isset($field[CONS_XML_FILEMAXSIZE]) ? humanSize($field[CONS_XML_FILEMAXSIZE]) : ini_get('upload_max_filesize');
                    if (isset($field[CONS_XML_FILEMAXSIZE]) && $field[CONS_XML_FILEMAXSIZE] > $p['mfs']) {
                        $p['mfs'] = $field[CONS_XML_FILEMAXSIZE];
                    }
                    $content = $using->techo($fillDT, $emptyme);
                    unset($emptyme);
                    break;
                case CONS_TIPO_LINK:
                    // ############################################### LINK TO ANOTHER MODULE
                    $mod = $core->loaded($field[CONS_XML_MODULE]);
                    if ($mod !== false) {
                        $core->safety = false;
                        // <-- in the select, we should always show every item
                        $fillDT['rmodule'] = $field[CONS_XML_MODULE];
                        if ($mod->options[CONS_MODULE_PARENT]) {
                            $field_sel = $core->template->get("_selecttree_field");
                            $using = clone $field_sel;
                            $sql = $mod->get_base_sql();
                            if (isset($data[$name])) {
                                $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected";
                            }
                            $sql['SELECT'][] = $mod->name . "." . $mod->title . " as treetitle";
                            $tree = $mod->getContents("", "treetitle", "", "\\", $sql);
                            $using->getTreeTemplate("_sdirs", "_ssubdirs", $tree);
                        } else {
                            $field_sel = $core->template->get("_select_field");
                            $using = clone $field_sel;
                            // checks if this field is/can be filtered by another, if can, leave empty on ADD
                            $canBeFilteredBy = array();
                            if (isset($field[CONS_XML_FILTEREDBY])) {
                                $canBeFilteredBy = $field[CONS_XML_FILTEREDBY];
                                // already a list of local fields
                                $using->assign('helper', $core->langOut("filtered_by") . ": " . implode(",", $canBeFilteredBy));
                                $havePreqs = true;
                                // either on add or edit, field that filter this could be present ... check them!
                                for ($cbf = 0; $cbf < count($canBeFilteredBy); $cbf++) {
                                    if (!isset($data[$canBeFilteredBy[$cbf]]) || $data[$canBeFilteredBy[$cbf]] == '' || $data[$canBeFilteredBy[$cbf]] == '0') {
                                        $havePreqs = false;
                                        break;
                                    }
                                }
                                if (!$havePreqs) {
                                    // we can't fill it, so display the select_other_field message
                                    $using->assign("_optional", "");
                                    $canBeFilteredBy_translated = array();
                                    for ($cbf = 0; $cbf < count($canBeFilteredBy); $cbf++) {
                                        $canBeFilteredBy_translated[$cbf] = $core->langOut($canBeFilteredBy[$cbf]);
                                    }
                                    $using->assign("_options", "<option value=\"\">" . $core->langOut("select_other_field") . ": " . implode(", ", $canBeFilteredBy_translated) . "</option>");
                                } else {
                                    // we can fill this since all prerequisites are present!
                                    $sql = $mod->get_base_sql();
                                    $sql['SELECT'] = array($mod->name . "." . $mod->keys[0] . " as ids", $mod->name . "." . $mod->title . " as title");
                                    if (isset($data[$name])) {
                                        $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected";
                                    }
                                    // add filters
                                    foreach ($canBeFilteredBy as $filterfield) {
                                        // we know the data exists because this is an edit, but it could be empty
                                        if ($data[$filterfield] != '') {
                                            $remodeField = $mod->get_key_from($module->fields[$filterfield][CONS_XML_MODULE]);
                                            $sql['WHERE'][] = $mod->name . "." . $remodeField . "=\"" . $data[$filterfield] . "\"";
                                        }
                                    }
                                    if ($core->runContent($mod, $using, $sql, "_options") === false) {
                                        $using->assign("_options");
                                    }
                                }
                                // add the corresponding data for the ajaxContextHandler
                                $p['ajaxContextHandler'][$name] = $canBeFilteredBy;
                            } else {
                                $sql = $mod->get_base_sql();
                                # TODO: this probably won't work on multiple keys
                                $sql['SELECT'] = array($mod->name . "." . $mod->keys[0] . " as ids", $mod->name . "." . $mod->title . " as title");
                                if (isset($data[$name])) {
                                    $sql['SELECT'][] = "if (" . $mod->name . "." . $mod->keys[0] . "='" . $data[$name] . "',1,0) as selected";
                                }
                                //print_r($sql);
                                //die();
                                if ($core->runContent($mod, $using, $sql, "_options") === false) {
                                    $using->assign("_options");
                                }
                            }
                        }
                        $content = $using->techo($fillDT);
                        $core->safety = true;
                        // back to normal mode
                        unset($using);
                    }
                    break;
                case CONS_TIPO_TEXT:
                    // ############################################### TEXT (textarea/cke)
                    $field_txt = $core->template->get("_textarea_field");
                    $using = clone $field_txt;
                    $fillDT['value'] = isset($data[$name]) ? $data[$name] : '';
                    if (isset($field[CONS_XML_HTML])) {
                        $fillDT['value'] = htmlspecialchars($fillDT['value']);
                    }
                    // ckedit will remove entities, so we add an extra layer!
                    $useCKE = isset($field[CONS_XML_HTML]);
                    # CKEdit
                    $content = $using->techo($fillDT);
                    $p['endScript'] .= $useCKE ? "var CKE{$name} = CKEDITOR.replace( '{$name}' , { language : '" . $_SESSION[CONS_SESSION_LANG] . "'" . (isset($module->fields[$name][CONS_XML_SIMPLEEDITFORCE]) ? ",toolbar : 'MiniToolbar'" : "") . "} );\n\tCKFinder.setupCKEditor( CKE{$name}, '/pages/_js/ckfinder/' ) ;\n" : '';
                    # CKEdit + CKFinder
                    unset($using);
                    break;
                case CONS_TIPO_ENUM:
                    // ############################################### LIST OF ITEMS IN ENUM FORM
                    preg_match("@ENUM \\(([^)]*)\\).*@", $field[CONS_XML_SQL], $regs);
                    if ($p['isADD'] && isset($field[CONS_XML_DEFAULT]) && (!isset($data[$name]) || $data[$name] == "")) {
                        $data[$name] = $module->fields[$name][CONS_XML_DEFAULT];
                    }
                    $xtp = "<option value=\"{enum}\" {checked}>{enum_translated}</option>";
                    $tp = new CKTemplate($core->template);
                    $tp->tbreak($xtp);
                    $temp = isset($field[CONS_XML_MANDATORY]) ? '' : "<option value=''></option>";
                    $enums = explode(",", $regs[1]);
                    foreach ($enums as $x) {
                        $x = str_replace("'", "", $x);
                        $db = array('enum' => $x, 'enum_translated' => $core->langOut($x), 'checked' => isset($data[$name]) && $data[$name] == $x ? ' selected="selected"' : '');
                        $temp .= $tp->techo($db);
                    }
                    $content = "<select " . ($p['isMultiple'] ? "onchange=\"\$('me_edit_" . $name . "').checked = true;\"" : "onchange=\"checkConditions();\"") . " id=\"{$name}\" name=\"{$name}\" >" . $temp . "</select>";
                    unset($temp);
                    unset($enums);
                    break;
                case CONS_TIPO_OPTIONS:
                    // ############################################# CHECKBOX LIST
                    $xtp = "<input type=\"checkbox\" onclick=\"checkopts('{field}');\" name=\"{name}\" id=\"{name}\" {checked}/><label for=\"{name}\">{translated}</label><br/>";
                    $tp = new CKTemplate($core->template);
                    $tp->tbreak($xtp);
                    $citem = 0;
                    $temp = "<input type='hidden' name='{$name}' id='{$name}' value=\"" . (isset($data[$name]) ? $data[$name] : "") . "\"/>";
                    foreach ($field[CONS_XML_OPTIONS] as $opt) {
                        $db = array('name' => $name . "_" . $citem, 'field' => $name, 'translated' => $core->langOut(str_replace("'", "", $opt)), 'checked' => isset($data[$name]) && strlen($data[$name]) >= $citem && $data[$name][$citem] == 1 ? ' checked="checked"' : '');
                        $temp .= $tp->techo($db);
                        $citem++;
                    }
                    $content = $temp;
                    unset($temp);
                    break;
                case CONS_TIPO_DATE:
                    // ############################################### DATE / DATETIME
                // ############################################### DATE / DATETIME
                case CONS_TIPO_DATETIME:
                    // updatestamp & includestap already treated befpre switch
                    if ($core->layout != 2) {
                        $fillDT['calendar'] = "<img id='divcalendar_" . $name . "' onclick=\"calendarHandler.showCalendar('" . $name . "','divcalendar_" . $name . "',-80,-8);\" src=\"" . CONS_INSTALL_ROOT . CONS_PATH_PAGES . "_js/calendar/gifs/dyncalendar.gif\" style=\"width:16px;height:16px;position:relative;top:3px;left:2px\" alt=\"" . $core->langOut('calendar') . "\"/>";
                    }
                    $fillDT['width'] = "120px";
                    $p['hasCalendar'] = true;
                case CONS_TIPO_VC:
                    // ############################################### SIMPLE INPUT WITH HEAVY TYPESETTING
                // ############################################### SIMPLE INPUT WITH HEAVY TYPESETTING
                case CONS_TIPO_INT:
                case CONS_TIPO_FLOAT:
                    $field_sel = $core->template->get("_normal_field");
                    $using = clone $field_sel;
                    $fillDT['value'] = isset($data[$name]) ? $data[$name] : '';
                    $fillDT['type'] = "text";
                    if (isset($field[CONS_XML_META])) {
                        if ($field[CONS_XML_META] == "masked") {
                            $fillDT['type'] = "password";
                        }
                        if ($field[CONS_XML_META] == "password") {
                            $fillDT['type'] = "password";
                            if ($_SESSION[CONS_SESSION_ACCESS_LEVEL] != 100) {
                                $data[$name] = "";
                                $fillDT['value'] = "";
                            }
                        }
                    }
                    if ($field[CONS_XML_TIPO] == CONS_TIPO_INT) {
                        if ($fillDT['helper'] == '') {
                            $fillDT['helper'] = $core->langOut('helper_integer');
                        }
                        $p['validators']['integer'][] = "'{$name}'";
                    } else {
                        if ($field[CONS_XML_TIPO] == CONS_TIPO_FLOAT) {
                            if ($fillDT['helper'] == '') {
                                $fillDT['helper'] = $core->langOut('helper_float');
                            }
                            $p['validators']['float'][] = "'{$name}'";
                        } else {
                            if ($field[CONS_XML_TIPO] == CONS_TIPO_DATE) {
                                $p['validators']['date'][] = "'{$name}'";
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = '(' . $core->intlControl->getDate() . ')';
                                }
                            } else {
                                if ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME) {
                                    if ($fillDT['helper'] == '') {
                                        $fillDT['helper'] = $core->langOut('helper_time') . ' ' . $core->intlControl->getDate() . ')';
                                    }
                                    $p['validators']['datetime'][] = "'{$name}'";
                                }
                            }
                        }
                    }
                    if (isset($field[CONS_XML_SPECIAL])) {
                        switch ($field[CONS_XML_SPECIAL]) {
                            case 'login':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_login');
                                }
                                $p['validators']['login'][] = "'{$name}'";
                                break;
                            case 'mail':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = '(ex: login@servidor.com)';
                                }
                                $p['validators']['mail'][] = "'{$name}'";
                                break;
                            case 'number':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_integer');
                                }
                                $p['validators']['integer'][] = "'{$name}'";
                                break;
                            case 'float':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_float');
                                }
                                $p['validators']['float'][] = "'{$name}'";
                                break;
                            case 'cpf':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_cpf');
                                }
                                $p['validators']['is_cpf'][] = "'{$name}'";
                                break;
                            case 'cnpj':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_cnpj');
                                }
                                $p['validators']['is_cnpj'][] = "'{$name}'";
                                break;
                            case 'id':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_id');
                                }
                                $p['validators']['is_id'][] = "'{$name}'";
                                break;
                            case 'date':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->intlControl->getDate();
                                }
                                $p['validators']['date'][] = "'{$name}'";
                                break;
                            case 'datetime':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_time') . " " . $core->langOut('helper_followedby') . " " . $core->intlControl->getDate() . ')';
                                }
                                $p['validators']['datetime'][] = "'{$name}'";
                                break;
                                break;
                            case 'onlinevideo':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_video');
                                }
                                break;
                            case 'time':
                                if ($fillDT['helper'] == '') {
                                    $fillDT['helper'] = $core->langOut('helper_time');
                                }
                                $p['validators']['time'][] = "'{$name}'";
                                break;
                            default:
                                if (strlen($field[CONS_XML_SPECIAL]) > 10 && substr($field[CONS_XML_SPECIAL], 0, 6) == "slider") {
                                    if (preg_match("@([0-9]*)\\,([0-9]*)@", $field[CONS_XML_SPECIAL], $ereg)) {
                                        unset($using);
                                        unset($field_sel);
                                        $field_sel = $core->template->get("_slider_field");
                                        $using = clone $field_sel;
                                        $fillDT['minor'] = $ereg[1];
                                        $fillDT['major'] = $ereg[2];
                                        if (!is_numeric($fillDT['value'])) {
                                            $fillDT['value'] = $ereg[1];
                                        }
                                        $p['hasSlider'] = true;
                                        if ($fillDT['helper'] == '') {
                                            $fillDT['helper'] = $ereg[1] . " - " . $ereg[2];
                                        }
                                    }
                                }
                                break;
                        }
                    }
                    $content = $using->techo($fillDT);
                    break;
                case CONS_TIPO_ARRAY:
                    # data is an array
                    $p['hasSerializedArray'] = true;
                    $p['serializedArrays'][] = '"' . $name . '"';
                    $p['endScript'] .= "CScontroler.fillData('{$name}'," . JSON_encode($field[CONS_XML_OPTIONS]) . "," . JSON_encode(isset($data[$name]) ? $data[$name] : '') . ");\n";
                    $field_ser = $core->template->get("_serializearray_field");
                    $using = clone $field_ser;
                    $content = $using->techo($fillDT);
                    unset($using);
                    break;
            }
            # switch
            if (isset($field['conditional']) && strpos($field['conditional'], "=") !== false) {
                $temp = explode("=", $field['conditional']);
                $ltemp = trim(strtolower($temp[0]));
                $negation = strpos($ltemp, "!") !== false;
                if ($negation) {
                    $ltemp = trim(str_replace("!", "", $ltemp));
                }
                $rtemp = str_replace("'", "", trim($temp[1]));
                $p['condHandlers'][] = "\$('tableitem" . $name . "').style.display = \$('{$ltemp}').value " . ($negation ? "!=" : "==") . "'{$rtemp}' ? '' : 'none';";
            }
        }
        # content not blank
    }
    # permission to see?
    if ($content === false) {
        return '';
    }
    // if content is false, ignore alltogether
    // build a template object with this field and print it out
    $using = clone $p['objfield'];
    $outdata = array('field' => $content, 'title' => $isSerialized ? substr($name, strlen($basename) + 1) : $name, 'mandatory' => in_array($name, $module->keys) || isset($field[CONS_XML_MANDATORY]) && $field[CONS_XML_MANDATORY] ? "y" : "n");
    if (!$p['isMultiple'] && (!$p['isMup'] || $name != $module->title) && $outdata['mandatory'] == 'y' && !in_array($name, $p['hideKeys']) && $field[CONS_XML_TIPO] != CONS_TIPO_UPLOAD && !isset($field[CONS_XML_READONLY])) {
        // EXCEPTION: a ignorenedit field CAN be blank during EDIT only
        if (!isset($field[CONS_XML_IGNORENEDIT]) || $p['isADD']) {
            $p['$validators']['mandatory'][] = "'{$name}'";
            $p['$validators']['translation'][] = "'" . $core->langOut($name) . "'";
            $p['$validators']['defaults'][] = isset($field[CONS_XML_DEFAULT]) ? "'" . $field[CONS_XML_DEFAULT] . "'" : "''";
        }
    }
    $p['tempOutput'] .= $using->techo($outdata);
    unset($using);
}