Stories

eBay Parcel Tracking!!!??

Posted on

So maybe you are like me and you collect the odd parcel from eBay every now and then, but they give you a crazy tracking number that doesn’t work?

Well, you need to check out this site, which will tell you where your package is and where it’s going.

This is especially helpful when Australia Post doesn’t specially know either.

Enter this example number, and you’ll see what I’m talking about: UPAAB000000234365152
(It’s not my order)

https://parceltracking.pb.com/app/#/dashboard/

UPAABXXXXXXXXXXXXXXX

This isn’t UPS, USPS or HDL. It’s for eBay postage.

Advertisements

Raid6 Recovery on a ReadyNAS Ultra 6

Posted on Updated on

Ok, well this was the update I didn’t want to ever need to do. But, I’ve done it and so far it’s been sucessful.

About a month ago, I was sitting using my computer, and for no “apparent” reason, I got a message saying “Server is shutting down”. I thought that was weird, but it did as it said. My NetGear ReadyNAS Ultra 6 shut itself down, and didn’t want to come back up – at all.

I didn’t know what to do, so I let it sit for a while.

I’ve always kept the NAS up to date with the official stock OS of RAIDiator 4.X, so I knew it probably wasn’t going to be something weird of a customisation I’d done.

A long time ago, I’d read that this NAS had a VGA out port on the motherboard. I’d never looked at this before, but I thought that may be my go-to. So I pulled the guts out of the board to see what the problem was.

0-02-01-8f5ea694993c01899c1a59baf4c672f5b62b3c73a9f12917d0e2db4f7c55eb02_full.jpg

I figured a drive may have died, but I didn’t know which one, or how to diagnose the issue, because the NAS just wouldn’t boot. In the past I’d received emails telling me that drives were failing and that it was going to shut down, but this time… I didn’t get those messages.

So, I travelled to my local computer shop and bought a new 3TB WD Red drive, and a VGA breakout port… turns out while the computer geek who served me, didn’t notice (nor myself) that the pins on the AUS GEFORCE GT 710 card was actually 8 pins and not the required 15 pins. So… that was a waste of $40.

Instead I went to JayCar and collected all the bits I needed to make sure I could do this thing and potentially read any output of the VGA port on the board. At this stage I didn’t even know if I could do it…

0-02-01-ecfe1fb3675c99580a9113aff136182381bf790e606639edf64f57cdaaa67b35_full.jpg

So, I built all the bits and then when I booted the device… It showed up on the screen… BINGO! 🙂

0-02-01-8a3763833f531aca3ce23076f6e1c273291051ee7d3971a8ee58d9f337b5457d_full.jpg

I had a dead drive.

This NAS is just your standard computer with bit of custom work for the NAS stuff. The BIOS told me it was all normal and that the drive was dead. So… I took out my Seagate 3TB drive – yeah, you know the type… What ever you do in the future – stay clear of these drives ST3000DM001. Trust me. Just look them up in Google, and you’ll see what I’m getting at.

I replaced it with the WD Red drive and boom, it started up and started a resync.

0-02-01-2d99e24aa249ba75001b3c9ef794091da2773dd1460fbf9c0fbd9a3ca39dfcf2_full.jpg0-02-01-cbcd6e540f933d49d335e909f5395c9c9c2c724cd52bd26fc01298239643c6a1_full.jpg

I had to move the NAS to a different location and was a bit hesitant to switch it off during a resync, but, if a controlled shutdown is performed, a resync will continue safely.

Everything was going great.

I fixed up the notifications so I’d get alerted via email and also push alerts (via Pushover) and it was all good. Actually, while I’m on that, you should look in to Pushover.net for real-time alerts on your phone or device. It’s brilliant.

So, the big scary problem happened next.

I was tidying up around the place and a small power plug knocked the top of the NAS. The NAS beeped (which is weird, ’cause it beeps when the front door opens too) and I received a series of messages on my phone too…

Those messages were the very big concern.

***** File system check performed at Sun Oct  8 13:22:00 EST 2017 *****
fsck 1.42.12 (29-Aug-2014)
fsck.ext4: No such file or directory while trying to open /dev/c/c
Possibly non-existent device?

and

