/** * 追加接口参数,支持过滤成功用例 * @param unknown_type $onlyfails */ function interXML($onlyfails) { if (!file_exists('report.xml')) { return array(); } $xmlFile = simpleXML_load_file("report.xml"); $caseList = array(); foreach ($xmlFile->testsuite as $testsuite) { foreach ($testsuite->testcase as $testResult) { // $totalCov = 0; $browser = strval($testResult['browserInfo']); $host = strval($testResult['hostInfo']); $caseName = strval($testResult['name']); $fail = strval($testResult['failNumber']); $total = strval($testResult['totalNumber']); $cov = strval($testResult['cov']); $recordCovForBrowser = strval($testResult['recordCovForBrowser']); if (!array_key_exists($caseName, $caseList)) { //如果这个用例不存在 $caseInfo = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser); // $totalCov += $cov; $caseList[$caseName] = array($browser => $caseInfo); // $caseList['totalCov'] = $totalCov; } else { //否则添加到相应的用例中去 $foundCase = $caseList[$caseName]; //找到用例名称对应的array,$caseName为key if (!array_key_exists($browser, $foundCase)) { //如果没有该浏览器信息,则添加 // $totalCov += $cov; $caseList[$caseName][$browser] = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser); // $caseList[$caseName]['totalCov'] = $totalCov; } else { $foundBrowser = $foundCase[$browser]; //有这个浏览器 array_push($foundBrowser, array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov, 'recordCovForBrowser' => $recordCovForBrowser)); } } } } //根据需求添加仅记录失败情况的接口 if ($onlyfails) { //如果仅考虑失败情况,此处根据用例情况过滤 foreach ($caseList as $name => $info) { $all_success = true; //记录当前用例是否全部运行成功 foreach ($info as $b => $result) { if ($result['fail'] > 0) { $all_success = false; } //如果有失败情况则终止循环并进入下一个用例分析 break; } //if($all_success) //如果全部通过则从记录中移除 //unset($caseList[$name]); } } return $caseList; }
public static function process() { $xml = simpleXML_load_file(self::$xmlFile, "SimpleXMLElement", LIBXML_NOCDATA); foreach ($xml->Offers->Item as $Item) { foreach ($Item->Images->Image as $image) { self::getImage($image); } } }
/** * * @param type $url * @return Object of parsed XML */ function parse_xml($url) { try { $weather_object = simpleXML_load_file($url, "SimpleXMLElement", LIBXML_NOCDATA); if ($weather_object === FALSE) { return false; } else { return $weather_object; } } catch (Exception $ex) { echo 'Error Parsing XML ', $e->getMessage(), "\n"; } }
function processXML($URL) { try { $file_headers = @get_headers($URL); if ($file_headers[0] != 'HTTP/1.1 404 Not Found') { return simpleXML_load_file($URL, "SimpleXMLElement", LIBXML_NOCDATA); } else { throw new Exception('Stations file not currently available from NOAA.'); return false; } } catch (Exception $e) { echo "Error thrown: " . $e->getMessage(); return false; } }
function get_legend($filename_main_kml) { global $template, $user; //Parser $xml = simpleXML_load_file($filename_main_kml); if ($user->data['user_id'] == 2) { //print_r($xml); } if ($xml === FALSE) { return; } else { $color = get_color_array($xml); $color_arry_size = count($color); //echo($color[0]['color'] . ' - ' . $color[1]['color']. ' - ' . $color[2]['color']); $i = 0; if ($xml->Document->Placemark) { foreach ($xml->Document->Placemark as $value) { if ($value->name) { if ($value->styleUrl) { $style = substr($value->styleUrl, 1); for ($z = 0; $z < $color_arry_size; $z++) { if ($user->data['user_id'] == 2) { // echo($z. ' ' . $color[$z]['id'] . ' ' .$color[$z]['img'] . '<br>'); } if ($style == $color[$z]['id']) { $data[$i]['color'] = $color[$z]['color']; $data[$i]['img'] = $color[$z]['img']; } } } $data[$i]['text'] = $value->name; $i++; } } } } $count_data = sizeof($data); // Output for ($i = 0; $i < $count_data; $i++) { $color = $data[$i]['color']; $text = $data[$i]['text']; $template->assign_block_vars('legend', array('COLOR' => $color, 'TEXT' => $text, 'S_IMG' => $data[$i]['img'])); } return $count_data; }
public static function LoadFromFile($pathFile) { $saoData = new SaoDatabase(); $listBinhChu = array(); $xmlData = simpleXML_load_file($pathFile); foreach ($xmlData->children() as $binhChu) { try { $saosNode = $binhChu->Saos; $cungsNode = $binhChu->Cungs; $lthansNode = $binhChu->LucThans; $lbinh = $binhChu->LoiBinh; $saos = array(); $cungs = array(); $lthans = array(); $CSData = $saoData->CSData; if (isset($saosNode->Sao)) { foreach ($saosNode->Sao as $sao) { $ID = intval(BinhChu::xml_attribute($sao, 'ID')); if (isset($CSData[$ID - 1])) { array_push($saos, $CSData[$ID - 1]); } } } if (isset($saosNode->Cung)) { foreach ($cungsNode->Cung as $cung) { $ID = intval(BinhChu::xml_attribute($cung, 'ID')); array_push($cungs, $ID); } } if (isset($saosNode->LucThan)) { foreach ($lthansNode->LucThan as $lucthan) { $ID = intval(BinhChu::xml_attribute($lucthan, 'ID')); array_push($lthans, $ID); } } if (count($saos) > 0 || count($cungs) > 0 || count($lthans) > 0) { array_push($listBinhChu, new BinhChu($saos, $cungs, $lthans, $lbinh)); } } catch (Exception $e) { } } return $listBinhChu; }
/** * Récupère les informations d'un album d'après son titre et son artiste ou de l'ID * @param string $p_sAlbum * @param string $p_sArtist * @return \LASTFM\Album Un objet contenant l'album */ public function getInfos($p_sAlbum, $p_sArtist, $p_sMbId = null) { if ($p_sMbId == null) { $sParams = '&artist=' . rawurlencode($p_sArtist) . '&album=' . rawurlencode($p_sAlbum); } else { $sParams = '&mbid=' . $p_sMbId; } if (!($oRssDoc = simpleXML_load_file($this->sBaseUrl . '?method=album.getinfo&api_key=' . $this->sApiKey . $sParams, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_NOWARNING))) { return null; } if ($oRssDoc->album->mbid == '') { return null; } $oAlbum = new Album($oRssDoc->album->name, $oRssDoc->album->artist, $oRssDoc->album->mbid); $oAlbum->setDate(date("Y-m-j G:i:s", strtotime($oRssDoc->album->releasedate))); $oAlbum->setCover($oRssDoc->album->image[4]); foreach ($oRssDoc->album->tracks->track as $oRssTrack) { $oAlbum->addTrack($oRssTrack->attributes()[0]->__toString(), $oRssTrack->name, $oRssTrack->duration); } return $oAlbum; }
/** * Retrieve a list of available fonts to be used with PDF Invoice generation & PDF Product view on FE * * @author Nikos Zagas * @return object List of available fonts */ function getTCPDFFontsList() { $dir = VMPATH_ROOT . DS . 'libraries' . DS . 'tcpdf' . DS . 'fonts'; $result = array(); if (function_exists('glob')) { $specfiles = glob($dir . DS . "*_specs.xml"); /*if(empty($specfiles) and is_dir($dir)){ vmWarn('No fonts _specs.xml files found in '.$dir); }*/ } else { $specfiles = array(); $manual = array('courier_specs.xml', 'freemono_specs.xml', 'helvetica_specs.xml'); foreach ($manual as $file) { if (file_exists($dir . DS . $file)) { $specfiles[] = $dir . DS . $file; } } } if (empty($specfiles)) { $manual = array('courier', 'freemono', 'helvetica'); foreach ($manual as $file) { if (file_exists($dir . DS . $file . '.php')) { $result[] = JHtml::_('select.option', $file, vmText::_($file . ' (standard)')); } } } else { foreach ($specfiles as $file) { $fontxml = @simpleXML_load_file($file); if ($fontxml) { if (file_exists($dir . DS . $fontxml->filename . '.php')) { $result[] = JHtml::_('select.option', $fontxml->filename, vmText::_($fontxml->fontname . ' (' . $fontxml->fonttype . ')')); } else { vmError('A font master file is missing: ' . $dir . DS . $fontxml->filename . '.php'); } } else { vmError('Wrong structure in font XML file: ' . $dir . DS . $file); } } } return $result; }
} else { die("Need to pass the 'access_key' URL parameter"); } try { /* query the database */ // $db = getCon(); $db = mysql_connect($db_hostname, $db_username, $db_password); if (!$db) { die("Could not connect: " . mysql_error()); } mysql_select_db("your_db", $db); echo "Starting to work with feed URL '" . $feed_url . "'"; /* Parse XML from http://www.instapaper.com/starred/rss/580483/qU7TKdkHYNmcjNJQSMH1QODLc */ //$RSS_DOC = simpleXML_load_file('http://www.instapaper.com/starred/rss/580483/qU7TKdkHYNmcjNJQSMH1QODLc'); libxml_use_internal_errors(true); $RSS_DOC = simpleXML_load_file($feed_url); if (!$RSS_DOC) { echo "Failed loading XML\n"; foreach (libxml_get_errors() as $error) { echo "\t", $error->message; } } /* Get title, link, managing editor, and copyright from the document */ $rss_title = $RSS_DOC->channel->title; $rss_link = $RSS_DOC->channel->link; $rss_editor = $RSS_DOC->channel->managingEditor; $rss_copyright = $RSS_DOC->channel->copyright; $rss_date = $RSS_DOC->channel->pubDate; //Loop through each item in the RSS document foreach ($RSS_DOC->channel->item as $RSSitem) { $item_id = md5($RSSitem->title);
private static function _saveXml($data, $filterNodes = false, $specificNodes = array()) { $result = false; $canSave = false; if (!self::_isLocalXmlWritable()) { return $result; } if ($filterNodes && empty($specificNodes)) { return $result; } try { $localXml = self::_getLocalXmlPath(); $xml = simpleXML_load_file(self::_getLocalXmlPath()); foreach ($data as $key => $node) { if ($filterNodes && !isset($specificNodes[$key])) { continue; } $canSave = true; $xParts = str_split($node['xpath'], strrpos($node['xpath'], '/')); $xpath = $xParts[0]; $nodeName = ltrim($xParts[1], '/'); $xpath = $xml->xpath($xpath); list($_node) = $xpath; $_node->{$nodeName} = NULL; $_node = dom_import_simplexml($_node->{$nodeName}); $nodeOwner = $_node->ownerDocument; $_node->appendChild($nodeOwner->createCDATASection($node['value'])); } if ($canSave) { $xmlContent = $xml->asXML(); $result = file_put_contents($localXml, $xmlContent); } } catch (Exception $e) { } return $result; }
* meant to be used as a cron job * * @package SlimRSS * @author AdamGold <*****@*****.**> * @copyright 2015 AdamGold */ require 'config.php'; require HOME . '/vendor/autoload.php'; $modelFactory = new \Core\ModelFactory(); $pdo = $modelFactory::$connection; $sth = $pdo->prepare('SELECT * FROM ' . DB_PREFIX . 'channels ORDER BY id DESC'); $sth->execute(); $channels = $sth->fetchAll(); foreach ($channels as $channel) { libxml_use_internal_errors(true); $rss = simpleXML_load_file($channel['link']); if (false === $rss) { // not an xml file continue; } $items = $rss->channel->item; $sth = $pdo->prepare('SELECT * FROM ' . DB_PREFIX . 'posts WHERE channel_id = ? ORDER BY date DESC'); // last post from this channel $sth->execute(array($channel['id'])); $lastPost = $sth->fetch(); /* get categories of channel */ $sth = $pdo->prepare('SELECT c.id FROM ' . DB_PREFIX . 'categories c JOIN ' . DB_PREFIX . 'channels_categories cr' . ' ON cr.cat_id = c.id WHERE cr.channel_id = :cid'); $sth->bindValue(':cid', $channel['id']); $sth->execute(); $cats = $sth->fetchAll(); /* check to see if we even need to update that channel (check the last post that was published from this channel) */
protected function _getStatus($zoneplayerIp) { $url = "http://" . $zoneplayerIp . ":1400/status/zp"; $xml = simpleXML_load_file($url); return $xml->ZPInfo->LocalUID; }
/** * Parse le flux RSS pour trouver les Torrents * @param Passkey $p_oPasskey * @return array */ public function parse($p_oPasskey) { $aTorrents = array(); //Ouverture du flux RSS libxml_use_internal_errors(true); if ($this->isPasskey()) { $sUrlWithPasskey = $p_oPasskey->getLinkWithPasskey($this->sUrl); } else { $sUrlWithPasskey = $this->sUrl; } $oRssDoc = simpleXML_load_file($sUrlWithPasskey); if (!$oRssDoc) { return array('error' => "Impossible d'ouvrir le flux : " . $this->sUrl); } //Traitement des items foreach ($oRssDoc->channel->item as $oRssItem) { //Traitement des jeux de caractères if ($this->sEncoding === "UTF-8") { $sPubDate = $oRssItem->pubDate; $sTitle = $oRssItem->title; $sLink = $oRssItem->link; } else { $sPubDate = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->pubDate); $sTitle = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->title); $sLink = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->link); } //On regarde si on a une date de publication : if (empty($sPubDate) || $this->bForcedate) { $sPubDate = date("Y-m-j G:i:s"); } if (strtotime($sPubDate) > strtotime($this->sLastCheck)) { $oTorrent = new Torrent($sTitle); $oTorrent->setDate(date("Y-m-j G:i:s", strtotime($sPubDate))); $oTorrent->setIdLink($this->getIdLink($sLink, $p_oPasskey)); $oTorrent->setTracker($this->iTracker); $aTorrents[] = $oTorrent; } } return $aTorrents; }
/** * Update node in axp file table * @param $projName: table axp project name * $tableNumber: table index inside axp file * $pluginName: plugin node to be updated * $data: data to update the node with * @return boolean */ function update_project_plugin_node($projName, $tableNumber, $pluginName, $data) { @($xmlFile = simpleXML_load_file("../projects/" . $projName)); //validate input if (preg_match('/^[a-z0-9-_]+\\.axp$/i', $projName) && isset($xmlFile) && isset($xmlFile->table[$tableNumber])) { //create spm node if not exist check_or_create_plugin_node($xmlFile->table[$tableNumber], $pluginName); $xmlFile->table[$tableNumber]->plugins->{$pluginName} = $data; $xmlFile->asXML("../projects/" . $projName); return true; } return false; }
function processXML($URL) { //error_log( '== ' . microtime(true) . ' start process XML', 0, '/var/log/httpd/error_log'); try { $file_headers = @get_headers($URL); //print $URL.'<br />'; //print $file_headers[0].'<br />'; if ($file_headers[0] != 'HTTP/1.1 404 Not Found') { return simpleXML_load_file($URL, "SimpleXMLElement", LIBXML_NOCDATA); } else { throw new Exception('Stations file not currently available from NOAA.'); } } catch (Exception $e) { //echo "Error thrown: " . $e->getMessage(); return false; } //error_log( '== ' . microtime(true) . ' end process XML', 0, '/var/log/httpd/error_log'); }
<?php //mysql connection $con2 = mysql_connect("localhost", "user", "pass"); if (!$con2) { die('Could not connect: ' . mysql_error()); } $selectdb = mysql_select_db("smoker", $con2); if (!$selectdb) { die('Database not used: ; ' . mysql_error()); } ini_set("date.timezone", "America/New_York"); $today = date("Y-m-d H:i:s"); $url = 'http://Hostname:8080/status.xml'; $xml = simpleXML_load_file($url, "SimpleXMLElement", LIBXML_NOCDATA); //loop through parsed xmlfeed and print output foreach ($xml->OUTPUT_PERCENT as $OUTPUT_PERCENT) { printf($OUTPUT_PERCENT); foreach ($xml->TIMER_CURR as $TIMER_CURR) { printf($TIMER_CURR); foreach ($xml->COOK_TEMP as $COOK_TEMP) { printf($COOK_TEMP); foreach ($xml->FOOD1_TEMP as $FOOD1_TEMP) { printf($FOOD1_TEMP); foreach ($xml->FOOD2_TEMP as $FOOD2_TEMP) { printf($FOOD2_TEMP); foreach ($xml->FOOD3_TEMP as $FOOD3_TEMP) { printf($FOOD3_TEMP); foreach ($xml->COOK_STATUS as $COOK_STATUS) { printf($COOK_STATUS); foreach ($xml->FOOD1_STATUS as $FOOD1_STATUS) {
<?php header('Access-Control-Allow-Origin: http://nikolayhg.github.io'); // Implementation of this interface https://www.bmf-steuerrechner.de/interface/ // RE4: Steuerpflichtiger Arbeitslohn $RE4 = $_GET["RE4"]; $RE4 = $RE4 . "00"; // add the two 00 after the comma // LZZ: 1 = Jahr, 2 = Monat, 3 = Woche, 4 = Tag $LZZ = $_GET["LZZ"]; if ($LZZ != 1 && $LZZ != 2 && $LZZ != 3 && $LZZ != 4) { $LZZ = 2; } // STKL: Steuerklasse $url = "http://www.bmf-steuerrechner.de/interface/2015.jsp?LZZ=" . $LZZ . "&RE4=" . $RE4 . "&STKL=1"; $xml = simpleXML_load_file($url); $lohsteuer_result_xml = $xml->xpath('//ausgabe [@name="LSTLZZ"]'); $soli_result_xml = $xml->xpath('//ausgabe [@name="SOLZLZZ"]'); $lohsteuer_result = $lohsteuer_result_xml[0]['value']; $soli_result = $soli_result_xml[0]['value']; if ($lohsteuer_result != 0) { $lohnsteuer = substr($lohsteuer_result, 0, -2) . "." . substr($lohsteuer_result, -2); $soli = substr($soli_result, 0, -2) . "." . substr($soli_result, -2); echo $lohnsteuer . ";" . $soli; } else { echo 0; }
public function ajaxProcessGetBlogRss() { $return = array('has_errors' => false, 'rss' => array()); if (!$this->isFresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', 86400)) { if (!$this->refresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', 'https://api.prestashop.com/rss/blog/blog-' . $this->context->language->iso_code . '.xml')) { $return['has_errors'] = true; } } if (!$return['has_errors']) { $rss = simpleXML_load_file(_PS_ROOT_DIR_ . '/config/xml/blog-' . $this->context->language->iso_code . '.xml'); $articles_limit = 2; foreach ($rss->channel->item as $item) { if ($articles_limit > 0 && Validate::isCleanHtml((string) $item->title) && Validate::isCleanHtml((string) $item->description)) { $return['rss'][] = array('date' => Tools::displayDate(date('Y-m-d', strtotime((string) $item->pubDate))), 'title' => (string) Tools::htmlentitiesUTF8($item->title), 'short_desc' => Tools::truncateString(strip_tags((string) $item->description), 150), 'link' => (string) $item->link); } else { break; } $articles_limit--; } } die(Tools::jsonEncode($return)); }
/** * 追加接口参数,支持过滤成功用例 * @param unknown_type $onlyfails */ function interXML($onlyfails = false) { if (!file_exists('report')) { return array(); } $fs = scandir('report'); require_once 'config.php'; foreach (Config::$BROWSERS as $b => $machine) { if (!Config::$DEBUG && !in_array($b . '.xml', $fs)) { print "none browser xml exist {$b}"; return; } } $caseList = array(); foreach ($fs as $f) { if (substr($f, 0, 1) == '.') { continue; } $xmlFile = simpleXML_load_file("report/{$f}"); foreach ($xmlFile as $testResult) { // $totalCov = 0; $browser = $testResult['browserInfo']; $host = $testResult['hostInfo']; $caseName = $testResult['caseName']; //得到用例名称 settype($caseName, "string"); //$caseName本来类型为object,需要做转换 $fail = $testResult['failNumber']; $total = $testResult['totalNumber']; $cov = $testResult['cov']; settype($browser, "string"); settype($host, "string"); settype($fail, "string"); settype($total, "string"); settype($cov, "float"); if (!array_key_exists($caseName, $caseList)) { //如果这个用例不存在 $caseInfo = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov); // $totalCov += $cov; $caseList[$caseName] = array($browser => $caseInfo); // $caseList['totalCov'] = $totalCov; } else { //否则添加到相应的用例中去 $foundCase = $caseList[$caseName]; //找到用例名称对应的array,$caseName为key if (!array_key_exists($browser, $foundCase)) { //如果没有该浏览器信息,则添加 // $totalCov += $cov; $caseList[$caseName][$browser] = array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov); // $caseList[$caseName]['totalCov'] = $totalCov; } else { $foundBrowser = $foundCase[$browser]; //有这个浏览器 array_push($foundBrowser, array('hostInfo' => $host, 'fail' => $fail, 'total' => $total, 'cov' => $cov)); } } } // unlink("report/$f"); } //根据需求添加仅记录失败情况的接口 if ($onlyfails) { //如果仅考虑失败情况,此处根据用例情况过滤 foreach ($caseList as $name => $info) { $all_success = true; //记录当前用例是否全部运行成功 foreach ($info as $b => $result) { if ($result['fail'] > 0) { $all_success = false; } //如果有失败情况则终止循环并进入下一个用例分析 break; } //if($all_success) //如果全部通过则从记录中移除 //unset($caseList[$name]); } } //rmdir("report"); return $caseList; }
public function ajaxProcessGetBlogRss() { $return = array('has_errors' => false, 'rss' => array()); if (!$this->isFresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', 86400)) { if (!$this->refresh('/config/xml/blog-' . $this->context->language->iso_code . '.xml', _PS_API_URL_ . '/rss/blog/blog-' . $this->context->language->iso_code . '.xml')) { $return['has_errors'] = true; } } if (!$return['has_errors']) { $rss = simpleXML_load_file(_PS_ROOT_DIR_ . '/config/xml/blog-' . $this->context->language->iso_code . '.xml'); $articles_limit = 2; foreach ($rss->channel->item as $item) { if ($articles_limit > 0 && Validate::isCleanHtml((string) $item->title) && Validate::isCleanHtml((string) $item->description) && isset($item->link) && isset($item->title)) { if (in_array($this->context->mode, array(Context::MODE_HOST, Context::MODE_HOST_CONTRIB))) { $utm_content = 'cloud'; } else { $utm_content = 'download'; } $shop_default_country_id = (int) Configuration::get('PS_COUNTRY_DEFAULT'); $shop_default_iso_country = (string) Tools::strtoupper(Country::getIsoById($shop_default_country_id)); $analytics_params = array('utm_source' => 'back-office', 'utm_medium' => 'rss', 'utm_campaign' => 'back-office-' . $shop_default_iso_country, 'utm_content' => $utm_content); $url_query = parse_url($item->link, PHP_URL_QUERY); parse_str($url_query, $link_query_params); if ($link_query_params) { $full_url_params = array_merge($link_query_params, $analytics_params); $base_url = explode('?', (string) $item->link); $base_url = (string) $base_url[0]; $article_link = $base_url . '?' . http_build_query($full_url_params); } else { $article_link = (string) $item->link . '?' . http_build_query($analytics_params); } $return['rss'][] = array('date' => Tools::displayDate(date('Y-m-d', strtotime((string) $item->pubDate))), 'title' => (string) Tools::htmlentitiesUTF8($item->title), 'short_desc' => Tools::truncateString(strip_tags((string) $item->description), 150), 'link' => (string) $article_link); } else { break; } $articles_limit--; } } die(Tools::jsonEncode($return)); }
public function procede() { try { if ($this->oRequest->existParam('name')) { if ($this->oRequest->existParam('edit')) { $oTracker = new Tracker($this->oRequest->getParam('name', 'string'), $this->oRequest->getParam('edit', 'int')); } else { $oTracker = new Tracker($this->oRequest->getParam('name', 'string')); } if ($this->oRequest->existParam('link')) { $oTracker->setLink($this->oRequest->getParam('link', 'string')); } if ($this->oRequest->existParam('directlink')) { $oTracker->setDirectLink($this->oRequest->getParam('directlink', 'string')); } if ($this->oRequest->existParam('edit')) { //Suppression if ($this->oRequest->existParam('delete') && $this->oRequest->getParam('delete', 'boolean')) { $oTracker->delete(); Logger::log('admin', 'Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été supprimé par ' . $this->oCurrentUser->getLogin()); $this->oView->addAlert('Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été supprimé.', 'success'); } else { //Edit $oTracker->update(); Logger::log('admin', 'Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été modifié par ' . $this->oCurrentUser->getLogin()); $this->oView->addAlert('Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été modifié.', 'success'); } } else { $oTracker->store(); Logger::log('admin', 'Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été ajouté par ' . $this->oCurrentUser->getLogin()); $this->oView->addAlert('Le Tracker ' . $this->oRequest->getParam('name', 'string') . ' a été ajouté.', 'success'); } } elseif ($this->oRequest->existParam('import')) { $sFile = './trackers/' . $this->oRequest->getParam('import', 'string') . '.xml'; $oRssDoc = simpleXML_load_file($sFile); if (!$oRssDoc) { throw new Error('Impossible d\'ouvrir le fichier de configuration pour ' . $this->oRequest->getParam('import', 'string') . '.', 1132); } //Traitement des items $oRssTracker = $oRssDoc->Tracker; $oRssFlux = $oRssDoc->RSS; $oTracker = new Tracker($oRssTracker->Name); $oTracker->setLink(str_replace('&', '&', $oRssTracker->Link)); $oTracker->setDirectLink(str_replace('&', '&', $oRssTracker->DirectLink)); $oTracker->store(); if ($oRssFlux->ForceDate === 'true') { $bForceDate = true; } else { $bForceDate = false; } $oFlux = new Rss($oTracker->getId(), str_replace('&', '&', $oRssFlux->Flux), str_replace('&', '&', $oRssFlux->Mask), $bForceDate, 0, $oRssFlux->Encoding); $oFlux->store(); Logger::log('admin', 'Le Tracker ' . $this->oRequest->getParam('import', 'string') . ' a été ajouté par ' . $this->oCurrentUser->getLogin()); $this->oView->addAlert('Le Tracker ' . $this->oRequest->getParam('import', 'string') . ' a été ajouté.', 'success'); } } catch (Exception $ex) { $this->oView->addAlert($ex, 'danger'); } finally { $this->createView(); } }
private function readconfig($file) { /* load one xml file to having one job */ $this->configItemFile = $file; $conf = array(); $xml = @simpleXML_load_file($file, "SimpleXMLElement", LIBXML_NOCDATA); if ($xml === FALSE) { throw new SSH2_Exception("Alert! unable to load xml file! check sintax. read: " . @file_get_contents($file), 0, 1); } if ($xml->getName() == 'sshjob') { /* ok xml */ foreach ($xml->children() as $child) { /* associate key from xml file */ $vars = (string) $child->getName(); $value = (string) $child; $value = str_replace($this->search, $this->replace, $value); $conf[$vars] = $value; if ($vars == '_sftp_pass') { /* password or passphrase decode */ $conf[$vars] = base64_decode((string) $child); } if ($vars == 'ssh_pub_key_file') { /* check method key if having */ /* file check local? */ $type = $xml->xpath("//ssh_pub_key_file[@type!='none']"); foreach ($type[0]->attributes() as $key => $val) { if ($val == 'dsa') { $this->connect_method = array('kex' => 'diffie-hellman-group1-sha1', 'hostkey' => 'ssh-dss', 'client_to_server' => array('crypt' => '3des-cbc', 'mac' => 'hmac-md5', 'comp' => 'none'), 'server_to_client' => array('crypt' => '3des-cbc', 'mac' => 'hmac-md5', 'comp' => 'none')); $this->stamp('Note: setting to dsa key '); } } } } if ($conf['_sftp_port'] < 1 || empty($conf['_sftp_port'])) { $conf['_sftp_port'] = 22; $this->stamp('Note: setting port default ->22'); } /////print_r($conf); $host = (string) $conf["_sftp_host"]; if (empty($host)) { die("Host not set!"); } if (empty($conf["ssh_pub_key_file"])) { $this->usekey = FALSE; //////$conf['ssh_pub_key_file'] = ''; //////$conf['ssh_pri_key_file'] = ''; } else { $this->usekey = TRUE; if (!is_file($conf['ssh_pub_key_file'])) { throw new SSH2_Exception("Alert! unable to find your -> ssh_pub_key_file!.", 0, 1); } if (!is_file($conf['ssh_pub_key_file'])) { throw new SSH2_Exception("Alert! unable to find your -> ssh_pub_key_file!.", 0, 1); } $pair_key = @file_get_contents($conf['ssh_pub_key_file']); if (strlen($pair_key) < 50) { throw new SSH2_Exception("Alert! -> _sftp_key_file content is smaller as 50 char: Not possibel.", 0, 1); } else { /* not destroy link */ } } $this->conf = $conf; print_r($conf); die(__LINE__); } }
<!-- Begin Advance Search --> <?php if (isset($_POST['gsexpertsearch_advancedsearch'])) { $gsexpertsearch_baseurl = get_site_option('gsexpertsearch_apiurl'); $gsexpertsearch_api = get_site_option('gsexpertsearch_apikey'); $gsexpertsearch_searchterm_name = urlencode($_POST['gsexpertsearch_advsearch_name']); $gsexpertsearch_searchterm_keyword = urlencode($_POST['gsexpertsearch_advsearch_keyword']); $gsexpertsearch_searchterm_college = urlencode($_POST['gsexpertsearch_advsearch_college']); //Make sure that they actually typed something in, if not replace it with a blank //checks keyword if ($gsexpertsearch_searchterm_keyword == 'Enter+Keyword+or+Interest') { $gsexpertsearch_searchterm_keyword = ''; } //check name if ($gsexpertsearch_searchterm_name == 'Enter+Name') { $gsexpertsearch_searchterm_name = ''; } //build url to pass to gsexpertsearch $gsexpertsearch_url = $gsexpertsearch_baseurl . 'expertsearchapi.php?appkey=' . $gsexpertsearch_api . '&name=' . $gsexpertsearch_searchterm_name . '&term=' . $gsexpertsearch_searchterm_keyword . '&college=' . $gsexpertsearch_searchterm_college; //echo $gsexpertsearch_url; //Load XML from API into simpleXML to parse $gsexpertsearch_xml = simpleXML_load_file($gsexpertsearch_url, "SimpleXMLElement", LIBXML_NOCDATA); //Check to see if the XML Load Failed if ($gsexpertsearch_xml === FALSE) { echo '<h3>There has been an error</h3>'; } else { include plugin_dir_path(__FILE__) . 'gsexpertsearch-displayresultstable.php'; //End Display Results } } //End If Post advanced search exists
/** * Retrieve a list of available fonts to be used with PDF Invoice generation & PDF Product view on FE * * @author Nikos Zagas * @return object List of available fonts */ function getTCPDFFontsList() { $dir = JPATH_ROOT . DS . 'libraries' . DS . 'tcpdf' . DS . 'fonts'; $result = array(); if (function_exists('glob')) { $specfiles = glob($dir . DS . "*_specs.xml"); foreach ($specfiles as $file) { $fontxml = @simpleXML_load_file($file); if ($fontxml) { if (file_exists($dir . DS . $fontxml->filename . '.php')) { $result[] = JHtml::_('select.option', $fontxml->filename, vmText::_($fontxml->fontname . ' (' . $fontxml->fonttype . ')')); } else { vmError('A font master file is missing: ' . $dir . DS . $fontxml->filename . '.php'); } } else { vmError('Wrong structure in font XML file: ' . $dir . DS . $file); } } } return $result; }
/*last refresh control*/ $QueryTime = "select lastrefresh from configuration where id = 0"; $ResultTime = mysql_query($QueryTime); $linetime = mysql_fetch_row($ResultTime); $actualtime = time(); $interval = time() - strtotime($linetime[0]); if ($interval > 300) { $doupdate2 = 1; } } if ($doupdate2 == 1) { $Query = "select `id`,`rss`,`name`,`logo` from `rssfeeds`"; $Result = mysql_query($Query); while ($line = mysql_fetch_row($Result)) { libxml_use_internal_errors(true); $RSS_DOC = simpleXML_load_file($line[1]); if (!$RSS_DOC) { echo "Failed loading XML\n"; foreach (libxml_get_errors() as $error) { echo "\t", $error->message; } } /* Get title, link, managing editor, and copyright from the document */ $rss_title = $RSS_DOC->channel->title; $rss_link = $RSS_DOC->channel->link; $rss_editor = $RSS_DOC->channel->managingEditor; $rss_copyright = $RSS_DOC->channel->copyright; $rss_date = $RSS_DOC->channel->pubDate; $rss_description = $RSS_DOC->channel->description; //Loop through each item in the RSS document foreach ($RSS_DOC->channel->item as $RSSitem) {