
gdfhghjdfghgfhf
Members-
Posts
218 -
Joined
-
Last visited
Everything posted by gdfhghjdfghgfhf
-
i use this code to convert html to bbcode: // Tags to Find $htmltags = array( '/\<b\>(.*?)\<\/b\>/is', '/\<i\>(.*?)\<\/i\>/is', '/\<u\>(.*?)\<\/u\>/is', '/\<ul(.*?)\>(.*?)\<\/ul\>/is', '/\<ol(.*?)\>(.*?)\<\/ol\>/is', '/\<li\>(.*?)\<\/li\>/is', '/\<img(.*?) src=\"(.*?)\" (.*?)\>/is', '/\<div\>(.*?)\<\/div\>/is', '/\<strong\>(.*?)\<\/strong\>/is', '/\<a(.*?)href(.*?)\"(.*?)\"(.*?)\>(.*?)\<\/a(.*?)\>/is', '/\<a(.*?)href(.*?)\'(.*?)\'(.*?)\>(.*?)\<\/a(.*?)\>/is', ); // Replace with $bbtags = array( '[b]$1[/b]', '[i]$1[/i]', '[u]$1[/u]', '[list]$2[/list]', '[list]$2[/list]', '[*]$1', '[img=$2]<br>', '$1', '[b]$1[/b]', '[url=$3]$5[/url]', '[url=$3]$5[/url]', ); // Replace $htmltags in $text with $bbtags $text = preg_replace ($htmltags, $bbtags, $zaqlinkclean); echo $text; it works good, but the problem is that when there are two images following each others, the result is messed up and i think there is a similar problem with link replacements Could anyone please help me to fix this ? Also, another problem (but less important) is that html tags are replaced even if empty (exemple: <a href=""></a> will still be replaced by ) thanks a lot!
-
regex: replace links captions by url
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in Regex Help
Yes, cags is right, i did an error in my example (sorry!) But sasa's code did exactly what i wanted with a little tweak! thanks a lot!!! -
Hello, i have a string that looks like this (a lot of different links with different attributes) <a href="http://www.mediafire.com/something">http://www.mediafire.com/something</a> text text text text text text text text text text text <a href="http://www.somelink.com"> text text text text text text text <a href="http://megaupload.com/something/blabla">Some link without WWW</a> text text text text text text text text text text text text text text <a title="somename" href="http://www.rapidshare.com/download" style="color:#000000" target="_blank">some confusing link</a> ...........more text here.......... <a href="http://www.microsoft.com"> ....more text........... <a href="http://www.4shared.com/download.php?file=myfile"><img src="a_link_with_an_image.gif"></a> I'm trying to replace the links and change the captions with the URL of the link.... BUT only for links pointing to these sites: mediafire.com, megaupload.com, rapidshare.com and 4shared.com Additionally, i want to add [DL][/DL] tags between the replaced links the links can come with or without WWW and with or without additional attributes (like Style, target, title, etc...) Here is the result i would want with the above example: [DL]<a href="http://www.mediafire.com/something">http://www.mediafire.com/something</a>[/DL] text text text text text text text text text text text <a href="http://www.somelink.com">link</a> text text text text text text text [DL]<a href="http://megaupload.com/something/blabla">http://megaupload.com/something/blabla</a>[/DL] text text text text text text text text text text text text text text [DL]<a title="somename" href="http://www.rapidshare.com/download" style="color:#000000" target="_blank">http://www.rapidshare.com/download</a>[/DL] ...........more text here.......... <a href="http://www.microsoft.com"> ....more text........... [DL]<a href="http://www.4shared.com/download.php?file=myfile">http://www.4shared.com/download.php?file=myfile</a>[/DL] Thanks a LOT to whoever can help me with this! I'm newbie to regex and i gave up after a lot of searchs
-
doesn't work, maybe because there is 1 row for each reply but only 1 row for the topic..... i don't know, i'm really a newbie :/
-
I use this code to display the last posts from my phpbb forum $query = "SELECT post_subject, topic_id from phpbb_posts ORDER BY post_id DESC LIMIT 15"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $title = substr($row["post_subject"], 0, 30); $topic_id = $row["topic_id"]; $post_id = $row["post_id"]; echo " <a href=\"viewtopic.php?f=5&t=$topic_id#p$post_id\" title=\"$title\">"; echo $title; echo "</a>..<br>"; } But if a topic has multiple new replys, it will list the topic multiple time. How can i remove the duplicate results? (keep only the last post of the topic) Exemple: Would be: thanks a lot!
-
help me fix this small part of code
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
thanks a lot! Seems to work correctly now! -
I use this code to take out all URL in a string. function xcleaner($url) { $U = explode(' ',$url); $W =array(); foreach ($U as $k => $u) { if (stristr($u,'http') || (count(explode('.',$u)) > 1)) { unset($U[$k]); return xcleaner( implode(' ',$U)); } } return implode(' ',$U); } The problem is that the last word before the first dot of the string will be removed.... How can i fix that? exemple: will give:
-
problem with character encoding
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
WOOHOO! thanks a lot cags, it worked! -
problem with character encoding
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
So this is probably the problem. I need to set UTF-8 in the left menu of my site. So if i put the header() call inside my left menu script, it will not be the very first thing in the file when index.php loads Even if i put the code in the first line of "last2.php", i get this error: so i have tryed to put the PHP code inside the beginning of "overall_header.html" but it doesn't change anything -
problem with character encoding
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
if i put it in "last2.php" menu it will write an error message saying the header has already been sent So i replaced the current charset with your code in phpbb header's template..... But i still have the same problem -
problem with character encoding
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
i already tryed that, just tryed again and it doesnt change anything see by yourself: http://www.anarcho-punk.net/ this is the script where the problem comes from (i include() this menu on the front page) http://www.anarcho-punk.net/last2.php As you can see the russian topic name is written "????????" but when you click on the link, everything is good: http://www.anarcho-punk.net/viewtopic.php?f=5&t=1981 -
I have a weird problem related to characters encoding on my website I have using a phpbb3 forum, and i have a french and russian forum. I have built a menu showing the last posts of all forums My problem is that when a post title includes weird character (french characters like "é à â î Ç" or russian characters) it will display incorrectly I don't understand why, because the characters are displayed correctly inside the forums What do i have to do?
-
desesperatly need help to fix this upload script
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
Speak to the Host provider as if the script works then it problem with their permissions, i have done tons of scripts with file access and never had these problems, with any host. so theirs something else going i already tryed that, but it is very hard to get support from my host... i have to find another work around to fix this If the thumbnail file is working then there must be a way to make it work.... theorically if i can manage to make the image the same way the thumbnail file is made then it should be working.... even if the image is resized a bit i dont really care... -
desesperatly need help to fix this upload script
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
- the main image and the thumbnail are created from the same php script - the thumbnail and the main image are stored on the same folder - the thumbnail and the main image have the same permissions if i take my script, and host it on a different server, there is no problem at all. i don't even have to change the permissions -
desesperatly need help to fix this upload script
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
here is the old thread if this can help... http://www.phpfreaks.com/forums/index.php/topic,195388.msg880039.html#msg880039 -
desesperatly need help to fix this upload script
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
-
desesperatly need help to fix this upload script
gdfhghjdfghgfhf replied to gdfhghjdfghgfhf's topic in PHP Coding Help
bump -
Ok well my problem is really weird, i'll try to explain it the best i can Basically i have this image upload script ive been working a lot on, and with the help of some peoples... so i really dont want to start it over My problem is that when an image is upload, i won't be able to touch the physical file.. I cannot download it from the ftp to my computer, i cannot change the chmod, but i can rename the file BUT, i tryed it on a different server and everything works perfectly Daniel0 suggested the problem was caused by this: BUT... The script is creating a thumbnail file of the uploaded file, and i have no problem with the thumb file!! I can transfer it, change the chmod, etc... here is what some user of phpfreaks suggested: So basically this is where i'm stuck at.... could anyone PLEASE help me to fix this script? I would be really happy if i can get this to work <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> $headinclude <title>$vboptions[bbtitle]</title> </head> <body> <?php include("db.php"); $bbuserinfo['userid'] = "1"; //This is the resize/sampler. function resample($img, $max_w, $max_h, $type, $thumb) { switch ($type) { case 2: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefromjpeg($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = @imagecreatetruecolor($rs_w, $rs_h); @imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } if($thumb == true) { $image = explode('/',$img); $x = 0; $num_dir = count($image)-1; while($x < count($image)-1) { $pre_img .=$image[$x]."/"; $x++; } $img = $pre_img."/sml_".$image[count($image)-1]; $img; } // generate resized image imagejpeg($rs_image, $img, 100); return true; break; case 3: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefrompng($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = imagecreatetruecolor($rs_w, $rs_h); imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } if($thumb == true) { $image = explode('/',$img); $img = $image[(count($image)-1)]."sml_".$image[count($image)]; print $img; } // generate resized image imagepng($rs_image, $img, 100); return true; break; case 4: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefromgif($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = imagecreatetruecolor($rs_w, $rs_h); imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } // generate resized image if($thumb == true) { $image = explode('/',$img); $img = $image[(count($image)-1)]."sml_".$image[count($image)]; print $img; } imagegif($rs_image, $img, 100); return true; break; } } ?> <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> <?php $headinclude;?> <title><?php $vboptions['bbtitle'];?></title> </head> <body> <br /><br /><br /><br /> <center> <?php $bbuserinfo['userid'] = "1"; if($bbuserinfo['userid'] != NULL) {} else { $url = 'connexion.php'; $timeout = 0; header('Refresh: ' . $timeout . ';url=' . $url); print' <meta http-equiv="refresh" content="'.$timeout.';url='.$url.';"> <script type="text/javascript"> setTimeout(function(){window.location.replace("'.$url.'; ", '.($timeout * 0).'); </script>'; } if($bbuserinfo['userid']) { print' <form action="'.$_server['php-self'].'" method="post" enctype="multipart/form-data" id="something" class="uniForm"> '; // @include("imgbands.php"); // print' <br /><hr /> <table> <tr> <td> Uploader la photo (#1): </td> <td> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> </td> </tr> <tr> <td> Description (optionel): </td> <td> <INPUT TYPE="TEXT" NAME="infos" VALUE="" size="60"> </td> </tr> </table> <INPUT TYPE="hidden" NAME="user" VALUE="'.$bbuserinfo['username'].'" size="60"> <input name="submit" type="submit" class="submitButton" value="AJOUTER L\'IMAGE" /> </form> '; } $band = $_POST['band']; if($_POST['submit']) { $imagenamz = $_FILES['new_image']['name']; $originalname = $_FILES['new_image']['name']; $date = date('dmy'); $imagename = "$band" . "_" . $date . "_" . $originalname; echo $imagename; $vraidate = date('d/m/y'); $nom = $_POST['user']; $infos = $_POST['infos']; echo "<br />L'image a été ajouté dans l'album photos de <b>$band</b><hr><br />"; $source = $_FILES['new_image']['tmp_name']; $target = "db/img/images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "db/img/images/" . $imagepath; //This is the new fileyou saving $file = "db/img/images/" . $imagepath; //This is the originalfile list($width, $height, $att) = getimagesize($file) ; $size = getimagesize($file); $uploadx = $size[0]; $uploady = $size[1]; } list($width, $height, $type, $attr) = getimagesize($target); resample($target, 800, 800, $type, false); resample($target, 150, 150, $type, true); if(isset($_POST['submit'])){ // if file exists // add to database $filename = 'db/img/images/sml_".$imagepath."'; if (file_exists($filename)) { $band = $_POST['band']; $originalname = $_FILES['new_image']['name']; $date = date('dmy'); $imagename = "$band" . "_" . $date . "_" . $originalname; // echo $imagename; $vraidate = date('d/m/y'); $nom = $_POST['user']; $infos = $_POST['infos']; $result = mysql_query("INSERT INTO bands_pics (id,band,url,date,infos,valide,user) VALUES ('NULL', '$band', '$imagename','$vraidate','$infos','0','$nom')"); } } ?> 123
-
i have just finished creating a search script you can search for an entry inside the database by accessing search.php?query=YOURSEARCHHERE but now i have a stupid question how do i create the html form that will process the search? basically i need to make a form with a text input and a send button when send button is hit, the browser will go to the URL i mentionned above, where "YOURSEARCHHERE" is the words the user have entered inside of the text input
-
just a simple question i would like to replace all single quotes with this character in the variable $text what syntax can i use to do this with str_replace? thanks
-
well the title says it all.. I have an entry in my database with a serialized array. I'm trying to remove one of the item inside of the array.. Here is the working part of my code $a = $row["options"]; $ary = unserialize($a); foreach ($ary as $thing) { $aff = str_replace("12345 test", "", $thing); echo $aff; } i managed to unserialize the array to take out the entry i wanted (12345 test), but now i need to make a serialized array with the updated items, and i'm stuck here... could anyone help me to complete my code? thanks a lot
-
hello, just one simple question i have a variable that contains stuff like this: $var = "cat - dog - fish" i'd like to keep only the part between the first " - " the result i'd want from the example above would be just "cat" thanks!