|
|
comments (1)
|
Thought of a new entry structure for Cloudica. I like to write about these things before I do them, to understand them in stone.
Anyway, as of now, in the entries table I have isPhoto, isLink. These tell me whether or not the user has attached a photo or link.
Now, I plan on removing these and replacing with a media_table feild, and when the user attaches a photo/link/etc..., the media_table will be the table containing the attachment. Very simple and incredibly easy to expand and add new attachments.
|
|
comments (2)
|
I've recently come up with a nice post parser for PHP, that uses just some basic functions.
First lets write the database class.
class connection
{private $connection, $database;
function connect()
{$this->database = array(
'username',
'password',
'database',
'host'
);
$this->connection = mysql_connect($this->database[3], $this->database[0], $this->database[1]) or die($this->error());
mysql_select_db($this->database[2], $this->connection) or die($this->error());
}
function error()
{return mysql_error();
}
function ready($string)
{return mysql_real_escape_string($string);
}
}
And then connect to the database.
$db = new connection();
$db->connect();
Finally, we build our parser.
------------------------------------------------------------------------------------------------------------
class dataParser
{public $data;
function collectData()
{global $db; //database in scope.
foreach($_REQUEST as $key => $value)
{$this->data[$key] = htmlentities($db->ready($value));
}
return $this->data; //return the array.
}
}
-------------------------------------------------------------------------------------------------------------
Now that the framework is complete, we can begin collecting database ready and XXS free data! ![]()
Simply do this:
--------------------------------------------------------------------------------------------------------
$parse = new dataParser();
$parse->collectData();
--------------------------------------------------------------------------------------------------------
This is where $_POST['stuff'] or $_GET['stuff'] becomes $parse->data['stuff']
|
|
comments (1)
|
Here's a simple tutorial on building your first ajax powered application.
Firstly, you'll need jQuery. http://jquery.com/
Create the file ajaxApp.js, and let's begin.
We are write a simple load function.
function load(element, file) {
$.ajax({
url: file,
cache: false,
success: function(response) { //response is the contents of the file.
$(element).html(response); //set the HTML of the element to the contents of the file
}
});
}
And there is your javascript function. Save ajaxApp.js.
Open a new file, external.html. In this file, place anything. Images, text, etc.. and then save.
66% done, now open index.html and write this:
<script src="./jquery.js" mce_src="./jquery.js" type="text/javascript"></script>
<script src="./ajaxApp.js" type="text/javascript"></script>
<div id="ajaxLoad"><a href="javascript:load('#ajaxLoad', 'external.html');">Do ajax stuff!</a></div>
When you click "Do ajax stuff!" external.html is loaded into
We could also do something like this in index.html:
<script type="text/javascript">
$(document).ready(function() {
load('ajaxLoad', 'external.html');
});
</script>
$(document).ready(function() {
load('#ajaxLoad', 'external.html');
});
to load the file into the div when the page is loaded. This is some basic ajax, and an introduction to the power of jQuery. Enjoy!
|
|
comments (1)
|
I find I needed a place where I can upload all my personal stuff and share it here. I don't plan on getting many visits but hey, doesn't bother me.
I'll mostly talk about websites, programming or Cloudica. Might even post a tutorial or two.