Get Jboss EAP 7.4 fix list in json format - jboss7.x

is there any way to get a list of jboss EAP fix list in json format ? or at least to get the latest fix pack - example 7.4.1.2 or so on..
I am trying to write a script to get regularly the latest fix version and i form on which servers it should be installed.
thank you

If somebody is also interested.. there is another way.
This is the PHP code:
//$ver="7.4"; example..
$arrver=array("7.4"=>0,"7.3"=>1,"7.2"=>2,"7.1"=>3,"7.0"=>4);
$dom = new DOMDocument();
$data="";
libxml_use_internal_errors(true);
$html=file_get_contents("https://access.redhat.com/articles/2332721");
$html=preg_replace('%<sup.*?</sup>%i', '', $html);
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$tables = $dom->getElementsByTagName('table');
$rows = $tables->item($arrver[$ver])->getElementsByTagName('tr');
$i=0;
foreach ($rows as $row)
{
$cols = $row->getElementsByTagName('td');
if (DateTime::createFromFormat('F j, Y', $cols->item(1)->nodeValue) !== false) {
$i++;
if($i==1){ $data=$ver.".".str_replace(array("Update ","\n","\t"," "),"",$cols->item(0)->nodeValue);}
}
}

Related

Trying to find a file that doesnt exist Yii2

Im trying to create an email function that sends a file attached.
I've created the function and added attach() with the route of file I want to attach as follows:
public function newMonthlyBillingRegister(Clinic $clinic, ClinicMonthlyBilling $clinicMonthlyBilling)
{
$countryAdmins = $clinic->findCountryAdmins($clinic->country->id);
$adminEmails = [];
foreach ($countryAdmins as $admin) {
$adminEmails[$admin->email] = $admin->fullName;
}
/** #var BaseMailer $mailer */
$mailer = Yii::$app->mailer;
$mailer->htmlLayout = 'layouts/standard_html';
//$mailer->htmlLayout = 'layouts/invoice_html';
// $mailer->textLayout = 'layouts/invoice_text';
try{
return $mailer
->compose(
['html' => 'newMonthlyBillingRegister-html', 'text' => 'newMonthlyBillingRegister-text'],
[
'clinic' => $clinic,
'clinicMonthlyBilling' => $clinicMonthlyBilling,
]
)
->setFrom([Yii::$app->params['supportEmail'] => Yii::t('app', 'support-email-name', ['appName' => Yii::$app->name])])
->setTo($adminEmails)
->setSubject(Yii::t('app', '[CLINIC][BACKOFFICE] A clinic has upgraded its information in Guarantee Fund Modal.'))
->attach('app/media/uploads/clinic/monthly-billing/'.$clinicMonthlyBilling->trimestralBillingFile)
->queue() && YII_DEBUG && Yii::$app->mailqueue->process();
}
catch(\Exception $e){
LogService::getLogger()->error("Error while sending mail.","EmailService:newMonthlyBillingRegister()",$e->getMessage());
}
}
It gave me an error, but the problem comes when I delete attach() from my code, reverting all my changes on this email function, and when I try to send again the email the following message appears:
PHP Warning: fopen(app/media/uploads/clinic/monthly-billing/user_1_clinic_1_trimestral_billing_file_2019_05_09_08_22_35): failed to open stream: No such file or directory in /app/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php on line 142
The user_1_clinic_1_trimestral_billing_file_2019_05_09_08_22_35 file doesnt exist in app/media/uploads/clinic/monthly-billing/ folder and even in my database
...what's wrong?¿ I know is in my local but I dont know the reason of trying to search a file that doesn't exist and I didn't code anything to search it,
Anyone can help? Im using PHPStorm,
Thanks a lot for your attention!
I had to clean my email queue and it worked!! Thanks a lot Insane Skull for your help ;)

whmcs server-side pagination

