public static function client($dsn, $username = '', $password = '', $driverOptions = array()) { try { return new ar_connect_dbClient(new PDO($dsn, $username, $password, $driverOptions)); } catch (Exception $e) { return ar::error($e->getMessage(), $e->getCode()); } }
function mogrifyDir($path, $type) { echo "== mogrify {$path} to {$type}\n"; $res = current(ar::get($path)->call('system.get.phtml')); if ($res && $res->type == "pdir") { print "Oldtype is pdir, mogrify to new type {$type}\n"; $res = ar::get($path)->call('system.mogrify.phtml', array('type' => $type)); } }
public function _soapCall($name, $arguments, $options = array(), $inputHeaders = array(), &$outputHeaders = array()) { try { $result = $this->wrapped->__soapCall($name, $arguments, $options, $inputHeaders, $outputHeaders); } catch (Exception $e) { $result = ar::error($e->getMessage(), $e->getCode()); } return $result; }
public function testFTPGetNonExisting() { $prep = [0 => 'a - odd,first', 1 => 'b - even', 2 => 'c - odd', 3 => 'd - even,last']; $list = array('a', 'b', 'c', 'd'); $le = ar::listExpression($list)->pattern('(odd even?)*', " single | first .* last "); foreach ($list as $position => $value) { $line = $value . " - " . implode(',', $le->item($position)); $this->assertEquals($prep[$position], $line); } }
public function testClosureCall() { $result = current(ar::get(TESTBASE . '/closure/')->call('closure.call.html')); $this->assertInternalType('array', $result); $this->assertCount(3, $result); if (is_array($result)) { $values = array_values($result); $this->assertEquals(['closure', 'closure child 1', 'closure child 2'], $values); } }
public function testDelete() { global $AR; $me = $this; ar::context()->callAtPath(TESTBASE . 'file-nls/', function () use($me) { ar_store_files::delete('test', 'nl'); $result = ar_store_files::ls(); $me->assertEquals(count($result), 0); }); }
public function testObjectAllNLS() { global $AR; $obj = current(ar::get(TESTBASE . '/image-nls/image-nls/')->call('system.get.phtml')); foreach ($obj->data->nls->list as $nls => $language) { $content = $obj->getExif(false, true, false, $nls); $content = trim($content['IFD0']['ImageDescription']); $this->assertEquals($nls, $content); } }
public static function info($path = null) { if (!isset($path)) { $path = ar::context()->getPath(); } if (self::$enabled) { return ' data-ar-path="' . htmlspecialchars($path) . '"'; } else { return ''; } }
private function getRows($list) { $nodes = ar_html::nodes(); foreach ($list as $key => $content) { if (!is_array($content)) { $content = array($content); } $cells = $this->getCells($content, 'td')->setAttribute('class', array('tableOddEven' => ar::listPattern('(tableOdd tableEven?)*'), 'tableFirstLast' => ar::listPattern('tableFirst .*', '.* tableLast'))); $nodes[] = ar_html::tag('tr', ar_html::nodes($header, $cells)); } return $nodes; }
function toPng($url) { global $AR; $image = false; if ($AR->Webkit2png->path) { $url = ar::url($url); if ($url->host) { // only allow remote fetches $cmd = $AR->Webkit2png->xvfbPath . ' ' . $AR->Webkit2png->xvfbOptions . ' ' . $AR->Webkit2png->path . ' ' . $AR->Webkit2png->options . ' ' . escapeshellarg((string) $url); //echo $cmd; $image = shell_exec($cmd); } } return $image; }
public static function create($prefix = null, $timeout = 7200) { // this method is used by pinp scripts to create a specific cache // so it must be more restrictive than the constructor of the cacheStore // which must be able to clear any and all caches if (!$prefix) { // make sure you have a default prefix, so you won't clear other prefixes unintended $prefix = 'default'; } $prefix = 'pinp/' . $prefix; // make sure the pinp scripts have their own top level $prefix = $prefix . ar::context()->getPath(); // make sure the cache store is limited to the current path in the context stack try { return new ar_cacheStore($prefix, $timeout); } catch (Exception $e) { return ar_error::raiseError($e->getMessage(), $e->getCode()); } }
public function send($protocol, $target, $message) { // Open socket $socket = @fsockopen($this->host, $this->port, $this->errorNr, $this->errorStr); if ($socket) { if ($this->isSupported($protocol)) { $matches = array("\n", "\r"); $replaces = array("¶", ""); // newlines are \xb6 in the internal multigate protocol. \r is replaced to make sure the socket is not abused. $result = fwrite($socket, str_replace($matches, $replaces, "TOPROTOCOL {$protocol} {$target} {$message}")); if ($result !== false) { return true; } else { $this->errorNr = 42; $this->errorStr = "Couldn't write to Multigate socket."; } } fclose($socket); } return ar::error($this->errorStr, $this->errorNr); }
function initTestData() { global $AR, $ARCurrent, $store_config, $store, $ARConfig; $origAR = clone $AR; $origARCurrent = clone $ARCurrent; $origARConfig = clone $ARConfig; // become admin $AR->user = new object(); $AR->user->data = new object(); $AR->user->data->login = $ARLogin = "******"; /* instantiate the store */ $storetype = $store_config["dbms"] . "store"; $store = new $storetype($root, $store_config); $res = ar::get('/projects/')->call('system.new.phtml', array('arNewType' => 'pproject', 'arNewFilename' => '/projects/{5:id}', 'en' => array('name' => 'Unit test dir (en)' . date(DATE_W3C)), 'nl' => array('name' => 'Unit test dir (nl)' . date(DATE_W3C)), 'de' => array('name' => 'Unit test dir (de)' . date(DATE_W3C)))); $base = current($res); // set grants for testrunner user ar::get($res)->call('system.save.grants.phtml', array("path" => '/system/users/testrunner/', "newgrants" => 'read add edit >delete config layout')); define('TESTBASE', $base); importContent($base, getcwd() . '/www/install/packages/demo.ax'); $AR = $origAR; $ARCurrent = $origARCurrent; $ARConfig = $origARConfig; }
function importTemplate($cpath, $args) { global $store, $axstore; $templatesrc = current($axstore->call('system.get.template.php', $args, $axstore->get($cpath))); $templatedst = current($store->call('system.get.template.php', $args, $store->get($cpath))); if (!$store->exists($cpath)) { // cannot install config on non-existing path print "{$cpath} doesn't exists, skipping\n"; } if (!ar_error::isError($templatesrc)) { if (ar_error::isError($templatedst)) { // error means no template found // save template $args['template'] = $templatesrc; ar::get($cpath)->call('system.save.layout.phtml', $args); } else { print "Already a configfile defined on {$cpath}, please merge the following in your configfile " . $args['function'] . "\n"; print $templatesrc . "\n"; } } else { print "Error src template not found on {$cpath} \n"; } }
public function testParents() { global $AR; $obj = current(ar::get(TESTBASE . 'projects/demo/demo/images/')->call('system.get.phtml')); $parents = $obj->parents('', 'system.get.path.phtml'); $this->assertTrue(in_array(TESTBASE . 'projects/demo/demo/images/', $parents)); $parents = $obj->parents(TESTBASE . 'projects/demo/', 'system.get.path.phtml'); // $top of the test object is TESTBASE.'/projects/demo/demo/ // so the request path is 'above' the $top $this->assertEmpty($parents); $parents = $obj->parents(TESTBASE . 'projects/demo/', 'system.get.path.phtml', array(), TESTBASE . 'projects/demo/'); $this->assertCount(1, $parents); $parents = $obj->parents('', 'system.get.path.phtml', array(), TESTBASE); $this->assertCount(5, $parents); $parents = $obj->parents(TESTBASE . 'projects/', 'system.get.path.phtml', array(), TESTBASE); $this->assertCount(2, $parents); $obj2 = current(ar::get(TESTBASE)->call('system.get.phtml')); $parents2 = $obj2->parents('projects/', 'system.get.path.phtml', array(), TESTBASE); $this->assertCount(2, $parents2); $this->assertEquals($parents, $parents2); $prep = array(TESTBASE, TESTBASE . 'projects/'); $this->assertEquals($prep, $parents); }
function importMissingData($path) { global $ARCurrent, $AR, $ax_config, $store; $importpath = false; echo "== testing for {$path}\n\n"; $res = current(ar::get($path)->call('system.get.phtml')); if (!$res) { print "{$path} does not exists\n"; $importpath = $path; } if ($importpath) { print "importing {$importpath}\n"; $ARCurrent->nolangcheck = true; $ARCurrent->options["verbose"] = true; $ARCurrent->AXAction == "import"; // become admin $AR->user = new object(); $AR->user->data = new object(); $AR->user->data->login = $ARLogin = "******"; $ax_config["writeable"] = false; $ax_config["database"] = "../packages/base.ax"; echo "ax file (" . $ax_config["database"] . ")\n"; set_time_limit(0); $inst_store = $ax_config["dbms"] . "store"; $axstore = new $inst_store("", $ax_config); if (!$axstore->error) { $ARCurrent->importStore =& $store; $args['srcpath'] = $importpath; $args['destpath'] = $importpath; $axstore->call("system.export.phtml", $args, $axstore->get("/")); $error = $axstore->error; $axstore->close(); } else { $error = $axstore->error; } } }
public static function getvar($name = null, $method = null) { /* The full list of field-name characters that PHP converts to _ (underscore) is the following (not just dot): chr(32) ( ) (space) chr(46) (.) (dot) chr(91) ([) (open square bracket) chr(128) - chr(159) (various) PHP irreversibly modifies field names containing these characters in an attempt to maintain compatibility with the deprecated register_globals feature. */ if (isset($name)) { $name = preg_replace("/[ \\.\\[€-Ÿ]/", "_", $name); } switch ($method) { case 'GET': $result = isset($name) ? $_GET[$name] : $_GET; break; case 'POST': $result = isset($name) ? $_POST[$name] : $_POST; break; case 'COOKIE': $result = isset($name) ? $_COOKIE[$name] : $_COOKIE; break; case 'SERVER': $result = isset($name) ? $_SERVER[$name] : $_SERVER; break; default: $result = !isset($name) ? $_REQUEST : (isset($_POST[$name]) ? $_POST[$name] : $_GET[$name]); break; } if (self::$tainting) { ar::taint($result); } return $result; }
public static function fire($eventName, $eventData = array(), $objectType = null, $path = '') { if (!isset(self::$listeners['capture'][$eventName]) && !isset(self::$listeners['listen'][$eventName])) { return $eventData; // no listeners for this event, so dont bother searching } $prevEvent = null; if (self::$event) { $prevEvent = self::$event; } $path = ar::context()->getPath(array('path' => $path)); $me = ar::context()->getObject(array('path' => $path)); if ($me && !isset($objectType)) { $objectType = $me->type; } else { if (!$objectType) { // when set to false to prevent automatic filling of the objectType, reset it to null $objectType = null; } } self::$event = new ar_eventsEvent($eventName, $eventData, $objectType, $path, $me); if (self::walkListeners(self::$listeners['capture'][$eventName], $path, $objectType, true)) { self::walkListeners(self::$listeners['listen'][$eventName], $path, $objectType, false); } if (self::$event->preventDefault) { $result = false; } else { if (self::$event->data) { $result = self::$event->data; } else { $result = true; } } self::$event = $prevEvent; return $result; }
<?php if (($this->CheckLogin('layout') || $this->CheckLogin('layout:read')) && $this->CheckConfig()) { $file = ""; if (isset($this->data->config->pinp[$type][$function][$language])) { $template = $type . "." . $function . "." . $language . ".pinp"; $templates = $this->store->get_filestore("templates"); if ($templates->exists($this->id, $template)) { $ARCurrent->arResult = $templates->read($this->id, $template); } else { $ARCurrent->arResult = ar::error('Template not accessible', 501); } } else { $ARCurrent->arResult = ar::error('Template not found', 404); } }
public function _find($criteria, $function = "list.html", $args = "", $limit = 100, $offset = 0) { $this->error = ''; // remove possible path information (greedy match) if (!$function instanceof \Closure) { $function = basename((string) $function); } $result = $this->store->call($function, $args, $this->store->find($this->path, $criteria, $limit, $offset)); if ($this->store->error) { $this->error = ar::error('' . $this->store->error, 1107, $this->store->error); } return $result; }
public function post($path, $options = array()) { $url = ar::url($this->rootURL . $path . '.json'); $json = $this->client->post($url, $options); if ($json && !ar_error::isError($json)) { return json_decode($json); } else { return $json; } }
protected function handleUpdates($default) { $check = $this->getvar($this->name); //$check = ar('http')->getvar( $this->name ); if (isset($check['Delete'])) { $delete = $check['Delete']; ar::untaint($delete); if ($this->children[$delete]) { unset($this->children[$delete]); } } else { if (isset($check['Add'])) { $addedField = $this->getvar($this->newField->name); //ar('http')->getvar( $this->newField->name ); if ($addedField) { // add a copy of default to the children of this field $newField = $default; $newField['value'] = $addedField; // FIXME: generiek maken $this->children[] = $this->form->parseField(0, $newField); } } } }
$info = parseFile($file); $nlsFiles[$info['file']][$info['nls']] = $info; } unset($files); foreach ($nlsFiles as $basefile => $nlsData) { if (count($nlsData)) { $needsUpgrade[$objectID] = '' . $objectID; } } unset($nlsFiles); foreach ($dirs as $dir) { recurse($dir); } unset($dirs); } recurse($files); sort($needsUpgrade); // in large instalations, the store mysql connction has timed out by now, restarting store global $store, $store_config; $inst_store = $store_config["dbms"] . "store"; $store = new $inst_store($root, $store_config); foreach ($needsUpgrade as $objID) { print "Searching for {$objID}\n"; $result = ar::get('/')->find("id == {$objID}")->call('system.get.phtml'); if (count($result) == 1) { $obj = current($result); print "Upgrading " . $obj->path . "\n<br>"; $obj->call('system.upgrade.filestore.8.4.php'); } } echo "Done with converting nls filestore.<br>\n";
function testArrayAccess() { $base = 'https://www.ariadne-cms.org/'; $url = ar::url($base); $url->query['test']['foo'] = 'bar'; $this->assertEquals('bar', $url->query['test']['foo']); $this->assertEquals($base . '?test%5Bfoo%5D=bar', (string) $url); $url->query->test['bar'] = 'foo'; $this->assertEquals('foo', $url->query->test['bar']); $this->assertEquals($base . '?test%5Bfoo%5D=bar&test%5Bbar%5D=foo', (string) $url); }
echo $this->make_local_url($this->currentsite(), $nls); ?> '; var vdCurrentPath=objectPath; var vdBrowseRoot='<?php echo $vdBrowseRoot; ?> '; var vdSelection = null; var vdSelectionState = null; var tbContentEditOptions = <?php echo json_encode($options); ?> ; var vdOpenMetaPane = <?php echo ar::getvar('vdOpenMeta') ? 'true' : 'false'; ?> ; var vdEditPane; var vdMetaPane; var vdEditorCanvas; var vdEditorFrame; var vdContextBar=false; var vdUndoEnabled=true; var vdMetaDataSlideEnabled=false; var vdHtmlContextHides=false; var vdTableDesigner; var vdLanguages = <?php echo json_encode($AR->nls->list); ?> ;
<?php ar_pinp::allow('ar_connect_rss'); ar::load('xml'); class ar_connect_rss extends arBase { public static function client($url = null, $httpClient = null) { if (!isset($httpClient)) { $httpClient = ar_http::client(); } return new ar_connect_rssClient($url, $httpClient); } public static function parse($xml) { $client = new ar_connect_rssClient(); return $client->parse($xml); } } class ar_connect_rssClient extends ar_xmlDataBinding { private $httpClient = null; private $feed = null; public function __construct($feed = null, $httpClient = null) { $this->feed = $feed; $this->httpClient = $httpClient; if ($feed && $this->httpClient) { $this->get($feed); } }
?> " class="inputline"> </div> <div class="field"> <label for="country" class="required"><?php echo $ARnls["country"]; ?> </label> <select id="country" name="country"> <option value=''><?php echo $ARnls["none"]; ?> </option> <?php $query = "object.parent='/system/addressbook/countries/' and name.nls='" . $nls . "' order by name.value"; $list = ar::get('/system/addressbook/countries/')->find($query)->call('system.get.phtml'); $country = $this->getdata("country", "none"); foreach ($list as $entry) { $selected = $entry->data->value == $country ? 'selected' : ''; printf('<option value="%s" %s>%s</option>', $entry->data->value, $selected, $entry->nlsdata->name); } ?> </select> </div> <div class="field"> <label for="state" class="required"><?php echo $ARnls["state"]; ?> </label> <input id="state" type="text" name="state" value="<?php $this->showdata("state", "none");
public function stripe($options = array()) { $options += array('striping' => ar::listPattern('menuFirst .*', '(menuOdd menuEven?)*', '.* menuLast'), 'stripingContinue' => false); if ($options['striping']) { if ($options['stripingContinue']) { $this->getElementsByTagName($this->options['itemTag'])->setAttribute('class', array('menuStriping' => $options['striping'])); } else { $this->childNodes->setAttribute('class', array('menuStriping' => $options['striping'])); $uls = $this->getElementsByTagName($this->options['listTag']); foreach ($uls as $ul) { $ul->childNodes->setAttribute('class', array('menuStriping' => $options['striping'])); } } } $this->stripeOptions = $options; return $this; }
} $args = array("path" => $this instanceof \pshortcut && $this->data->path && ar::exists($this->data->path) ? $this->data->path : $this->path, "query" => '', "limit" => $items_per_page, "offset" => $offset, "sanity" => true, "order" => $orderQuery, "view" => $viewtype, "total" => ar::ls()->count(), "template" => 'system.list.entry.php', "args" => array("columns" => $colDefs), "filters" => array(), "method" => "post"); $args['parent'] = $args['path']; $eventData = ar_events::fire('ariadne:onFilterGather', $args); $eventData = ar_events::fire('ariadne:onFilter', $eventData); if ($eventData) { $query = $eventData['query']; if ($eventData['parent'] && $query) { $query = sprintf('object.parent="%s" and ( %s )', $eventData['parent'], $query); } else { if (!$query) { $query = sprintf('object.parent="%s"', $eventData['parent'] ? $eventData['parent'] : $eventData['path']); } } $object_list = ar::get($eventData['path'])->find($query)->limit($eventData['limit'])->offset($eventData['offset'])->order($eventData['order'])->call($eventData['template'], $eventData['args']); $object_count = ar::get($eventData['path'])->find($query)->limit($eventData['limit'])->offset($eventData['offset'])->order($eventData['order'])->count(); $divId = "resultsDiv"; $tableId = "resultsTable"; $colDefs = $eventData['args']['columns']; foreach ($colDefs as $colKey => $colDef) { if ($colDef['hide']) { unset($colDefs[$colKey]); } else { $colDefs[$colKey] = array_merge($colDef, ['key' => $colKey]); } } $colDefs = array_values($colDefs); $viewtype = $eventData['view']; $items_per_page = $eventData['limit']; $current_page = 1 + floor($eventData['offset'] / $eventData['limit']); if ($viewtype == "details") {
<?php $ARCurrent->nolangcheck = true; $ARCurrent->allnls = true; if ($this->CheckLogin("read") && $this->CheckConfig()) { require_once $this->store->get_config("code") . "modules/mod_yui.php"; if ($AR->user->data->language) { ldSetNls($AR->user->data->language); } $wwwroot = $AR->dir->www; $menuitems = array(array('label' => $ARnls['ariadne:logoff'], 'iconalt' => $ARnls['ariadne:logoff'], 'icon' => $AR->dir->images . 'icons/medium/logout.png', 'href' => $this->make_ariadne_url() . 'logoff.php'), array('label' => $ARnls['ariadne:search'], 'iconalt' => $ARnls['ariadne:search'], 'icon' => $AR->dir->images . 'icons/small/search.png', 'onclick' => "muze.ariadne.explore.toolbar.searchwindow(); return false;", 'href' => $this->make_ariadne_url() . 'dialog.search.php'), array('label' => $ARnls['ariadne:folders'], 'iconalt' => $ARnls['ariadne:folders'], 'icon' => $AR->dir->images . 'icons/small/view_tree.png', 'href' => "#", 'onclick' => 'muze.ariadne.explore.tree.toggle(); return false;'), array('label' => $ARnls['ariadne:preferences'], 'iconalt' => $ARnls['ariadne:preferences'], 'icon' => $AR->dir->images . 'icons/small/preferences.png', 'onclick' => "muze.ariadne.explore.arshow('dialog.preferences','" . $this->store->get_config('root') . $AR->user->path . "dialog.preferences.php'); return false;", 'href' => $this->make_ariadne_url($AR->user->path) . "dialog.preferences.php"), array('iconalt' => $ARnls['ariadne:iconview'], 'icon' => $AR->dir->images . 'icons/small/view_icon.png', 'onclick' => 'return false;', 'submenu' => array(array('href' => "javascript:muze.ariadne.explore.viewpane.setviewmode('list');", 'label' => $ARnls['ariadne:small']), array('href' => "javascript:muze.ariadne.explore.viewpane.setviewmode('icons');", 'label' => $ARnls['ariadne:large']), array('href' => "javascript:muze.ariadne.explore.viewpane.setviewmode('details');", 'label' => $ARnls['ariadne:details']))), array('iconalt' => $ARnls['ariadne:help'], 'icon' => $AR->dir->images . 'icons/small/help.png', 'onclick' => 'return false;', 'submenu' => array(array('href' => "#", 'onclick' => "muze.ariadne.explore.arshow('help', 'http://www.ariadne-cms.org/docs/'); return false;", 'label' => $ARnls['ariadne:help']), array('href' => "#", 'onclick' => "muze.ariadne.explore.arshow('help.about','help.about.php'); return false;", 'label' => $ARnls['ariadne:about']))), array('iconalt' => $ARnls['ariadne:up'], 'icon' => $AR->dir->images . 'icons/small/up.png', 'href' => $this->make_ariadne_url($this->parent) . "explore.html", 'onclick' => "muze.ariadne.explore.toolbar.viewparent(); return false;", 'id' => "viewparent")); ar::call('ariadne.logo.html'); ?> <?php echo yui::yui_menuitems($menuitems, "yuimenubar", "explore_menubar") . "\n"; ?> <div class="searchdiv"> <form action="explore.html" onsubmit="muze.ariadne.explore.toolbar.searchsubmit(this.arPath.value); return false;"> <div> <input size="30" id="searchpath" class="text searchpath" type="text" name="arPath" value="<?php echo $this->path; ?> "> <input type="image" src="<?php echo $AR->dir->www; ?> images/icons/small/go.png" title="<?php echo htmlspecialchars($ARnls['ariadne:search']); ?> " id="searchbutton" name="searchsubmit" value="<?php echo $ARnls["ariadne:search"];