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(); }
$output .= $toprowObj->techo($rowData, $core->layout != 0 || $linkField[CONS_XML_TIPO] == CONS_TIPO_UPLOAD ? array("_noOrder") : array()); if ($haveListADD) { $outputAdd .= $lineAddObj->techo($rowData); } } $outputLine .= $lineObj->techo($rowData); } } // foreach field to display // end creation of listing templates ############################ FINALIZE TEMPLATE ##################### // prepare real output if (!$notitle) { $core->template->assign("_top_row", $output); } $lineObj = new CKTemplate($core->template); $lineObj->tbreak($outputLine); $core->template->assign("_row", $lineObj); if ($haveListADD && !$notitle) { $core->template->assign("_rowla", $outputAdd); $core->template->assign("colspan", $usedColumns + ($core->layout == 0 ? 3 : 2)); $core->template->assign("lafields", implode("','", $laFields)); } else { $core->template->assign("_la"); } ############################ FILL SEARCH FORMS ##################### // prepare template parameters for runContent $core->templateParams['callbackModule'] =& $module; $core->templateParams['forcepost'] = "frmbase|haveinfo=1"; # not really needed to change the haveinfo but TC requires a field to change $core->templateParams['noOutputParse'] = !$imageDetected;
$module->generateBackup(); if ($this->nearTimeLimit()) { break; } } } } if (CONS_CRONDBBACKUP_MAIL != '' && !$this->nearTimeLimit()) { $bfile = CONS_PATH_BACKUP . $_SESSION['CODE'] . "/backup.zip"; if (is_file($bfile)) { @unlink($bfile); } $files = listFiles(CONS_PATH_BACKUP . $_SESSION['CODE'] . "/", '/.*\\.sql/'); if (count($files) == 0) { return; } $zip = new ZipArchive(); $zip->open($bfile, ZipArchive::CREATE); foreach ($files as $file) { $zip->addFile(CONS_PATH_BACKUP . $_SESSION['CODE'] . "/" . $file, $file); } $zip->close(); unset($zip); $mail = "BACKUP PERFORMED AT " . date("Y-m-d H:i:s"); $tmail = new CKTemplate(); $tmail->tbreak($mail); sendmail(CONS_CRONDBBACKUP_MAIL, "backup " . $_SESSION['CODE'], $tmail, CONS_MASTERMAIL, '', true, $bfile); } } $this->dimconfig['_cronH'] = date("H"); }
# CKEdit $content = $using->techo($fillDT); $endScript .= $useCKE ? "var CKE" . $data['name'] . " = CKEDITOR.replace( '" . $data['name'] . "' , { language : '" . $_SESSION[CONS_SESSION_LANG] . "'} );\n\tCKFinder.setupCKEditor( CKE" . $data['name'] . ", '/pages/_js/ckfinder/' ) ;\n" : ''; # CKEdit + CKFinder break; case CONS_TIPO_ENUM: // ############################################### LIST OF ITEMS IN ENUM FORM preg_match("@ENUM \\(([^)]*)\\).*@", $dimconfigMD[$data['name']][CONS_XML_SQL], $regs); if (isset($dimconfigMD[$data['name']][CONS_XML_DEFAULT]) && $data['value'] == "") { $data['value'] = $dimconfigMD[$data['name']][CONS_XML_DEFAULT]; } if ($data['name'] == 'bi_adm_skin') { $regs = array(1 => CONS_ADM_ACTIVESKINS); } $xtp = "<option value=\"{enum}\" {checked}>{enum_translated}</option>"; $tp = new CKTemplate($core->template); $tp->tbreak($xtp); $temp = isset($dimconfigMD[$data['name']][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' => $data['value'] == $x ? ' selected="selected"' : ''); $temp .= $tp->techo($db); } $content = "<select id=\"" . $data['name'] . "\" name=\"" . $data['name'] . "\" >" . $temp . "</select>"; break; case CONS_TIPO_DATE: // ############################################### DATE / DATETIME // ############################################### DATE / DATETIME case CONS_TIPO_DATETIME: $fillDT['calendar'] = "<img id='divcalendar_" . $data['name'] . "' onclick=\"calendarHandler.showCalendar('" . $data['name'] . "','divcalendar_" . $data['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') . "\"/>";
$newlist = array(); foreach ($_GET as $gname => $gitem) { if (substr($gname, 0, 3) == "la_") { $newlist[substr($gname, 3)] = $gitem; } else { $newlist[$gname] = $gitem; } } $where = $sm->getRemoteKeys($module, $newlist); } foreach ($where as $whereItem) { $sql['WHERE'][] = $whereItem; } } // prepare template $tp = new CKTemplate($this->template); $tp->tbreak("<select id=\"{$container}\" name=\"{$container}\" {extras}>" . ($allowEmpty ? "<option value=''></option>" : "") . "{_options}<option {selected|selected} value=\"{id}\">{title}</option>{/options}</select>"); $extras = ""; if ($aoc) { $extras .= "onChange=\"selectChange();\" "; } if ($className != "") { $extras .= "class=\"{$className}\" "; } if ($widthValue != "") { $extras .= "style=\"width:{$widthValue}\" "; } $tp->assign("extras", $extras); // fill select $this->safety = false; // <-- show all fields we can list
// fill up title, metas etc if (isset($param['title'])) { $mytemplate = new CKTemplate($this->template); $mytemplate->tbreak($param['title']); $this->template->constants['PAGE_TITLE'] = $mytemplate->techo($result); $this->storage['LOCKTITLE'] = true; unset($mytemplate); } if (isset($param['metadesc'])) { $mytemplate = new CKTemplate($this->template); $mytemplate->tbreak($param['metadesc']); $this->template->constants['METADESC'] = $mytemplate->techo($result); $this->storage['LOCKDESC'] = true; unset($mytemplate); } if (isset($param['metakeys'])) { $mytemplate = new CKTemplate($this->template); $mytemplate->tbreak($param['metakeys']); $this->template->constants['METAKEYS'] = $mytemplate->techo($result); $this->storage['LOCKKEYS'] = true; unset($mytemplate); } return true; } else { unset($this->storage['friendlyurldata']); // just in case unset($this->storage['friendlyurlmodule']); // jic } } return false;
<?php // this code is taken from default.php $template = new CKTemplate($core->template); $template->fetch(CONS_PATH_SYSTEM . "plugins/bi_adm/payload/template/skin/" . $this->skin . "/admframe.html"); $mObj = $template->get("_monitor"); // monitored items if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/monitor.xml") && $core->authControl->checkPermission('bi_adm', 'can_monitor')) { // we have monitored items AND can see them $monitorXml = $this->getMonitorArray(); // now perform sql queries COUNTING items we are monitoring $monitorTxt = ""; $c = 0; $totalItems = 0; foreach ($monitorXml as $monitoredItem) { $monitoredModule = $core->loaded($monitoredItem['module'], true); $monitoredItem['sql'] = str_replace("\$id_user", $_SESSION[CONS_SESSION_ACCESS_USER]['id'], $monitoredItem['sql']); $sql = $monitoredModule->get_base_sql("(" . $monitoredItem['sql'] . ")", "", ""); $sql['ORDER'] = array(); $sql['SELECT'] = array("count(*) as myresult"); if (!isset($monitoredItem['monitor_level'])) { $monitoredItem['monitor_level'] = 'warning'; } $ok = $core->dbo->query($sql, $r, $n); if ($ok) { if ($n > 0) { list($n) = $core->dbo->fetch_row($r); } $monitorData = array('monitor' => $c, 'level' => $monitoredItem['monitor_level'], 'notifies' => $n, 'txt' => $n == 1 ? isset($monitoredItem['monitor_text']) ? $core->langOut($monitoredItem['monitor_text']) : '' : (isset($monitoredItem['monitor_text_plural']) ? $core->langOut($monitoredItem['monitor_text_plural']) : '')); $totalItems += $n; $monitorTxt .= $mObj->techo($monitorData);
<?php if (!$core->authControl->checkPermission('bi_adm', 'can_monitor')) { $core->fastClose(403); } // We use the same scripts as in the list.html to handle ajax lists, get them $listHTML = new CKTemplate($core->template); $listHTML->fetch(CONS_PATH_SYSTEM . "plugins/" . $this->name . "/payload/template/list.html"); $core->template->assign("commonscript", $listHTML->get("_commonScripts")); unset($listHTML); $monitorXML = $this->getMonitorArray(); $monitorTP = $core->template->get("_monitorLists"); $temp = ""; $getOnlyThis = isset($_REQUEST['filter']) && is_numeric($_REQUEST['filter']) ? $_REQUEST['filter'] : -1; if (is_array($monitorXML)) { // now perform sql queries COUNTING items we are monitoring $c = 0; foreach ($monitorXML as $monitoredItem) { if ($getOnlyThis == -1 || $getOnlyThis == $c) { if (!isset($monitoredItem['monitor_level'])) { $monitoredItem['monitor_level'] = 'low'; } $outputData = array("frommonitor" => $c, "module" => $monitoredItem['module'], "level" => $monitoredItem['monitor_level'], "title" => isset($monitoredItem['monitor_text_plural']) ? $monitoredItem['monitor_text_plural'] : (isset($monitoredItem['monitor_text']) ? $monitoredItem['monitor_text'] : $monitoredItem['module'])); $temp .= $monitorTP->techo($outputData); } $c++; } $core->template->assign("_monitorLists", $temp); }
function getuseravatar(&$template, &$params, $data, $processed = false) { if ($processed) { return $data; } if ($data['image'] == 'n') { $params['excludes'][] = "_imageyes"; } else { $params['excludes'][] = "_imageno"; $data['image'] = CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/users/t/image_" . $data['id_author'] . "_2"; $ext = ""; locateFile($data['image'], $ext); } if (isset($params['mainpost']) && $data['includehtml'] != '') { $file = ""; if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/" . $data['includehtml'])) { $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/" . $data['includehtml']; } else { if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/" . $data['includehtml'] . ".html")) { $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/" . $data['includehtml'] . ".html"; } } if ($file != '') { $tmpTP = new CKTemplate($params['core']->template); $tmpInner = new CKTemplate($params['core']->template); $tmpTP->append($data['content']); $tmpInner->fetch($file); $tmpTP->append($tmpInner); $params['core']->removeAutoTags($tmpTP); $data['content'] = $tmpTP; } else { $data['content'] .= "<br/><small>File not found: " . $data['includehtml'] . "</small>"; } } return $data; }
$rssId = 0; foreach ($modules as $mod) { $module = $this->loaded($mod); if (!$module) { continue; } $sql = $module->get_base_sql('', '', $itemsPerModule); $hasCategory = $hasCategory || isset($category[$rssId]) && $category[$rssId] != ""; $this->dbo->query($sql, $r, $n); $dateField = ""; foreach ($module->fields as $fname => &$field) { if ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME && isset($field[CONS_XML_TIMESTAMP])) { $dateField = $fname; } } $ppage = new CKTemplate($this->template); $ppage->tbreak($ilt[$rssId]); for ($c = 0; $c < $n; $c++) { $dados = $this->dbo->fetch_assoc($r); $rssItem = array("title" => $dados[$it[$rssId]], "description" => $dados[$idesc[$rssId]], "date" => $dateField != "" ? gmdate("D, d M Y H:i:s", tomktime($dados[$dateField])) . " GMT" : $NOWdate, "link" => $ppage->techo($dados)); if (!isset($category[$rssId]) || $category[$rssId] != "") { if ($hasCategory) { $rssItem['category'] = $dados[$category[$rssId]]; } } $mylist[] = $rssItem; } $rssId++; } function datesort($a, $b) {
<?php // ------------------------ Prescia prepareMail. Will look for $name if cannot find $name_$lang # prepareMail($name="",$fillArray=array()) { $file = ""; $l = $_SESSION[CONS_SESSION_LANG]; if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/template_{$l}.html")) { $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/template_{$l}.html"; } else { if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/template.html")) { $file = CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/template.html"; } } $mail = new CKTemplate($this->template); if ($file != "") { $mail->fetch($file); } if ($name != "") { $innerFile = CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/" . $name . "_{$l}.html"; if (!is_file($innerFile)) { $innerFile = CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/" . $name . ".html"; if (!is_file($innerFile)) { $innerFile = CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/" . $name; if (!is_file($innerFile)) { $this->errorControl->raise(183, $name); $innerFile = ""; } } } if ($innerFile != "") { if ($file != "") {
$link = isset($mod['link']) ? $mod['link'] : ''; $limit = isset($mod['limit']) ? $mod['limit'] : 15; $where = isset($mod['where']) ? $mod['where'] : ''; $order = isset($mod['order']) ? $mod['order'] : ''; $sql = $module->get_base_sql($where, $order, $limit); $this->dbo->query($sql, $r, $n); $dateField = isset($mod['date']) ? $mod['date'] : ''; if ($dateField == '') { foreach ($module->fields as $fname => &$field) { if (($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME || $field[CONS_XML_TIPO] == CONS_TIPO_DATE) && isset($field[CONS_XML_TIMESTAMP])) { $dateField = $fname; } } } if ($link != '') { $ppage = new CKTemplate($this->template); $ppage->tbreak($link); } for ($c = 0; $c < $n; $c++) { $dados = $this->dbo->fetch_assoc($r); $resultData = array("module" => $mod['module'], "title" => $dados[$title], "description" => $dados[$desc], "date" => $dateField != "" ? $dados[$dateField] : date("Y-m-d H:i:s"), "link" => $link != '' ? $ppage->techo($dados) : '', "id" => $dados[$module->keys[0]]); // TODO: does not support multiple keys $mylist[] = $resultData; } $c++; } if (!$groupPerModule) { function datesort($a, $b) { return datecompare($a['date'], $b['date']) ? 1 : -1; }
function field_interface($field, $action, &$data) { if ($field == "permissions") { $output = ""; $this->parent->loadPermissions(); // makes sure it's loaded $perm = array(); $allperm = $this->parent->permissionTemplate; // get default permission array if (isset($data['permissions']) && $data['permissions'] != "") { $perm = unserialize($data['permissions']); } // loads // merge with standard permissions to make sure we have ALL permissions (example: a new module was added and this group still don't have permissions set?) foreach ($perm as $name => $permission) { $allperm[$name] = $permission; } // if a permission is lacking, will not override, thus using default // load template $mytp = new CKTemplate($this->parent->template); $mytp->fetch(CONS_PATH_SYSTEM . "plugins/" . $this->name . "/payload/permission_field.html"); $customPerm = $mytp->get("_custompermission"); $objPerm = $mytp->get("_permission"); foreach ($this->parent->modules as $name => $pmodule) { if ($pmodule->options[CONS_MODULE_SYSTEM]) { continue; } // cannot edit system modules $locker = "ccccccccc"; if ($pmodule->permissionOverride != "") { $locker = $pmodule->permissionOverride; $hasSOME = false; for ($pos = 0; $pos < 9; $pos++) { if ($pmodule->permissionOverride[$pos] == "c") { $hasSOME = true; break; } } } if ($hasSOME) { $thisPermission = array('title' => $this->parent->langOut($name) . (defined("CONS_MODULE_PARTOF") && $pmodule->options[CONS_MODULE_PARTOF] != '' ? " (" . $this->parent->langOut($pmodule->options[CONS_MODULE_PARTOF]) . ")" : ""), 'module' => $name, 'mr_checked' => $allperm[$name][0] == "1" || $locker[0] == "a" ? true : "", 'mr_disabled' => $locker[0] != "c" ? "disabled" : "", 'mw_checked' => $allperm[$name][1] == "1" || $locker[1] == "a" ? true : "", 'mw_disabled' => $locker[1] != "c" ? "disabled" : "", 'me_checked' => $allperm[$name][2] == "1" || $locker[2] == "a" ? true : "", 'me_disabled' => $locker[2] != "c" ? "disabled" : "", 'gr_checked' => $allperm[$name][3] == "1" || $locker[3] == "a" ? true : "", 'gr_disabled' => $locker[3] != "c" ? "disabled" : "", 'gw_checked' => $allperm[$name][4] == "1" || $locker[4] == "a" ? true : "", 'gw_disabled' => $locker[4] != "c" ? "disabled" : "", 'ge_checked' => $allperm[$name][5] == "1" || $locker[5] == "a" ? true : "", 'ge_disabled' => $locker[5] != "c" ? "disabled" : "", 'or_checked' => $allperm[$name][6] == "1" || $locker[6] == "a" ? true : "", 'or_disabled' => $locker[6] != "c" ? "disabled" : "", 'ow_checked' => $allperm[$name][7] == "1" || $locker[7] == "a" ? true : "", 'ow_disabled' => $locker[7] != "c" ? "disabled" : "", 'oe_checked' => $allperm[$name][8] == "1" || $locker[8] == "a" ? true : "", 'oe_disabled' => $locker[8] != "c" ? "disabled" : ""); $output .= $objPerm->techo($thisPermission); } $pos = 9; } foreach ($this->parent->loadedPlugins as $pname => $plugin) { // stand alone plugins (no module) if (count($plugin->customPermissions) != 0) { $pos = 9; foreach ($plugin->customPermissions as $ptag => $pi18n) { $thisPermission = array('title' => $pos == 9 ? $this->parent->langOut($pname) : '', 'pname' => 'c_' . $pname . "_" . $ptag, 'ptitle' => $pi18n, 'checked' => isset($allperm["plugin_" . $pname][$pos]) && $allperm["plugin_" . $pname][$pos] == '1' ? true : ''); $output .= $customPerm->techo($thisPermission); $pos++; } } } $mytp->assign("_permission", $output); $mytp->assign("_custompermission", ""); $output = $mytp->techo(); if ($output == '') { return false; } return $output; } return true; }
function onEcho(&$PAGE) { if ($this->parent->layout == 2 || $this->parent->servingFile) { return; } # don't mess with ajax # Happens just after the template has been parsed (note it received the page as a STRING now), after this, is ECHO and DIE ###### -> Construct should add this module to the onEcho array if (!$this->devDisable) { $thereAreErrors = false; if ($this->devCheckHTML || isset($_REQUEST['dev_test'])) { if (!function_exists('checkHTML')) { include CONS_PATH_INCLUDE . "checkHTML.php"; } $log = checkHTML($PAGE, false); if (count($log) > 0) { $thereAreErrors = true; $this->log[] = implode("<br/>", $log); // for dev_test } unset($log); } if (isset($_REQUEST['dev_test'])) { if (count($this->parent->log) > 0 || count($this->parent->warning) > 0) { # failed basic test , log it $_SESSION['affbidevut'][2][] = $this->parent->context_str . $this->parent->action . " Reports errors:"; foreach ($this->parent->log as $log) { $_SESSION['affbidevut'][2][] = $log; } foreach ($this->parent->warning as $log) { $_SESSION['affbidevut'][2][] = $log; } } $this->unitTest(); } else { $qs = $this->parent->action . ".html?" . arrayToString(false, array("login", "gfc", "haveinfo", "password", "debugmode", "nosession", "nocache", "dev_html")); $totalTime = scriptTime() * 1000; // ###############################--- // ## This is the info strip that stays on top of the site: array_unshift($this->log, number_format($totalTime, 2) . "ms (" . CONS_AFF_DATABASECONNECTOR . ": " . number_format($this->parent->dbo->dbt, 2) . "ms, framework: " . number_format($this->overheadTime, 2) . " ms), SQL(s): " . $this->parent->dbo->dbc . ", caches: " . number_format($this->parent->cachetime / 1000) . "ms main, " . number_format($this->parent->cachetimeObj / 1000) . "ms obj" . (isset($this->parent->storage['CORE_CACHECONTROL']) ? " avg: " . number_format($this->parent->storage['CORE_CACHECONTROL'][0] / 1000) . "s factor " . number_format($this->parent->storage['CORE_CACHECONTROL'][1], 2) : "") . " (" . $_SESSION[CONS_SESSION_LANG] . ") (" . ($this->devCheckHTML ? "<a style='color:#" . $this->textColor . "' href='{$qs}&dev_html=0'><strong>checkHTML</strong> is on</a>" : "<a style='color:#" . $this->textColor . "' href='{$qs}&dev_html=1'><strong>checkHTML</strong> is off</a>") . ") (" . ($thereAreErrors ? "<strong><a style='color:#" . $this->textColor . "' href='?dev_log=1'>Errors!</a></strong>" : "no errors") . ") (<a style='color:#" . $this->textColor . "' href='?debugmode=true&nosession=true&nocache=true'>RESET</a>)" . " (<a style='color:#" . $this->textColor . "' href='?dev_help=1'>DEVELOPER OPTIONS</a>) (<a style='color:#" . $this->textColor . "' href=\"" . $qs . "&dev_disable=1\">disable</a>)" . ($this->parent->cacheControl->contentFromCache ? " CACHED CONTENT" : "")); // ###############################--- $pl = strlen($PAGE); $tp = new CKTemplate(); $tp->fetch(CONS_PATH_SYSTEM . "plugins/" . $this->name . "/payload/overlay.html"); $tp->assign("AFFBIDEV_CONTENT", implode("<br/>", $this->log) . (count($this->parent->warning) != 0 ? "<br/>Warnings:" . implode("<br/>", $this->parent->warning) : "")); $arrowColor = $this->parent->cacheControl->contentFromCache ? "#000099" : ($thereAreErrors ? "#BB0000" : "#000000"); $tp->assign("ARROWCOLOR", $arrowColor); $tp->assign("ARROWSIZE", $thereAreErrors ? 20 : 12); $PAGE = str_replace("</body>", $tp->techo() . "</body>", $PAGE); if (strlen($PAGE) == $pl) { $this->log[] = "WARNING: no /body on page"; $PAGE .= $tp->techo(); } $PAGE .= "<!-- bi_dev output logs. To stop this output, disable bi_dev"; $PAGE .= "\nDbLOG:\n" . implode("\n", $this->parent->dbo->log); $C = $_SESSION; unset($C['prescia_cache']); // the cache can contain whole HTML that would cause havok $PAGE .= "\n" . print_r($C, 1) . "\n"; $PAGE .= "-->"; } } }
function echoCalendar(&$containerTP, $width = 0, $month = 0, $year = 0, $highlights = array(), $dayborder = 0, $prevquery = "", $nextquery = "", $divname = "inlinecalendar") { /* width should be divisible by 7 highlights is an array, each with the following: 'day' => # day 'title' => title on the cell (if nothing, will use the day #) 'link' => link if click on the cell (if nothing, no link) 'class' => (optional) class for the cell dayborder is the number in pixels of border (+margin +padding) you will use on each cell */ $tp = new CKTemplate($containerTP); if (!is_file(CONS_PATH_SETTINGS . "defaults/calendar.html")) { return "echoCalendar: File not found"; } $tp->fetch(CONS_PATH_SETTINGS . "defaults/calendar.html"); if ($month == 0) { $month = date("m"); } if ($year == 0) { $year = date("Y"); } $width = 7 * floor($width / 7); $widthDay = floor($width / 7) - 2 * $dayborder; $month = (int) $month; $year = (int) $year; if ($year < 100) { $year += 2000; } if ($month < 10) { $month = "0" . $month; } $initDay = $year . "-" . $month . "-01"; $endDate = datecalc($initDay, 0, 1); $monthLine = $tp->get("_line"); $dayTp = $tp->get("_day"); $temp = ""; // <-- main $tempL = ""; // <-- a line $column = date("w", tomktime($initDay)); // where this month starts $today = date("Y-m-d"); $daysOnPreviousMonth = $column; while ($daysOnPreviousMonth > 0) { $tempL .= $dayTp->techo(array('class' => 'calendarDayEmpty', "title" => " ", "widthday" => $widthDay)); $daysOnPreviousMonth--; } while (datecompare($endDate, $initDay)) { // while we are within the month (loop will increase initDay) $isWeekend = $column == 0 || $column == 6; $isToday = $initDay == $today; $day = substr($initDay, 8, 2); // the following line will put the appropriate class on the day depending on start/end of the project, weekend or deadline $output = array("class" => $isToday ? "calendarDayToday" : ($isWeekend ? "calendarDayWeekend" : "calendarDayNormal"), "title" => (int) $day, "widthday" => $widthDay); // now we check if we have a highlight foreach ($highlights as $high) { if ($high['day'] == $day) { $output['class'] = isset($high['class']) && $high['class'] != '' ? $high['class'] : "calendarDayHighlight"; $output['title'] = isset($high['title']) ? $high['title'] : (int) $day; if (isset($high['link']) && $high['link'] != '') { $output['title'] = "<a href=\"" . $high['link'] . "\">" . $output['title'] . "</a>"; } } } $tempL .= $dayTp->techo($output); if ($column == 6) { // end of a line $temp .= $monthLine->techo(array("_day" => $tempL)); // <-- echo line $tempL = ""; } $column++; if ($column >= 7) { $column = 0; } $initDay = datecalc($initDay, 0, 0, 1); } if ($column != 0) { // we might not have finished the last line ... check it: for ($column = $column; $column < 7; $column++) { $tempL .= $dayTp->techo(array('class' => 'calendarDayEmpty', "title" => "", "widthday" => $widthDay)); } $temp .= $monthLine->techo(array("_day" => $tempL)); // <-- echo line $tempL = ""; } $tp->assign("width", $width); $tp->assign("month", $month); $tp->assign("year", $year); $tp->assign("widthday", $widthDay); $tp->assign("_line", $temp); $tp->assign("calendar", $divname); if ($prevquery != '' && $nextquery != '') { $tp->assign("ajaxcommandprev", $prevquery); $tp->assign("ajaxcommandnext", $nextquery); } else { $tp->assign("_prevnext"); } return $tp->techo(); }
/* foreach ($filteredBy as $fname) { if (!in_array($fname,$refererModule->keys) && count($keys)>0) { $_REQUEST[$key] = array_shift($keys); // if fowarder off $str .= "&".$key."=".$_REQUEST[$key]; } } */ $core->headerControl->internalFoward($str); $core->action = "edit"; // if internalFoward is disabled $pa_dealt = true; } case 4: // public $url = new CKTemplate($core->template); $url->tbreak($module->options[CONS_MODULE_PUBLIC]); $url = $url->techo($_POST); $url = CONS_INSTALL_ROOT . $url; $core->headerControl->internalFoward($url); list($core->context, $core->action, $core->original_action, $ext) = extractUri("", $url); $core->context_str = implode("/", $core->context); $pa_dealt = true; break; } if (!$pa_dealt) { $core->action = "list"; $_REQUEST = array('module' => $_REQUEST['module']); // prevents filtering the list in the event of non-foward mode $core->headerControl->internalFoward("list.html?module=" . $_REQUEST['module']); }
if ($line > $lData['rows']) { // next page $line = 1; } } $offset--; } // print // prepare templates $aPage = clone $core->template->get("_page"); $core->template->assign("fontsize", $lData['fontsize']); $aPage->assign("fontsize", $lData['fontsize']); $aPage->assign("fullwidth", $lData['pfl'] + $lData['sw'] * $lData['cols'] + $lData['ol'] * ($lData['cols'] - 1) + 2); $aPage->assign("fullheight", $lData['pft'] + $lData['sh'] * $lData['rows'] + $lData['ot'] * ($lData['rows'] - 1) + 2); $aLabel = clone $core->template->get("_etiqueta"); $content = new CKTemplate(); $content->tbreak(nl2br($lData['content'])); $output = ""; $pageOutput = ""; // get labels $basesql = $module->get_base_sql("", "", 1); foreach ($theKeys as $ids) { if ($ids != "" && preg_match('/' . $ereg_pattern . '/', $ids, $regs)) { // valid multiple keys (checkboxes) $sql = $basesql; for ($pos = 0; $pos < $keyscount; $pos++) { // build WHERE based on keys $sql['WHERE'][] = $module->name . "." . $keys[$pos] . "=\"" . $regs[$pos + 1] . "\""; } if ($core->dbo->query($sql, $r, $n) && $n > 0) { // get data
function runAction($action, $data, $silent = false, $mfo = false, $startedAt = "") { # mfo is "Mandatory Fields Ok", which removes the need to check them # returns TRUE or FALSE # check for auto_increment during insert on $parent->lastReturnCode if (is_object($action)) { $this->parent->errorControl->raise(126); } $this->parent->lastReturnCode = 0; unset($this->parent->storage['lastactiondata']); if (is_numeric($data)) { if ($action == CONS_ACTION_DELETE) { $id = $data; $data = array(); $data[$this->keys[0]] = $id; } else { if (!$silent) { $this->parent->errorControl->raise(187, $data, $this->name); } return false; } } if (count($this->plugins) > 0 && ($action == CONS_ACTION_UPDATE || $action == CONS_ACTION_INCLUDE || $action == CONS_ACTION_DELETE)) { foreach ($this->plugins as $pname) { if (!$this->parent->loadedPlugins[$pname]->edit_parse($action, $data)) { if (!$silent) { $this->parent->errorControl->raise(168, $pname, $this->name); } return false; } } } if (!$mfo) { $missing = $this->check_mandatory($data, $action); # returns a list of mandatory fields missing or invalid if (count($missing) > 0) { $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(127, implode(",", $missing), $this->name); } return false; } } $EnumPrunecache = array(); switch ($action) { case CONS_ACTION_UPDATE: ###################################################### UPDATE ############################################ $wS = ""; # whereStruct $kA = array(); # keyArray $haveAllKeys = $this->getKeys($wS, $kA, $data); // is it ok not to have all keys? # security if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) { $Owner = $this->parent->authControl->checkOwner($this, $kA); // array with isOwner and isSameGroup $this->parent->lockPermissions(); # Load permissions to this, in case something changed if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_UPDATE, $Owner, $data)) { $this->parent->errorControl->raise(151, '', $this->name); return false; } } $this->parent->notifyEvent($this, CONS_ACTION_UPDATE, $data, $startedAt, true); # early notify $sql = "UPDATE " . $this->dbname . " SET "; $output = ""; $outfield = false; foreach ($this->fields as $name => $field) { if ($this->parent->safety && isset($field[CONS_XML_RESTRICT]) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < $field[CONS_XML_RESTRICT] && !isset($field[CONS_XML_UPDATESTAMP])) { # safety is on and this is a restricted field, while the user trying to change it does not have enough level if (isset($data[$name])) { $this->parent->errorControl->raise(145, $name, $this->name); } continue; } if ($name != $this->keys[0] && strpos($field[CONS_XML_SQL], "AUTO_INCREMENT") === false) { # cannot change main key or auto_increment ones $outfield = $this->sqlParameter(false, $data, $name, $field, $EnumPrunecache, false, $kA, $wS); if ($outfield !== false) { $output .= $name . "=" . $outfield . ","; } } # if (not key) } #foreach unset($outfield); if ($output != "") { # removes end , $output = substr($output, 0, strlen($output) - 1); $sql .= $output . " WHERE " . $wS; if (!$this->parent->dbo->simpleQuery($sql, $this->parent->debugmode)) { $this->parent->errorState = true; $lastError = $this->parent->dbo->log[count($this->parent->dbo->log) - 1]; if (strpos(strtolower($lastError), "duplicate") === false) { if (!$silent) { $this->parent->errorControl->raise(136, "", $this->name); } } else { if (!$silent) { $this->parent->errorControl->raise(137, "", $this->name); } } return false; } else { $this->parent->notifyEvent($this, CONS_ACTION_UPDATE, $data, $startedAt); # later notify $this->parent->storage['lastactiondata'] =& $data; } } else { $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(138, "", $this->name); } return false; } if (count($EnumPrunecache) != 0) { $this->autoPrune($EnumPrunecache, $data); } return true; break; case CONS_ACTION_INCLUDE: ###################################################### INCLUDE ############################################ if ($this->parent->safety) { # checkPermission has this test but this is faster if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) { $this->parent->lockPermissions(); if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_INCLUDE, array(true, true, true, 0))) { $this->parent->errorControl->raise(150, '', $this->name); return false; # cannot create even OWNED items } } # can create items } # if this module have multiple key fields, there is no auto_increment IF there is an id (id created automatically w/o AI) if (count($this->keys) > 1 && $this->keys[0] == "id") { $wheres = array(); foreach ($this->keys as $field) { if ($field != "") { if (!isset($data[$field])) { # we need this parent data to create the id, but it's missing! $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(139, $field, $this->name); } return false; } array_push($wheres, $field . "=\"" . $data[$field] . "\""); } } # foreach $sql = "SELECT MAX(id) FROM " . $this->dbname . (count($wheres) != 0 ? " WHERE " . implode(" AND ", $wheres) : ""); $id = $this->parent->dbo->fetch($sql, $this->parent->debugmode); if (!$id) { # suposes it was empty $id = 1; } else { $id++; } $sql = "INSERT INTO " . $this->dbname . " SET id='{$id}',"; $data['id'] = $id; } else { $id = false; $sql = "INSERT INTO " . $this->dbname . " SET "; } $output = ""; $hasAuto = ""; $outfield = false; foreach ($this->fields as $name => $field) { if ($this->parent->safety && isset($field[CONS_XML_RESTRICT]) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < $field[CONS_XML_RESTRICT]) { # safety is on and this is a restricted field, while the user trying to add it does not have enough level # however while ADDING a field that is mandatory, if it has no default you can add if (!isset($field[CONS_XML_MANDATORY]) || isset($field[CONS_XML_DEFAULT])) { if (isset($data[$name])) { $this->parent->errorControl->raise(145, $name, $this->name, 'not mandatory or default on add'); } unset($data[$name]); } } if (strpos(strtolower($field[CONS_XML_SQL]), "auto_increment") === false && !($this->keys[0] == "id" && $name == $this->keys[0] && count($this->keys) > 1)) { # cannot change auto_increment or main key fields $outfield = $this->sqlParameter(true, $data, $name, $field, $EnumPrunecache); if ($outfield !== false) { $output .= $name . "=" . $outfield . ","; } if ((!$outfield || !isset($data[$name]) || $data[$name] == '') && isset($field[CONS_XML_AUTOFILL]) && !isset($field[CONS_XML_DEFAULT])) { if (isset($data[$field[CONS_XML_AUTOFILL]])) { $data[$name] = $data[$field[CONS_XML_AUTOFILL]]; // if the autofill field is HTML and this is NOT, remove HTML if ($field[CONS_XML_TIPO] == CONS_TIPO_TEXT && !isset($field[CONS_XML_HTML])) { if (isset($this->fields[$field[CONS_XML_AUTOFILL]][CONS_XML_HTML])) { $data[$name] = preg_replace("/(<)([^<>]*)(>)/", "", $data[$name]); } } $output .= $name . "=\"" . $data[$name] . "\","; } } } else { # if (not AutoIncrement) $hasAuto = $name; } } #foreach $id = 0; unset($outfield); if ($output != "") { # removes end , $output = substr($output, 0, strlen($output) - 1); $sql .= $output; if (!$this->parent->dbo->simpleQuery($sql, $this->parent->debugmode)) { $this->parent->errorState = true; $lastError = $this->parent->dbo->log[count($this->parent->dbo->log) - 1]; if (strpos(strtolower($lastError), "duplicate") === false) { if (!$silent) { $this->parent->errorControl->raise(140, $lastError, $this->name); } } else { if (!$silent) { $this->parent->errorControl->raise(141, $lastError, $this->name); } } return false; } else { # post processing ... if ($this->keys[0] == "id") { $id = $this->parent->dbo->insert_id(); if ($hasAuto != "") { $data[$hasAuto] = $id; } else { $data['id'] = $id; } } # check for uploads and urla $wS = ""; $kA = array(); $this->getKeys($wS, $kA, $data); foreach ($this->fields as $name => $field) { if ($field[CONS_XML_TIPO] == CONS_TIPO_SERIALIZED) { foreach ($field[CONS_XML_SERIALIZEDMODEL] as $exname => $exfield) { #--- serialized uploads if ($exfield[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) { $upOk = $this->prepareUpload($name . "_" . $exname, $kA, $data); if ($upOk != 4 && $upOk != 0) { // 4 = nothing sent, 0 = sent and ok # not mandatory but failed, warn about it but do not abort if (!$silent) { $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name . '_' . $exname); } //$this->deleteUploads($kA,$name."_".$exname,'',$name); // delete possible partial thumbnail process # so far, serialized uploads have no flag //} else if ($upOk == 0) { // $this->parent->dbo->simpleQuery("UPDATE ".$this->dbname." SET $name='y' WHERE $wS"); } } } } if ($field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD) { #--- normal uploads $upOk = $this->prepareUpload($name, $kA, $data); if ($upOk != 0 && isset($field[CONS_XML_MANDATORY])) { # failed or didn't send upload but it's mandatory $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name); } # must remove inserted data! $this->parent->dbo->simpleQuery("DELETE FROM " . $this->dbname . " WHERE " . $wS, $this->parent->debugmode); $this->deleteUploads($kA); return false; } else { if ($upOk != 4 && $upOk != 0) { // 4 = nothing sent, 0 = sent and ok # not mandatory but failed, warn about it but do not abort if (!$silent) { $this->parent->errorControl->raise(200 + $upOk, $upOk, $this->name, $name); } $this->deleteUploads($kA, $name); // delete possible partial thumbnail process } else { if ($upOk == 0) { $this->parent->dbo->simpleQuery("UPDATE " . $this->dbname . " SET {$name}='y' WHERE {$wS}"); } } } } else { if ($field[CONS_XML_TIPO] == CONS_TIPO_VC && isset($field[CONS_XML_SPECIAL]) && $field[CONS_XML_SPECIAL] == "urla" && (!isset($data[$name]) || $data[$name] == '')) { # EMPTY special VC urla might require the data to be fully processed to create the proper result, so we do it after the include $source = isset($field[CONS_XML_SOURCE]) ? $field[CONS_XML_SOURCE] : "{" . $this->title . "}"; $tp = new CKTemplate($this->parent->template); $tp->tbreak($source); $urla = removeSimbols($tp->techo($data), true, false); if ($urla != '') { $this->parent->dbo->simpleQuery("UPDATE " . $this->dbname . " SET {$name}=\"{$urla}\" WHERE {$wS}"); $data[$name] = $urla; } unset($tp); } } } $this->parent->lastReturnCode = $id; $this->parent->notifyEvent($this, CONS_ACTION_INCLUDE, $data, $startedAt, false); # later notify (there is no early notify for an include) $this->parent->lastReturnCode = $id; // notifyEvent could have changed/consumed lastReturnCode $this->parent->storage['lastactiondata'] =& $data; } } else { # null insert? error $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(142, "", $this->name); } return false; } if (count($EnumPrunecache) != 0) { $this->autoPrune($EnumPrunecache, $data); } return true; break; case CONS_ACTION_DELETE: ###################################################### DELETE ############################################ $wS = ""; $kA = array(); $haveallKeys = $this->getKeys($wS, $kA, $data); # security $Owner = $this->parent->authControl->checkOwner($this, $kA); // array with isOwner and isSameGroup if ($this->parent->safety && $_SESSION[CONS_SESSION_ACCESS_LEVEL] < 100) { $this->parent->lockPermissions($this, $data, $Owner); if (!$this->parent->authControl->checkPermission($this, CONS_ACTION_DELETE, $Owner, $data)) { $this->parent->errorControl->raise(149, '', $this->name); return false; } } $this->parent->notifyEvent($this, CONS_ACTION_DELETE, $data, $startedAt, true); # early notify if ($this->parent->dbo->simpleQuery("DELETE FROM " . $this->dbname . " WHERE " . $wS, $this->parent->debugmode)) { $this->deleteUploads($kA); $this->parent->notifyEvent($this, CONS_ACTION_DELETE, $data, $startedAt, false); # later notify return true; } else { $this->parent->errorState = true; if (!$silent) { $this->parent->errorControl->raise(143, "", $this->name); } return false; } break; } # switch }
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); }