Ejemplo n.º 1
1
function getEventbriteEvents($eb_keywords, $eb_city, $eb_proximity)
{
    global $eb_app_key;
    $xml_url = "https://www.eventbrite.com/xml/event_search?...&within=50&within_unit=M&keywords=" . $eb_keywords . "&city=" . $eb_city . "&date=This+month&app_key=" . $eb_app_key;
    echo $xml_url . "<br />";
    $xml = simplexml_load_file($xml_url);
    $count = 0;
    // loop over events from eventbrite xml
    foreach ($xml->event as $event) {
        // add event if it doesn't already exist
        $event_query = mysql_query("SELECT * FROM events WHERE id_eventbrite={$event->id}") or die(mysql_error());
        if (mysql_num_rows($event_query) == 0) {
            echo $event_id . " ";
            // get event url
            foreach ($event->organizer as $organizer) {
                $event_organizer_url = $organizer->url;
            }
            // get event address
            foreach ($event->venue as $venue) {
                $event_venue_address = $venue->address;
                $event_venue_city = $venue->city;
                $event_venue_postal_code = $venue->postal_code;
            }
            // get event title
            $event_title = str_replace(array("\r\n", "\r", "\n"), ' ', $event->title);
            // add event to database
            mysql_query("INSERT INTO events (id_eventbrite, \n                                      title,\n                                      created, \n                                      organizer_name, \n                                      uri, \n                                      start_date, \n                                      end_date, \n                                      address\n                                      ) VALUES (\n                                      '{$event->id}',\n                                      '" . parseInput($event_title) . "',\n                                      '" . strtotime($event->created) . "',\n                                      '" . trim(parseInput($event->organizer->name)) . "',\n                                      '{$event_organizer_url}',\n                                      '" . strtotime($event->start_date) . "',\n                                      '" . strtotime($event->end_date) . "',\n                                      '{$event_venue_address}, {$event_venue_city}, {$event_venue_postal_code}'\n                                      )") or die(mysql_error());
        }
        $count++;
    }
}
 /**
  * Add an xml file to the bean definition
  * @param $xml
  * @param $relatifPath
  * @return unknown_type
  */
 public function addConfig($xmlFile)
 {
     $xmlFile = $this->getFullPath($xmlFile);
     $xml = @simplexml_load_file($xmlFile);
     if ($xml == false) {
         $str = "Error parsing file (" . libxml_get_last_error()->file . ") on line (" . libxml_get_last_error()->line . ") : " . libxml_get_last_error()->message;
         echo $str;
         throw new \org\equinox\exception\EquinoxException($str);
     }
     $currentContextPath = dirname($xmlFile);
     foreach ($xml->{'component-scan'} as $scan) {
         $this->getComponentScan()->scanPackage((string) $scan['base-package']);
     }
     foreach ($xml->{'ini-file'} as $iniFile) {
         $this->addIniFile($currentContextPath, $iniFile);
     }
     foreach ($xml->bean as $bean) {
         $this->addBean($bean, $xmlFile);
     }
     foreach ($xml->import as $import) {
         $resource = $currentContextPath . '/' . (string) $import['resource'];
         $this->addConfig($resource);
     }
     foreach ($xml->modules as $module) {
         $this->loadModules($this->applicationContext->getIniValue((string) $module->iniValue));
     }
 }
Ejemplo n.º 3
0
 /**
  * Retrieves the XML geocode address lookup.
  * ! Results of this method are cached for 1 day.
  *
  * @param string $address adress
  * @return object SimpleXML
  */
 public static function address_to_xml($address)
 {
     static $cache;
     // Load Cache
     if ($cache === NULL) {
         $cache = Cache::instance();
     }
     // Address cache key
     $key = 'gmap-address-' . sha1($address);
     if ($xml = $cache->get($key)) {
         // Return the cached XML
         return simplexml_load_string($xml);
     } else {
         // Set the XML URL
         $xml = Gmap::api_url('maps/geo', array('output' => 'xml', 'q' => $address), '&');
         // Disable error reporting while fetching the feed
         $ER = error_reporting(~E_NOTICE);
         // Load the XML
         $xml = simplexml_load_file($xml);
         if (is_object($xml) and $xml instanceof SimpleXMLElement and (int) $xml->Response->Status->code === 200) {
             // Cache the XML
             $cache->set($key, $xml->asXML(), array('gmaps'), 86400);
         } else {
             // Invalid XML response
             $xml = FALSE;
         }
         // Turn error reporting back on
         error_reporting($ER);
     }
     return $xml;
 }
