Skip navigation.

Contridentuallity

Not a fact, a theory!?

Posts tagged with "php"

Free Google Pagerank Script

, , , ...

With the Tribulant Google pagerank script, you can now instantly check your site's Google pagerank and output the results with either and image or text. There are two versions...one for an image and one for text.

To download and start using the Google pagerank script right now, click the link below :

Tribulant Google Pagerank Script v1.0

If you have any comments, suggestions or appraisals, please feel free to post them here.
All suggestions will be greatly appreciated, since it will allow me to improve the script

Free Turing/Captcha Image Script

, , , ...

Ever wanted to protect a form (such as a contact form) on your site to prevent spam bots from using your mail server to send out mass emails to hundreds...no thouands...hundreds of thousands of users?

I have the perfect solution for you. The Tribulant turing image script uses PHP GD to generate an image with random characters on it which needs to be typed in by the user in order to successfully submit a specific form on your site.

Tribulant Turing Image Script

Give it a shot.
Unfortunately...as I type this, the documentation for this script isn't done yet. It will be done and ready very soon, though the implementation is very simple.

The backend creates a new $_SESSION variable named $_SESSION['code']. You can compare this variable with the user's imput to ensure that the code which the user has typed is correct. You'll need to convert the user's string to lowercase after encrypting it with md5(); hash PHP function.

Please feel free to post your questions and comments here.
All ideas, queries and requests will be appreciated if it could help me to improve the script.

Enjoy, and have fun! :wink:

Tribulant.com - PHP, MySQL, JavaScript, Flash, etc... Scripts

, , , ...

My new website design :



http://www.tribulant.com

Feel free to test out the site, scripts and other resources and post your comments here.
All comments will be greatly appreciated, since the site is still under fast development.

Upload & Extract ZIP File

, ,

I always enjoy working on interesting and stimulating projects rather than large projects, since they keep my mind busy, usually pay well and is different from the usual development procedure.

I have a client who has a huge bunch of articles on his local computer which is being created on a regular basis. He wanted to somehow get these articles into his database in order to display on his site without having to process each and every article individually.

So I came to the conclusion that I need to make a simple, yet user-friend interface to allow my client to upload a single '.zip' file containing all the articles and let the script do the rest.

Anyhow...it was just a nice little script to code, since the '.zip' file had to be uploaded, extracted and then each file had to be read, stripped and assigned to variables for insertion into the database.

It turned out a success, and I learned a few things in the process as well. Don't ya just love learning? :wink:

Tribulant.com

, , , ...

I've always had the bad habit of revamping my sites way too often.
I used to have a site at http://www.tribulant.com but there is nothing there now except for a "Coming Soon..." page.
I recently decided that I needed to get the site up and running again, so I've been spending some time on doing just that.

Screenshot :


This is what I have now.
It's not up yet, since I'm still working on the backend programming.

Let me know what you think of the design so far. :wink:

MySQL Last Inserted ID

, , , ...

In some cases, you will need to retrieve the last inserted ID which was inserted into your database using PHP specifically when you are using an 'auto_increment' parameter for that field. Obviously there is a common way of doing this, but there is also a built in function which will help you to achieve the same result with less code.

The common way :
$query = "INSERT INTO table (id, value) VALUES ('', 'value')";
mysql_query($query) or die(mysql_error());

$id = mysql_result((mysql_query("SELECT * FROM table WHERE value = 'value'")), 0, 'id');

echo "The last inserted ID was :" . $id;


The easy way :
$query = "INSERT INTO table (id, value) VALUES ('', 'value')";
mysql_query($query) or die(mysql_error());

echo "The last inserted ID was :" . mysql_insert_id();


A useful snippet if you aren't familiar with the 'mysql_insert_id()' function. This will save you some coding and time if you've been using other common, longer ways in the past.

PHP Random Digit

, , ,

Just a quick snippet which will help you to create a random number in a specific range, using PHP. PHP has a built in rand(); fuction which allows you to do this with ease. See the example below :

PHP Random Function :
rand([int_min], [int_max]);


Example :
rand(1, 999);


The code shown above will create a random number between 1 (which is the minimum) and 999 (which is the maximum).

You can make the [min] and [max] values of this function dynamic, simply by replacing the digits with your variables. You can also assign this function to a variable itself and ouput the results if needed. See the simple example below :

$min = 1;
$max = 99;

$random_number = rand($min, $max);

