dinsdag 17 maart 2015

Teddy woofpaw Wordpress Installer android app

Installing wordpress on your webhost has never been so easy, as with Teddy Woofpaw wordpress installer.

Step1:
Download, Install & start the wordpress installer app on your android device. (search google play for teddy wordpress installer).

Step2:
Input the credentials provided by your webhost: Domain name, ftp hostname, ftp user, ftp password & click install.


Step 3:
Enter the mysql user and password,


Done! Wordpress is up and running!

Step 4:

Official wordpress app can now be installed and used to connect to your site.







Current limitation:
will always be installed to the domain root.


Encountering a problem?
Determining the correct folder for the ftp uploads is done simply by trying to open certain folders in the right order.

The order in which the app tries to enter folders is this:

domains \  _usersupplieddomain_ \  html \ htdocs \ public_html \ www \ wwwroot

This ensures support for all modern webhosts.
Please let me know if your webhost uses an incompatible folder layout on the ftpserver, and provide me a screenshot (via email (click the keyboard) or here in the comment section), i'd be happy to update the app.


Geek talk; Technical explanation of how the app works
When the user submits the data, the app connects with the ftp.
In slow mode (max compatible), next: the app uploads http://wordpress.org/latest.zip.
Then, the app uploads an php script (click to see it).
After uploading is complete, the app opens a webview, visits the url to the php script.
In fast mode, the php script downloads http://wordpress.org/latest.zip.
The php script unzips the wordpress zip file and puts everything in place.
The php script deletes itself, and sends the webview in the app user to the wordpress first-run script with a header redirect.


maandag 16 maart 2015

Wordpress installer PHP script

Example PHP script for installing wordpress in the root of your domain.
This exact script is used in my new upcoming android app Wordpress Installer.
You can save it in a file, upload it to your host and run it in your browser.
It will download Wordpress, unzip the wordpress archive, launch the wordpress first-run script, afterwards this script will delete itself.
the $wpextr variable can be changed to install into a subfolder. Use a leading and a trailing slash.


<?php

// www.bartbosma.eu
// 2015
@ob_start();
function rrmdir($dir) {
   if (is_dir($dir)) {
     $objects = scandir($dir);
     foreach ($objects as $object) {
       if ($object != "." && $object != "..") {
         if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
       }
     }
     reset($objects);
     rmdir($dir);
   }
}
$wpextr="/wp/";
$wpextr="/";
$url = "https://wordpress.org/latest.zip";
$destination = "wordpress_latest.zip";   
if (!file_exists($destination)){
   
    if (function_exists("curl_init")){   
    $fp = fopen ($destination, 'w+');
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
    curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch, CURLOPT_AUTOREFERER, true );

    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 100 );
    curl_setopt( $ch, CURLOPT_FILE, $fp );
    curl_exec( $ch );
    curl_close( $ch );
  fclose( $fp );
}else{
    if (!file_put_contents($destination, fopen($url, "r"))){
        $succes=false;
        die("Cant download file..");   
    }
   
}
if (filesize($destination) > 0) {$succes= true;echo "Archive download succes.<br />";}else{$succes=false;}


}else{
    echo "Archive already exists, no download required<br />";
$succes=true;}   


if ($succes==true)
{
$zip = new ZipArchive;
if ($zip->open($destination) === TRUE) {
    #echo $_SERVER['DOCUMENT_ROOT'].$wpextr;
    $zip->extractTo($_SERVER['DOCUMENT_ROOT'].$wpextr);
    $zip->close();
    echo 'Archive extracted succes';
    sleep(1);

if ($handle = opendir($_SERVER['DOCUMENT_ROOT'].$wpextr.'wordpress')) {
    while (false !== ($fileName = readdir($handle))) {
        if ($fileName!==".." ||$fileName!==".")     @rename($_SERVER['DOCUMENT_ROOT'].$wpextr."wordpress/".$fileName, $_SERVER['DOCUMENT_ROOT'].$wpextr.$fileName);
    }
    closedir($handle);
   

@unlink("wpinst.php");
sleep(1);
rrmdir($_SERVER['DOCUMENT_ROOT'].$wpextr.'wordpress');
header("Location: http://".$_SERVER['HTTP_HOST'].$wpextr."/wp-admin/install.php");

}
   
   
} else {
    echo 'ExtractTo function: Opening the wordpress zip file failed. Your webhost seems ancient.';
}   
   
}
// www.bartbosma.eu xD
?>

maandag 9 maart 2015

Android HTPC TVMC hdmistick ultimate guide tutorial

So, you stumbled upon those android HDMI sticks, and now you wonder how to set it up for epic HTPC usage, and what software to use.

I'll explain what i did.

First i bought the hardware.
I bought:
Rikomagic 802 version 3.
This version has some small wifi bugs, requiring a hard reboot occasionally, with a minute pauze after powerdown.

I added:
externally powered USB hub with support for all different types of SD cards (brand Icidu).
External USB blu-ray player.
External USB HDD for MP3/photos.
Instead of powering the HDMI stick with the TV it's USB slot, i decided to use an old USB DC adapter (from some phone).


Setting up the software to interact together nicely, requires some proper effort, but nothing too fancy.
Controlling the device can be done with a keyboard that includes multimedia keys like play / stop / back.
Using the TAB button and the windows keys, you have enough to set up the device for remote control.

The first remote control app you (not mandatory) need on both your HDMI stick as your android phone, is RemoDroid:
https://play.google.com/store/apps/details?id=de.im.RemoDroid
Determining the IP address to connect to, on the HDMI device, simply goto wifi settings and click your wifi network. Your IP should popup.
Now, unfortunately remodroid is kinda slow, so if you want to, like, play games on your hdmi stick, there are some specialist stores selling nice USB/bluetooth remote control devices, tailored for Android specifically.