Ejemplo n.º 4
0
 /**
  * Returns array of simple xml objects, where key is a handle name
  *
  * @return SimpleXmlElement[]
  * @throws RuntimeException in case of load error (malformed xml, etc)
  */
 public function load()
 {
     $this->validate();
     $original = libxml_use_internal_errors(true);
     $simpleXmlElement = simplexml_load_file($this->filePath);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     libxml_use_internal_errors($original);
     if ($simpleXmlElement === false) {
         $messages = array();
         foreach ($errors as $error) {
             $messages[] = sprintf('%s, line %s, column %s', trim($error->message), $error->line, $error->column);
         }
         throw new RuntimeException(sprintf('File "%s" has a malformed xml structure: %s', $this->filePath, PHP_EOL . implode(PHP_EOL, $messages)));
     }
     $stringXml = array();
     // First convert all elements to string,
     // as in xml file can be multiple string with the same handle names
     foreach ($simpleXmlElement->children() as $key => $element) {
         if (!isset($stringXml[$key])) {
             $stringXml[$key] = '';
         }
         foreach ($element->children() as $child) {
             $stringXml[$key] .= $child->asXml();
         }
     }
     $result = array();
     foreach ($stringXml as $key => $xml) {
         $result[$key] = simplexml_load_string(sprintf('<%1$s>%2$s</%1$s>', $key, $xml));
     }
     return $result;
 }
Ejemplo n.º 5
0
 public function ApplyChanges()
 {
     parent::ApplyChanges();
     $this->RegisterAction('Volume', 'Lautstärke', $typ = 1, $profil = '');
     $this->RegisterAction('Mute', 'Stumm', $typ = 0, $profil = 'RPC.OnOff');
     $this->RegisterVariableInteger('GroupMember', 'Gruppe', 0);
     if ($this->CheckConfig() === true) {
         $zoneConfig = IPS_GetKernelDir() . '/modules/ips2rpc/sonos_zone.config';
         if (!file_exists($zoneConfig)) {
             $file = $this->API()->BaseUrl(true) . '/status/topology';
             if ($xml = simplexml_load_file($file)) {
                 $out = [];
                 foreach ($xml->ZonePlayers->ZonePlayer as $item) {
                     if ($v = (array) $item->attributes()) {
                         $v = array_shift($v);
                     }
                     $v['name'] = (string) $item;
                     $out[$v['name']] = $v;
                 }
                 file_put_contents($zoneConfig, serialize($out));
             }
         }
         $this->Update();
     }
 }
Ejemplo n.º 6
0
    /**
	 * Get the list of commands
	 *
	 * Will attempt to use information from the xml manifest if possible
	 *
	 * @return  array
	 */
	public function getCommands()
	{
	    $name     = $this->getController()->getIdentifier()->name;
	    $package  = $this->_identifier->package;
	    $manifest = JPATH_ADMINISTRATOR.'/components/com_'.$package.'/manifest.xml';

	    if(file_exists($manifest))
	    {
	        $xml = simplexml_load_file($manifest);
	        
	        if(isset($xml->administration->submenu)) 
	        {
	            foreach($xml->administration->submenu->children() as $menu)
	            {
	                $view = (string)$menu['view'];
	                
	                $this->addCommand(JText::_((string)$menu), array(
	            		'href'   => JRoute::_('index.php?option=com_'.$package.'&view='.$view),
	            		'active' => ($name == KInflector::singularize($view))
	                ));
	            }
	        }
	    }
	
	    return parent::getCommands();   
	}