The paths for the shares listed below could not be found.  Typically, this occurs when the ReadyNAS is unable to access the data volume.
media
webroot
backup
[Sun Oct  8 13:22:17 EST 2017]

 

Oh dear… This meant bad news. really bad news.

So, I did some digging.

My Admin panel said “No Volumes”. I nearly freaked. My computer couldn’t located the shared drive paths either.

After doing some searching, I found a few answers I wasn’t sure about, but it couldn’t hurt.

I logged in via FTP. As suggested, there was nothing in the “/c/” path, or in the “/mount/c” path. So… this was troubling.

What I discovered which was worse is that RAID6 array had failed to mount, or load, or something. This was bad. 9TB of data missing…

This was as bad as it gets.

Or was it?

Below is a list of the commands I typed via SSH, and you can clearly see the results.

In case you don’t know how to SSH to your box, you should have already installed the Enable Root SSH Access” Addon. If you haven’t, then you’ll need to find a way in before you run these commands.

 
ReadyNas:~# cat /proc/mdstat
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md1 : active raid1 sda2[0] sdf2[8] sde2[7] sdd2[6] sdc2[9] sdb2[1]
 524276 blocks super 1.2 [6/6] [UUUUUU]
 
md0 : active raid1 sda1[0] sdf1[6] sde1[8] sdd1[7] sdc1[9] sdb1[2]
 4193268 blocks super 1.2 [6/6] [UUUUUU]
 
unused devices: <none>

ReadyNas:~# mdadm --examine
mdadm: No devices to examine

ReadyNas:~# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md1 : active raid1 sda2[0] sdf2[8] sde2[7] sdd2[6] sdc2[9] sdb2[1]
 524276 blocks super 1.2 [6/6] [UUUUUU]
 
md0 : active raid1 sda1[0] sdf1[6] sde1[8] sdd1[7] sdc1[9] sdb1[2]
 4193268 blocks super 1.2 [6/6] [UUUUUU]
 
unused devices: <none>

ReadyNas:~# mdadm --examine 
mdadm: No devices to examine

ReadyNas:~# mdadm --assemble --scan --assume-clean
mdadm:option --assume-clean not valid in assemble mode

ReadyNas:~# mdadm --assemble --scan 
mdadm: /dev/md/001AD40EDDAC:2 assembled from 5 drives and 1 rebuilding - not enough to start the array while not clean - consider --force.
mdadm: No arrays found in config file or automatically

ReadyNas:~# mdadm --scan 
mdadm: --scan does not set the mode, and so cannot be the first option.

ReadyNas:~# mdadm --assemble --scan
mdadm: /dev/md/001AD40EDDAC:2 assembled from 5 drives and 1 rebuilding - not enough to start the array while not clean - consider --force.
mdadm: No arrays found in config file or automatically

ReadyNas:~# mdadm --assemble --scan --force
mdadm: Marking array /dev/md/001AD40EDDAC:2 as 'clean'
mdadm: /dev/md/001AD40EDDAC:2 has been started with 5 drives (out of 6) and 1 rebuilding.

ReadyNas:~# cat /proc/mdstat 
Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md127 : active raid6 sda3[0] sdf3[6] sde3[8] sdd3[7] sdc3[9] sdb3[2]
 11702178816 blocks super 1.2 level 6, 64k chunk, algorithm 2 [6/5] [UU_UUU]
 [>....................] recovery = 2.4% (71975936/2925544704) finish=1255.9min speed=37866K/sec
 
md1 : active raid1 sda2[0] sdf2[8] sde2[7] sdd2[6] sdc2[9] sdb2[1]
 524276 blocks super 1.2 [6/6] [UUUUUU]
 
md0 : active raid1 sda1[0] sdf1[6] sde1[8] sdd1[7] sdc1[9] sdb1[2]
 4193268 blocks super 1.2 [6/6] [UUUUUU]
 
unused devices: <none>

 

As you can see, the md127 listing, this meant that the RAID6 was back! And… It was ready to resync!!

So, I cleanly restarted the box, and it’s now resyncing the data and all the shares are  working again. All shares are back. And I’m super happy I still have my data! 😀

 

I hope this helps someone. ‘Cause it was difficult to know what to do, but it was fairly simple in the end.

