Ejemplo n.º 1
0
 public static function _parser()
 {
     $context = pobject::getContext();
     $me = $context['arCurrentObject'];
     $parser = new xml_parser($me);
     return $parser;
 }
Ejemplo n.º 2
0
 function setUser($login, $userInfo = array())
 {
     global $AR, $store;
     pobject::pushContext(array("scope" => "php"));
     $result = mod_auth_default::getUser($login, $this->config["ar:userDir"]);
     if ($result === LD_ERR_ACCESS) {
         $aLogin = '******';
         // FIXME: make this configurable
         $AR->user = current($store->call("system.get.phtml", "", $store->find("/system/users/", "login.value='{$aLogin}' and object.implements='puser'")));
         $user_dir = $this->config["ar:userDir"];
         $user_profile = $this->config["ar:userProfile"];
         $data = array();
         $data["arNewFilename"] = "{$user_dir}{$login}/";
         $data["name"] = $login;
         $data["newpass1"] = '!';
         $data["newpass2"] = '!';
         $data["profile"] = $user_profile;
         $data["setowner"] = true;
         $data["email"] = $userInfo["email"];
         foreach ($userInfo as $key => $value) {
             $data["custom"]["none"][$key] = $value;
         }
         $userType = $this->config["ar:userType"] ? $this->config["ar:userType"] : "puser";
         $user = $store->newobject("{$user_dir}{$login}/", "{$user_dir}", $userType, new object());
         $user->arIsNewObject = true;
         $user->call('system.save.data.phtml', $data);
         $AR->user = $user;
     }
     ldSetCredentials($login, $this->config["ar:userDir"]);
     // unbecome system user
     pobject::popContext();
     return $AR->user;
 }
Ejemplo n.º 3
0
 public static function _make_real_path($path, &$redirects = array())
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $path = $me->make_path($path);
     $originalPath = $path;
     while ($path != $prevPath && !$me->exists($path)) {
         $prevPath = $path;
         $path = $me->make_path($path . '../');
     }
     if ($path != $originalPath) {
         $shortcut = current($me->get($path, 'system.get.phtml'));
         if (!$shortcut || !$shortcut->AR_implements('pshortcut')) {
             $result = $originalPath;
         } else {
             if (!is_array($redirects)) {
                 $redirects = array();
             }
             $subpath = substr($originalPath, strlen($path));
             $target = $shortcut->call('system.get.target.phtml');
             array_push($redirects, array("src" => $path, "dest" => $target, "keepurl" => $shortcut->data->keepurl));
             if ($me->exists($target . $subpath)) {
                 $result = $target . $subpath;
             } else {
                 $result = self::_make_real_path($target . $subpath, $redirects);
             }
         }
     } else {
         $result = $path;
     }
     return $result;
 }
Ejemplo n.º 4
0
 public static function loadFromString($string)
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     /* parse rss feed and initialize and return an rssFeed object */
     $rss = new rssFeed($me);
     $rss->setFeedString($string);
     return $rss;
 }
Ejemplo n.º 5
0
 function ShowSections($sections, $template = "", $args = "", $recurse = false, $level = 0)
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     if (is_array($sections)) {
         $max = count($sections);
         for ($i = 0; $i < $max; $i++) {
             multipart::ShowSection($sections[$i], $template, $args, $recurse, $level);
             $me->_resetloopcheck();
         }
     }
 }
Ejemplo n.º 6
0
 public function readFromArray($csvArray, $settings = array())
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $csv = new csvFeed($me, $settings);
     $result = $csv->readFromArray($csvArray, $settings);
     if ($result && ar_error::isError($result)) {
         return $result;
     } else {
         return $csv;
     }
 }
Ejemplo n.º 7
0
 public function __construct($config = array())
 {
     if (!$config['cmd']) {
         $config['cmd'] = '/usr/local/bin/wkhtmltoimage --disable-local-file-access ';
     }
     if (!$config['temp']) {
         $context = pobject::getContext();
         $me = $context["arCurrentObject"];
         $config['temp'] = $me->store->get_config("files") . "temp/";
     }
     $this->config = $config;
     $this->options = array('format' => 'png');
     $this->cookies = array();
     $this->headers = array();
 }