I'm working with WHMCS and I notice that list views are not working well.
That's because in the clientarea's list views I have tousans thousands of records to display and the DataTables is crashing.
Is there a way to paginate from the server-side? I will appreciate any idea.
Here is an idea: let' say you are viewing the Domains list page, you can use ClientAreaPage hook to create a variable to load a "paged" copy of domains:
add_hook( 'ClientAreaPage', 1, function( $vars )
{
$myVars = array();
if (App::getCurrentFilename() == 'clientarea' && isset($_GET['action']) && $_GET['action'] == 'domains') {
$domains2 = array();
foreach($vars['domains'] as $k => $domain) {
if ($k < 3) {//your code to handle pagination
$domains2[] = $domain;
}
}
$myVars['domains2'] = $domains2;
$myVars['currentpage'] = 1;
}
return $myVars;
});
In clientareadomains.tpl (template file), you need to change $domains to $domains2:
{foreach key=num item=domain from=$domains2}
Of course, it is not simple task, you need to handle pagination in the hook and the tpl files.
Hope it helps.

How can I do a SQL query to an Oracle database with Perl and get the result as JSON?

I'm working with a legacy system and need to get data out of an Oracle database using Perl. Perl is one of the languages I don't spend much time in, so I'd like to be able to run a simple SQL query and pass the data to another system via JSON.
It seems that JSON, DBI, and DBD are available on this system. I'd like to accomplish this without making too many changes or updates to the system, if possible. I believe the JSON library is at version 5.12.2
I found DBI-Link library on Github and I believe this file is almost exactly what I need:
#!/usr/bin/perl -l
use strict;
use warnings;
$|++;
use JSON;
use DBI;
use DBD::Oracle qw(:ora_types);
my $dbh = DBI->connect(
'dbi:Oracle:host=localhost;sid=xe',
'hr',
'foobar',
{
AutoCommit => 1,
RaiseError => 1,
}
);
my #methods = qw(table_info column_info primary_key_info);
foreach my $method (#methods) {
if ( $dbh->can($method) ) {
print "Handle has method $method. w00t!"
}
else {
$dbh->disconnect;
print "Sadly, handle does not have method $method. D'oh!";
exit;
}
}
my $sth=$dbh->table_info('%', '%', '%', 'TABLE');
while(my $table = $sth->fetchrow_hashref) {
my $t;
$t->{'Table Name'} = $table->{TABLE_NAME};
$t->{'Column Info'} = $dbh->column_info(
undef,
$table->{TABLE_SCHEM},
$table->{TABLE_NAME},
'%'
)->fetchall_arrayref({});
$t->{'Primary Key Info'} = $dbh->primary_key_info(
undef,
$table->{TABLE_SCHEM},
$table->{TABLE_NAME}
)->fetchall_arrayref({});
print map {"$_: ". json_encode($t->{$_})} grep{ defined $t->{$_} } 'Table Name', 'Column Info', 'Primary Key Info';
print;
}
$sth->finish;
$dbh->disconnect;
The Error
I've installed the dependencies but when I run it I am getting:
Undefined subroutine &main::json_encode called at ./oracle.t line 47.
I searched the rest of the source in that repository and don't see any my json_encode definition, so maybe I have a version of the JSON library that is too old is my possible idea, but it seems unlikely that the json_encode method would have changed names.
The Next Steps
After I get json_encode to work I know I will need to execute a custom query and then save the data, it would be something like this:
$sth = $dbh->prepare("select * from records where pending = 1");
$sth->execute;
my $records = new HASH;
while($r = $sth->fetchrow_hashref)
{
$records << $r
}
my $json = json_encode($records)
However I'm unsure how to build the $records object for encoding so any help would be appreciated. I have searched stackoverflow, google, and github for perl examples of oracle to json and only had luck with the code from that DBI-Link repo.
According to the documentation for the JSON module, the function you want is encode_json and not json_encode.
I'd probably store the records in an array of hashes; something like this:
my #records;
while (my $r = $sth->fetchrow_hashref)
{
push(#records, $r);
}
If you know what field you want a hash-of-hashes keyed on:
my %records;
while (my $r = $sth->fetchrow_hashref)
{
$records{ $r->{key_field} } = $r;
}

retrieve data from online database using input file

Im using Postgres 9.3 on MacOSX.
I would be very happy if anyone could point me in the right direction here. I would like to write a function which connects to an existing (online) database (e.g. this one) and retrieves data (in this case shapefiles) using an input file with appropriate strings (in this case MRGIDs). Im sorry I don't have any code, I literally don't know where to start and I don't seem to find any threads on it. Maybe SQL isn't the way to go here?
Input file example;
species,mrgids
Sp1,4279
Sp1,8366
Sp1,21899
Sp1,21834
Sp1,7130
Sp1,1905
Sp1,21900
Sp1,5679
Sp1,5696
Thanks!
This is almost certainly done best outside the database, using a script in your choice of language. I'd use Python and psycopg2, but things like Ruby + the Pg gem, Perl and DBI / DBD::Pg, or even PHP and PDO, are equally reasonable choices.
Your code can do an HTTP fetch, then (if it's CSV-like) use the COPY command to load the data into PostgreSQL. If it's a shapefile, you can feed the data to PostGIS's shp2pgsql loader, or make individual INSERTs using the GeomFromText PostGIS function.
You could do the HTTP fetch from a PL/Pythonu or PL/Perlu stored procedure, but there'd be no real benefit over just doing it from a script, and it'd be more robust as an external script.
So, really, you need to split this problem up.
You'll need code to talk to the website(s) of interest, possibly including things like HTTP POSTs to submit forms. Or, preferably, use a web API for the site(s) that's designed for automatic scripted interaction. Most simple RESTful APIs are easy to use from scripting languages using libraries like Perl's LWP, Python's httplib, etc. In the case of the site you linked to, as user623952 mentioned, there's a RESTful API.
Then you'll need code to fetch the data of interest, and code to read the fetched data and load it into PostgreSQL. You might want to download all the data then load it, or you may want to stream it into the database as it's downloaded (pipe to shp2pgsql, etc).
this a very basic example with with PHP and CURL
I used your input file exactly and saved it as input.txt
species,mrgids
Sp1,4279
Sp1,8366
Sp1,21899
Sp1,21834
Sp1,7130
Sp1,1905
Sp1,21900
Sp1,5679
Sp1,5696
and this is the PHP and CURL doing its stuff:
<?php
$base_url = "http://www.marineregions.org/rest/getGazetteerRecordByMRGID.json/%s/";
// just get the input file into an array to use
$csv = read_file("input.txt");
// if you want to see the format of $csv
print "<pre>".print_r($csv,true)."</pre>";
// go through each csv item and run a curl request on it
foreach($csv as $i => $data)
{
$mrgids = $data['mrgids'];
$url = sprintf($base_url,$mrgids);
$response = run_curl_request($url);
if ($response!==false)
{
//http://us2.php.net/manual/en/function.json-decode.php
$json = json_decode($response,true);
if (!is_null($json))
{
// this is where you would write the code to stick this info in
// your DB or do whatever you want with it...
print "<pre>$url \n".print_r($json,true)."\n\n</pre>";
}
else
{
print "error: response was not proper JSON for $url <br/><br/>";
print $response."<br/><br/><br/>";
}
}
else
{
print "error: response was false for $url <br/><br/>";
}
}
function read_file($filename, $has_headers=true, $assoc=true)
{
$headers = array();
$row = 1;
if (($handle = fopen($filename, "r")) !== FALSE)
{
$return = array();
if ($has_headers)
{
if (($data = fgetcsv($handle, 1000, ",")) !==false)
{
$headers = $data;
}
}
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
if ($assoc)
{
$temp = array();
foreach($headers as $hi => $header)
{
$temp[$header] = (isset($data[$hi])) ? $data[$hi] : '';
}
$return[] = $temp;
}
else
{
$return[] = $data;
}
}
fclose($handle);
}
else
{
$return = false;
}
return $return;
}
// requires PHP CURL extension
// http://php.net/manual/en/function.curl-setopt.php
function run_curl_request($url)
{
// create curl resource
$ch = curl_init();
$defaults = array(
CURLOPT_POST => false,
CURLOPT_HEADER => false,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => true,
CURLOPT_FAILONERROR => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FORBID_REUSE => true,
CURLOPT_TIMEOUT => 4
);
curl_setopt_array($ch, $defaults);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
return $output;
}
?>
And if it worked, you get a bunch of these as output:
http://www.marineregions.org/rest/getGazetteerRecordByMRGID.json/4279/
Array
(
[MRGID] => 4279
[gazetteerSource] => IHO 23-3rd: Limits of Oceans and Seas, Special Publication 23, 3rd Edition 1953, published by the International Hydrographic Organization.
[placeType] => IHO Sea Area
[latitude] => 39.749996185303
[longitude] => 5.0942182540894
[minLatitude] => 35.071937561035
[minLongitude] => -6.0326728820801
[maxLatitude] => 44.42805480957
[maxLongitude] => 16.221109390259
[precision] => 1079464.0796258
[preferredGazetteerName] => Mediterranean Sea - Western Basin
[preferredGazetteerNameLang] => English
[status] => standard
[accepted] => 4279
)
notes:
I had to do this to get CURL to work on WAMP for PHP 5.3.13
json_decde()
curl_setopt()
curl_exec()
fgetcsv()
curl_multi_exec() - look into this if you chose this route, you will want it

Magento 1.6, Google Shopping / Products / Content

Magento 1.6 was out at the beginning of this week but upgrading from 1.5.1 with the mage_googleshopping extension (http://www.magentocommerce.com/magento-connect/Magento+Core/extension/6887/mage_googleshopping) up to v.1.6 was not something feasible.
mage_googleshopping remained compatible only with 1.5. Any working alternative to have the mage_googleshopping extension available on a clean Magento 1.6 installation or we have to wait for a stable extension release which goes with v.1.6?
Cheers,
Bogdan
I have browsed the Internet and searched for a problem to this, eventually I've turned into this script which runes separately but it connects to the Magento DB. The scripts generates the file, which can be uploaded following a schedule to Google.
Besides the fact that the script is totally editable, you can fully monitor all the processes behind it. The Magento script still can't be removed from a 1.6 Magento version.
The script wasn't developed by me but I did update it according with the latest rules enforced from 22/9/2011 by Google.
<code>
<?php
define('SAVE_FEED_LOCATION','google_base_feed.txt');
set_time_limit(1800);
require_once '../app/Mage.php';
Mage::app('default');
try{
$handle = fopen(SAVE_FEED_LOCATION, 'w');
$heading = array('id','mpn','title','description','link','image_link','price','brand','product_type','condition', 'google_product_category', 'manufacturer', 'availability');
$feed_line=implode("\t", $heading)."\r\n";
fwrite($handle, $feed_line);
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('status', 1);
$products->addAttributeToFilter('visibility', 4);
$products->addAttributeToSelect('*');
$prodIds=$products->getAllIds();
$product = Mage::getModel('catalog/product');
$counter_test = 0;
foreach($prodIds as $productId) {
if (++$counter_test < 30000){
$product->load($productId);
$product_data = array();
$product_data['sku'] = $product->getSku();
$product_data['mpn'] = $product->getSku();
$title_temp = $product->getName();
if (strlen($title_temp) > 70){
$title_temp = str_replace("Supply", "", $title_temp);
$title_temp = str_replace(" ", " ", $title_temp);
}
$product_data['title'] = $title_temp;
$product_data['description'] = substr(iconv("UTF-8","UTF-8//IGNORE",$product->getDescription()), 0, 900);
$product_data['Deeplink'] = "http://www.directmall.co.uk/".$product->getUrlPath();
$product_data['image_link'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
$price_temp = round($product->getPrice(),2);
$product_data['price'] = round($product->getPrice(),2) + 5;
$product_data['brand'] = $product->getData('brand');
$product_data['product_type'] = 'Laptop Chargers & Adapters';
$product_data['condition'] = "new";
$product_data['category'] = $product_data['brand'];
$product_data['manufacturer'] = $product_data['brand'];
$product_data['availability'] = "in stock";
foreach($product_data as $k=>$val){
$bad=array('"',"\r\n","\n","\r","\t");
$good=array(""," "," "," ","");
$product_data[$k] = '"'.str_replace($bad,$good,$val).'"';
}
echo $counter_test . " ";
$feed_line = implode("\t", $product_data)."\r\n";
fwrite($handle, $feed_line);
fflush($handle);
}
}
fclose($handle);
}
catch(Exception $e){
die($e->getMessage());
}</code>
Change www.directmall.co.uk into what you need.
Assign the proper permissions.
Fully updated according with Google's requirements.