Username:
Members-
Posts
155 -
Joined
-
Last visited
Never
Everything posted by Username:
-
It will be for an imageboard type-thinger. I need to have post numbers, or maybe I don't, I don't know yet.
-
Didn't edit in time, my apologies. My current structure looks like this: thread -> ---name var(32) ---subject var(128) ---email var(128) ---message longtext(2000) ---last int(11) ---password varchar(128) ---id int(11) <- this is what I need to auto-increment reply -> ---name var(32) ---subject var(128) ---email var(128) ---message longtext(2000) ---password varchar(128) ---id int(11) <- this is what I need to auto-increment I need "id" to be unique over both tables (reply & thread) and consecutive (in thread you'll see 11, and in reply you'll see 12, assuming they were both posted consecutively after eachother)
-
Is this possible? I want ids to auto-increment over two tables.
-
Well, it's gonna be a rather large code, so it has to be in a seperate file now anyway haha. http://pictureunrelated.com/screengrabbr/2.30.55-AM_2011-11-29.png It works alright I guess. It's really slow after about "Hello PHPFrea"
-
I sure did Thanks!
-
<script> $('#canvas').mousedown(function(e){ alert("test"); }); </script> <canvas class="canvas" id="canvas" width="500" height="300" style="border: solid 1px"></canvas> I'm almost positive there's nothing wrong This is killing meeeeee, please help
-
I don't believe in censorship myself, but the script I'm making it for, the user wants a censor! I am aware that filters could easily be bypassed, but simply allowing only alphanumeric letters should do the trick, right? The users should theoretically be English only. I have tried using the one-or-more blabbity blah, but this allows anyone to simply write "f.uck"
-
I'm currently making some regular expressions for a word filter Now, if the user enters for example: f**k It would censor to **** and if he enters f**************************************kkkkkkkkkkkkkkkkkkkkkkkkkkkk it would censor to *************************************************************** Now, if the user enters: f * * k it won't censor. My current code (I apologize for the swearing, I just wanted you to see what I see): public static function wordFilter($text) { $filter_terms = array('s+h+i+t(|ting|er|e|ing|s)\b','f+u+c+k(|ing|ed|s|er)','a+s+s(|hole)\b','c+u+n+t', 'p+u+s+s+y', 'n+i+g+g+e+r', 'f+a+g(|got)'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/' . $bwstr . '/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } A) Yes I am aware that is not a good way to filter words B) Could someone point me in the better direction? Thanks in advance If you need anymore details just ask.
-
display a success message after form is submitted
Username: replied to $php_mysql$'s topic in PHP Coding Help
function insertDATA($postData) { if(!ifEmailExists($postData['email'])){ $sql = " INSERT INTO tbl SET email = '".$postData['email']."', name = '".$postData['name']."', phone = '".$postData['phone']."' "; echo "data submitted successfully!";//this line withing the form $res = executeSql($sql); if($res) { echo "<img src='path/to/image.jpg'></img."; } else { die(mysql_error()); } } I don't know if that will work, since you never told us how executeSql works, and you'll have to have the link for the image in the img tag. -
This code runs fine on my server. <?php $title = "Home"; $username = "user"; if(file_exists("styles/top.php")) { require("styles/top.php"); } else { echo "styles/top.php is missing"; } if (isset($username) && strlen(trim($username)) >= 1) { echo "<br>Welcome $username!"; echo " <table> </div> </td> </tr> <tr> <td width='244' valign='top'><br /> <form id='form1' name='form1' method='post' action='search_results.php' style='margin-left:20px;'> <input name='var' type='text' class='size12' id='var' style='width:124px; background-color: #A4D1FF;' /> <input name='button' type='submit' class='size11' id='button' value='Search' /> </form> <br /> <div id='leftNav' style='margin-left:22px;'> <!-- Start tv --> <strong> <font color='#FFFFFF'><span class='size16'>TV</span></font></strong><br /> <a href='tv.php?c=tv&sc=cartoons'>Cartoons <font size='-3' color='#FFFFFF'></font></a><br /><a href='tv.php?c=tv&sc=news'>News <font size='-3' color='#FFFFFF'></font></a><br /><a href='tv.php?c=tv&sc=adventures'>Adventures <font size='-3' color='#FFFFFF'></font></a><br /><a href='tv.php?c=tv&sc=horror'>Horror<font size='-3' color='#FFFFFF'></font></a><br /><a href='tv.php?c=tv&sc=Drama'>Drama<font size='-3' color='#FFFFFF'></font></a><br><br /> <!-- End TV --> <!-- Start Videos --> <strong> <font color='#FFFFFF'><span class='size16'>Videos</span></font></strong><br /> <a href='videos.php?c=videoss&sc=children'>Children <font size='-3' color='#FFFFFF'></font></a><br /><a href='videos.php?c=videos&sc=music'>Music<font size='-3' color='#FFFFFF'></font></a><br /><a href='videos.php?c=videos&sc=comedy'>Comedy<font size='-3' color='#FFFFFF'></font></a><br /><a href='videos.php?c=videos&sc=youtubemovies'>Youtube Movies <font size='-3' color='#FFFFFF'></font></a><br /><a href='videos.php?c=videos&sc=sports'>Sports <font size='-3' color='#FFFFFF'></font></a><br /> <br> <!-- End videos--> <!-- Start Movies --> <strong><font color='#FFFFFF'><span class='size16'>Movies</span></font></strong><br /> <a href='movies.php?c=movies&sc=comedy'>Comedy <font size='-3' color='#FFFFFF'></font></a><br /> <a href='movies.php?c=movies&sc=action'>Action <font size='-3' color='#FFFFFF'></font></a><br /><a href='movies.php?c=movies&sc=adventure'>Adventures <font size='-3' color='#FFFFFF'></font></a> <a href='movies.php?c=movies&sc=horror'>horror <font size='-3' color='#FFFFFF'></font></a><br /> <a href='movies.php?c=movies&sc=drama'>Drama<font size='-3' color='#FFFFFF'></font></a><br /><br /> <br /> <!-- End Movies --> </div> </table>"; } else { echo "<h2><font color='red'>You must be logged view this Part.</font></h2>"; } if(file_exists("styles/bottom.php")) { require("styles/bottom.php"); } else { echo "styles/bottom.php is missing"; } ?>
-
:shrug: :shrug: Please help before this script drives me insane. It tries to download a skin from Minecraft. It works fine, except, if it returns an error code, (301, 302, 404), don't download, and using my image (char.png) as a replacement. I can get the error code, except, no matter how I compare it, it will a) still say it's 302 or b) not work at all. Here's my code: userskin.inc.php > <?php require('class.mineuser.php'); if(!isset($_GET['width']) || strlen(trim($_GET['width'])) == 0 || !isset($_GET['height']) || strlen(trim($_GET['height'])) == 0) { $x = 16; $y = 16; } else { $x = $_GET['width']; $y = $_GET['height']; } if(isset($_GET['refresh'])) $refresh = true; else $refresh = false; if(isset($_GET['debug'])) $debug = true; else $debug = false; $http = curl_init("http://www.minecraft.net/skin/{$_GET['user']}.png"); curl_setopt($http, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($http); $http_status = curl_getinfo($http, CURLINFO_HTTP_CODE); $resp = preg_match("/302/", $http_status, $match); $code = $match[0]; if($code == 302) { mineuser::downloadSkin($_GET['user'], $_GET['path'], $code, $refresh); mineuser::getFace($_GET['user'].".png", $x, $y, $_GET['path'], $code, $debug); } else { mineuser::getFace("char.png", $x, $y, $_GET['path'], $code, $debug); } class.mineuser.php > <?php class mineuser { public static function downloadSkin($user, $path = "", $resp, $new = false) { if($resp !== 302) { //Checks if $new is true, if it is, then delete $user.png and download a new one. if($new == true) unlink("$path/$user.png"); //Checks if the users skin already exists (faster loading time) if(!file_exists("$path/$user.png")) { $fh = fopen("$path/$user.png", "w"); $file = file("http://www.minecraft.net/skin/$user.png"); foreach($file as $char) //Since it's an array, we use a foreach loop and write each character individually fwrite($fh, $char); fclose($fh); //Close our file handler. } } else { } } //End of function downloadSkin() public static function getFace($user, $width, $height, $path, $resp, $debug = true) { $im = imagecreatetruecolor($width, $height); if($debug == false) { header("Content-type: image/png"); } if($resp === 302) { $image = imagecreatefrompng("$path/char.png"); } else { $image = imagecreatefrompng("$path/$user"); } imagecopyresampled($im, $image, 0, 0, 8, 8, $width, $height, 8, ; imagepng($im); imagedestroy($im); } //End of function getFace() } ?> please help before i go insane :-\ Thanks in advance
-
php image to ascii problems (alpha -> green)
Username: replied to Username:'s topic in PHP Coding Help
I tried adding an alpha channel to my script, but it just made it appear worse. just read the rest of that script, I get it now $alpha = (imagecolorat($im,$x,$y) & 0x7F000000) >> 24; //DITHER! if ($alpha > 3 && ( $alpha >=127-3 || (rand(0,127))>=(127-$alpha) )){ imagesetpixel($im,$x,$y,$transparentColor); // <----------- that } edit: I added it, with no change. Did I do it wrong? <?php function imgToAscii($img, $letter) { echo " <style type='text/css'> .ascii { font-smooth:never; font-size:1px; line-height:1; letter-spacing:-1px; font:fixedsys; } </style>"; $ext = substr(strrchr($img, '.'), 1); if($ext == "jpg" || $ext == "jpeg") { $imgh = imagecreatefromjpeg($img); } elseif($ext == "png") { $imgh = imagecreatefrompng($img); } elseif($ext == "gif") { $imgh = imagecreatefromgif($img); } else { die("<font color='white'>Unknown file format!</font>"); } $trans = imagecolorallocate($imgh, 0xfe, 0x3, 0xf4 ); $w = imagesx($imgh); $h = imagesy($imgh); for($y=0; $y<$h; $y++) { for($x=0; $x<=$w; $x++){ $rgb = imagecolorat($imgh, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8 ) & 0xFF; $b = $rgb & 0xFF; $alpha = (imagecolorat($imgh,$x,$y) & 0x7F000000) >> 24; if ($alpha > 3 && ($alpha >=127-3 || (rand(0,127))>=(127-$alpha))){ imagesetpixel($imgh,$x,$y,$trans); } if($x == $w) { $art .= "<br>"; } else { $art .= "<span class='ascii' style='color: rgb($r, $g, $b);'>$letter</span>"; } } } return $art; } ?> -
php image to ascii problems (alpha -> green)
Username: replied to Username:'s topic in PHP Coding Help
Why is that? Transparency in fonts etc is supported natively by CSS. Could I just check for the color it sends out and tell it to put color: transparent; instead? Oh, and after I changed it to RGB(), transparency makes the image have a blue tint instead. And, transparency is this: color: rgb(0, 0, 251); -
php image to ascii problems (alpha -> green)
Username: replied to Username:'s topic in PHP Coding Help
I dunno, lemme look. I adjusted some things (changed from using hex codes to raw RGB format color: rgb($r, $g, $b)) and now not ALL images are green, just some images (like the Google logo) have discoloration on it's text. It actually looks almost perfect if I set the font to 1px, any higher looks stretched etc. I'm using @ signs so it's able to be round, not just square, the picture just looks a little blurry after. Do you want decimal values or hex values? Both? -
php image to ascii problems (alpha -> green)
Username: replied to Username:'s topic in PHP Coding Help
bump -
I made a small project last night that converts an image into text (with color etc). When the image is transparent, it spits out something like this. http://i.imgur.com/PEET5.png sometimes images look like this, even without a transparent background: http://i.imgur.com/WbEOF.png Can you help me? Here's my code function imgToAscii($img) { $ext = substr(strrchr($img, '.'), 1); if($ext == "jpg" || $ext == "jpeg") { $imgh = imagecreatefromjpeg($img); } elseif($ext == "png") { $imgh = imagecreatefrompng($img); } elseif($ext == "gif") { $imgh = imagecreatefromgif($img); } else { die("<font color='white'>Unknown file format!</font>"); } $w = imagesx($imgh); $h = imagesy($imgh); for($y=0; $y<$h; $y++) { for($x=0; $x<=$w; $x++){ $rgb = imagecolorat($imgh, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $hex = "#".dechex($r).dechex($g).dechex($b); if($x == $w) { $art .= "<br>"; } else { $art .= "<font style='font-size:1px;line-height:1;letter-spacing:-1px;size:1px;font:fixedsys;' color='".$hex."'>@</font>"; } } } return $art; } I tried adding an alpha value, but it made regular images worse and no change on transparent ones.
-
Mod lock or delete this thread please? I've discontinued the project. And the site getting blocked for suspicious ads or whatever are from my host, not me. Complain to ULMB with a picture of the ad if you like. I've switched hosts to 000webhost anyway.
-
After script executes it still continues to load
Username: replied to Username:'s topic in PHP Coding Help
Still the same -
After script executes it still continues to load
Username: replied to Username:'s topic in PHP Coding Help
Warning: Invalid argument supplied for foreach() in C:\wamp\www\phpIRC\common\functions\func.php on line 19 I replaced flush() with sleep(2) and it loaded faster, but about 3 lines of it was cut off EDIT: Meant to edit, could someone merge these [This one and the last one] posts please? -
After script executes it still continues to load
Username: replied to Username:'s topic in PHP Coding Help
Warning: Invalid argument supplied for foreach() in C:\wamp\www\phpIRC\common\functions\func.php on line 19 -
After script executes it still continues to load
Username: replied to Username:'s topic in PHP Coding Help
Shamefully bumping (Is that even allowed?) I still haven't resolved my problem. -
After script executes it still continues to load
Username: replied to Username:'s topic in PHP Coding Help
I already thought about that. I added it, and it had no effect. -
The following code does what I want it to, but after it's done doing it, it won't stop loading. I believe it is because of the while loops (while(1) { ... } and while($data = ...) { ... }). I need while($data = ...) to read the data from the fsockopen. Thanks in advance function ircConnect($server, $port, $channel, $nick, $pass, $name, $msg) { set_time_limit(15); //If we put set_time_limit(0), the page won't timeout and never stops loading (The script works, that I'm aware of) $fp = fsockopen($server, $port); if(!$fp) die($php_errormsg); if(empty($php_errormsg)) { $error = "None!"; } else { $error = $php_errormsg; } echo "<table border='1' bordercolor='#FFCC00' style='background-color:#FFFFCC' width='400' cellpadding='3' cellspacing='3'>"; echo "<tr><td>Server</td><td>Port</td><td>Channel</td><td>Nick</td><td>Password</td><td>Error</td></tr>"; echo "<tr><td>$server</td><td>$port</td><td>$channel</td><td>$nick</td><td>$pass</td><td>$error</td></tr>"; echo "</table>"; fputs($fp, "USER aBot testchan.org TestchanIRCBot :TheBot\n"); fputs($fp, "PASS $pass\n"); fputs($fp, "NICK $nick\n"); fputs($fp, "JOIN $channel\n"); fputs($fp, "PRIVMSG $channel :$msg, my name is $nick!\n"); while($data = fgets($fp, 128)) { $ex = explode(' ', $data); echo nl2br($data); flush(); if($ex[0] == "PING") fputs($fp, "PONG " . $ex[1] ."\n"); } } http://i.imgur.com/E6j79.jpg