People want to use my Jquery plugin, but get a list of images from a database instead of a directory, which is the standard way the plugin works.
My Jquery plugin that uses the ajax() function to deliver & return data to a php script.
The php script pulls files from a directory with getdir(), adds those files to an array and assigns that array to a variable.
People have requested the ability to create that variable value themselves by generating it from a database (not just pulling files from a directory using scandir).
What is a good, secure way to do to allow others to replace a variable value inside my php script?
Ideally, I would like there to be a way where users can create their own script in a separate document (and they don't need to alter my document).
Here is a simplified example of my script:
HTML Document
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$.ajax({
type: "POST",
url: "example.php",
cache: false,
data: {
foo: "some_directory",
},
success: function(html){
alert(html);
}
});
</script>
PHP Document
<?php
$foo = $_POST["foo"];
$foo = scandir($foo);
$foo = (explode(",",$foo)); // how can I allow others to change this variable value?
foreach ($foo as $a) {
echo "<p>$a</p>";
}
?>