
onlyican
Members-
Posts
921 -
Joined
-
Last visited
Everything posted by onlyican
-
mysql_real_escape_string() is changing the < to friendly < The best method would be just to store the embed ID
-
Why are you using JavaScript onSubmit() This function is normally used when you want to track a submit on a form. not throughout the website. If you want a simple echo at that point, use php echo, else just use JavaScript alert.
-
Depends what you are trying to achieve
-
Where shall i start 1) DONT rely on the file type being the file extension. list($origWidth, $origHeight, $fileType = getimagesize($myFile); $standardFileTypes = array(1 => 'gif', 2 => 'jpg', 3 => 'png', 4 => 'swf', 5 => 'pnd', 6 => 'bmp', 7 => 'tiff', 8 => 'tuff', 9 => 'jpc', 10 => 'jp2', 11 => 'jpx', 12 => 'jb2', 13 => 'swc', 14 => 'iff', 15 => 'wbmp', 16 => 'xbm'); $fileExt = $standardFileTypes[$fileType]; 2: You check if the file size is too big but you dont stop execution if($var1 == $var2){ // If the condition is true, execute this } // Execute this, regardless of the above if statement Check if file exists and not empty if(isset($_FILES['field']['tmp_name']) && $_FILES['field']['tmp_name']['size'] > 0){ }else{ // Nothing to upload }
-
I was about to say could be LAMP but then I noticed they tried IE, so WAMP / WIMP You require Apache and MySQL (dont bother trying to use IIS)
-
you need double quotes for the \n "\n" or "\r" sometimes, depending how the data is stored in the DB and the DB Type / Table Type
-
The file may exist but <img src="X" /> AND getimagesize() looks at different levels.
-
HTM Tag img src="X" takes from website root Whereas getimagesize() taks from Web Server Root Try something like $imageFile = $_SERVER['DOCUMENT_ROOT']."uploads/".$cat."/".urlencode($query_row['url']); if(file_exists($imageFile){ $info = getimagesize("uploads/".$cat."/".urlencode($query_row['url']).""); // Continue rest of code; }else{ // add debug for file not found }
-
I would guess by the name $boolType is a boolean (true / false) Therefore $boolType does not equal 1, its true if($boolType == true){ echo 'True'; }else{ echo 'its false'; } // ANOTHER OPTION, the same as above // The default of below is to check if something is true if($boolType){ echo 'True'; }else{ echo 'false'; }
-
Hi All I am building a website and I basically want to be able to log my own Error Logging. This could be anything from a usual PHP Notice, An SQL Query failing, a 404 page or a user reaching an activity they should not have (For example, hitting a default: on a switch when they shouldn't have) I have 3 options that I can think off 1) MySQL 2) Email 3) File Write All have pros and cons MySQL - Pro - I can build an admin script to read the errors and display them for me to handle and mark when completed. MySQL - CON - What is the Queries fail for what ever reason (too many connections), then the query to log the error would also fail, thus I would never know Email: PRO - Should always work, I will know straight away Email: CON - Getting the data from an email to a user friendly screen, instead of clogging up my email box File Write - PRO - I can put the data into MySQL at any point, Should near enough always work File Write - CON - Other people could possibly see the the errors, which could give away directories or weaknesses in the web project. Does anyone have any suggestions?
-
I am re-building one of my old sites, adding a few extra features. Basically I have a list of stories and comments I want to pull latest stories and the comments for them stories if any and where valid Table Strus tblStories stories_id INT(11) stories_owner INT(11) stories_status TINYINT(2) story_title VARCHAR(255) tblUsers users_id INT(11) username VARCHAR(255) user_level INT(11) tblComments comments_id INT(11) comments_story_id INT(11) comment_owner_id INT(11) comment_text VARCHAR(255) comment_status TINYINT(2) ** This is a basic stru and not correct SO I have the basic query ** Using ALL as cant be assed to write every field here, but yes I would in real sitution SELECT * FROM tblStories INNER JOIN tblUsers ON tblStories.stories_owner = tblUsers.users_id LEFT JOIN tblComments ON tblStories.stories_id = tblComments.comments_story_id INNER JOIN tblUsers AS CommentUser ON CommentUser.users_id = tblComments.comment_owner_id THIS works fine But I have flags in each table, the *_status says if its pending / online ect (2 is online) So a story / comment can be hidden / deleted If I add the following WHERE tblStories.stories_status = 2 AND tblUsers.users_level >=5 AND tblComments.comments_status = 2 AND CommentUser.users_level >= 5 Any story without comments does not show. So basically I want to pull all stories that are live, (status = 2) With all users who are valid users (user_level >= 5) And all comments on the same. (status = 2 and user_level for the person who added comment >= 5) I am doing the user, so if a user is removed, it will automatically remove all comments. As mentioned, adding the WHERES does not bring up stories where there are no comments, as the comment_status is NOT greater than 2
-
I am confused, a class is usually a cluster of functions relating to the same thing. For example, I just wrote an upload class, which handles uploading / checking / manipulating the image That gets called from another class where the form is uploaded (As I work in OOP, everything is classes) So basically to answer your question class myClassName{ private $arrSomething = array(); public function __construct($arrSomething){ $this->setArrSomething($arrSomething); } //------------------------ private function setArrSomething($arrSomething){ if(is_array($arrSomething){ $this->arrSomething = $arrSomething; } } //------------------------ private function doingSomethingWhile(){ while($this->arrSomething => $strSomething){ //I am doing something i think. Not Sure. } }
-
I would if I know how!!
-
Basic test to find out if your email mail() is working. NOTE: this will have NO headers and most likely end up in your Junk email box. Will also be from your server not u. Try it and we can go from there. $strTo = '[email protected]'; $strSubject = 'My Test Email'; $strBody = 'This is the Email message'; if(mail($strTo, $strSubject, $strBody){ echo 'Mail has been sent'; }else{ echo 'This is going to cause a headache'; }
-
Hey. I am not 100% with it at the moment, bit under the weather. (If you ask why I am working, your not a developer) Sob story aside (excuses really) Basically I have built a function to manipulate BB Code to HTM I wrote it, looked back at it and thought, my god this looks overly complex for this sort of thing. It works but just seems like a lot of wasted code. Please help me narrow this down public function BB2HTM($str){ /* Valid BB Code [b] / [/b] = STRONG [i] / [/i] = Italic [u] / [/u] = Underline [url=http://www.example.com]My Example[/url] = A Link [size=X]bla[/size] = Change font size where X is percentage of actual size, default options 50=>small, 100=>normal, 200->large [list]bla[/list] Handles Unordered Lists, with New Line being new list item [list=X]bla[/list] Handles Ordered List, where X is start number, again New Line is New List item */ /* First, we will do the basics, with a simple str_replace */ $str = nl2br($str); $arrBBCode = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]'); $arrHTMCode = array('<strong>', '</strong>', '<i>', '</i>', '<u>', '</u>'); $str = str_replace($arrBBCode, $arrHTMCode, $str); // /* Now we want to handle a URL, open in new window */ $regexURLPattern = '#(\[url\=(.*))(\])(.*?)(\[/url\])#is'; preg_match_all($regexURLPattern, $str, $arrMatches); /* Loop through the results, build a valid HTM link and replace what we found with the correct format */ for($i = 0; $i < count($arrMatches[0]); $i++){ $strNewLink = '<a href="'.$arrMatches[2][$i].'" target="_blank">'.$arrMatches[4][$i].'</a>'; $str = str_replace($arrMatches[0][$i], $strNewLink, $str); } /* End Handle URL */ /* Now font size. User can maniplate the number on size so we want to check for this and limit, so someone dont put 1% and hide stuff or 10000% and break the website */ $regexSizePattarn = '#(\[size=)([0-9]*)(\])#'; preg_match_all($regexSizePattarn, $str, $arrMatches); /* Loop through the results, put a check on the number */ for($i=0; $i < count($arrMatches[0]); $i++){ if($arrMatches[2][$i] > 200){ $arrMatches[2][$i] = 200; }elseif($arrMatches[2][$i] < 100){ $arrMatches[2][$i] = 100; } /* Change it and close the tag, keep the str_replace with the opener for later editing / auditing */ $strFontTag = '<span style="font-size:'.$arrMatches[2][$i].'%">'; $str = str_replace($arrMatches[0][$i], $strFontTag, $str); } $str = str_replace('[/size]', '</span>', $str); /* End Handle Size */ /* Is it a list, What list, where to start */ $regexListPattern = '#(\[list)(=?)([0-9]*)?(\])(.*?)(\[/list\])#is'; preg_match_all($regexListPattern, $str, $arrMatches); /* Loop through our results */ for($i = 0; $i < count($arrMatches[0]); $i++){ $strLstItems = ''; /* Is it unordered or Ordered? Where do we start, 1 or 100 Add our closing tag here as well in variable, save doing this again*/ if($arrMatches[3][$i] != ''){ $strEndLst = '</ol>'; if($arrMatches[3][$i] > 1){ $strLstItems = '<ol start="'.$strLstItems[3][$i].'">'; }else{ $strLstItems = '<ol>'; } }else{ $strEndLst = '</ul>'; $strLstItems = '<ul>'; } /* We can split the New lines as we done nl2br() as the top, we split on br */ $arrListItems = split("<br />", $arrMatches[5][$i]); for($x = 0; $x < count($arrListItems); $x++){ /* We dont want empty items, where people double enter or something */ if($arrListItems[$x] != ''){ $strLstItems .= '<li>'.$arrListItems[$x].'</li>'; } } /* Close the item as set above and replace it in our main str */ $strLstItems .= $strEndLst; $str = str_replace($arrMatches[0][$i], $strLstItems, $str); } /* End Handle Lists */ return $str; }
-
Ignore above. Ill moment. Its sorted.
-
hey all. It may have been dealt with. but I am ill and tired so please link or slap round the face to wake me up Basically, new project has a WYSIWYG style BBCode Editor (hey, bit like this here) Anyway, the new Line is killing me I have nl2br() but it aint doing anything Example Code //Dont say it, i know $str is a BAD variable name, but this is from a private function inside a class $str = nl2br($str); $regexURLPattern = '#(\[url\=(.*))(\])(.*)(\[/url\])#'; preg_match_all($regexURLPattern, $str, $arrMatches); for($i = 0; $i < count($arrMatches[0]); $i++){ $strNewLink = '<a href="'.$arrMatches[2][$i].'" target="_blank">'.$arrMatches[4][$i].'</a>'; $str = str_replace($arrMatches[0][$i], $strNewLink, $str); } so [url=http://www.example.com]Text[/url] // Outputs correctly [url=http://www.example.com]Not Idiot Proof[/url] // See what I did, added a new line like an idiot would, it now breaks Please help
-
Contact Directory Database - Pull Unique Values
onlyican replied to Call-911's topic in PHP Coding Help
You have to look at the bigger picture IF every category as CATEGORY Director CATEGORY Secretary then you can do a simple solution of having an INT in the table for ranking 1 = DIRECTOR 2 = SECRETARY ect ect If the position can be different per category a better solution Still keep the Ranking 1 = TOP DOG 2 = NEXT ONE DOWN then also have a varchar containing there rank Order by the rank, get the rank name and sorted. -
Copy table data from one databse to another databse table daily
onlyican replied to sunilpaladugu's topic in PHP Coding Help
PHP to run a MySQL query along the lines of INSERT INTO tbl2 (SELECT * FROM tbl1) -
I have cracked down a lot on spam bots I am securing all GETS / POSTS / REQUESTS as these were NOT always done. I am using a sneaky method (Later found to be a known method called honeypot) Where I have a text field that is in a hidden div. The field has to remain empty, else log in fails. (As most bots complete all fields) Also another field with a value thats hidden, the 2nd page has to match (this is hard coded but helps stop cross scripting) And user approval via email (Should have done this ages ago) I have done a couple of other tricks but not going to tell all my secrets.
-
The reason I doubt these are users actually registering is the amount and Spam posts are starting to appear. When I look at the user Data, they registered on X date, last logged in: never. For them to confirm account, they have to log in, which would cause a last log in date. Only email validation is standard SMF, I may change this to check the MX Records.
-
Recaptcha has been activated since the start but they are coming through thick and fast
-
Hi I got a smallish website, smallish forum using SMF My god am I suffering hard with bot registrations. I got 72 posts and over 1300 users (You do the maths, this is NOT right) I have moded the registration form to use ReCaptcha (Yes I know recent news about ReCaptcha) Other than that, its pretty standard. Any suggestions how to help prevent bot registrations (They are starting to post now so I can't just leave it and say, hey I got loads of members)
-
Hi, I have a string which contains a mix of Content and anchor links Example: //Example $strContent = 'I am some <a href="/content.htm">Content</a> here, but I could have <a href="/link.php">a Link</a> <a href="http://www.example.com">Followed by another</a> Link, Mix external and not.'; I basically want to programatically pull out all of the Anchor links, and have an array of such Array('/content.htm', '/link.php', 'http://www.example.com'); Help me please. Got a brain freeze as its Friday Afternoon
-
A trick I do when working with this is, saves referencing soo many indexes. [php $arrMyData = $parsedxml['oaklistinfo']['contact']; $strContactName = $arrMyData['contactname']; [/code]