stuffradio
Members-
Posts
253 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
stuffradio's Achievements
Regular Member (3/5)
0
Reputation
-
Nevermind guys, I figured it out. Programming hours at a time doesn't help much I was posting the username field as "user" but it's actually "username" so it was just going by the first result it came up with from the password field!
-
I have a query like this: $query = $this->CI->db->get_where('userstable', array('user' => $this->username, 'pass' => md5($this->password))); This is a CodeIgniter query. Here is a translated query in standard MySQL mysql_query("SELECT * FROM `userstable` WHERE `user`='$username' AND `pass`='md5($pass)'"); That's fine, you would expect it to select values where the user = username and pass = pass. Well, the problem is it's returning all users that are similar to the username. I have multiple test accounts that are like this: "stuff, stuffradio, stuf" etc. and it always logs me in as stuffradio. Any ideas what is wrong?
-
Any of you read this book? Is it good and if you like it what did you like about it? If it's good, I'm thinking of trying to find the cheapest place to buy it
-
Let me rephrase my question. In Javascript, if you use document.writeln() or document.write()... you can only have one line written. How can I use Javascript to output mutliple lines without breaking.
-
I have a PHP string that I get from a database. What I need to do is echo this in Javascript. How can I do something like document.writeln or document.write something that has multiple lines?
-
I'm running a C++ or C (not sure which one, it's a TCPecho socket server) server. I want to take the data I receive on the server and send it to a php file so I can insert the data into a database. Any idea on what I can do to do this?
-
I found this socket server now that does have a loop, but whenever it receives a client message then it dies. Where in here can I keep it alive? <?php error_reporting(E_ALL); mysql_connect("localhost", "root", "admin"); mysql_select_db("awc"); // don't timeout set_time_limit (10000); // set some variables $host = "192.168.0.197"; $port = 2100; // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // bind socket to port $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // start listening for connections $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); echo "Waiting for connections...\n"; // accept incoming connections // spawn another socket to handle communication $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); echo "Received connection request\n"; // write a welcome message to the client $welcome = "Roll up, roll up, to the greatest show on earth!\n? "; socket_write($spawn, $welcome, strlen ($welcome)) or die("Could not send connect string\n"); // keep looping and looking for client input do { // read client input $input = socket_read($spawn, 1024, 1) or die("Could not read input\n"); if (trim($input) != "") { echo "Received input: $input\n"; mysql_query("INSERT INTO `socket` (socketdata) VALUES ('$input')"); // if client requests session end if (trim($input) == "END") { // close the child socket // break out of loop socket_close($spawn); break; } // otherwise... else { // reverse client input and send back $output = strrev($input) . "\n"; socket_write($spawn, $output . "? ", strlen (($output)+2)) or die("Could not write output\n"); echo "Sent output: " . trim($output) . "\n"; } } } while (true); // close primary socket socket_close($socket); echo "Socket terminated\n"; ?>
-
<?php mysql_connect("localhost", "root", "admin"); mysql_select_db("awc"); // set some variables $host = "192.168.0.197"; $port = 2100; // don't timeout! set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // bind socket to port $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // start listening for connections $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // accept incoming connections // spawn another socket to handle communication $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); // read client input $input = socket_read($spawn, 1024) or die("Could not read input\n"); // clean up input string $input = trim($input); // reverse client input and send back $output = strrev($input) . "\n"; socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n"); mysql_query("INSERT INTO `socket` (socketdata) VALUES ('$input')"); // close sockets socket_close($spawn); socket_close($socket); ?>
-
Running sudo ./socket.php & does not keep it in the process list. Any idea why that would be?
-
Is there any way to keep a socket server alive? I have a socket server that runs fine, and does what I need it to... but when I close the window that has the socket server in it, it stops the server. How can I prevent this from happening?
-
I commented out this line $img->showAsJpg(); and it shows text output, but that means I'm still stuck on why it doesn't output any images.
-
I'm not sure if it is the fault of imagejpeg though. This is my upload code: <?php define('MAX_FILE_SIZE', 9000); require_once("TextToImage.class.php"); $img = new TextToImage(); $target_path = $_SERVER['DOCUMENT_ROOT']."wordpress2-8/wp-content/uploads/"; $topx = $_POST['xtopalignment']; $title = $_POST['titletext']; $target_path = $target_path . basename( $_FILES['file']['name']); $img->im = $_FILES['file']['name']; if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded"; echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; //echo "Image: <img src=imagedisplay.php?text=" . $_POST[titletext] ."&file=".$_FILES["file"]["name"]. "&x=" . $topx . "&y=" . $topy ." border=0 />"; echo $img->imagettfJustifytext($title, "arial.ttf", $topx); print_r($img->showAsJpg()); imagedestroy($target_path); } else{ echo "There was an error uploading the file, please try again!"; } ?> This is the image creation code: <?php /** * Class for converting Text to Image. * Left Right Center align/justify of text in image. * Create an image from text and align them as you want. * @author Taslim Mazumder Sohel * @deprecated 1.0 - 2007/07/25 * */ class TextToImage { var $im; private $L_R_C; /** * @name : makeImageF * * Function for create image from text with selected font. * * @param String $text : String to convert into the Image. * @param String $font : Font name of the text. Kip font file in same folder. * @param int $W : Width of the Image. * @param int $H : Hight of the Image. * @param int $X : x-coordinate of the text into the image. * @param int $Y : y-coordinate of the text into the image. * @param int $fsize : Font size of text. * @param array $color : RGB color array for text color. * @param array $bgcolor : RGB color array for background. * */ public function imagettfJustifytext($text, $font="CENTURY.TTF", $Justify=2, $W=0, $H=0, $X=0, $Y=0, $fsize=12, $color=array(0x0,0x0,0x0), $bgcolor=array(0xFF,0xFF,0xFF)){ $angle = 0; $this->L_R_C = $Justify; $_bx = imageTTFBbox($fsize,0,$font,$text); $W = ($W==0)?abs($_bx[2]-$_bx[0]):$W; //If Height not initialized by programmer then it will detect and assign perfect height. $H = ($H==0)?abs($_bx[5]-$_bx[3]):$H; //If Width not initialized by programmer then it will detect and assign perfect width. $this->im = @imagecreate($W, $H) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($this->im, $bgcolor[0], $bgcolor[1], $bgcolor[2]); //RGB color background. $text_color = imagecolorallocate($this->im, $color[0], $color[1], $color[2]); //RGB color text. if($this->L_R_C == 0){ //Justify Left imagettftext($this->im, $fsize, $angle, $X, $fsize, $text_color, $font, $text); }elseif($this->L_R_C == 1){ //Justify Right $s = split("[\n]+", $text); $__H=0; foreach($s as $key=>$val){ $_b = imageTTFBbox($fsize,0,$font,$val); $_W = abs($_b[2]-$_b[0]); //Defining the X coordinate. $_X = $W-$_W; //Defining the Y coordinate. $_H = abs($_b[5]-$_b[3]); $__H += $_H; imagettftext($this->im, $fsize, $angle, $_X, $__H, $text_color, $font, $val); $__H += 6; } } elseif($this->L_R_C == 2){ //Justify Center $s = split("[\n]+", $text); $__H=0; foreach($s as $key=>$val){ $_b = imageTTFBbox($fsize,0,$font,$val); $_W = abs($_b[2]-$_b[0]); //Defining the X coordinate. $_X = abs($W/2)-abs($_W/2); //Defining the Y coordinate. $_H = abs($_b[5]-$_b[3]); $__H += $_H; imagettftext($this->im, $fsize, $angle, $_X, $__H, $text_color, $font, $val); $__H += 6; } } } /** * @name showAsPng * * Function to show text as Png image. * */ public function showAsPng(){ header("Content-type: image/png"); return imagepng($this->im); } /** * @name saveAsPng * * Function to save text as Png image. * * @param String $filename : File name to save as. * @param String $location : Location to save image file. */ public function saveAsPng($fileName, $location= null){ $_fileName = $fileName.".png"; $_fileName = is_null($location)?$_fileName:$location.$_fileName; return imagepng($this->im, $_fileName); } /** * @name showAsJpg * * Function to show text as JPG image. * */ public function showAsJpg(){ header("Content-type: image/jpeg"); return imagejpeg($this->im); } /** * @name saveAsJpg * * Function to save text as JPG image. * * @param String $filename : File name to save as. * @param String $location : Location to save image file. */ public function saveAsJpg($fileName, $location= null){ $_fileName = $fileName.".jpg"; $_fileName = is_null($location)?$_fileName:$location.$_fileName; return imagejpeg($this->im, $_fileName); } /** * @name showAsGif * * Function to show text as GIF image. * */ public function showAsGif(){ header("Content-type: image/gif"); return imagegif($this->im); } /** * @name saveAsGif * * Function to save text as GIF image. * * @param String $filename : File name to save as. * @param String $location : Location to save image file. */ public function saveAsGif($fileName, $location= null){ $_fileName = $fileName.".gif"; $_fileName = is_null($location)?$_fileName:$location.$_fileName; return imagegif($this->im, $_fileName); } } ?> I don't expect you to go through the image creation class, but I am trying to use showAsJpg() and the imagettfJustifytext() function because it has the alignment built in to it. The problem is, whatever is going on (the uploading of a file works) but it always outputs and I'm not sure why.
-
I found a class that has Image alignment: http://www.phpclasses.org/browse/file/20089.html I still need help with finding out how to write text on images with effects though.
-
Thank you. Would this keep it pushed down to the bottom as the content box expands down?
-
I am trying to have my layout template have a footer that always stays on the bottom and will keep going down as the content box goes down. I don't have the content box expand yet and I don't know the best way to expand the content box and keep the footer down. Can anyone see anything wrong with my CSS that would fix the problem? http://carlwuensche.com/unknown/create.html