FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


This is my lf2sig code 0.01, anyone see errors?





Mgccl
This is LF2sig system, which genorates dynamic signature. But I don't have a computer that installed PHP, SO here I want people to help me see if there is any errors, please tell me.

Config.php
Code:
$host = "localhost";
$username = "root";
$password = "";
$dbname = "lf2sig";
$link = mysql_connect($host, $username, $password) or die (mysql_error());
mysql_selec_db ($dbname) or die (mysql_error());


dbcreat.php
Code:
$query = "SELECT *".
    "FROM layer_create".
    "WHERE id = ".$layer[$i][$n]['id_create'];
$resut = mysql_query($query, $link);
$row = mysql_fech_array($result);
$file = $row['file'];


index.php
Code:
// creae base
$base = imagecreat ($bwidth, $bheight);

// calculate $max, this calculation is not needed in index.php. It is used for the backend to genorate how many different id there are

function calc_max(){
$query = "SELECT id".
    "FROM layer";
$resul = mysql_query($query,$link);
while ($row = mysql_fetch_array($result)) {
   $num[] = $row['id'];
}   
$num = array_unique($num);
$max = count($num);
$query = "UPDATE stat SET.
   "max = ".$max.
   "WHERE id = 1";
$result = mysql_query($query)
   or die(mysql_error());
}

//Ge the $max for $i and $views
$query = "SELECT *".
    "FROM stat".
    "WHERE id = 1";
$result = mysql_query($query, $link);
$row = mysql_fetch_array($resul);
$max = $row['max'];
$view = $row['view'];




//BIG WHILE LOOP STAR
$i = 1
While($i <= $max){

//genorate layer from random $i
$query = "SELECT *".
    "FROM layer".
    "WHERE id =".$i;
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) {
$layer[$i] = array(id => $row['id'],
               switch_create => $row['switch_create'],
               switch_draw => $row['switch_draw'],
               height => $row['height'],
               width => $row['width'],
               id_create => $row['id_create'],
               id_draw => $row['id_draw'],
               dx => $row['dx'],
               dy => $row['dy'],
               sx => $row['sx'],
               sy => $row['sy'],
               s_width => $row['s_width'],
               s_height =>$row['s_height'],
               trans => $row['trans']
               );
$n = array_rand($layer[$i]);
//var_create_switch
switch $layer[$i][$n]['switch_create']{
  case 1:
  $switch_create = "new";
  break;
  case 2:
  $switch_create = "png";
  include(dbcreate.php);
  break;
  case 3:
  $switch_create = "gif";
  include(dbcreate.php);
  break;
  case 4:
  $switch_create = "jpg";
  include(dbcreate.php);
  break;
}

//var_draw_switch
switch $layer[$i][$n]['switch_draw']{
  case 1:
  $switch_draw = "none";
  break;
 
  case 2:
  $switch_draw = "text";
  $query = "SELECT *".
           "FROM layer_draw_text".
           "WHERE id=".$layer[$i][$n]['id_draw'];
  $result = mysql_query($query, $link);
  $row = mysql_fetch_array($result);
  $fontsize = $row['fontsize'];
  $fontangle = $row['fontangle'];
  $x = $row['x'];
  $y = $row['y'];
  $color = $row['color'];
  $fonturl = $row['fonturl'];
  $string = $row['string'];
  break;

  case 3:
  $switch_draw = "fill";
  $query = "SELECT *".
           "FROM layer_draw_fill".
           "WHERE id = ".$layer[$i][$n]['id_draw'];
  $result = mysql_query($query, $link);
  $row = mysql_fetch_array($result);
  $x = $row['x'];
  $y = $row['y'];
  $color = $row['color'];
  break;
 
  case 4:
  $switch_draw = "thumb";
  $query = "SELECT *".
           "FROM layer_draw_thumb".
           "WHERE id=".$layer[$i][$n]['id_draw'];
  $result = mysql_query($query,$link);
  $row = mysql_fetch_array($result);
  $thumb_width = $row['w'];
  $thumb_height = $row['h'];
  break;
}         
$width = $layer[$i][$n]['w'];
$height = $layer[$i][$n]['h'];

//image create
switch ($switch_create) {
  case "new":
  $img = imagecreate($width, $height);
  break;
    case "png":
  $img = imagecreatepng($file);
  break;
    case "jpg":
  $img = imagecreatejpeg($file);
  break;
    case "gif":
  $img = imagecreategif($file);
  break;
 
}

//draw functions
switch ($switch_draw) {
  case "text":
  imagettftext($img, $fontsize, $fontangle, $x, $y, $color, $fonturl, $string);
  break;
  case "fill":
  imagefill($img, $x, $y, $color);
  break;
    case "thumb":
  $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
  imagecopyresampled($thumb, $img, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
  imagedestory ($img);
  $img = imagecreate($thumb_width, $thumb_height);
  imagecopy($img, $thumb, 0, 0, 0, 0, $thumb_width, $thumb_height);
  imagedestory ($thumb);
  break;
  case "none":
  break;
}
// assign merge vars

$dx = $layer[$i][$n]['dx'];
$dy = $layer[$i][$n]['dy'];
$sx = $layer[$i][$n]['sx'];
$sy = $layer[$i][$n]['sy'];
$s_width = $layer[$i][$n]['s_width'];
$s_height = $layer[$i][$n]['s_height'];
$trans = $layer[$i][$n]['trans'];

//Merge
imagecopymerge($base, $img, $dx, $dy, $sx, $sy, $s_width, $s_height, $trans);
$i = $i + 1;
 imagedestroy ($img);
}

//output
headr ('Content-type: image/png');
imagepng($base);

//destory
imagedestroy ($base);
Related topics
PHP Tutorials
CUSTOM ERROR PAGES
C++ assignment help
Java tutorials
Email from Yahoo! and AOL will be CHARGED
Php Syntax Errors, Need Help
problem creating on-the-fly jpeg thumbnails
PageRank =0 ?
OR for empty posts?
Czas odpowiedzi serwerów Frihost
Get week number from date
Does 0.999.... = 1?
php..free account help
What happened to Perl?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.