Getting the IPs from AWS on a load balancer using Piwik Stats

Posted on Updated on

I’ll keep this short and give the general gist of this.

Basically I had a problem, whereby Piwik was not getting the correct IP of the visitor, as the AWS setup was not passing the correct IP through on the expected value.

Try this code out as a test and see what you get.

Getting server/client IP:<br>

<?php
var_dump($_SERVER['SERVER_ADDR']);
var_dump($_SERVER['SERVER']); 
var_dump($_SERVER['HTTP_X_FORWARDED_PORT']);
var_dump($_SERVER['HTTP_X_FORWARDED_PROTO']);
var_dump($_SERVER['HTTP_X_FORWARDED_FOR']);
var_dump($_SERVER['SERVER_ADDR']);
var_dump($_SERVER['SERVER_PORT']);
var_dump($_SERVER['REMOTE_ADDR']);

echo "1: " . $_SERVER['SERVER_ADDR'] . "<br>";
echo "2: " . $_SERVER['SERVER'] . "<br>";
echo "3: " . $_SERVER['HTTP_X_FORWARDED_PORT'] . "<br>";
echo "4: " . $_SERVER['HTTP_X_FORWARDED_PROTO'] . "<br>";
echo "5: " . $_SERVER['HTTP_X_FORWARDED_FOR'] . "<br>";
echo "6: " . $_SERVER['SERVER_ADDR'] . "<br>";
echo "7: " . $_SERVER['SERVER_PORT'] . "<br>";
echo "8: " . $_SERVER['REMOTE_ADDR'] . "<br>";

echo phpinfo();
?>

As an intro, to help you figure out the correct value, use the above code as a test.

The problem with the suggestions on the Piwik site saying to make changes to these files, is that is didn’t work for me.

[General]
; Uncomment line below if you use a standard proxy
;proxy_client_headers[] = HTTP_X_FORWARDED_FOR
;proxy_host_headers[] = HTTP_X_FORWARDED_HOST

; Uncomment line below if you use CloudFlare
;proxy_client_headers[] = HTTP_CF_CONNECTING_IP

; Uncomment line below if you use another proxy (that sets Client-IP header)
;proxy_client_headers[] = HTTP_CLIENT_IP

You have more luck, but it’s for viewing here: https://piwik.org/faq/how-to-install/faq_98/

So, while there are many values in Piwik to have various settings, it’s worth filling in as many as possible…

The key value for this IP issue is this:

$IP_Tracker = $_SERVER['HTTP_X_FORWARDED_FOR'];

Here’s an example that will probably work for you. It’s pulled from a live site, but modified for anonymous use).

<?php

global $IDSITE;
$IDSITE = 2;  
    
// This is so we can get the correct IP of the visitor from behind the AWS load balancer.    
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) 
    { $IP_Tracker = $_SERVER['HTTP_X_FORWARDED_FOR'];} else
    { $IP_Tracker = $_SERVER['REMOTE_ADDR']; }
$pagetitle = "Home"; // The name of the tab for the stats.
// Tracking Code
// -- Piwik Tracking API init -- 
require_once "PiwikTracker.php";
PiwikTracker::$URL = 'http://loadbalancer.serverlocation.com/piwik/';

$t = new PiwikTracker( $IDSITE, 'http://loadbalancer.serverlocation.com/piwik/');

// End of configuration settings.  

// Optional function calls
$t->setUserAgent($_SERVER['HTTP_USER_AGENT']);
$t->setBrowserLanguage('en');
$vid = '';

// Allow the follow-through tracking from page to page. - Visitor ID
if( isset($_POST['vid']) ) { $vid = addslashes($_POST['vid']); } else { if( isset($_GET['vid']) ) { $vid = addslashes($_GET['vid']); } }; // get vid
if(strlen($vid) > 10 && strlen($vid)< 30) { $t->setVisitorId($vid); }; // double check it
 
// If you want to force the visitor IP, or force the server date time to a date in the past,
// it is required to authenticate the Tracking request by calling setTokenAuth
// You can pass the Super User token_auth or any user with 'admin' privilege on the website $idSite

$token_auth = "YOURTOKEN";
$t->setTokenAuth( $token_auth );
$t->setIp( $IP_Tracker );
  