Ejemplo n.º 7
0
/**
* Generates plugin XML
* This command generates the necessary files and configuration 
* to "plugin" to a preexisting Magento 2 object manager object. 
*
*     pestle.phar generate_plugin_xml Pulsestorm_Helloworld 'Magento\Framework\Logger\Monolog' 'Pulsestorm\Helloworld\Plugin\Magento\Framework\Logger\Monolog'
* 
* @argument module_name Create in which module? [Pulsestorm_Helloworld]
* @argument class Which class are you plugging into? [Magento\Framework\Logger\Monolog]
* @argument class_plugin What's your plugin class name? [<$module_name$>\Plugin\<$class$>]
* @command generate_plugin_xml
*/
function pestle_cli($argv)
{
    // $module_info = askForModuleAndReturnInfo($argv);
    $module_info = getModuleInformation($argv['module_name']);
    $class = $argv['class'];
    $class_plugin = $argv['class_plugin'];
    $path_di = $module_info->folder . '/etc/di.xml';
    if (!file_exists($path_di)) {
        $xml = simplexml_load_string(getBlankXml('di'));
        writeStringToFile($path_di, $xml->asXml());
        output("Created new {$path_di}");
    }
    $xml = simplexml_load_file($path_di);
    //     $plugin_name    = strToLower($module_info->name) . '_' . underscoreClass($class);
    //     simpleXmlAddNodesXpath($xml,
    //         "/type[@name=$class]/plugin[@name=$plugin_name,@type=$class_plugin]");
    $type = $xml->addChild('type');
    $type->addAttribute('name', $class);
    $plugin = $type->addChild('plugin');
    $plugin->addAttribute('name', strToLower($module_info->name) . '_' . underscoreClass($class));
    $plugin->addAttribute('type', $class_plugin);
    writeStringToFile($path_di, formatXmlString($xml->asXml()));
    output("Added nodes to {$path_di}");
    $path_plugin = getPathFromClass($class_plugin);
    $body = implode("\n", ['    //function beforeMETHOD($subject, $arg1, $arg2){}', '    //function aroundMETHOD($subject, $procede, $arg1, $arg2){return $proceed($arg1, $arg2);}', '    //function afterMETHOD($subject, $result){return $result;}']);
    $class_definition = str_replace('<$body$>', "\n{$body}\n", createClassTemplate($class_plugin));
    writeStringToFile($path_plugin, $class_definition);
    output("Created file {$path_plugin}");
}
Ejemplo n.º 8
0
 /**
  * Create main page of the site and set rights for it.
  *
  * @param int $id Site ID.
  */
 private function createMainPage($id)
 {
     //Ищем в перечне шаблонов модуля по которому создан сайт, шаблоны отмеченные аттрибутом default
     //если не находим - берем default.[type].xml
     //а если и такого нет - берем шаблон default.[type].xml из ядра ..а что делать?
     $module = $this->getData()->getFieldByName('site_folder')->getRowData(0);
     $content = $layout = false;
     foreach (array('content', 'layout') as $type) {
         foreach (glob(implode(DIRECTORY_SEPARATOR, array(SITE_DIR, self::MODULES, $module, 'templates', $type, '*'))) as $path) {
             if ($xml = simplexml_load_file($path)) {
                 $attrs = $xml->attributes();
                 if (isset($attrs['default'])) {
                     ${$type} = $module . '/' . basename($path);
                     break;
                 }
             }
         }
         if (!${$type} && file_exists(implode(DIRECTORY_SEPARATOR, array(SITE_DIR, self::MODULES, $module, 'templates', $type, 'default.' . $type . '.xml')))) {
             ${$type} = $module . '/' . 'default.' . $type . '.xml';
         }
         if (!${$type}) {
             ${$type} = 'default.' . $type . '.xml';
         }
         //Если шаблона там не окажется
         //та пошло оно в жопу ...это ж не для ядерного реактора ПО
     }
     $translationTableName = 'share_sites_translation';
     //Если не задан параметр конфигурации  - создаем одну страницу
     $smapId = $this->dbh->modify(QAL::INSERT, 'share_sitemap', array('smap_content' => $content, 'smap_layout' => $layout, 'site_id' => $id, 'smap_segment' => QAL::EMPTY_STRING));
     foreach ($_POST[$translationTableName] as $langID => $siteInfo) {
         $this->dbh->modify(QAL::INSERT, 'share_sitemap_translation', array('lang_id' => $langID, 'smap_id' => $smapId, 'smap_name' => $siteInfo['site_name']));
     }
     //права берем ориентируясь на главную страницу дефолтного сайта
     $this->dbh->modify('INSERT IGNORE INTO share_access_level ' . '(smap_id, right_id, group_id) ' . 'SELECT %s, al.right_id, al.group_id ' . 'FROM `share_access_level` al ' . 'LEFT JOIN share_sitemap s ON s.smap_id = al.smap_id ' . 'WHERE s.smap_pid is NULL AND site_id= %s', $smapId, E()->getSiteManager()->getDefaultSite()->id);
 }
 private function __construct($strPath)
 {
     if (!file_exists($strPath)) {
         throw new Exception("Plugin config file does not exist: " . $strPath);
     }
     $this->mixPluginSet = simplexml_load_file($strPath);
 }
Ejemplo n.º 10
0
 /**
  * Checks which edition is used
  * @return int
  */
 public static function getPlatform()
 {
     if (self::$_platform == -1) {
         $pathToClaim = BP . DS . "app" . DS . "etc" . DS . "modules" . DS . self::ENTERPRISE_DETECT_COMPANY . "_" . self::ENTERPRISE_DETECT_EXTENSION . ".xml";
         $pathToEEConfig = BP . DS . "app" . DS . "code" . DS . "core" . DS . self::ENTERPRISE_DETECT_COMPANY . DS . self::ENTERPRISE_DETECT_EXTENSION . DS . "etc" . DS . "config.xml";
         $isCommunity = !file_exists($pathToClaim) || !file_exists($pathToEEConfig);
         if ($isCommunity) {
             self::$_platform = self::CE_PLATFORM;
         } else {
             $_xml = @simplexml_load_file($pathToEEConfig, 'SimpleXMLElement', LIBXML_NOCDATA);
             if (!$_xml === FALSE) {
                 $package = (string) $_xml->default->design->package->name;
                 $theme = (string) $_xml->install->design->theme->default;
                 $skin = (string) $_xml->stores->admin->design->theme->skin;
                 $isProffessional = $package == self::PROFESSIONAL_DESIGN_NAME && $theme == self::PROFESSIONAL_DESIGN_NAME && $skin == self::PROFESSIONAL_DESIGN_NAME;
                 if ($isProffessional) {
                     self::$_platform = self::PE_PLATFORM;
                     return self::$_platform;
                 }
             }
             self::$_platform = self::EE_PLATFORM;
         }
     }
     return self::$_platform;
 }
