Teensweb
New Member
- Messages
- 352
- Reaction score
- 1
- Points
- 0
I have a php code for a 5 star rating swervice i am gonna provide. But unfortunately, I had to write the code myself and I have messed it up a lot.So I need help to make it clean and fast.
Thank you in advance!
Avin
PHP:
<?php
require ( '/home/avin/public_html/teensweb.co.cc/Login/settings.php' );
?>
<?php
if(isset($_POST['submit'])) //has the form been submitted?
{
$id = $login->get_username ( $_SESSION [ AUTH_SESSION_ID ] );
$file_directory = "files/"; //the directory you want to store the new file in
$file_name = strip_tags($_POST['file_name']);//the file's name, stripped of any dangerous tags
$prefix = "$id-$file_name";
$file_ext = ".php"; //the file's extension, stripped of any dangerous tags
$file = $file_directory.$prefix.$file_ext; //this is the entire filename
$outof = strip_tags($_POST['number']);
$percent = strip_tags($_POST['percent']);
$votes = strip_tags($_POST['votes']);
$tagopen = '<?';
$tagclose = '?>';
$color = strip_tags($_POST['color']);
$votes = strip_tags($_POST['votes']);
$css = strip_tags($_POST['extension']);
$html = '<body';
$htclose = '>';
$filename = "files/$id-$file_name$file_ext";
$background = "$html bgcolor=$color$htclose";
if (file_exists($filename))
{
unlink($filename);
}
$create_file = fopen($file, "w+"); //create the new file
if ($css = png) {
$content = '<? include("includes/rating_functions.php"); ?>
<link href="css/rating_style.css" rel="stylesheet" type="text/css" media="all">
<script type="text/javascript" src="js/rating_update.js"></script>';
}
else {
$content = '<? include("includes/rating_functions.php"); ?>
<link href="css/rating_style_gif.css" rel="stylesheet" type="text/css" media="all">
<script type="text/javascript" src="js/rating_update.js"></script>';
}
$phfiles = "$tagopen echo pullRating($file_name,$outof,$percent,$votes) $tagclose";
$code = 'Rating sytem created success fully! copy and paste the following code where you want the stars to appear<textarea rows="5" cols="50"><iframe src=http://www.teensweb.co.cc/' . $filename . ' frameborder="0" ></textarea>';
if(!$create_file)
{
die("There was an error creating/opening the file! Make sure you have the correct permissions!\n");
}
$chmod = chmod($file, 7545); //set the appropriate permissions.
//attempt to set the permissions
if(!$chmod)
{
echo("There was an error changing the permissions of the new file!\n"); //error changing the file's permissions
}
//attempt to write basic content to the file
if (fwrite($create_file, "$content$phfiles$background") === FALSE) {
echo "Error writing to file: ($file)\n";
}
fclose($create_file);
}else{ //the form hasn't been submitted!
header("Location: addfile.html"); //redirect the user back to the add file page
}
if($create_file)
{echo $code;}
?>
Avin