// If you wanted to force to record the page view or conversion to a specific visitorId
$t->setUrl($url = 'https://app.yoursever.com/2015_home_tab.php');

// Finally, track the page view with a Custom Page Title
// In the standard JS API, the content of the <title> tag would be set as the page title
$t->doTrackPageView($pagetitle);
?>

<a href="http://app.yoursitecom/page2.php?vid=<?php echo $t->getVisitorId(); ?>">Page 2</a>

 

 

 

 

 

Artist and Song search of Spotify and iTunes via web URL

Posted on Updated on

This took me a while to find out how to do, so I thought I’d share my research to you.

I had a problem where I wanted users to be able to click on a link and it would open up the Spotify, or iTunes program to the search results of the values I passed it.

As mentioned, this took a long while to get. The Spotify one was easy as, and they should be commended for their simplicity. The iTunes one was not as easy to find.

So, this is my resulting code example, which I hope will help you in the future.

See this example work in JSFiddle
https://jsfiddle.net/vr_driver/e4q2nme3/13/

HTML Code

&lt;a href="https://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/advancedSearch?genreIndex=1&amp;media=music&amp;restrict=true&amp;submit=seeAllLockups&amp;entity=songs&amp;allArtistNames=tobyMac&amp;allTitle=Love+Broke+Thru"&gt;&lt;i class="fa fa-apple"&gt;&lt;/i&gt;Apple iTunes&lt;/a&gt;
&lt;a href="spotify:search:tobyMac+Love+Broke+Thru"&gt;&lt;i class="fa fa-spotify"&gt;&lt;/i&gt;Spotify&lt;/a&gt;

PHP Source Code

$artist = "TobyMac";
$title = "Love Broke Through";
echo '&lt;a href="spotify:search:' . str_replace(" ","+",$artist) . "+" . str_replace(" ","+",$title) . '"&gt;&lt;i class="fa fa-spotify"&gt;&lt;/i&gt; Spotify&lt;/a&gt;';
echo '&lt;a href="https://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/advancedSearch?genreIndex=1&amp;media=music&amp;restrict=true&amp;submit=seeAllLockups&amp;entity=songs&amp;allArtistNames=' . str_replace(" ","+",$artist) . "&amp;allTitle=" . str_replace(" ","+",$title) . '"&gt;&lt;i class="fa fa-apple"&gt;&lt;/i&gt; iTunes&lt;/a&gt;';

// Or so the browser opens a window and then closes it.
$iTunes_link = "https://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/advancedSearch?genreIndex=1&amp;media=music&amp;restrict=true&amp;submit=seeAllLockups&amp;entity=songs&amp;allArtistNames=". str_replace(" ","+",$artist) . "&amp;allTitle=" . str_replace(" ","+",$title);
echo '&lt;a href="javascript:closeOnLoad(\'' . $iTunes_link. '\');"&gt;&lt;i class="fa fa-apple"&gt;&lt;/i&gt;&lt;/a&gt;';

JS

&lt;script type="text/Javascript"&gt;
function closeOnLoad(myLink)
{
    var newWindow = window.open(myLink);
    newWindow.blur();
    setTimeout
    (
	function()
	{
	  newWindow.close();
	},
	1000
    );
};
&lt;/script&gt;

Both of these examples do 2 different things.
The Full iTunes example opens up a new window by JS and then closes it a second later. This is to allow the page to load, and then have the Apple page call the iTunes program. It then opens it to an advanced search page (which until I started playing with this stuff didn’t even know existed).

The Spotify example just opens the app directly if you have it installed – if you don’t use WordPress of course. They’ve wrecked the link in the example by removing the “spotify:search:” at the front of the link.

If this has helped you, please let me know, I’d love to hear, even send me a donation through PayPal.

Cloudflare is great – most of the time.

Posted on Updated on

So for the last month or so, I’ve given a few sites the Cloudflare boost. The DNS has come up faster, pages and the sites work much better.

However, I’ve discovered something it doesn’t work so well for…

I run GLPI and it’s great for computer digital asset management.

However today I discovered how frustrating it can be as well for certain applications. On my CMS and other static sites I have no problems with it, as it compresses the JS, CSS and HTML for speed – which is good.