Ejemplo n.º 8
0
 function activate($path, $workspace = "workspace")
 {
     // Activate the workspace for the current path. All
     // calls on objects will return the workspaced
     // version when this has been called. This should be
     // called from within the workspace loader.
     $context = pobject::getContext();
     $me = $context['arCurrentObject'];
     // FIXME: Checken of de gevraagde workspace wel geconfigged is voor dit pad.
     $layer = workspace::getLayer($workspace);
     if (!isset($layer)) {
         return false;
     } else {
         $me->store->setLayer($layer);
         return true;
     }
 }
Ejemplo n.º 9
0
 function _DownloadFile($filename = "", $cacheSeconds = 1800, $contentType = "application/zip")
 {
     global $AR;
     $context = pobject::getContext();
     $me = $context['arCurrentObject'];
     $size = filesize($this->_filename);
     ldSetContent($contentType, $size);
     $expires = time() + $cacheSeconds;
     if ($AR->user->data->login == "public" || $me->CheckPublic("read")) {
         ldSetClientCache(true, $expires);
     }
     if ($filename) {
         ldHeader("Content-Disposition: attachment; filename={$filename}");
         ldHeader("Content-length:" . (string) $size);
     }
     readfile($this->_filename);
 }
Ejemplo n.º 10
0
Archivo: nls.php Proyecto: poef/ariadne
 public function load($section = "", $nls = null, $varName = null)
 {
     if (!isset($nls)) {
         $nls = $this->currentLanguage;
     }
     if (!isset($varName)) {
         $varName = $this->defaultVarName;
     }
     $nls = preg_replace('|[^a-z]*|i', '', $nls);
     $re = '|[^a-z-_.:0-9/]*|i';
     // only allow 'normal' characters
     $section = str_replace('//', '/', str_replace('..', '', preg_replace($re, '', $section)));
     // add .js if not set, remove .. and other dirty characters
     if (strpos($section, 'current:') !== false) {
         $context = pobject::getContext();
         $arLibraryPath = $context['arLibraryPath'];
         $sectionCacheName = str_replace('current:', $arLibraryPath . ':', $section);
     } else {
         $sectionCacheName = $section;
     }
     if (!$section) {
         if (!$this->loaded[$sectionCacheName][$nls] && ($fullFile = $this->baseDir . $nls) && file_exists($fullFile)) {
             include $fullFile;
             $this->loaded[$sectionCacheName][$nls] = true;
             $this->languages[$nls] = array_merge((array) $this->languages[$nls], (array) ${$varName});
         }
     } elseif (!$this->loaded[$sectionCacheName][$nls]) {
         $this->loaded[$sectionCacheName][$nls] = true;
         $fullFile = $this->baseDir . $section . "." . $nls;
         if (file_exists($fullFile)) {
             include $fullFile;
             $this->languages[$nls] = array_merge((array) $this->languages[$nls], (array) ${$varName});
         } else {
             // FIXME: UGLY hack stolen from pobject::loadtext()
             global $ARCurrent;
             $context = pobject::getContext();
             $me = $context["arCurrentObject"];
             if (!$me || !is_object($me)) {
                 //FIXME: this should not happen, but ldObjectNotFound() sometimes triggers this
                 // the problem is that there is no arCurrentObject pushed on the stack
                 // generally we can just return and nothing serious will happen
                 debug('No current object found on the context stack, skipping loadtext', 'all');
                 return $this;
             }
             $arResult = $ARCurrent->arResult;
             $me->pushContext(array());
             $oldnls = $me->reqnls;
             $me->reqnls = $nls;
             $oldAllnls = $ARCurrent->allnls;
             $ARCurrent->allnls = true;
             $me->CheckConfig($section, array("nls" => $nls));
             $ARCurrent->allnls = $oldAllnls;
             $me->reqnls = $oldnls;
             $me->popContext();
             $nlsarray = array();
             if (is_array($ARCurrent->arResult)) {
                 $nlsarray = $ARCurrent->arResult;
             } elseif (is_array($me->{$varName})) {
                 $nlsarray = $me->{$varName};
             } elseif (is_array($ARCurrent->{$varName})) {
                 $nlsarray = $ARCurrent->{$varName};
             }
             $ARCurrent->arResult = $arResult;
             $this->languages[$nls] = array_merge((array) $this->languages[$nls], (array) $nlsarray);
         }
     }
     return $this;
 }