Ejemplo n.º 11
0
/**
* Creates a Route XML
* generate_route module area id 
* @command generate_route
*/
function pestle_cli($argv)
{
    $module_info = askForModuleAndReturnInfo($argv);
    $module = $module_info->name;
    $legend = ['frontend' => 'standard', 'adminhtml' => 'admin'];
    $areas = array_keys($legend);
    $area = inputOrIndex('Which area? [frontend, adminhtml]', 'frontend', $argv, 1);
    $router_id = $legend[$area];
    if (!in_array($area, $areas)) {
        throw new Exception("Invalid areas");
    }
    $frontname = inputOrIndex('Frontname/Route ID?', null, $argv, 2);
    $route_id = $frontname;
    $path = $module_info->folder . '/etc/' . $area . '/routes.xml';
    if (!file_exists($path)) {
        $xml = simplexml_load_string(getBlankXml('routes'));
        writeStringToFile($path, $xml->asXml());
    }
    $xml = simplexml_load_file($path);
    simpleXmlAddNodesXpath($xml, "router[@id={$router_id}]/" . "route[@id={$route_id},@frontName={$frontname}]/" . "module[@name={$module}]");
    writeStringToFile($path, formatXmlString($xml->asXml()));
    $class = str_replace('_', '\\', $module) . '\\Controller\\Index\\Index';
    $controllerClass = createControllerClass($class, $area);
    $path_controller = getPathFromClass($class);
    writeStringToFile($path_controller, $controllerClass);
    output($path);
    output($path_controller);
}
Ejemplo n.º 12
0
 public function import_file($filename, $filetype = "xml", $destdir = "")
 {
     // test sur validité du paramètre filename et type
     if ($filename == "" || $filename == null) {
         throw new odException("Class : odImportExport - Method : import_file - Error : give a good filename to import");
     }
     if (!file_exists($filename)) {
         throw new odException("Class : odImportExport - Method : import_file - Error : " . $filename . " does'nt exists");
     }
     if ($filetype == null || $filetype == "") {
         throw new odException("Class : odImportExport - Method : import_file - Error : give a good filename type to import");
     }
     // cas des fichiers xml
     switch ($filetype) {
         case "xml":
             $xml = simplexml_load_file($filename, null, LIBXML_NOCDATA);
             $json = json_encode($xml);
             $xml_tree = json_decode($json, TRUE);
             if (isset($xml_tree["drops"])) {
                 $drops = $xml_tree["drops"]["drop_request"];
             } else {
                 $drops = array();
             }
             if (isset($xml_tree["creates"])) {
                 $creates = $xml_tree["creates"]["create_request"];
             } else {
                 $creates = array();
             }
             if (isset($xml_tree["deletes"])) {
                 $deletes = $xml_tree["deletes"]["delete_request"];
             } else {
                 $deletes = array();
             }
             if (isset($xml_tree["inserts"])) {
                 $inserts = $xml_tree["inserts"]["insert_request"];
             } else {
                 $inserts = array();
             }
             $all_requests = array();
             $all_requests = array_merge($all_requests, $drops);
             $all_requests = array_merge($all_requests, $deletes);
             $all_requests = array_merge($all_requests, $creates);
             $all_requests = array_merge($all_requests, $inserts);
             // Instanciation de l'outil de fabrication des requêtes
             $request = odDatabaseRequest::getInstance();
             // Utilisation de la base concernée
             $request->makeRequest("USE " . $this->_basename);
             $result = $request->runQuery();
             foreach ($all_requests as $req) {
                 $request->makeRequest(str_replace("\n", "", $req));
                 $request->runQuery();
             }
             break;
         case "zip":
             odZip::unZip($filename, $destdir);
             break;
         default:
             throw new odException("Class : odImportExport - Method : import_file - Error : bad type (" . $type . ") for filename : " . $filename);
     }
 }
