2014年7月10日星期四

Unity Android facebook hash SSL problem

Download and install OpenSSL.
Add the OpenSSL directory to your path.
  • Go to: Control Panel > System > Advanced system settings > Environment Variables
  • Select the Variable "Path" in the "System variables" window and click Edit.
  • Add the path to your OpenSSL bin folder to the end of the "Variable value" text. e.g. I added ";C:\Program Files\OpenSSL-Win64\bin" to the end of the value text.
Restart Unity3D.
If you get the error in FacebookSettings "Keytool not found", you need to add the JDK (Java Development Kit) bin directory to the Path variable value.
  • Follow the same steps as before, but instead of the OpenSSL bin path, add the JDK bin path. e.g. I added ";C:\Program Files\Java\jdk1.7.0_45\bin" to the end of the value text.


If error occurred after restart unity
go to Control Panel > advanced system setting > environment variables
edit "Path" to C:\Windows\System32;C:\Program Files\Java\jdk1.7.0_51\bin;C:\OpenSSL\bin

2014年5月5日星期一

php sql injection prevent

mysql_real_escape_string($value)

php get value from url

for example url.com?code=abc

$active = htmlspecialchars($_GET["code"]);

$active = abc;

javascript count down and redirect

<html>
<head>
<script type="text/javascript">
var counter = 5;
setInterval(function() {
counter--;
if(counter < 0) {
window.location = 'index.php';
} else {
document.getElementById("count").innerHTML = counter;
}
}, 1000);
</script>
</head>
<body>
<?php echo $msg ?><b id="count">5</b> seconds.
</body>
</html>

QR Generator Download

http://systemtest.webuda.com/QR_Gen.rar

SQL insert value

INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);

2014年5月4日星期日

javascript check numeric

isNaN(value)

javascript simple email validation

var filter = /[\w-]+@([\w-]+\.)+[\w-]+/;

if (!filter.test(email)) {
alert('Please enter a valid email address');
}

javascript get form element

<script language="javascript">

function validate_form() {

var username = document.forms['register'].elements['user_username'].value;
var password = document.forms['register'].elements['user_pass'].value;
var name = document.forms['register'].elements['user_name'].value;
var email = document.forms['register'].elements['user_email'].value;
var phone = document.forms['register'].elements['user_phone'].value;

}
</script>

<form name="register" method="post" action="register.php">
<table>
<tr><td>Username</td><td>: <input type="text" name="user_username"></td></tr>
<tr><td>Password</td><td>: <input type="text" name="user_pass"></td></tr>
<tr><td>Name</td><td>: <input type="text" name="user_name"></td></tr>
<tr><td>Email Address</td><td>: <input type="text" name="user_email"></td></tr>
<tr><td>Phone number</td><td>: <input type="text" name="user_phone"></td></tr>
<tr><td colspan="2" align="center"><input type="Button" onClick = "validate_form()" value="Register"></td></tr>
</table>
</form>

php sql query and fetch results

$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);

while ($row = mysql_fetch_row($result)) {
    echo "Table: {$row[0]}\n";
}

php include file

<?php include("conn.php"); ?>

php testing on database connection

<?php
if (!mysql_connect( 'localhost', 'root', '')) {
    echo 'Could not connect to mysql';
    exit;
}

$dbname = 'demo';
$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);

if (!$result) {
    echo "DB Error, could not list tables\n";
    echo 'MySQL Error: ' . mysql_error();
    exit;
}

while ($row = mysql_fetch_row($result)) {
    echo "Table: {$row[0]}\n";
}

mysql_free_result($result);
?>

php connect database

<?php
$link_identifier = mysql_connect('localhost', 'root', 'password');
mysql_set_charset('UTF8', $link_identifier);
mysql_select_db("database name");
?>

2014年3月11日星期二

Installing ASP.NET on Windows 7 (Step by Step)

It had takes me few hours to figure out how to install ASP.NET on Windows 7, so I decided to make a step by step tutorial in order to help more people that still struggling with the installation.

Before starting anything, please make sure that you have the administrative user rights.

Step 1: Start Menu -> Control Panel



Step 2: Programs -> Turn Windows features on or off



Step 3:  click on the features that are checked on the following screens and then hit the OK button.



Step 4: After finishing step 3, open a web browser and type "localhost" in URL, press enter and you will now see the welcome page.
For those programmers that using wamp server and IIS together, they will find that either one of it is not running, either the server activated is apache or asp.net, it won't running both at the same time.

In this case, I had find out a useful method to overcome this problem, that is run only one server at a time, off the other one when not in used. In order to run ASP.net, you need to switch off the wamp server by configuring the ports like what I did in the pictures below:

Select Wamp server -> Apache -> httpd.conf


Change Listen and ServerName localhost from 80 to 8080


Restart Wamp services so that changes will take effect


Search "Internet Information Services" in Startup menu


Select on "Default Web Site" and click on "Start"


Type "localhost" in browser URL and here you will see the IIS is running

Here is the end of the installation of ASP.NET, thanks for viewing :D Happy Coding~