echo "$random_number";


I wouldn't say that this function is really used that often, but it definitely comes in handy from time to time. Enjoy! :wink:

php explode

, , , ...

I was first introduced to this amazing function when I was building a keyword database for a product website. I needed to allow an administrator to create a range of keywords for a product in a comma/comma-space delimited format using a text input field. So the comma/comma-space delimited keyword string will be saved into a database in that format, but I needed a way to break up the string into all the seperate keywords if needed.

This was quite some time ago, and I didn't really have a large amount of knowledge on php, so after a bit of research on sites found by google for my search, I managed to find, grasp and understand the php explode function. It's a really simple function, but yet extremely useful in almost any application with or without a database.

Have a look at the sample below :

Let's say that we have a string of keywords in a database which is comma/comma-space delimited which looks something like this :

keyword1, keyword2, keyword3, keyword4, keyword5, keyword6


So the string you see above was inserted by the user, using an input text field. A form was submitted, and the string was stored into a database just as you see it there, possibly with the spaces as
 
using str_replace. In order to break this single string up into it's seperate keywords, and possiblly output those keywords, you would use a simple php explode function like the below :

<?php

//first insert the string into a variable
$string = "keyword1, keyword2, keyword3, keyword4, keyword5, keyword6";

//execute the explode function
$str = exlode(", ", $string);

//output the keywords one by one using foreach
foreach ($str as $s)
{
echo
"
$s <br/>
";
};

?>


So that's about it. The result of the code you see above will output something like this :

keyword1
keyword2
keyword3
keyword4
keyword5
keyword6


A simple, but yet extremely useful function of php which I use regularly due to the functionality it offers.

Theory of PHP Security

,

A large number of web programmers are using PHP as a primary programming language to create online applications, content management systems, or other small scripts. PHP is a great language and platform to work with, and definitely delivers the cherry on top of the cake. I've been programming in this language for a short while, and find the experience extremely pleasant.

Just as any other programming language, you need to follow general security measures and techniques to ensure that your content is safe and secure from malicious or unintended actions. I'm going to provide a simple sample which will make you realize how easy it sometimes is for a user to access content which you are trying to secure.

Let's say that you are requesting a user to login with a username and password, in order for the user to see/access certain content. You might have something like the below :

<?php

if ($_POST['username'] == "username" && $_POST['password'] == "password")
{
$access = 1;
};

secret();

function secret()
{
if ($access == 1)
{
SHOW SECRET CONTENT
}
else
{
DONT SHOW SECRET CONTENT
};
};

?>


So basically what this code does is it gets a posted username and password from a form on another page. It then checks whether the username and password is what you want it to be. If the username and password is what you want it to be, then the variable named $access will be equal to 1. But...

Any user can access the secret content by manually posting a value as 1 when register_globals are turned on.

This is just a basic sample, and I do realize that there are many ways to work around this, but below is the code which I would use to make this code more secure :

<?php

$access = 0;

if ($_POST['username'] == "username" && $_POST['password'] == "password")
{
$access = 1;
};

secret();

function secret()
{
if ($access == 1)
{
SHOW SECRET CONTENT
}
else
{
DONT SHOW SECRET CONTENT
};
};

?>


Note how I set the variable to 0 before executing the IF statement.

Just something to chew on. :smile:

Programming - Language or Purpose!?

, , , ...

As we move towards the area of computers, technology, internet and other related areas, we start to wonder where it all came from, and how everything works.

Well...
At the end of the day, all of this was and is programmed using languages, which is understood by digital devices and parsed as binary and hexidecimal code.

My question is :
There are so many different programming languages available, which could all more or less serve the same purpose. They all aim more or less at the same goal, and many of them can be used to accomplish the same task.

I am a PHP and MySQL web developer and designer. I create websites, scripts and other internet back end systems. Not only do I use PHP for online/remote communication, but if I really wanted to, I could build full desktop/offline applications which could run through a browser and store data in a MySQL database.

I guess it's quite logical that these different platforms, programming languages and back end systems were created and developed by different companies. I see it this way : Intel and AMD are both digital electronic devices developing companies, mainly known for the CPU's they develop. They both serve the same purpose....which is to make a PC run, but which is better?

Think about it. Let me know what you think.

Thanks.
Best,
Contrid.
Download Opera, the fastest and most secure browser
November 2009
S M T W T F S
October 2009December 2009
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30