Ejemplo n.º 13
0
/**
* Generates Magento 2 Observer
* This command generates the necessary files and configuration to add 
* an event observer to a Magento 2 system.
*
*    pestle.phar generate_observer Pulsestorm_Generate controller_action_predispatch pulsestorm_generate_listener3 'Pulsestorm\Generate\Model\Observer3'
*
* @command generate_observer
* @argument module Full Module Name? [Pulsestorm_Generate]
* @argument event_name Event Name? [controller_action_predispatch]
* @argument observer_name Observer Name? [<$module$>_listener]
* @argument model_name Class Name? [<$module$>\Model\Observer]
*/
function pestle_cli($argv)
{
    $module = $argv['module'];
    $event_name = $argv['event_name'];
    $observer_name = $argv['observer_name'];
    $model_name = $argv['model_name'];
    $method_name = 'execute';
    $path_xml_event = initilizeModuleConfig($module, 'events.xml', 'urn:magento:framework:Event/etc/events.xsd');
    $xml = simplexml_load_file($path_xml_event);
    $nodes = $xml->xpath('//event[@name="' . $event_name . '"]');
    $node = array_shift($nodes);
    $event = $node;
    if (!$node) {
        $event = $node ? $node : $xml->addChild('event');
        $event->addAttribute('name', $event_name);
    }
    $observer = $event->addChild('observer');
    $observer->addAttribute('name', $observer_name);
    $observer->addAttribute('instance', $model_name);
    // $observer->addAttribute('method',   $method_name);
    output("Creating: {$path_xml_event}");
    $path = writeStringToFile($path_xml_event, $xml->asXml());
    output("Creating: {$model_name}");
    $contents = createClassTemplate($model_name, false, '\\Magento\\Framework\\Event\\ObserverInterface');
    $contents = str_replace('<$body$>', "\n" . '    public function execute(\\Magento\\Framework\\Event\\Observer $observer){exit(__FILE__);}' . "\n", $contents);
    createClassFile($model_name, $contents);
}
Ejemplo n.º 14
0
 public function index()
 {
     $this->data = $this->load->language('extension/payment');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
     $this->data['success'] = $this->build->data('success', $this->session->data);
     $this->data['error_warning'] = $this->build->data('warning', $this->error);
     $this->load->model('extension/extension');
     $extensions = $this->model_extension_extension->getInstalled('payment');
     foreach ($extensions as $key => $value) {
         if (!file_exists(DIR_EXTENSION . 'payment/' . $value . '/controller/' . $value . '.php')) {
             $this->model_extension_extension->uninstall('payment', $value);
             unset($extensions[$key]);
         }
     }
     $this->data['extensions'] = array();
     $files = glob(DIR_EXTENSION . 'payment/*', GLOB_ONLYDIR);
     if ($files) {
         foreach ($files as $file) {
             $extension = basename($file);
             $this->load->language('payment/' . $extension . '/' . $extension);
             $xml = simplexml_load_file(DIR_EXTENSION . 'payment/' . $extension . '/details.xml');
             $this->data['extensions'][] = array('name' => $this->language->get('heading_title'), 'author' => $xml->author, 'url' => $xml->url, 'version' => $xml->version, 'email' => $xml->email, 'code' => $extension, 'status' => $this->config->get($extension . '_status'), 'sort_order' => $this->config->get($extension . '_sort_order'), 'edit' => $this->url->link('payment/' . $extension . '/' . $extension, 'token=' . $this->session->data['token'], 'SSL'), 'install' => $this->url->link('extension/payment/install', 'token=' . $this->session->data['token'] . '&extension=' . $extension, 'SSL'), 'uninstall' => $this->url->link('extension/payment/uninstall', 'token=' . $this->session->data['token'] . '&extension=' . $extension, 'SSL'), 'installed' => in_array($extension, $extensions));
         }
     }
     $this->data['token'] = $this->session->data['token'];
     $this->data['header'] = $this->load->controller('common/header');
     $this->data['footer'] = $this->load->controller('common/footer');
     $this->response->setOutput($this->render('extension/payment.tpl'));
 }