But. As it turns out, GLPI doesn’t play nicely with a feature that CloudFlare offer. Granted, they call it BETA technology so I will give them that, but, after having upgraded my version to the latest and still have it breaking and breaking other parts that were not broken originally, I managed to finally figure out the problem.

The JS that Cloudflare inserts breaks pretty much every “html::” POST class in GLPI.

So, the solution is to disable what they call “Rocketscript”, and your site will work fine.

These pages will explain it a little better:

http://webmasters.stackexchange.com/questions/60276/how-does-cloudflares-rocket-loader-actually-work-and-how-can-a-developer-ensur
https://laracasts.com/discuss/channels/javascript/rocketscript-what-is-it
https://snippets.webaware.com.au/snippets/stop-cloudflare-rocketscript-breaking-wordpress-plugin-scripts/

Full Screen Webpage HTML5 API

Posted on Updated on

This code will make your website go in to a full screen view, with the click of a button.

Or, if you prefer, you can press CTL + ` instead.

I modified the original code from sitepointstatic.com with the keyboard shortcut, but it’s still basically the same.

          <span id="fullscreen">Go Full Screen</span>
JS Script:

        // full screen script         
        // http://blogs.sitepointstatic.com/examples/tech/full-screen/index.html
        var e = document.getElementById("fullscreen"); // button for activation.
        // var b = document.getElementById("body");  // Does not allow scrolling- good for individual elements, like pictures or video.
        var b = document.documentElement; // Does allow scrolling
        e.onclick = function() {
            if (RunPrefixMethod(document, "FullScreen") || RunPrefixMethod(document, "IsFullScreen")) {
                RunPrefixMethod(document, "CancelFullScreen");
            }
            else {
                RunPrefixMethod(b, "RequestFullScreen");
            }
        }
        
        var pfx = ["webkit", "moz", "ms", "o", ""];
        function RunPrefixMethod(obj, method) {
            var p = 0, m, t;
            while (p < pfx.length && !obj[m]) {
                m = method;
                if (pfx[p] == "") {
                    m = m.substr(0,1).toLowerCase() + m.substr(1);
                }
                m = pfx[p] + m;
                t = typeof obj[m];
                if (t != "undefined") {
                    pfx = [pfx[p]];
                    return (t == "function" ? obj[m]() : obj[m]);
                }
                p++;
            } 
        }
        
        // keydown event handler
        document.addEventListener('keydown', function(e) {
          if (e.ctrlKey && e.keyCode == 192) { // ` AND CTL
        RunPrefixMethod(b, "RequestFullScreen");
          }
        }, false);

Fail2Ban – You will lock yourself out

Posted on Updated on

There are parts I love about being able to manage a VPS, but there are parts I hate.

One of the biggest problems is if you get passwords wrong. Yep… It happens.

So when your server blocks your static IP, it gets difficult to get back in.

It’s not impossible, but, once you do you have to unblock yourself.

This took me a while to find, but it actually works, especially if you are running a Centos box with f2b.

Remove IP from blocklist

check its being blocked by running

iptables -L -n

if it is, unblock it by running

iptables -D <CHAIN> -s <IP>  -j <ACTION>

where <IP> is the one you want to remove, <ACTION> is what it does and <CHAIN> is the ruleset its blocked under. Some examples below;

iptables -L -n
...
Chain f2b-default (2 references)
target     prot opt source               destination
REJECT     all  --  217.147.243.129      anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere
...
server:# iptables -D f2b-default -s 217.147.243.129 -j REJECT # remove it
server:# /sbin/service iptables save 

Whitelisting

Whitelisting is setup in the jail.conf file using a space separated list.

[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not                          
# ban a host which matches an address in this list. Several addresses can be                             
# defined using space separator.
                                                                         
ignoreip = 127.0.0.1 192.168.1.0/24 8.8.8.8 XXX.XXX.XXX.XXX
# where the XXX.etc is your static IP.

# This will ignore connection coming from common private networks.
# Note that local connections can come from other than just 127.0.0.1, so
# this needs CIDR range too.
ignoreip = 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16

Source: http://wiki.vitro.co.uk/mw/Fail2ban