Jump to content

TheMayhem

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

TheMayhem's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello there, I am working on a script that will take a user submitted text and display the text in rainbow. I found a very nice function on the Internet and used it as my base. Here is an example of the code. function rainbow($text) { /*** initialize the return string ***/ $ret = ''; /*** an array of colors ***/ $colors = array( 'ff00ff', 'ff00cc', 'ff0099', 'ff0066', 'ff0033', 'ff0000', 'ff3300', 'ff6600', 'ff9900', 'ffcc00', 'ffff00', 'ccff00', '99ff00', '66ff00', '33ff00', '00ff00', '00ff33', '00ff66', '00ff99', '00ffcc', '00ffff', '00ccff', '0099ff', '0066ff', '0033ff', '0000ff', '3300ff', '6600ff', '9900ff', 'cc00ff'); /*** a counter ***/ $i = 0; /*** get the length of the text ***/ $textlength = strlen($text); /*** loop over the text ***/ while($i<=$textlength) { /*** loop through the colors ***/ foreach($colors as $value) { if ($text[$i] != "") { $ret .= '<span style="color:#'.$value.';">'.$text[$i]."</span>"; } $i++; } } /*** return the highlighted string ***/ return $ret; } $post[message] = rainbow($post[message]); And it works very well Here is my problem. At times $post[message] will contain some basic html such as a bold tag, user smiley (img tag), a link tag, and so forth. How can I take my function above so that it doesn't edit and add the html font color coding for anything inside html tags where it just skips over them and leaves that part alone? I need this otherwise it will breakup every html tag I might have inside $post[message] and add a font color html tag to it, thus voiding all other html in it.
  2. I am trying to figure out the exact path to my file. Right now I've been using: $_SERVER['DOCUMENT_ROOT'] This works if my file is currently uploaded into the root directory. However document root doesn't take into account any extra folders my file location might be loaded. For example: /home/users/web/b888/nf.vbpointmarketcom/public_html/forum/admin Printing out the $_SERVER['DOCUMENT_ROOT'] would only show me: /home/users/web/b888/nf.vbpointmarketcom/public_html Is there any premade function or way that I can quickly figure out what the subdirectories are as well so I can output it or assign it to a variable?
  3. I've spent two hours comparing strings. $string1 = $gettext['$number']; $string2 = $getstuff['url']; if (strlen(strstr($string1,$string2))>0) { print "YES<br />"; } There is my code. $string1 == aad.com $string2 == aad.com So why does it refuse to print out Yes? I am getting $string1 from an array that I created and $string2 from the database but all I want to see is $string2 has text in $string1 &/or it is identical. String1 is the haystack and String2 is the needle. I've tried every kind of tutorial possible but nothing is working.
  4. Pretty basic question here, I have a string called: $string I want to use a php replace function or whatever would be best to find the first occurence of ] and for the string to delete from ] And everything after that first occurence of ] In the string. Example $string = "Hello Friends [Test] My name is John"; After the php function $string "Hello Friends [Test";
  5. Can you provide me with an example? The function I am using to check if the URL is valid is called: is_valid_url and the phrase that everything is located in is called $find[pagetext]. Trying to extract data from strings is something that always confused me as well as for loops.
  6. I currently have an array called: $find[pagetext] In this array, there is going to be one to several instances where I am looking for a specific forum coding called: [url=http://megaupload.com/?d=X]http://megaupload.com/?d=X[/url] Everyone has used megaupload but what this script basically is going to do is check the validity of the upload site the user has chosen. Above I selected megaupload but there are about 6 sites I am going to check in the code I'm writing. I'm stuck on 1 part. How can I extract from $find[pagetext] all occurances of the website (In this case) megaupload and assign each instance to array. Once I assign it to an array I've already written a function that will check and see if the web link is valid I just need to basically extract each URL occurance of megaupload or whatever the upload site I am checking there is. All help is greatly appreciated.
  7. I am working on a debug script to see if users had setup my script correctly. The very last part I have is a little debug section where it checks for some common errors. I am having problems with one last part, which is checking to see if they correctly setup the chmod permissions to 0777. This is my coding below: // Directory Permissions $path = $_SERVER['DOCUMENT_ROOT']; $customavatar = $path."/customavatars"; $smilies = $path."/images/smilies"; $store = $path."/images/pointmarket/store"; $text4 = $vbphrase['market_maintenance_directory_good']; $icon4 = "$site_url/checkmark.png"; if (!is_writable(dirname($customavatar))) { $badfolder = $customavatar; $text4 = $vbphrase['market_maintenance_directory_bad']; $icon4 = "$site_url/warning.gif"; } if (!is_writable(dirname($smilies))) { $badfolder = $smilies; $text4 = $vbphrase['market_maintenance_directory_bad']; $icon4 = "$site_url/warning.gif"; } if (!is_writable(dirname($store))) { $badfolder = $store; $text4 = $vbphrase['market_maintenance_directory_bad']; $icon4 = "$site_url/warning.gif"; } Now I've physically tested it to see if I have all directories chmodded to 0777 and they all are. However, whenever I output each time I am being shown that the directories are showing me that they aren't writeable because $badfolder, $text4, and $icon4 are all being reassigned within the if statement. I've tried each one of the three above to see and all of them are going within the if statement even though they shouldn't be. Can anyone tell me what I might be doing wrong?
  8. I've been trying to find tutorials/coding today related to controlling the ability to download files. The problem I think I'm having because I know it exists is I don't actually know what it's called. Below is kind of a basis for a tutorial or describing what I'm trying to do. I'm trying to find a tutorial or a how to on storing downloadable files either in a Mysql Database &/or on the file server system. I want to make it so that only users that are stored within the user database who have certain rights or a field can be able to download a file. Those users who don't have the proper permissions in the user table will not be able to and those who do when they go to download a file, will be able to. I know these scripts use PHP but am not really sure where to begin on my search because I don't even know what file permissions coding they are using.
  9. Nah you guys misunderstood me. I know how to assign variables I just typed that as an example. I have this variable called $musername It contains things like: <b>$username</b> OR <font color="#ff0000"><u>$username</u></font> OR <i><u>$username</b></i> etc. What I need to do is to take one variable and assign it so that it takes only the code before whatever the $username variable is. So for example it would take <b><i> And then I need to assign a second variable to take everything after the $username variable in the phrase so for example it would take: </b></i> Basically I have a string and want to chop it up into 3 pieces, all the beginning html, the username and then all the closing tag html
  10. Okay I need a little bit of help on this as strings constantly confuse me and reading tutorials actually got me a bit more loss then before. I have developed this mod that has become pretty popular and I'm debugging it. What I have are two variables. $username (The user's username, no html markup in it) $musername (The user's username, with html markup in it) So for example: $musername = <b><u>$username</u></b> The php code above would be the equivolant to what $musername is equal to. What I need to do is create an array or two variables, whatever is easier and grab all that html markup. The first variable would be all the html or anything really before the $username variable, and the other would take all of that html after the $username variable. I need to store those html markups in either two seperate variables or an array so i can call upon it later in the script. I need this to fix a bug issue.
  11. I'm a little stumped how to do this, so hopefully I'll find the right answer. I have two strings: $customtitle and $censoredwords Inside the $customtitle string is a user typed string consisting of words, letters, numbers, etc. Inside the $censoredwords are censored words or characters typed by the Administrator. Each word is seperated by a space, which is what is really confusing me. My question to you is how can I compare the two strings and see if $customtitle contains any words from $censoredwords and if so kickback a TRUE or numerical value of 1 and if not kick back a FALSE or a numerical value of 0.
  12. Using the suggested query statement above outputs the following mysql error: MySQL Error : Every derived table must have its own alias Error Number : 1248 Any ideas?
  13. Will a query like that work with mysql 4.x series? Unfortunately, the scripts I am working with still support mysql 4x and therefore what I create as addons should follow suite until the script no longer supports it.
  14. I come to you guys for a solution on a problem I honestly cannot figure out. I'm a developer for addons for the popular vBulletin script and I have been using the group by function for statistics. The query is listed as: SELECT *, COUNT(marketid) FROM market_transactions GROUP BY marketid ORDER BY COUNT( marketid ) DESC LIMIT 0 , 1; It's a nice looking query that works for 90% of the users including myself. My problem is for the last 10% they are getting a php/mysql error stating: MySQL Error : Invalid use of group function Error Number : 1111 I looked into it a bit and found the similarities with these users are that all are using mysql version 4.1 instead of mysql 5x series. I can only assume that this is the reason why they are getting this error but don't know how exactly to rescript this mysql/php query to work for them as well or run an alternative for them that accomplishes the same thing. The goal of the query is simply to group everything by the marketid column within the mysql database. Count what has the most table rows for a specific market id and sort it in a descending order to display what is the most popular marketid.
×
×
  • 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.