Ejemplo n.º 11
0
function ldOnFinish()
{
    global $ARCurrent, $store;
    $error = error_get_last();
    if ($error['type'] == 1) {
        // Fatal error
        $context = pobject::getContext();
        if ($context['scope'] == 'pinp') {
            pobject::pinpErrorHandler($error['type'], $error['message'], $error['file'], $error['line'], null);
        }
    }
    if ($ARCurrent->session) {
        $ARCurrent->session->save();
    }
    if ($store) {
        $store->close();
    }
}
Ejemplo n.º 12
0
 protected static function processArCall($page, $full = false)
 {
     global $ARCurrent, $AR;
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     // parse {arCall:/path/to/object/template.phtml?a=1&b=2}
     //		$regExp = '|\{arCall:(/(.*/)*)([^?]+)[?]([^}]*?)}|i';
     $regExp = '|\\{arCall:(.*?)\\}|i';
     while (preg_match($regExp, $page, $matches)) {
         if (!$settings) {
             if (!$ARCurrent->arEditorSettings) {
                 $settings = $me->call("editor.ini");
             } else {
                 $settings = $ARCurrent->arEditorSettings;
             }
         }
         ob_start();
         $parts = explode("?", substr($matches[0], strlen('{arCall:'), -1), 2);
         $args = $parts[1];
         $rest = $parts[0];
         $template = "";
         if (substr($rest, -1) !== '/') {
             $template = basename($rest);
         }
         $path = $me->make_path(substr($rest, 0, -strlen($template)));
         if (is_array($settings['arCall'][$template])) {
             $cpaths = $settings['arCall'][$template]['paths'];
             if (is_array($cpaths)) {
                 $mayCall = false;
                 foreach ($cpaths as $cpath) {
                     if (substr($cpath, -1) == '*') {
                         $cpath = substr($cpath, 0, -1);
                         if (substr($path, 0, strlen($cpath)) == $cpath) {
                             $mayCall = true;
                             break;
                         }
                     } else {
                         if ($path === $cpath) {
                             $mayCall = true;
                             break;
                         }
                     }
                 }
                 if (!$mayCall) {
                     error("no permission to call '{$template}' on '{$path}'");
                 } else {
                     $me->get($path, $template, $args);
                 }
             } else {
                 error("no paths were listed for '{$template}'");
             }
         } else {
             error("template '{$template}' is not in white list");
         }
         $output = ob_get_contents();
         ob_end_clean();
         $page = str_replace($matches[0], $output, $page);
     }
     return $page;
 }
Ejemplo n.º 13
0
 function _registerDataField($name)
 {
     $id = edit::registerDataField();
     // FIXME: Temporary fix voor older code which still use registerDataField
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $prefix = edit::getEditPrefix();
     echo "<script> parent.registerDataField('" . $prefix . $id . "','" . AddCSlashes($name, ARESCAPE) . "','" . $me->path . "'\n\t\t\t\t," . $me->id . "); </script>\n";
     return $id;
 }
