Jump to content

stuffradio

Members
  • Posts

    253
  • Joined

  • Last visited

Everything posted by stuffradio

  1. 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!
  2. 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?
  3. 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
  4. 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.
  5. 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?
  6. 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?
  7. 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"; ?>
  8. <?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); ?>
  9. Running sudo ./socket.php & does not keep it in the process list. Any idea why that would be?
  10. 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?
  11. 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.
  12. 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.
  13. 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.
  14. Thank you. Would this keep it pushed down to the bottom as the content box expands down?
  15. 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
  16. Does anyone know the equation to find out how to center text that you will write in PHP? So if I have an image that is always around 270 x 400 and 290x400 what would I do for math equations for centering it near the top and near the bottom of the image? Also, I found this class: http://www.phpclasses.org/browse/file/20034.html Does anyone know any other classes that would do more like writing text effects in PHP GD? Like shadow effect, strike through the text effect, etc. etc.?
  17. I think I copied it from W3schools and edited it a bit to do what I need, where is the best and cleanest uploader do you think? Also, is it possible to do the image(insert file format here) function on the same page? Right now I need to use two php files, one for the image upload and one to display the image and write the text.
  18. I'm trying this Image uploader: <?php $target_path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/"; $topx = $_POST['topxstart']; $topy = $_POST['topystart']; $target_path = $target_path . basename( $_FILES['file']['name']); $target_pathoriginal = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . basename( $_FILES['file']['name'] . 'original'); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { 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 />"; if (file_exists($_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } elseif (file_exists($_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $_FILES["file"]["name"]. 'original')) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $target_path); move_uploaded_file($_FILES["file"]["tmp_name"], $target_pathoriginal); echo "Stored in: " . file_exists($_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $_FILES["file"]["name"]); } } } else { echo "Invalid file"; } ?> Some JPEG images I upload make the code output Invalid file. I'm not sure why it's invalid since the type of image is JPEG, 37 KB, 400 x 491 dimention. Any ideas why it would be invalid? Also, do you know of any class that would help with writing titles and captions on images and save the image to a path?
  19. No it isn't. Edit: Ohhh thanks, it works now
  20. Thanks for the reply, but it still doesn't work: <?php header ('Content-type: image/jpeg'); $imag = $_GET['file']; $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag; $im = imagecreatefromjpeg($path); $cor = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); $text = $_GET['text']; $font = 'arial.ttf'; imagettftext($im, 18, 0, 10, 5, $cor, $font, $text); imagejpeg($im); ?>
  21. Ok, so I have a php file that creates the image. In that file, I have it calling a script that is supposed to write text on the image, but that script that is supposed to write text on the image doesn't work. This is what gets outputted in the browser: Here is the code: <?php $imag = $_GET['file']; $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag; $im = imagecreatefromjpeg($path); $cor = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); $text = $_GET['text']; header ('Content-type: image/jpeg'); imagettftext($im, 18, 0, 10, 5, $cor, 'Arial', $text); imagejpeg($im); ?> Any idea what I'm doing wrong? I want to have text on the top of the image and on the bottom. I just need to know how to do this correctly though and I will figure out the positioning part.
  22. Have you had this happen to you? There is a database I have that shows 13 existing tables, but only lists 10. When I try and create one of the tables that aren't showing up... it says the table already exists. I'm not really sure what to do for this one.
  23. I converted this theme in to a wordpress theme. The theme works fine in FF but in IE 7 the navigation bar is black instead of red. http://carlwuensche.com/redtiger View it in IE 7 and FF to see the difference. I'm not a css expert and I didn't do this theme, can anyone give me any ideas on why it is having this conflict? Thanks!
  24. Can anyone help me find out how to check if a twitter username/password is correct upon form submit. I have code to do that in PHP already, but if the user/pass combo is incorrect I want the form to stay where it is so the user can correct the info instead of reloading the page. This is the code function followUser() { $apiUrl='http://twitter.com/friendships/create/'.$this->follower.'.xml'; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$apiUrl"); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username.':'.$this->password); //Attempt to send $buffer = curl_exec($curl_handle); $resultArray = curl_getinfo($buffer); if ($resultArray['http_code'] == 200): return true; else: return false; endif; curl_close($curl_handle); } Any help with this would be appreciated!
  25. I feel that using a database can be a lot more secure then trying to use a work around.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.