summaryrefslogtreecommitdiffstats
path: root/system/plugins
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-21 21:44:22 +0200
committeradmin <devnull@localhost>2006-10-21 21:44:22 +0200
commite334c472fb4be44feec3a73402fc4a2b062cbfc0 (patch)
tree553f17d67e7ef652016ec85b2a576bb2210f0ff8 /system/plugins
parentbd6bee75dd26ade1c8d9cfd104bb913065797c59 (diff)
Diffstat (limited to 'system/plugins')
-rw-r--r--system/plugins/captcha_pi.php54
-rw-r--r--system/plugins/js_calendar_pi.php26
2 files changed, 40 insertions, 40 deletions
diff --git a/system/plugins/captcha_pi.php b/system/plugins/captcha_pi.php
index 54944b823..b3c22f092 100644
--- a/system/plugins/captcha_pi.php
+++ b/system/plugins/captcha_pi.php
@@ -7,19 +7,19 @@
* @package CodeIgniter
* @author Rick Ellis
* @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
+ * @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
* @filesource
*/
-
+
// ------------------------------------------------------------------------
/*
Instructions:
Load the plugin using:
-
+
$this->load->plugin('captcha');
Once loaded you can generate a captcha like this:
@@ -42,9 +42,9 @@ NOTES:
The captcha function requires the GD image library.
- Only the img_path and img_url are required.
+ Only the img_path and img_url are required.
- If a "word" is not supplied, the function will generate a random
+ If a "word" is not supplied, the function will generate a random
ASCII string. You might put together your own word library that
you can draw randomly from.
@@ -56,11 +56,11 @@ NOTES:
The "expiration" (in seconds) signifies how long an image will
remain in the captcha folder before it will be deleted. The default
is two hours.
-
+
RETURNED DATA
The create_captcha() function returns an associative array with this data:
-
+
[array]
(
'image' => IMAGE TAG
@@ -68,10 +68,10 @@ The create_captcha() function returns an associative array with this data:
'word' => CAPTCHA WORD
)
-The "image" is the actual image tag:
+The "image" is the actual image tag:
<img src="http://your-site.com/captcha/12345.jpg" width="140" height="50" />
-The "time" is the micro timestamp used as the image name without the file
+The "time" is the micro timestamp used as the image name without the file
extension. It will be a number like this: 1139612155.3422
The "word" is the word that appears in the captcha image, which if not
@@ -81,12 +81,12 @@ supplied to the function, will be a random string.
ADDING A DATABASE
In order for the captcha function to prevent someone from posting, you will need
-to add the information returned from create_captcha() function to your database.
-Then, when the data from the form is submitted by the user you will need to verify
+to add the information returned from create_captcha() function to your database.
+Then, when the data from the form is submitted by the user you will need to verify
that the data exists in the database and has not expired.
Here is a table prototype:
-
+
CREATE TABLE captcha (
captcha_id bigint(13) unsigned NOT NULL auto_increment,
captcha_time int(10) unsigned NOT NULL,
@@ -98,7 +98,7 @@ Here is a table prototype:
Here is an example of usage with a DB.
-
+
On the page where the captcha will be shown you'll have something like this:
$this->load->plugin('captcha');
@@ -110,10 +110,10 @@ On the page where the captcha will be shown you'll have something like this:
$cap = create_captcha($vals);
$data = array(
- 'captcha_id' => '',
- 'captcha_time' => $cap['time'],
+ 'captcha_id' => '',
+ 'captcha_time' => $cap['time'],
'ip_address' => $this->input->ip_address(),
- 'word' => $cap['word']
+ 'word' => $cap['word']
);
$query = $this->db->insert_string('captcha', $data);
@@ -127,7 +127,7 @@ On the page where the captcha will be shown you'll have something like this:
Then, on the page that accepts the submission you'll have something like this:
// First, delete old captchas
- $expiration = time()-7200; // Two hour limit
+ $expiration = time()-7200; // Two hour limit
$DB->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);
// Then see if a captcha exists:
@@ -175,7 +175,7 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
return FALSE;
}
- if ( ! @is_dir($img_path))
+ if ( ! @is_dir($img_path))
{
return FALSE;
}
@@ -200,7 +200,7 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
$current_dir = @opendir($img_path);
while($filename = @readdir($current_dir))
- {
+ {
if ($filename != "." and $filename != ".." and $filename != "index.html")
{
$name = str_replace(".jpg", "", $filename);
@@ -223,13 +223,13 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$str = '';
- for ($i = 0; $i < 8; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+ for ($i = 0; $i < 8; $i++)
+ {
+ $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
$word = $str;
- }
+ }
// -----------------------------------
// Determine angle and position
@@ -267,12 +267,12 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
// -----------------------------------
$theta = 1;
- $thetac = 7;
- $radius = 16;
- $circles = 20;
+ $thetac = 7;
+ $radius = 16;
+ $circles = 20;
$points = 32;
- for ($i = 0; $i < ($circles * $points) - 1; $i++)
+ for ($i = 0; $i < ($circles * $points) - 1; $i++)
{
$theta = $theta + $thetac;
$rad = $radius * ($i / $points );
diff --git a/system/plugins/js_calendar_pi.php b/system/plugins/js_calendar_pi.php
index 16c3f4136..987bd49ed 100644
--- a/system/plugins/js_calendar_pi.php
+++ b/system/plugins/js_calendar_pi.php
@@ -7,19 +7,19 @@
* @package CodeIgniter
* @author Rick Ellis
* @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
+ * @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
* @filesource
*/
-
+
// ------------------------------------------------------------------------
/*
Instructions:
Load the plugin using:
-
+
$this->load->plugin('js_calendar');
Once loaded you'll add the calendar script to the <head> of your page like this:
@@ -123,13 +123,13 @@ Lastly, you'll need some CSS for your calendar:
*/
-
+
function js_calendar_script($form_name = 'entryform')
-{
+{
ob_start();
?>
-<script type="text/javascript">
+<script type="text/javascript">
<!--
var form_name = "<?php echo $form_name; ?>";
var format = 'us'; // eu or us
@@ -167,7 +167,7 @@ function calendar(id, d, highlight, adjusted)
}
else
{
- this.selected_date = this.year + '' + this.month + '' + this.date;
+ this.selected_date = this.year + '' + this.month + '' + this.date;
}
// Set the "selected date"
@@ -253,7 +253,7 @@ function total_days()
if (( this.date_obj.getFullYear() % 4 == 0
&& this.date_obj.getFullYear() % 100 != 0)
|| this.date_obj.getFullYear() % 400 == 0)
- return 29;
+ return 29;
else
return 28;
case 3:
@@ -361,7 +361,7 @@ function update_calendar(id, dateValue)
if (dateParts.length < 3) return;
var newYear = dateParts[0];
var newMonth = dateParts[1];
- var newDay = dateParts[2];
+ var newDay = dateParts[2];
if (isNaN(newDay) || newDay < 1 || (newDay.length != 1 && newDay.length != 2)) return;
if (isNaN(newYear) || newYear < 1 || newYear.length != 4) return;
@@ -376,7 +376,7 @@ function update_calendar(id, dateValue)
case 1: // Check for leap year
if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
{
- if (newDay > 29) newDay = 29;
+ if (newDay > 29) newDay = 29;
}
else
{
@@ -500,7 +500,7 @@ function change_month(mo, cal)
var newMonth = cal.date_obj.getMonth() + mo;
var newDate = cal.date_obj.getDate();
- if (newMonth == 12)
+ if (newMonth == 12)
{
cal.date_obj.setYear(cal.date_obj.getFullYear() + 1)
newMonth = 0;
@@ -520,7 +520,7 @@ function change_month(mo, cal)
case 1: // Check for leap year
if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
{
- if (newDate > 29) newDate = 29;
+ if (newDate > 29) newDate = 29;
}
else
{
@@ -584,7 +584,7 @@ function date_str(time)
<?php
$r = ob_get_contents();
-ob_end_clean();
+ob_end_clean();
return $r;
}