Unable to extract and upload PackageInfo.xml

If you get the following error on Microsoft Partner Center: Unable to extract and upload PackageInfo.xmlUnable to extract and upload PackageInfo.xml You just need to repackage the HLKX file to solve the issue. -Rename the current .hckx/hlkx file to .zip -Extract to a folder -Open the folder -Select all items, then right-click and select Send […]

Stop Bad Bots from Crawling Your Website

A robots.txt example to block bad bots from crawling your website: User-agent: * Allow: /   User-agent: CuteStat Disallow: /   User-agent: AhrefsBot Disallow: /   User-agent: SemrushBot Disallow: /   User-agent: GrapeshotCrawler Disallow: /   User-agent: WebsiteOutlook Disallow: /   User-agent: MJ12bot Disallow: /User-agent: * Allow: / User-agent: CuteStat Disallow: / User-agent: AhrefsBot Disallow: […]

DEB.SURY.ORG Updated the Signing Key (March 2019)

On 18 March 2019 OndÅ™ej announced that he changed the signing key: https://www.patreon.com/posts/dpa-new-signing-25451165 I was informed that the current DPA signing key DF3D585DB8F0EB658690A554AC0E47584A7A714D was present on the server maintained by an other user of the repositories that got compromised. I do not believe that the users of the packages.sury.org repositories are at any risk because […]

PHP Check if XML String is Valid

Simple PHP function to check if a XML string is valid: function isValidXML($xml) { libxml_use_internal_errors(true);   $doc = new DOMDocument(‘1.0’, ‘utf-8’); $doc->loadXML($xml);   $errors = libxml_get_errors();   libxml_clear_errors();   if(empty($errors)){ return array("valid" => true); }   $error = $errors[0];   if($error->level < 3){ return array("valid" => true); }   $explodedxml = explode("r", $xml); $badxml = […]

PHP Securely Save Passwords in Your Database

To securely save passwords in your database you should use password_hash()! When the user registers, you hash the password and then save it to the database: // Create the hashed password from the user submitted password // Notice that we hash() the password using sha256 before creating the hashed password   $hashed_password = password_hash(hash("sha256", trim($_POST["password"])), […]

Redirect 404 Errors to Homepage with Nginx

You can redirect 404 errors to homepage with Nginx. To do so, just add this inside server {}: # Redirect 404 errors to homepage error_page 404 = @myownredirect; # My custom 302 redirect to homepage location @myownredirect { return 302 /; }# Redirect 404 errors to homepage error_page 404 = @myownredirect; # My custom 302 […]

Bash Script to Dump a MySQL Table into a CSV File

Simple bash script to dump a MySQL table into a CSV file: mysql dbname -u’user’ -p’password’ <<QUERY_INPUT SELECT field1, field2, field3, field4 FROM table_name INTO OUTFILE ‘/path/file.csv’ FIELDS ENCLOSED BY ‘"’ TERMINATED BY ‘,’ ESCAPED BY ‘"’ LINES TERMINATED BY ‘\r\n’; QUERY_INPUTmysql dbname -u’user’ -p’password’ <<QUERY_INPUT SELECT field1, field2, field3, field4 FROM table_name INTO OUTFILE […]

How to block CuteStat from crawling your website

CuteStat shows traffic statistics, but it is bad for your website! It steals your page title and thus also your position on Google searches! To block CuteStat from crawling your website, add this on robots.txt: User-agent: * Allow: /   User-agent: CuteStat Disallow: /User-agent: * Allow: / User-agent: CuteStat Disallow: / In case your website […]

How to Test Robots.txt via Google Search Console

First register your website on Google Search Console: https://search.google.com/search-console/about Then browse to this Robots Testing Tool: https://www.google.com/webmasters/tools/robots-testing-tool Select the property (website) and test your Robots.txt. You can test if a web page is blocked by Googlebot.

PHP Generate Secure Random Passwords

This simple PHP function can generate secure random passwords: function generate_strong_password($length = 15, $symbols = array("!", "#", "=", "@", "+", "(")) { $characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;   $charactersLength = strlen($characters);   $randomString = ”;   // Generate the random alphanumeric string for ($i = 0; $i < $length; $i++) $randomString .= $characters[random_int(0, $charactersLength – 1)];   […]