/** * @param string $to - path where the archive should be extracted to * @return bool */ public function extract($to) { $r = false; $ext = SPFs::getExt($this->_filename); switch ($ext) { case 'zip': $zip = new ZipArchive(); if ($zip->open($this->_filename) === true) { SPException::catchErrors(SPC::WARNING); try { $zip->extractTo($to); $zip->close(); $r = true; } catch (SPException $x) { $t = Sobi::FixPath(Sobi::Cfg('fs.temp') . DS . md5(microtime())); SPFs::mkdir($t, 0777); $dir = SPFactory::Instance('base.fs.directory', $t); if ($zip->extractTo($t)) { $zip->close(); $dir->moveFiles($to); $r = true; } SPFs::delete($dir->getPathname()); } SPException::catchErrors(0); } break; } return $r; }
protected function menu(&$data) { if (Sobi::Cfg('general.top_menu', true)) { $data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section()))))); if (Sobi::Can('section.search')) { $data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section())))); } if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) { $data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid())))); } } }
protected function upload() { $ident = SPRequest::cmd('ident', null, 'post'); $data = SPRequest::file($ident, 'tmp_name'); $secret = md5(Sobi::Cfg('secret')); if ($data) { $properties = SPRequest::file($ident); $fileName = md5(SPRequest::file($ident, 'name') . time() . $secret); $path = SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $fileName; /** @var $file SPFile */ $file = SPFactory::Instance('base.fs.file'); if (!$file->upload($data, $path)) { $this->message(array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE'), 'id' => '')); } $path = $file->getPathname(); $type = $this->check($path); $properties['tmp_name'] = $path; SPFs::write($path . '.var', SPConfig::serialize($properties)); $response = array('type' => 'success', 'text' => Sobi::Txt('FILE_UPLOADED', $properties['name'], $type), 'id' => 'file://' . $fileName, 'data' => array('name' => $properties['name'], 'type' => $properties['type'], 'size' => $properties['size'])); } else { $response = array('type' => 'error', 'text' => SPLang::e('CANNOT_UPLOAD_FILE_NO_DATA'), 'id' => ''); } // $field = SPRequest::cmd( 'field', null ); $this->message($response); }
/** * @param string $definition * @param string $type * @return SPInstaller */ public function __construct($definition, $type = null) { $this->type = $type; $this->xmlFile = $definition; $this->definition = new DOMDocument(Sobi::Cfg('xml.version', '1.0'), Sobi::Cfg('xml.encoding', 'UTF-8')); $this->definition->load($this->xmlFile); $this->xdef = new DOMXPath($this->definition); $this->root = dirname($this->xmlFile); }
private function nameField() { /* get the field id of the field contains the entry name */ if ($this->section == Sobi::Section() || !$this->section) { $nameField = Sobi::Cfg('entry.name_field'); } else { $nameField = SPFactory::db()->select('sValue', 'spdb_config', array('section' => $this->section, 'sKey' => 'name_field', 'cSection' => 'entry'))->loadResult(); } return $nameField ? $nameField : Sobi::Cfg('entry.name_field'); }
public function getRevision($rev) { if (Sobi::Cfg('entry.versioning', true)) { $log = (array) SPFactory::db()->select('*', 'spdb_history', array('revision' => $rev))->loadObject('revision'); if (count($log)) { $log['changes'] = SPConfig::unserialize($log['changes']); } return $log; } else { return array(); } }
private function view() { $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $visitor = $this->get('visitor'); $current = $this->get('section'); $categories = $this->get('categories'); $entries = $this->get('entries'); $data = array(); $data['id'] = $current->get('id'); $data['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $data['name'] = array('_complex' => 1, '_data' => $this->get('listing_name'), '_attributes' => array('lang' => Sobi::Lang(false))); if (Sobi::Cfg('category.show_desc')) { $desc = $current->get('description'); if (Sobi::Cfg('category.parse_desc')) { Sobi::Trigger('prepare', 'Content', array(&$desc, $current)); } $data['description'] = array('_complex' => 1, '_cdata' => 1, '_data' => $desc, '_attributes' => array('lang' => Sobi::Lang(false))); } $data['meta'] = array('description' => $current->get('metaDesc'), 'keys' => $this->metaKeys($current), 'author' => $current->get('metaAuthor'), 'robots' => $current->get('metaRobots')); $data['entries_in_line'] = $this->get('$eInLine'); $data['categories_in_line'] = $this->get('$cInLine'); $this->menu($data); $this->alphaMenu($data); $data['visitor'] = $this->visitorArray($visitor); if (count($categories)) { foreach ($categories as $category) { if (is_numeric($category)) { $category = SPFactory::Category($category); } $data['categories'][] = array('_complex' => 1, '_attributes' => array('id' => $category->get('id'), 'nid' => $category->get('nid')), '_data' => $this->category($category)); unset($category); } } if (count($entries)) { $this->loadNonStaticData($entries); $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false; foreach ($entries as $eid) { $en = $this->entry($eid, $manager); $data['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id']), '_data' => $en); } $this->navigation($data); } $this->_attr = $data; } // general listing trigger Sobi::Trigger('Listing', ucfirst(__FUNCTION__), array(&$this->_attr)); // specific lisitng trigger Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); }
protected function search() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__); } // $selected = SPRequest::int( 'selected', 0 ); $ssid = SPRequest::base64('ssid'); $query = SPRequest::string('q', null); $session = SPFactory::user()->getUserState('userSelector', null, array()); $setting = $session[$ssid]; /* get the site to display */ $site = SPRequest::int('site', 1); $eLim = Sobi::Cfg('user_selector.entries_limit', 18); $eLimStart = ($site - 1) * $eLim; $params = array(); if ($query) { $q = '%' . $query . '%'; $params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR'); } try { $count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult(); $data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList(); } catch (SPException $x) { echo $x->getMessage(); exit; } $response = array('sites' => ceil($count / $eLim), 'site' => $site); if (count($data)) { $replacements = array(); preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements); $placeholders = array(); if (isset($replacements[0]) && count($replacements[0])) { foreach ($replacements[0] as $placeholder) { $placeholders[] = str_replace('%', null, $placeholder); } } if (count($replacements)) { foreach ($data as $index => $user) { $txt = $setting['format']; foreach ($placeholders as $attribute) { if (isset($user[$attribute])) { $txt = str_replace('%' . $attribute, $user[$attribute], $txt); } } $data[$index]['text'] = $txt; } } $response['users'] = $data; } SPFactory::mainframe()->cleanBuffer(); echo json_encode($response); exit; }
/** * @return string */ public function display() { $this->_view[] = "\n <!-- Sobi Pro - admin side menu start -->"; $this->_view[] = "\n<div id=\"SPaccordionTabs\" class=\"SPmenuTabs\">"; $this->_view[] = '<div id="SPMenuCtrl">'; $this->_view[] = ' <button class="btn btn-mini btn-sobipro" id="SPMenuCtrlBt" type="button">-</button>'; $this->_view[] = '</div>'; $media = Sobi::Cfg('img_folder_live'); $this->_view[] = "\n<div class='well well-small'><a href=\"http://www.Sigsiu.NET\" target=\"_blank\" title=\"Sigsiu.NET Software Development\"><img src=\"{$media}/sp.png\" alt=\"Sigsiu.NET Software Development\" style=\"border-style:none;\" /></a></div>\n"; $fs = null; if (count($this->_sections)) { if ($this->_task == 'section.view') { // $this->_task = 'section.entries'; $this->_open = 'AMN.ENT_CAT'; } $this->_view[] = '<div class="accordion" id="SpMenu">'; foreach ($this->_sections as $section => $list) { $sid = SPLang::nid($section); $in = false; if (!$fs) { $fs = $sid; } if (!$this->_open && array_key_exists($this->_task, $list)) { $this->_open = $sid; $in = ' in'; } if ($this->_open && $section == $this->_open) { $in = ' in'; } if (!$this->_open && array_key_exists($this->_task, $list)) { $in = ' in'; } $this->_view[] = '<div class="accordion-group">'; $this->_view[] = '<div class="accordion-heading">'; $this->_view[] = '<a class="accordion-toggle" data-toggle="collapse" data-parent="#SpMenu" href="#' . $sid . '">'; $this->_view[] = Sobi::Txt($section); $this->_view[] = '</a>'; $this->_view[] = '</div>'; $this->_view[] = '<div id="' . $sid . '" class="accordion-body collapse' . $in . '">'; $this->_view[] = '<div class="accordion-inner">'; $this->_view[] = $this->section($list, $section); $this->_view[] = '</div>'; $this->_view[] = '</div>'; $this->_view[] = '</div>'; } $this->_view[] = '</div>'; } $this->_view[] = "\n</div>\n"; $this->_view[] = '<div class="brand" style="display: inherit;">© <a href="http://www.sigsiu.net">Sigsiu.NET GmbH</a></div>'; $this->_view[] = "\n<!-- Sobi Pro - admin side menu end -->\n"; return implode("\n", $this->_view); }
/** */ protected function view() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); $cInLine = $this->tKey($this->template, 'categories_in_line', Sobi::Cfg('list.categories_in_line', 2)); $cLim = $this->tKey($this->template, 'categories_limit', -1); $entriesRecursive = $this->tKey($this->template, 'entries_recursive', Sobi::Cfg('list.entries_recursive', false)); /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; /* get the right ordering */ $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc'))); $cOrder = $this->parseOrdering('categories', 'corder', $this->tKey($this->template, 'categories_ordering', Sobi::Cfg('list.categories_ordering', 'name.asc'))); $orderings = array('entries' => $eOrder, 'categories' => $cOrder); /* get entries */ $eCount = count($this->getEntries($eOrder, 0, 0, true, null, $entriesRecursive)); $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, false, null, $entriesRecursive); $categories = array(); if ($cLim) { $categories = $this->getCats($cOrder, $cLim); } /* create page navigation */ $url = array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name')); if (SPRequest::cmd('sptpl')) { $url['sptpl'] = SPRequest::cmd('sptpl'); } $pnc = SPLoader::loadClass('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt')); /* @var SPPageNavXSLT $pn */ $pn = new $pnc($eLimit, $eCount, $site, array('sid' => SPRequest::sid(), 'title' => Sobi::Cfg('sef.alias', true) ? $this->_model->get('nid') : $this->_model->get('name'))); /* handle meta data */ SPFactory::header()->objMeta($this->_model); /* add pathway */ SPFactory::mainframe()->addObjToPathway($this->_model, array(ceil($eCount / $eLimit), $site)); $this->_model->countVisit(); /* get view class */ // $class = SPLoader::loadView( $this->_type ); $view = SPFactory::View($this->_type); // $view = new $class( $this->template ); $view->assign($eLimit, '$eLimit')->assign($eLimStart, '$eLimStart')->assign($eCount, '$eCount')->assign($cInLine, '$cInLine')->assign($eInLine, '$eInLine')->assign($this->_task, 'task')->assign($this->_model, $this->_type)->setConfig($this->_tCfg, $this->template)->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template)->assign($categories, 'categories')->assign($pn->get(), 'navigation')->assign(SPFactory::user()->getCurrent(), 'visitor')->assign($entries, 'entries')->assign($orderings, 'orderings'); Sobi::Trigger($this->name(), 'View', array(&$view)); $view->display($this->_type); }
private function errors() { $errors = $this->get('errors'); $levels = $this->get('levels'); $icons = array('error' => Sobi::Cfg('list_icons.err_err'), 'warning' => Sobi::Cfg('list_icons.err_warn'), 'notice' => Sobi::Cfg('list_icons.err_notice'), 'details' => Sobi::Cfg('list_icons.err_details')); /* create the header */ if (count($errors)) { foreach ($errors as $i => $error) { $error['errFile'] = str_replace(SOBI_ADM_PATH, null, $error['errFile']); $error['errFile'] = str_replace(SOBI_PATH, null, $error['errFile']); $error['errFile'] = str_replace(SOBI_ROOT, null, $error['errFile']); $error['errFile'] = $error['errFile'] . ': ' . $error['errLine']; if ($error['errReq']) { $error['errReq'] = "<a href=\"{$error['errReq']}\" target=\"_blank\">{$error['errReq']}</a>"; } $level = $levels[$error['errNum']]; switch ($error['errNum']) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: $error['errNum'] = "<img src=\"{$icons['error']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}"; break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: $error['errNum'] = "<img src=\"{$icons['warning']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}"; break; case E_NOTICE: case E_USER_NOTICE: case E_STRICT: case E_USER_WARNING: case E_DEPRECATED: case E_USER_DEPRECATED: $error['errNum'] = "<img src=\"{$icons['notice']}\" alt=\"{$level}\" title=\"{$level}\"/><br/>{$level}"; break; } $error['errMsg'] = str_replace(SOBI_ROOT, null, $error['errMsg']); $error['errMsg'] = str_replace('href=\'function.', 'target="_blank" href=\'http://php.net/manual/en/function.', $error['errMsg']); $dh = Sobi::Url(array('task' => 'error.details', 'eid' => $error['eid'])); $error['details'] = "<a href=\"{$dh}\"><img src=\"{$icons['details']}\"/></a>"; $errors[$i] = $error; } } // Sobi::Error( 'H', date( DATE_RFC1123 ), SPC::ERROR ); $this->assign($errors, 'errors'); }
/** */ private function edit() { $pid = $this->get('category.parent'); $path = null; if (!$pid) { $pid = SPRequest::int('pid'); } $this->assign($pid, 'parent'); $id = $this->get('category.id'); if ($id) { $this->addHidden($id, 'category.id'); } if (!strstr($this->get('category.icon'), 'font')) { if ($this->get('category.icon') && SPFs::exists(Sobi::Cfg('images.category_icons') . '/' . $this->get('category.icon'))) { $i = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . $this->get('category.icon')); $this->assign($i, 'category_icon'); } else { $i = Sobi::FixPath(Sobi::Cfg('images.category_icons_live') . Sobi::Cfg('icons.default_selector_image', 'image.png')); $this->assign($i, 'category_icon'); } } // else { // $i = SPLang::clean( $this->get( 'category.icon' ) ); // $this->assign( $i, 'category_icon' ); // } /* if editing - get the full path. Otherwise get the path of the parent element */ $id = $id ? $id : $pid; if ($this->get('category.id')) { $path = $this->parentPath($id); $parentCat = $this->parentPath($id, false, true); } else { $path = $this->parentPath(SPRequest::sid()); $parentCat = $this->parentPath(SPRequest::sid(), false, true, 1); } $this->assign($path, 'parent_path'); $this->assign($parentCat, 'parent_cat'); if (SPRequest::sid()) { $this->assign(Sobi::Url(array('task' => 'category.chooser', 'sid' => SPRequest::sid(), 'out' => 'html'), true), 'cat_chooser_url'); } elseif (SPRequest::int('pid')) { $this->assign(Sobi::Url(array('task' => 'category.chooser', 'pid' => SPRequest::int('pid'), 'out' => 'html'), true), 'cat_chooser_url'); } $this->assign(Sobi::Url(array('task' => 'category.icon', 'out' => 'html'), true), 'icon_chooser_url'); }
/** * @param string $section - error section. I.e. Entry controller * @param string $msg - main message * @param int $type - error type * @param int $code - error code * @param int $line - file line * @param string $file - file name * @param null $sMsg * @internal param string $smsg - additional message * @return null */ public static function Error($section, $msg, $type = SPC::NOTICE, $code = 0, $line = null, $file = null, $sMsg = null) { if ($type == 0) { $type = SPC::NOTICE; } /* * Mi., Jul 4, 2012 * So now could someone explain me what was the sense of the code below and why trigger_error was commented out??!! * * Mi., Jul 4, 2012 * Ok, it doesn't make much sense. * This is what actually should be removed. * if( Sobi::Cfg( 'debug.level', 0 ) < $type ) { return true; } * It was the problem with the ACL when error reporting was disabled. * But why the hell I removed the damn trigger_error from it?!!! * Being sloppy again?!!!! * Frack me - it means that since 20.07.2011 the whole error reporting went in nirvana?? */ if ($type == E_USER_ERROR) { $rType = E_ERROR; $code = $code ? $code : 500; } elseif ($type == E_USER_WARNING) { $rType = E_WARNING; } else { $rType = $type; } if (Sobi::Cfg('debug.level', 0) >= $rType) { if ($file) { $sMsg .= sprintf('In file %s at line %d', $file, $line); } if (SPRequest::task()) { $sMsg .= ' [ ' . SPRequest::task() . ' ]'; } $error = array('section' => $section, 'message' => $msg, 'code' => $code, 'file' => $file, 'line' => $line, 'content' => $sMsg); trigger_error('json://' . json_encode($error), $type); } if ($code) { SPLoader::loadClass('base.mainframe'); SPLoader::loadClass('cms.base.mainframe'); SPFactory::mainframe()->runAway($msg, $code, SPConfig::getBacktrace()); } return null; }
/** * @param array $recipient Recipient e-mail address * @param string $subject E-mail subject * @param string $body Message body * @param bool $html - HTML mail or plain text * @param array $replyto Reply to email address * @param array $cc CC e-mail address * @param array $bcc BCC e-mail address * @param string $attachment Attachment file name * @param array $cert - pem certificate * @param array $from - array( from, fromname ) * @internal param array $replytoname Reply to name * @return boolean True on success */ public static function SpSendMail($recipient, $subject, $body, $html = false, $replyto = null, $cc = null, $bcc = null, $attachment = null, $cert = null, $from = null) { $from = is_array($from) ? $from : array(Sobi::Cfg('mail.from'), Sobi::Cfg('mail.fromname')); $mail = new self(); $mail->setSender($from); $mail->setSubject($subject); $mail->setBody($body); if ($html) { $mail->IsHTML(true); } if ($cert) { $mail->Sign($cert['certificate'], $cert['key'], $cert['password']); } $mail->addRecipient($recipient); $mail->addCC($cc); $mail->addBCC($bcc); $mail->addAttachment($attachment); $mail->addReplyTo($replyto); return $mail->Send(); }
/** * */ public function display() { $this->_type = 'frontpage'; $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $sections = $this->get('sections'); $data = array(); if (count($sections)) { foreach ($sections as $section) { $s = array('name' => array('_complex' => 1, '_data' => $section->get('name'), '_attributes' => array('lang' => Sobi::Lang(false))), 'description' => array('_complex' => 1, '_cdata' => 1, '_data' => $section->get('description'), '_attributes' => array('lang' => Sobi::Lang(false))), 'createdTime' => $section->get('createdTime'), 'meta' => array('description' => $section->get('metaDesc'), 'keys' => $this->metaKeys($section), 'author' => $section->get('metaAuthor'), 'robots' => $section->get('metaRobots')), 'owner' => $section->get('owner'), 'version' => $section->get('version'), 'validSince' => $section->get('validSince'), 'validUntil' => $section->get('validUntil'), 'url' => Sobi::Url(array('sid' => $section->get('id')))); $data[] = array('_complex' => 1, '_data' => $s, '_attributes' => array('id' => $section->get('id'), 'nid' => $section->get('nid'))); } } $this->assign($data, 'sections'); Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); } parent::display(); }
public function cachedView($xml, $template, $cacheId, $config = array()) { $this->_xml = $xml; Sobi::Trigger('Start', ucfirst(__FUNCTION__), array(&$this->_xml)); $templatePackage = SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'); $templateOverride = SPRequest::cmd('sptpl'); if ($templateOverride) { if (strstr($templateOverride, '.')) { $templateOverride = str_replace('.', '/', $templateOverride); } $template = $templateOverride . '.xsl'; } if (file_exists(Sobi::FixPath($templatePackage . '/' . $template))) { $template = Sobi::FixPath($templatePackage . '/' . $template); } else { $type = SPFactory::db()->select('oType', 'spdb_object', array('id' => SPRequest::sid()))->loadResult(); $template = $templatePackage . '/' . $type . '/' . $template; } SPFactory::registry()->set('current_template', $templatePackage); $this->_templatePath = $templatePackage; $this->_template = str_replace('.xsl', null, $template); $ini = array(); if (count($config)) { foreach ($config as $file) { $file = parse_ini_file($file, true); foreach ($file as $section => $keys) { if (isset($ini[$section])) { $ini[$section] = array_merge($ini[$section], $keys); } else { $ini[$section] = $keys; } } } } $this->setConfig($ini, SPRequest::task('get')); $this->parseXml(); $this->validateData($cacheId); Sobi::Trigger('After', ucfirst(__FUNCTION__), array(&$this->_xml)); }
/** * @author Radek Suski * @param string $name * @param bool $adm * @param string $type * @param bool $raiseErr * @throws SPException * @return string */ public static function loadClass($name, $adm = false, $type = null, $raiseErr = true) { static $types = array('sp-root' => 'sp-root', 'base' => 'base', 'controller' => 'ctrl', 'controls' => 'ctrl', 'ctrl' => 'ctrl', 'model' => 'models', 'plugin' => 'plugins', 'application' => 'plugins', 'view' => 'views', 'templates' => 'templates'); $type = strtolower(trim($type)); $name = trim($name); if (isset($types[$type])) { $type = $types[$type] . '/'; } else { $type = null; } if (strstr($name, 'cms') !== false) { $name = str_replace('cms.', 'cms.' . SOBI_CMS . '.', $name); } else { if (strstr($name, 'html.')) { $name = str_replace('html.', 'mlo.', $name); } } if ($adm) { if ($type == 'view') { $path = SOBI_ADM_PATH . '/' . $type; } else { $path = SOBI_PATH . "/lib/{$type}/adm/"; } } elseif (strstr($type, 'plugin')) { $path = SOBI_PATH . '/opt/' . $type; } elseif (strstr($type, 'template')) { $path = SOBI_PATH . '/usr/templates/' . Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); } elseif ($type == 'sp-root/') { $path = SOBI_PATH . '/'; } elseif (!strstr($name, 'opt.')) { $path = SOBI_PATH . '/lib/' . $type; } else { $path = SOBI_PATH . '/' . $type; } $name = str_replace('.', '/', $name); $path .= $name . '.php'; $path = self::clean($path); /* to prevent double loading of the same class */ /* class exists don't works with interfaces */ if (isset(self::$loaded[$path])) { return self::$loaded[$path]; } // if ( key_exists( $path, self::$loaded ) && class_exists( self::$loaded[ $path ] ) ) { // return self::$loaded[ $path ]; // } if (!file_exists($path) || !is_readable($path)) { if ($raiseErr) { /* We had to change it to notice because all these script kiddies are trying to call some not existent file which causes this error here * As a result we have the error log file full of USER_ERRORs and it looks badly but it's not really an error. * So we result wit the 500 response code but we log a notice for the logfile * */ if (!strstr($path, 'index.php')) { if (class_exists('Sobi')) { Sobi::Error('Class Load', sprintf('Cannot load file at %s. File does not exist or is not readable.', str_replace(SOBI_ROOT . '/', null, $path)), SPC::NOTICE, 0); throw new SPException(sprintf('Cannot load file at %s. File does not exist or is not readable.', str_replace(SOBI_ROOT . '/', null, $path))); } } } return false; } else { ob_start(); $content = file_get_contents($path); $class = array(); preg_match('/\\s*(class|interface)\\s+(\\w+)/', $content, $class); if (isset($class[2])) { $className = $class[2]; } else { Sobi::Error('Class Load', sprintf('Cannot determine class name in file %s.', str_replace(SOBI_ROOT . '/', null, $path)), SPC::ERROR, 500); return false; } require_once $path; self::$count++; ob_end_clean(); self::$loaded[$path] = $className; return $className; } }
public static function validateVisibility(&$data) { SPLoader::loadClass('env.browser'); $humanity = SPBrowser::getInstance()->get('humanity'); $display = Sobi::Cfg('mail_protection.show'); if (!($humanity >= $display)) { $data['_data'] = array(); } }
/** * @param $directory * @return array */ private function getAjaxFiles($directory) { $secret = md5(Sobi::Cfg('secret')); $coordinates = null; $dirNameHash = str_replace('directory://', null, $directory); if (strstr($dirNameHash, '::coordinates://')) { $struct = explode('::coordinates://', $dirNameHash); $dirNameHash = $struct[0]; $coordinates = $struct[1]; } $data = $dirNameHash; $dirName = SPLoader::dirPath("tmp.files.{$secret}.{$dirNameHash}", 'front', false); $files = scandir($dirName); return array($data, $dirName, $files, $coordinates); }
echo Sobi::Cfg('legacy.maxCats', '5'); ?> ; var Cinit = new String( parent.document.getElementById( 'entry.parent' ).value ); if( Cinit != '' ) { var cats = Cinit.split( ',' ); for( var i = 0; i < cats.length; i++ ) { if( cats[ i ] > 0 ) { SP_selectCat( cats[ i ], 1 ); } } } function SP_selectCat( sid, add ) { var separator = "<?php echo Sobi::Cfg('string.path_separator', ' > '); ?> "; var node = SP_id( 'sobiCatsstNode' + sid ); try { SP_id( 'sobiCats_CatUrl' + sid ).focus(); } catch( e ) {} var cats = new Array(); var request = new SobiPro.Json( "<?php $this->show('parent_ajax_url'); ?> " + '&sid=' + sid, { onComplete: function( jsonObj, jsons ) {
/** * @param string $title * @param bool $forceAdd */ public function setTitle($title, $forceAdd = false) { $document = JFactory::getDocument(); if (!is_array($title) && (Sobi::Cfg('browser.add_title', true) || $forceAdd)) { $title = array($title); } if (is_array($title)) { //browser.add_title = true: adds the Joomla part (this is normally the menu item) in front of it (works only if full_title is also set to true) $jTitle = $document->getTitle(); //get the title Joomla has set if (Sobi::Cfg('browser.add_title', true) || $forceAdd) { if ($title[0] != $jTitle) { array_unshift($title, $jTitle); } } else { if ($title[0] == $jTitle) { array_shift($title); } } //if ( Sobi::Cfg( 'browser.full_title', true ) || true ) { //browser.full_title = true: if title is array, use only the last. That's e.g. the entry name without categories for SobiPro standard title if (count($title)) { if (is_array($title)) { if (Sobi::Cfg('browser.reverse_title', false)) { $title = array_reverse($title); } $title = implode(Sobi::Cfg('browser.title_separator', ' - '), $title); } else { $title = isset($title[count($title) - 1]) ? $title[count($title) - 1] : $title[0]; } } else { $title = null; } } if (strlen($title)) { if (!defined('SOBIPRO_ADM')) { if (JFactory::getApplication()->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', JFactory::getApplication()->getCfg('sitename'), $title); } elseif (JFactory::getApplication()->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, JFactory::getApplication()->getCfg('sitename')); } } $document->setTitle(SPLang::clean(html_entity_decode($title))); } }
/** * Sets the SQL query string for later execution. * * @param string $sql * @return void */ public function setQuery($sql) { $sql = str_replace('spdb', $this->prefix . 'sobipro', $sql); $sql = str_replace('NOW()', '\'' . gmdate(Sobi::Cfg('date.db_format', 'Y-m-d H:i:s')) . '\'', $sql); return $this->db->setQuery($sql); }
/** * Checks for a form token in the request. * @param string $method * @return boolean */ public function checkToken($method = 'post') { if (Sobi::Cfg('security.token', true)) { return JSession::checkToken($method); } else { return true; } }
/** * Enter description here... * * @param unknown_type $row * @param unknown_type $id * @return unknown */ public static function checkedOut($row, $id = 'sid') { $state = $row->get('cout'); if ($state && $state != Sobi::My('id') && strtotime($row->get('coutTime')) > time()) { /* translate alternative text */ $user = SPUser::getInstance($state); $uname = $user->get('name'); $img = Sobi::Cfg('list_icons.checked_out'); $s = Sobi::Txt($row->get('oType') . '.checked_out'); $a = Sobi::Txt($row->get('oType') . '.checked_out_by', array('user' => $uname, 'time' => $row->get('coutTime'))); $r = SPTooltip::toolTip($a, $s, $img); } else { $sid = $row->get('id'); $r = "<input type=\"checkbox\" name=\"{$id}[]\" value=\"{$sid}\" onclick=\"SPCheckListElement( this )\" />"; } return $r; }
protected function view() { /* determine template package */ $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE); Sobi::ReturnPoint(); $this->_task = 'user'; if (!$this->_model) { $this->setModel('section'); $this->_model->init(Sobi::Section()); } $this->visible(); /* load template config */ $this->template(); $this->tplCfg($tplPackage); /* get limits - if defined in template config - otherwise from the section config */ $eLimit = $this->tKey($this->template, 'entries_limit', Sobi::Cfg('list.entries_limit', 2)); $eInLine = $this->tKey($this->template, 'entries_in_line', Sobi::Cfg('list.entries_in_line', 2)); $url = array('sid' => SPRequest::sid(), 'task' => 'list.user'); if (SPRequest::int('uid')) { $url['uid'] = SPRequest::int('uid'); $this->uid = (int) SPRequest::int('uid'); } else { $this->uid = (int) Sobi::My('id'); } $this->user = SPJoomlaUser::getBaseData((int) $this->uid); if (!$this->user) { throw new SPException(SPLang::e('UNAUTHORIZED_ACCESS')); } /* get the site to display */ $site = SPRequest::int('site', 1); $eLimStart = ($site - 1) * $eLimit; $eOrder = $this->parseOrdering('entries', 'eorder', $this->tKey($this->template, 'entries_ordering', Sobi::Cfg('list.entries_ordering', 'name.asc'))); $eCount = count($this->getEntries($eOrder, 0, 0, true, array('spo.owner' => $this->uid), true, Sobi::Section())); $entries = $this->getEntries($eOrder, $eLimit, $eLimStart, true, array('spo.owner' => $this->uid), true, Sobi::Section()); // $eCount = count( $this->_getEntries( 0, 0, true ) ); // $entries = $this->_getEntries( $eLimit, $site ); $pn = SPFactory::Instance('helpers.pagenav_' . $this->tKey($this->template, 'template_type', 'xslt'), $eLimit, $eCount, $site, $url); if (SPRequest::int('site', 0)) { $url['site'] = SPRequest::int('site', 0); } SPFactory::header()->addCanonical(Sobi::Url($url, true, true, true)); /* handle meta data */ SPFactory::header()->objMeta($this->_model); SPFactory::mainframe()->addToPathway(Sobi::Txt('UL.PATH_TITLE', array('username' => $this->user->username, 'user' => $this->user->name)), Sobi::Url('current')); SPFactory::header()->addTitle(Sobi::Txt('UL.TITLE', array('username' => $this->user->username, 'user' => $this->user->name, 'section' => $this->_model->get('name'))), array(ceil($eCount / $eLimit), $site)); /* add pathway */ /* get view class */ $view = SPFactory::View('listing'); $view->assign($eLimit, '$eLimit'); $view->assign($eLimStart, '$eLimStart'); $view->assign($eCount, '$eCount'); $view->assign($eInLine, '$eInLine'); $view->assign($this->_task, 'task'); $view->assign($this->_model, 'section'); $view->setConfig($this->_tCfg, $this->template); $view->setTemplate($tplPackage . '.' . $this->templateType . '.' . $this->template); $view->assign($pn->get(), 'navigation'); $view->assign(SPFactory::user()->getCurrent(), 'visitor'); $view->assign($entries, 'entries'); Sobi::Trigger('UserListing', 'View', array(&$view)); $view->display(); }
/** * @param $name - field name * @param $value - field value * @param string $dateFormat - date format in PHP * @param null $params - additional parameters * @param string $icon - field icon * @param bool $addOffset * @param null $timeOffset * @return string */ public static function datePicker($name, $value, $dateFormat = 'Y-m-d H:i:s', $params = null, $icon = 'th', $addOffset = false, $timeOffset = null) { self::createLangFile(); $timeOffset = strlen($timeOffset) ? $timeOffset : Sobi::Cfg('time_offset'); // another mystery - what the heck was this supposed to do? // $value = ( ( int ) $value != 0 && $value ) ? strtotime( $value ) : null; /** The stupid JavaScript to PHP conversion. */ // $jsDateFormat = str_replace( // array( 'n', 'm', 'd', 'j', 'h', 'H', 'i', 's', 'A' ), // array( 'm', 'MM', 'dd', 'd', 'HH', 'hh', 'mm', 'ss', 'PP' ), // $dateFormat // ); if (strstr($dateFormat, 'A')) { $dateFormat = str_replace(array('h', 'H'), array('g', 'G'), $dateFormat); } $jsDateFormat = $dateFormat; $jsReplacements = array('y' => 'yy', 'Y' => 'yyyy', 'F' => 'MM', 'n' => 'm', 'm' => 'MM', 'd' => 'dd', 'j' => 'd', 'H' => 'hh', 'g' => 'HH', 'G' => 'HH', 'i' => 'mm', 's' => 'ss', 'A' => 'PP'); foreach ($jsReplacements as $php => $js) { $jsDateFormat = str_replace($php, $js, $jsDateFormat); } if ($value && !is_numeric($value)) { $value = $addOffset ? strtotime($value . 'UTC') : strtotime($value); } $offset = null; if ($addOffset) { $offset = SPFactory::config()->getTimeOffset(); } $valueDisplay = $value ? SPFactory::config()->date($value + $offset, null, $dateFormat, $addOffset) : null; // SPConfig::debOut( gmdate( "l jS \of F Y h:i:s A", $value + $offset ) ); // SPConfig::debOut( $valueDisplay ); self::checkArray($params); if (!isset($params['id'])) { $params['id'] = SPLang::nid($name); } if (!isset($params['data'])) { $params['data'] = array(); } if (strstr($dateFormat, 'A')) { $params['data']['am-pm'] = 'true'; } // $offset = 0; $params['data']['format'] = $jsDateFormat; if ($addOffset) { $params['data']['time-zone'] = $timeOffset; $params['data']['time-offset'] = SPFactory::config()->getTimeOffset(); // $offset = $params[ 'data' ][ 'time-offset' ]; } $data = self::createDataTag($params); SPFactory::header()->addCssFile('bootstrap.datepicker')->addJsFile(array('locale.' . Sobi::Lang(false) . '_date_picker', 'bootstrap.datepicker')); $params = self::params($params); $f = "\n"; $f .= '<div class="input-append date spDatePicker">'; $f .= "\n\t"; $f .= '<input type="text" disabled="disabled" value="' . $valueDisplay . '" ' . $params . ' name="' . $name . 'Holder" ' . $data . '/>'; /** * Mon, Nov 17, 2014 11:39:34 So here I am a bit baffled: we initially changed it to integer (unfortunately I do not remember why) * but it seems that it may be overwriting the 32 bit (why a 64-bit machine limits integer to 32 bit is another story). * I suppose it was to get rid of (possible) decimal place. * So let's try another method! * */ if (strstr($value, '.')) { $value = explode('.', $value); $value = $value[0]; } /** no offset, we are using UTC times only */ // $value = ( $value ? ( ( $value + $offset ) * 1000 ) : null ); $value = $value ? $value * 1000 : null; $f .= '<input type="hidden" value="' . $value . '" name="' . $name . '"/>'; // $f .= '<input type="hidden" value="' . ( $value ? (int)( ( $value + SPFactory::config()->getTimeOffset() ) * 1000 ) : null ) . '" name="' . $name . '"/>'; // $f .= '<input type="hidden" value="' . ( $value ? ( $value + SPFactory::config()->getTimeOffset() ) * 1000 : null ) . '" name="' . $name . '"/>'; $f .= "\n\t"; $f .= '<span class="add-on"><i data-date-icon="icon-' . $icon . '" class="icon-' . $icon . '"></i></span>'; $f .= "\n"; $f .= '</div>'; $f .= "\n"; Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$f)); return "\n<!-- Date Picker '{$name}' Output -->{$f}<!-- Date Picker '{$name}' End -->\n\n"; }
public function display() { $this->_type = 'search'; $type = $this->key('template_type', 'xslt'); if ($type != 'php' && Sobi::Cfg('global.disable_xslt', false)) { $type = 'php'; } if ($type == 'xslt') { $searchData = array(); $fields = $this->get('fields'); $visitor = $this->get('visitor'); $p = $this->get('priorities'); $priorities = array(); if (is_array($p) && count($p)) { foreach ($p as $priority => $eids) { if (is_array($eids) && count($eids)) { foreach ($eids as $sid) { $priorities[$sid] = $priority; } } } } $entries = $this->get('entries'); $searchData['section'] = array('_complex' => 1, '_data' => Sobi::Section(true), '_attributes' => array('id' => Sobi::Section(), 'lang' => Sobi::Lang(false))); $searchPhrase = $this->get('search_for'); $phrase = $this->get('search_phrase'); $searchPhrase = strlen($searchPhrase) ? $searchPhrase : Sobi::Txt('SH.SEARCH_FOR_BOX'); SPFactory::header()->addJsCode('var spSearchDefStr = "' . Sobi::Txt('SH.SEARCH_FOR_BOX') . '"'); if ($this->get('$eInLine')) { $searchData['entries_in_line'] = $this->get('$eInLine'); } if ($this->get('$eCount') >= 0) { $searchData['message'] = Sobi::Txt('SH.SEARCH_FOUND_RESULTS', array('count' => $this->get('$eCount'))); } $this->menu($searchData); $this->alphaMenu($searchData); $fData = array(); if (Sobi::Cfg('search.show_searchbox', true)) { $fData['searchbox'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_FOR'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::text('sp_search_for', $searchPhrase, array('class' => Sobi::Cfg('search.form_box_def_css', 'SPSearchBox'), 'id' => 'SPSearchBox')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchBox')); } if (Sobi::Cfg('search.top_button', true)) { $fData['top_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START'), array('id' => 'top_button')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton')); } if (Sobi::Cfg('search.show_phrase', true)) { $fData['phrase'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::radioList('spsearchphrase', array('all' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ALL_WORDS'), 'any' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_ANY_WORDS'), 'exact' => Sobi::Txt('SH.FIND_ENTRIES_THAT_HAVE_EXACT_PHRASE')), 'spsearchphrase', strlen($phrase) ? $phrase : Sobi::Cfg('search.form_searchphrase_def', 'all'), null, 'right'))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchPhrase')); } if (count($fields)) { foreach ($fields as $field) { $data = $field->searchForm(); $suffix = $field->get('searchMethod') != 'range' ? $field->get('suffix') : null; if (strlen($data)) { $fData[$field->get('nid')] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => $field->get('name'), '_attributes' => array('lang' => Sobi::Lang())), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => $data)), '_attributes' => array('id' => $field->get('id'), 'type' => $field->get('type'), 'suffix' => $suffix, 'position' => $field->get('position'), 'css_class' => strlen($field->get('cssClass')) ? $field->get('cssClass') : 'spField')); } } } if (Sobi::Cfg('search.bottom_button', false)) { $fData['bottom_button'] = array('_complex' => 1, '_data' => array('label' => array('_complex' => 1, '_data' => Sobi::Txt('SH.SEARCH_START'), '_attributes' => array('lang' => Sobi::Lang(false))), 'data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('search', Sobi::Txt('SH.START')))), '_attributes' => array('position' => 1, 'css_class' => 'SPSearchButton')); } $searchData['fields'] = $fData; if (count($entries)) { $this->loadNonStaticData($entries); $manager = Sobi::Can('entry', 'edit', '*', Sobi::Section()) ? true : false; foreach ($entries as $entry) { $en = $this->entry($entry, $manager); $searchData['entries'][] = array('_complex' => 1, '_attributes' => array('id' => $en['id'], 'search-priority' => isset($priorities[$en['id']]) ? $priorities[$en['id']] : 'undefined'), '_data' => $en); } $this->navigation($searchData); } $searchData['visitor'] = $this->visitorArray($visitor); $this->_attr = $searchData; } Sobi::Trigger($this->_type, ucfirst(__FUNCTION__), array(&$this->_attr)); parent::display($this->_type); }
private function SQLite() { $v = false; if (class_exists('SQLiteDatabase')) { $v = true; } else { if (class_exists('PDO')) { try { $db = new PDO('sqlite:' . Sobi::Cfg('cache.store', SOBI_PATH . DS . 'var' . DS . 'cache' . DS) . '.htCache.db'); $v = true; } catch (PDOException $e) { } } } if ($v) { echo $this->ok($this->txt('REQ.SQLITE_AVAILABLE'), __FUNCTION__); } else { echo $this->warning($this->txt('REQ.SQLITE_NOT_AVAILABLE'), __FUNCTION__); } }
public function __call($fn, $args) { $return = array('error' => 500); array_unshift($args, Sobi::Lang(false)); array_unshift($args, Sobi::Cfg('live_site')); if ($this->_server instanceof SPSoapClient) { try { $return = $this->_server->__soapCall($fn, $args); } catch (SoapFault $x) { throw new SPException($x->getMessage()); } /* what the hell ???!!!!!*/ if ($return instanceof SoapFault) { throw new SPException($return->getMessage()); } } return $return; }
private function editFile() { if (Sobi::Section() && Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE) { SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage(); } $file = SPRequest::cmd('file'); $file = $this->file($file); $ext = SPFs::getExt($file); $fileContent = SPFs::read($file); $path = str_replace('\\', '/', SOBI_PATH); if (strstr($file, $path)) { $filename = str_replace($path . '/usr/templates/', null, $file); } else { $filename = str_replace(SOBI_ROOT, null, $file); } $menu = $this->createMenu(); if (Sobi::Section()) { $menu->setOpen('AMN.APPS_SECTION_TPL'); } else { $menu->setOpen('GB.CFG.GLOBAL_TEMPLATES'); } /** @var $view SPAdmTemplateView */ $view = SPFactory::View('template', true)->assign($fileContent, 'file_content')->assign($filename, 'file_name')->assign($ext, 'file_ext')->assign($menu, 'menu')->assign($this->_task, 'task')->assign(Sobi::Section(), 'sid')->addHidden(SPRequest::cmd('file'), 'fileName')->addHidden($filename, 'filePath')->determineTemplate('template', 'edit'); Sobi::Trigger('Edit', $this->name(), array(&$file, &$view)); $view->display(); }