Ejemplo n.º 14
0
 function generate($config)
 {
     global $fpdf_charwidths;
     global $g_baseurl;
     global $g_border;
     global $g_box_uid;
     global $g_boxes;
     global $g_colors;
     global $g_config;
     global $g_css;
     global $g_css_defaults_obj;
     global $g_css_handlers;
     global $g_css_index;
     global $g_css_obj;
     global $g_font_family;
     global $g_font_resolver;
     global $g_font_resolver_pdf;
     global $g_font_size;
     global $g_frame_level;
     global $g_html_entities;
     global $g_image_cache;
     global $g_last_assigned_font_id;
     global $g_list_item_nums;
     global $g_manager_encodings;
     global $g_media;
     global $g_predefined_media;
     global $g_pt_scale;
     global $g_px_scale;
     global $g_stylesheet_title;
     global $g_table_border;
     global $g_tag_attrs;
     global $g_unicode_glyphs;
     global $g_utf8_converters;
     global $g_utf8_to_encodings_mapping_pdf;
     global $g_valign;
     global $psdata;
     global $g_font_style;
     global $g_font_family;
     global $g_font_weight;
     global $g_font_size;
     global $g_line_height;
     //			global $base_font_size;
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     require_once HTML2PS_LOCATION . 'pipeline.factory.class.php';
     set_time_limit(600);
     check_requirements();
     $g_baseurl = trim($config['URL']);
     if ($g_baseurl === "") {
         $me->error = "Please specify URL to process!";
         return false;
     }
     // Add HTTP protocol if none specified
     if (!preg_match("/^https?:/", $g_baseurl)) {
         $g_baseurl = 'http://' . $g_baseurl;
     }
     $g_css_index = 0;
     // Title of styleshee to use (empty if no preferences are set)
     $g_stylesheet_title = "";
     $g_config = array('cssmedia' => isset($config['cssmedia']) ? $config['cssmedia'] : "screen", 'convert' => isset($config['convert']), 'media' => isset($config['media']) ? $config['media'] : "A4", 'scalepoints' => isset($config['scalepoints']), 'renderimages' => isset($config['renderimages']), 'renderfields' => isset($config['renderfields']), 'renderforms' => isset($config['renderforms']), 'pslevel' => isset($config['pslevel']) ? $config['pslevel'] : 2, 'renderlinks' => isset($config['renderlinks']), 'pagewidth' => isset($config['pixels']) ? (int) $config['pixels'] : 800, 'landscape' => isset($config['landscape']), 'method' => isset($config['method']) ? $config['method'] : "fpdf", 'margins' => array('left' => isset($config['leftmargin']) ? (int) $config['leftmargin'] : 0, 'right' => isset($config['rightmargin']) ? (int) $config['rightmargin'] : 0, 'top' => isset($config['topmargin']) ? (int) $config['topmargin'] : 0, 'bottom' => isset($config['bottommargin']) ? (int) $config['bottommargin'] : 0), 'encoding' => isset($config['encoding']) ? $config['encoding'] : "", 'ps2pdf' => isset($config['ps2pdf']) ? $config['ps2pdf'] : 0, 'compress' => isset($config['compress']) ? $config['compress'] : 0, 'output' => isset($config['output']) ? $config['output'] : 0, 'pdfversion' => isset($config['pdfversion']) ? $config['pdfversion'] : "1.2", 'transparency_workaround' => isset($config['transparency_workaround']), 'imagequality_workaround' => isset($config['imagequality_workaround']), 'draw_page_border' => isset($config['pageborder']), 'debugbox' => isset($config['debugbox']), 'watermarkhtml' => isset($config['watermarkhtml']), 'smartpagebreak' => isset($config['smartpagebreak']), 'html2xhtml' => !isset($config['html2xhtml']), 'mode' => 'html');
     // ========== Entry point
     parse_config_file(HTML2PS_LOCATION . './.html2ps.config');
     // validate input data
     if ($g_config['pagewidth'] == 0) {
         $me->error = "Please specify non-zero value for the pixel width!";
         return false;
     }
     // begin processing
     $g_media = Media::predefined($g_config['media']);
     $g_media->set_landscape($g_config['landscape']);
     $g_media->set_margins($g_config['margins']);
     $g_media->set_pixels($g_config['pagewidth']);
     $g_px_scale = mm2pt($g_media->width() - $g_media->margins['left'] - $g_media->margins['right']) / $g_media->pixels;
     if ($g_config['scalepoints']) {
         $g_pt_scale = $g_px_scale * 1.43;
         // This is a magic number, just don't touch it, or everything will explode!
     } else {
         $g_pt_scale = 1.0;
     }
     // Initialize the coversion pipeline
     $pipeline = new Pipeline();
     // Configure the fetchers
     $pipeline->fetchers[] = new FetcherURL();
     // Configure the data filters
     $pipeline->data_filters[] = new DataFilterDoctype();
     $pipeline->data_filters[] = new DataFilterUTF8($g_config['encoding']);
     if ($g_config['html2xhtml']) {
         $pipeline->data_filters[] = new DataFilterHTML2XHTML();
     } else {
         $pipeline->data_filters[] = new DataFilterXHTML2XHTML();
     }
     $pipeline->parser = new ParserXHTML();
     $pipeline->pre_tree_filters = array();
     if ($g_config['renderfields']) {
         $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields("", "", "");
     }
     if ($g_config['method'] === 'ps') {
         $pipeline->layout_engine = new LayoutEnginePS();
     } else {
         $pipeline->layout_engine = new LayoutEngineDefault();
     }
     $pipeline->post_tree_filters = array();
     // Configure the output format
     if ($g_config['pslevel'] == 3) {
         $image_encoder = new PSL3ImageEncoderStream();
     } else {
         $image_encoder = new PSL2ImageEncoderStream();
     }
     switch ($g_config['method']) {
         case 'ps':
             $pipeline->output_driver = new OutputDriverPS($g_config['scalepoints'], $g_config['transparency_workaround'], $g_config['imagequality_workaround'], $image_encoder);
             break;
         case 'fastps':
             $pipeline->output_driver = new OutputDriverFastPS($image_encoder);
             break;
         case 'pdflib':
             $pipeline->output_driver = new OutputDriverPDFLIB($g_config['pdfversion']);
             break;
         case 'fpdf':
             $pipeline->output_driver = new OutputDriverFPDF();
             break;
         default:
             $me->error = "Unknown output method";
             return false;
     }
     if ($g_config['debugbox']) {
         $pipeline->output_driver->set_debug_boxes(true);
     }
     if ($g_config['draw_page_border']) {
         $pipeline->output_driver->set_show_page_border(true);
     }
     if ($g_config['ps2pdf']) {
         $pipeline->output_filters[] = new OutputFilterPS2PDF($g_config['pdfversion']);
     }
     if ($g_config['compress']) {
         $pipeline->output_filters[] = new OutputFilterGZip();
     }
     $pipeline->destination = new DestinationBrowser($g_baseurl);
     $dest_filename = $pipeline->destination->filename_escape($pipeline->destination->get_filename());
     ldSetContent("application/pdf");
     if (!$me->cached("html2ps_" . md5($dest_filename))) {
         // Start the conversion
         $status = $pipeline->process($g_baseurl, $g_media);
         if ($status == null) {
             ldSetContent("text/html");
             $me->error = "Error in conversion pipeline: " . $pipeline->error_message();
             $me->savecache(0);
             return false;
         } else {
             $me->savecache(999);
         }
     }
     return true;
 }