Ejemplo n.º 15
0
 public function compute($XMLfile)
 {
     $doc = simplexml_load_file($XMLfile);
     foreach ($doc->patch_list->patch as $patch) {
         $tab = array();
         $last = 0;
         $i = 0;
         foreach ($patch->children() as $op) {
             $rang = (int) $op["position"];
             if ($op->getName() == "insert") {
                 $tab[$rang]["insert"][] = $op;
             } else {
                 $tab[$rang]["delete"][] = $op;
             }
         }
         $delta = 0;
         $this->clock = utils::getNextClock();
         foreach ($tab as $rang => $liste_op) {
             $ligne = $rang + 1 + $delta;
             $nb_ins = isset($liste_op["insert"]) ? count($liste_op["insert"]) : 0;
             $nb_del = isset($liste_op["delete"]) ? count($liste_op["delete"]) : 0;
             for ($i = 0; $i < $nb_del; $i++) {
                 $logoot_op = $this->generate_del_line($ligne, $liste_op["delete"][$i]);
             }
             if ($nb_ins > 0) {
                 $logoot_op_list = $this->generate_ins_text($ligne, $liste_op["insert"]);
             }
             $delta += $nb_ins - $nb_del;
         }
     }
 }
 function __construct()
 {
     date_default_timezone_set('Asia/Manila');
     session_start();
     if (!file_exists(__DIR__ . '/../assets/xml/settings.xml')) {
         $newXml = fopen(__DIR__ . '/../assets/xml/settings.xml', 'w');
         fwrite($newXml, '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL);
         fwrite($newXml, '<settings><setting name="hostname" value="localhost"/><setting name="username" value="root"/><setting name="password" value=""/><setting name="database" value="law_election_database"/></settings>');
         fclose($newXml);
     }
     $xml = simplexml_load_file(__DIR__ . '/../assets/xml/settings.xml');
     foreach ($xml->setting as $setting) {
         if ($setting['name'] == 'hostname') {
             $this->host = $setting['value'];
         } else {
             if ($setting['name'] == 'username') {
                 $this->username = $setting['value'];
             } else {
                 if ($setting['name'] == 'password') {
                     $this->password = $setting['value'];
                 } else {
                     if ($setting['name'] == 'database') {
                         $this->database = $setting['value'];
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
 function getEvents($feedURL, $maxItems = 10, $backfill = 0)
 {
     $eventsXML = simplexml_load_file($feedURL);
     if (!$eventsXML) {
         echo 'Visit events.uoit.ca to see all events.';
     }
     $minItems = 5;
     $itemCount = 1;
     foreach ($eventsXML->channel->item as $event) {
         if ($itemCount <= $maxItems) {
             $title = $event->title;
             $description = $event->description;
             $url = $event->link;
             $unixdate = $event->date;
             $date = new DateTime();
             $date->setTimestamp((int) $unixdate);
             $monthDisplay = $date->format('M');
             $dayDisplay = $date->format('d');
             $time = $event->time;
             $location = $event->location;
             echo "<li data-equalizer style='display:block;float:none;width:100%;padding:0;'>\n\t\t\t\t    \t<a href='" . $url . "' target='_blank'>\n\t\t\t\t        <p class='event_date' data-equalizer-watch>" . $monthDisplay . "\n\t\t\t\t            <span>" . $dayDisplay . "</span>\n\t\t\t\t        </p>\n\t\t\t\t        <p class='event_info' data-equalizer-watch>\n\t\t\t\t          <span class='event_title'>" . $title . "</span>\n\t\t\t\t          <span class='event_time'>" . $location . "\n\t\t\t\t          <br>" . $time . "</span>\n\t\t\t\t        </p>\n\t\t\t\t      </a>\n\t\t\t\t    </li>";
             $itemCount++;
         }
     }
     if ($itemCount <= 5 && $backfill == '1') {
         getEvents("http://events.uoit.ca/api/v1/rss");
     }
 }
Ejemplo n.º 18
0
 private function getCoverPath()
 {
     //Find opf file
     $xmlfile = findFile($this->uploadPath . 'temp/' . $this->id, "*.opf");
     //Load opf as simplexml
     $values = simplexml_load_file($xmlfile);
     $values->registerXPathNamespace('ns', current($values->getNamespaces(true)));
     //Find metadata cover
     $cover = current($values->xpath("//ns:metadata/ns:meta[@name='cover']")[0]['content']);
     //If Metadata does not point to to file, loat manifest Item it points to
     if (!preg_match("/\\w+\\.\\w{3,4}?/", $cover)) {
         //If manifest Item does not exist, creates one new
         if (!$values->xpath("//ns:manifest/ns:item[@id='" . $cover . "']")) {
             $manifestNode = $values->xpath("//ns:manifest")[0];
             $itemNode = $manifestNode->addChild("item");
             $itemNode->addAttribute('id', "{$cover}");
             $itemNode->addAttribute('media-type', 'image/jpeg');
             $itemNode->addAttribute('href', 'cover.jpg');
         }
         //Load manifest Item
         $cover = current($values->xpath("//ns:manifest/ns:item[@id='{$cover}']")[0]['href']);
     }
     //Build cover full path
     preg_match("/.*\\//", $xmlfile, $matches);
     $cover = $matches[0] . $cover;
     //Save changed opf file
     $values->asXml($xmlfile);
     //Return cover path
     return $cover;
 }
Ejemplo n.º 19
0
 /**
  * @dataProvider xmlDataProvider
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Root node could not be unset.
  */
 public function testGetParent($xmlData)
 {
     /** @var $xml \Magento\Framework\Simplexml\Element */
     $xml = simplexml_load_file($xmlData[0], $xmlData[1]);
     $this->assertTrue($xml->getName() == 'root');
     $xml->unsetSelf();
 }
Ejemplo n.º 20
0
 public function cron()
 {
     if ($files = Mage::helper('cachewarm')->getMaps()) {
         Mage::helper('cachewarm')->unsMaps();
         foreach ($files as $file) {
             if (file_exists($file)) {
                 $xml = simplexml_load_file($file);
                 foreach ($xml as $sectionName => $sectionData) {
                     if ($sectionName == "url") {
                         try {
                             Mage::log($sectionData->loc, null, 'cachewarm.log', true);
                             $ch = curl_init();
                             curl_setopt($ch, CURLOPT_URL, (string) $sectionData->loc);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                             curl_exec($ch);
                             curl_close($ch);
                         } catch (Exception $e) {
                             Mage::logException($e);
                             Mage::log('error: ' . $e->getMessage(), null, 'cachewarm.log', true);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
    /**
     * Create auth adapter
     *
     * @param string $rolefile File containing XML with users and roles
     */
    public function __construct($rolefile)
    {
        $this->acl = new Acl();
        $xml = simplexml_load_file($rolefile);
/*
Roles file format:
 <roles>
   <role id=”admin”>
        <user name=”user1” password=”pwd”/>
    </role>
   <role id=”hr”>
        <user name=”user2” password=”pwd2”/>
    </role>
</roles>
*/
        foreach($xml->role as $role) {
            $this->acl->addRole(new Role\GenericRole((string)$role["id"]));
            foreach($role->user as $user) {
                $this->users[(string)$user['name']] = array(
                    'password' => (string)$user['password'],
                    'role'     => (string)$role['id']
                );
            }
        }
    }
Ejemplo n.º 22
0
 public function loadDescriptor($path)
 {
     if (($xml = @simplexml_load_file($path)) === false) {
         throw new Bc_Application_Plugin_Dao_Exception('Path ' . $path . ' not found');
     }
     return new Bc_Application_Plugin_Descriptor($xml);
 }
Ejemplo n.º 23
0
 public function getInput()
 {
     global $gantry;
     $gantry->addScript($gantry->gantryUrl . '/admin/widgets/tips/js/tips.js');
     $xmlist = $gantry->templatePath . '/admin/tips/' . $this->element['tab'] . '.xml';
     if (!file_exists($xmlist)) {
         die($xmlist . ' file not found');
     }
     $xml = simplexml_load_file($xmlist);
     $count = count($xml);
     $random = rand(0, $count - 1);
     $output = "\n\t\t<div class=\"gantrytips\">\n\n\t\t\t<div class=\"gantry-pin\"></div>\n\n\t\t\t<div class=\"gantrytips-controller\">\n\n\t\t\t\t<div class=\"gantrytips-arrow gantrytips-left\">&#x25c0;</div>\n\n\t\t\t\t<div class=\"gantrytips-middle\"><span><span class=\"current-tip\">" . ($random + 1) . "</span> / " . $count . "</span></div>\n\n\t\t\t\t<div class=\"gantrytips-arrow gantrytips-right\">&#x25b6;</div>\n\n\t\t\t</div>\n\n\t\t\t<div class=\"gantrytips-desc\">\n\n\t\t\t\t<div class=\"gantrytips-wrapper\">\n";
     for ($i = 0; $i < $count; $i++) {
         $tip_title = $xml->tip[$i]['label'];
         $tip_id = isset($xml->tip[$i]['id']) ? $xml->tip[$i]['id'] : false;
         $cls = $i != $random ? ' style="visibility: hidden; opacity: 0;"' : ' style="visibility: visible; opacity: 1;"';
         if (!$tip_id) {
             $outputID = '';
         } else {
             $outputID = 'id="tip-' . str_replace('-', '_', $tip_id) . '"';
         }
         $output .= "<div " . $outputID . " class=\"gantrytips-tip\"" . $cls . ">\n";
         $output .= "<div class=\"gantrytips-bar h2bar\">\n\n\t\t\t\t\t<span>" . $tip_title . "</span>\n\n\t\t\t\t</div>\n";
         $output .= $xml->tip[$i] . "</div>\n";
     }
     $output .= "\n\t\t\t\t</div>\n\n\t\t\t</div>\n\n\t\t</div>\n";
     return $output;
 }
 function makeButton()
 {
     global $sabnzbd_ip;
     global $sabnzbd_port;
     global $sabnzbd_api;
     $sabnzbdXML = simplexml_load_file('http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=qstatus&output=xml&apikey=' . $sabnzbd_api);
     if ($sabnzbdXML->state == 'Downloading') {
         $speed = $sabnzbdXML->speed;
         if (strpbrk($speed, 'K')) {
             // This converts the speed from KBps or MBps to Mbps
             $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8 / 1024, 1);
         } else {
             $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8, 0);
         }
         $icon = '<i class="icon-' . ($this->status ? 'download-alt' : 'remove') . ' icon-white"></i>';
         $txt = $this->status ? $convertedSpeed . 'Mb' : 'Offline';
     } else {
         $icon = '<i class="icon-' . ($this->status ? 'ok' : 'remove') . ' icon-white"></i>';
         $txt = $this->status ? 'Online' : 'Offline';
     }
     $btn = $this->status ? 'success' : 'warning';
     $prefix = $this->url == "" ? '<button style="width:62px" class="btn btn-xs btn-' . $btn . ' disabled">' : '<a href="' . $this->url . '" style="width:62px" class="btn btn-xs btn-' . $btn . '">';
     $suffix = $this->url == "" ? '</button>' : '</a>';
     return $prefix . $icon . " " . $txt . $suffix;
 }
Ejemplo n.º 25
0
 /**
  * Parse the manifest file
  * @access private
  */
 function __parseManifestFile($unzip)
 {
     $manifestfile = $this->__getManifestFilePath();
     $unzip->unzip('manifest.xml', $manifestfile);
     $this->_modulexml = simplexml_load_file($manifestfile);
     unlink($manifestfile);
 }
/**
 * Image List XML Parser
 *
 * @param string $xml Xml file
 * @param string $data dataId to read
 * @return $total
 */
function traer_info($xml, $data)
{
    if (!strrpos("__" . $xml, "http")) {
        $sx = simplexml_load_file($xml);
    } else {
        $content = file_get_contents($xml);
        $sx = simplexml_load_string($content);
    }
    foreach ($sx->data as $item) {
        if ($data == $item->dataId) {
            $headerImageFile = $item->imageFile;
            foreach ($item->list->listItem as $item2) {
                $text[] = $item2->text;
                $nextLevelLevelId[] = $item2->nextLevel->nextLevelLevelId;
                $nextLevelDataId[] = $item2->nextLevel->nextLevelDataId;
            }
        }
    }
    $total[0] = $headerImageFile;
    if (isset($item->list->listItem)) {
        $total[1] = $text;
        $total[2] = $nextLevelLevelId;
        $total[3] = $nextLevelDataId;
    }
    return $total;
}
Ejemplo n.º 27
0
 public function parseGithubFeeds($feeds)
 {
     $cacheName = 'ppi-website-github-activity';
     if ($this->cache->contains($cacheName)) {
         return $this->cache->fetch($cacheName);
     }
     $activity = array();
     foreach ($feeds as $feed) {
         $xml = simplexml_load_file($feed);
         if (isset($xml->entry)) {
             foreach ($xml->entry as $commit) {
                 $timestamp = strtotime((string) $commit->updated);
                 $title = (string) $commit->title;
                 if (strlen($title) > 70) {
                     $title = trim(substr($title, 0, 70)) . '..';
                 }
                 $title = htmlentities($title);
                 $activity[$timestamp] = array('source' => 'github', 'url' => (string) $commit->link['href'], 'title' => $title, 'date' => date('jS M Y \\a\\t g:i a', $timestamp));
             }
         }
     }
     krsort($activity);
     $this->cache->save($cacheName, $activity, 60 * 60);
     return $activity;
 }
Ejemplo n.º 28
0
 public static function parseKunenaInstallFile($path)
 {
     $xml = simplexml_load_file($path);
     if (!$xml || $xml->getName() != 'kinstall') {
         return false;
     }
     $data = new stdClass();
     $data->name = (string) $xml->name;
     $data->type = (string) $xml->attributes()->type;
     $data->creationdate = (string) $xml->creationDate;
     $data->author = (string) $xml->author;
     $data->copyright = (string) $xml->copyright;
     $data->authorEmail = (string) $xml->authorEmail;
     $data->authorUrl = (string) $xml->authorUrl;
     $data->version = (string) $xml->version;
     $data->description = (string) $xml->description;
     $data->thumbnail = (string) $xml->thumbnail;
     $data->kversion = (string) $xml->attributes()->version;
     if ($data->version == '@kunenaversion@') {
         $data->version = KunenaForum::version();
     }
     if ($data->creationdate == '@kunenaversiondate@') {
         $data->creationdate = KunenaForum::versionDate();
     }
     if (!$data->version) {
         $data->version = JText::_('Unknown');
     }
     if (!$data->creationdate) {
         $data->creationdate = JText::_('Unknown');
     }
     if (!$data->author) {
         $data->author = JText::_('Unknown');
     }
     return $data;
 }
 /**
  * Return all rewrites
  *
  * @return array
  */
 protected function loadRewrites()
 {
     $return = array('blocks', 'models', 'helpers');
     // Load config of each module because modules can overwrite config each other. Globl config is already merged
     $modules = Mage::getConfig()->getNode('modules')->children();
     foreach ($modules as $moduleName => $moduleData) {
         // Check only active modules
         if (!$moduleData->is('active')) {
             continue;
         }
         // Load config of module
         $configXmlFile = Mage::getConfig()->getModuleDir('etc', $moduleName) . DIRECTORY_SEPARATOR . 'config.xml';
         if (!file_exists($configXmlFile)) {
             continue;
         }
         $xml = simplexml_load_file($configXmlFile);
         if ($xml) {
             $rewriteElements = $xml->xpath('//rewrite');
             foreach ($rewriteElements as $element) {
                 foreach ($element->children() as $child) {
                     $type = simplexml_import_dom(dom_import_simplexml($element)->parentNode->parentNode)->getName();
                     if (!in_array($type, $this->_rewriteTypes)) {
                         continue;
                     }
                     $groupClassName = simplexml_import_dom(dom_import_simplexml($element)->parentNode)->getName();
                     if (!isset($return[$type][$groupClassName . '/' . $child->getName()])) {
                         $return[$type][$groupClassName . '/' . $child->getName()] = array();
                     }
                     $return[$type][$groupClassName . '/' . $child->getName()][] = (string) $child;
                 }
             }
         }
     }
     return $return;
 }
Ejemplo n.º 30
0
 function LoadFromFile($filename)
 {
     $this->Xml = simplexml_load_file($filename);
     if (!$this->Xml) {
         throw new Exception(sprintf(_("Cannot load navigation menu from file '%s'"), $filename));
     }
 }