Next, installing TVMC is the easiest way to go:
http://www.tvaddons.ag/tvmc-android/
It comes with all the nice plugins preconfigured.
Icefilms and NavX are my recommendations.

Ofcourse there are tons of repositorys with nice plugins, ill list the most common, you can set these up as file sources in TVMC; system > file manager > add source:

http://srp.nu
https://superrepo.org/

i.totalxbmc.tv
http://www.totalxbmc.tv/

http://xunitytalk.com/xfinity/
http://www.xunitytalk.com/

Good, now you could basically watch any tv show/movie, have subtitles in your preferred language (in TVMC goto addons and install subtitle addon).

TVMC on android has some minor hardware-keyboard bugs. Backspace won't work, delete key (also multimedia back key) acts like backspace instead.
But who cares, since we will remote control the device with the official XBMC remote app:
https://play.google.com/store/apps/details?id=org.xbmc.android.remote
(which became outdated, search for KODI instead in the play store for alternatives)

Or if you are exrtemely special, you can use an Apple phone:
https://itunes.apple.com/nl/app/official-xbmc-remote/id520480364?mt=8
However i strongly suggest that Apple users also buy an Apple HDMI stick. They are very rare, but keep looking and maybe one day you might find one.

Before this TVMC remote control app works, you need to goto settings in TVMC and enable the remote control setting.

If you are dutch, you could also install the xot-uzg plugin:
http://www.rieter.net/

Installing SambaDroid APP allows you to manage / sync your external USB hard drive its MP3 database with your linux/windows workstation, which you probably use to collect MP3 files:
https://play.google.com/store/apps/details?id=berserker.android.apps.sambadroid&hl=nl

There are some andoid apps which allow one to collect mp3 files aswell, like goSeek:
https://play.google.com/store/apps/details?id=org.thylakoid.goseek

an example sync from workstation to miniHTPC script for use in windows: (you can create a .bat file with this text in it, or open an terminal via start-search "cmd":)

robocopy  "E:\My Music\sort" \\SAMBADROID\usb\USB_disk0\OneTouch4\user\mp3 /R:1 /MIR /Z /DCOPY:T /FFT

Syncing from the device to your windows workstation, use the same command, but just name the local folder last.

Sometimes the drive ID will change depending on your hdmistick, you can just add multiple commands with multiple drive ids like DISK3 etc
Ofcourse a local NAS drive is much prefered.


There is just one problem now.
You need to turn on your TV before you can play music from your HTPC device.
Fixing this requires one more investment.
It's unfortunately a device not often used thus not for sale at most stores, search engines or ebay will pick it up when you search for stuff like HDMI to HDMI + audio extractor.
One brand that i know of is DeLOCK, searching delock HDMI extractor should give you results.
DON'T buy an USB soundcard. it WON'T work.

Perhaps you want TVMC to launch automatically whenever you turn on the device, simply get an app like autostart:
https://play.google.com/store/apps/details?id=com.autostart

MAMCWES, The most secure mysqli php class wrapper i've ever seen.

This post is all about...... mamcwes (GPL v3)

What's that?

Easy to use PHP class for MySQL interaction, optionally allowing linking between multiple database user logins (with custom user rights on your databases/tables) and custom userlevels.

For who is it?

PHP writers / developers / coders generally.

What does it do, how does it differ from other mysqli classes?

Its an mysqli wrapper providing extensive security protection.
Basically, the required credentials for the mysqli connection are loaded only very briefly into the php memory, inside the class call. It is fully impossible for people to get the mysql login credentials.

Furtermore, it allows you to login as multiple mysql users based on your custom userlevel table, useful for hard-restricting permissions to the database, providing even more security.

How does it work?

$this->gl_conf_ulvl in the mysqlcfgdata.inc.php is the userlevel setting. Default it loads from $_SESSION['rdmstring'].
One should use the escstr function to parse any kind of user input.
Looking at the class (functions) name(s), it won't be too hard figuring out how to make the DB connection / calls.

Usage example:
First add your database connection login to the cfg file. @session_start();
$_SESSION['rdmstring']="us0rlv0l";
$_SESSION['us0rlv0l']=1; # userlevel, optionally set by your own login script. will be used to select login data (array) id from config file.





#For more protection you could use:
#$_SESSION['rdmstring']="md5(time());";

#$_SESSION[${$_SESSION['rdmstring']}]=1; # userlevel

$mysqlerrordie=0;# 1 to terminate php execution on mysql error.
#$olddir=getcwd(); #optional
#chdir("classes");
include "mysql.class.5.php"; # note: when you put the class in another folder, use chdir("classes"); first to navigate to that folder. go back with chdir($olddir); if needed.
#chdir($olddir);

$sql=@new MYSQL();
$r=$sql->query("
SELECT badword
FROM `badwords` WHERE `badword` = '".$sql->escstr(customvalidatefunction($_POST['badword']))."'"
");

if (isset($r) && $sql->count_rows($r) > 0){
foreach($sql->db_array2($r) as $item){ #also available are db_array, db_object(2) and db_assoc(2), whereas the 2 means more then 1 entry can be fetched, thus requiring processing via foreach loop.
print_r($item);
echo $item[0];
}



Basically, if you build your own userlogin system with this class, you first connect with a readonly mysql user that retrieves your user table, retrieves the userlevel of the logged in person, and than you can use that userlevel variable to select the desired mysql user credentials (permissions) for that userlevel, while the userlevel will always be stored in a random Session variable.
Untracable and ultrasecure.

Download

mamcwes 0.2 (English)