Ejemplo n.º 15
0
 public static function stripARNameSpace($page)
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     include_once $me->store->get_config('code') . "modules/mod_htmlcleaner.php";
     $cleanAR = array('rewrite' => array('^(A|IMG|DIV)$' => array('^ar:.*' => false, '^arargs:.*' => false, '^class' => array('htmlblock[ ]*uneditable[ ]*' => false), '^data-vedor-*' => false)), 'delete_emptied' => array('div', 'a'));
     return htmlcleaner::cleanup($page, $cleanAR);
 }
Ejemplo n.º 16
0
 public static function getFormField()
 {
     global $ARCurrent;
     $ARCurrent->arDontCache = true;
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $context = $me->getContext();
     $captcha = $context['captcha'];
     $captcha->make_captcha();
     $elements = $captcha->public_key_input();
     $try = $captcha->get_try(FALSE);
     $elements .= "<input type=\"hidden\" name=\"hncaptcha\" value=\"{$try}\">";
     $elements .= "<input type=\"text\" class=\"captcha\" name=\"private_key\" value=\"\" maxlength=\"" . $captcha->chars . "\" size=\"" . $captcha->chars . "\">";
     return $elements;
 }
Ejemplo n.º 17
0
Archivo: ar.php Proyecto: poef/ariadne
 public static function callAtPath($path, $callback)
 {
     $ob = current(ar_store::get($path)->call('system.get.phtml'));
     pobject::pushContext(array("arCurrentObject" => $ob, "scope" => "php"));
     call_user_func($callback);
     pobject::popContext();
 }
Ejemplo n.º 18
0
 public static function pinpErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
 {
     global $nocache;
     if (($errno & error_reporting()) == 0) {
         return true;
     }
     $nocache = true;
     $context = pobject::getContext();
     if ($context["arLibraryPath"]) {
         //  != null) {
         $msg = "Error on line {$errline} in " . $context['arCallTemplateType'] . '::' . $context['arCallFunction'] . " in library " . $context["arLibraryPath"] . "\n" . $errstr . "\n";
     } else {
         $msg = "Error on line {$errline} in " . $context['arCallTemplateType'] . '::' . $context['arCallFunction'] . " on object " . $context['arCurrentObject']->path . "\n" . $errstr . "\n";
     }
     $display = ini_get('display_errors');
     if ($display) {
         echo $msg;
     }
     error_log($msg);
     return false;
 }
Ejemplo n.º 19
0
 function _uasort(&$array, $callback)
 {
     $context = pobject::getContext();
     $me = $context["arCurrentObject"];
     $result = false;
     if (pinp_util::is_callback($callback)) {
         $result = uasort($array, $callback);
     } else {
         $me->error = "'{$callback}' is not a valid callback function";
     }
     return $result;
 }