Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. As long as download.php performs checking to determine if the user has access to download the file they've requested, there's no harm in using a GET parameter. Messy, but perfectly valid.
  2. Probably with binary punch cards.
  3. I've been playing video games for 25 years; I'm 27. I don't think it's his gaming habit that makes him a moron.
  4. When all else fails, dump output to the screen and see if it's what you expect. In this case, try: alert(document.FormName.Card_Type); Make sure it says something about it being an object. If it's not, then it might just be easier to do something like: var ctype = document.getElementById("fCardType"); if(ctype.options[ctype.selectedIndex].value != "Visa" || ctype.options[ctype.selectedIndex].value != "Mastercard"){ }else{ }
  5. [quote]I'm pretty sure that C and all of it's variants are or originally were CREATED BY Assembly. And most high level languages like PHP are created from creations of Assembly.[/quote] The original C compilers had to be written in assembly; but once a single C compiler exists then you can create future C compilers in C instead of assembly. IIRC, the first Microsoft C compiler was written in Borland's C IDE.
  6. I didn't want to steer the following thread off into a wild tangent, but I did want to respond to the emerging argument about design process: http://www.phpfreaks.com/forums/index.php/topic,149945.0.html If you're going to pick one between test cases and UML then I agree with Jenk; it is a matter of preference. However, I think it's important to understand that both are intended for a different purpose. Test cases exist so that we can be reasonably sure that as we add new features to software we don't break existing features. UML exists primarily to describe a software's design and use in a common language understandable by programmers, users, and business people. In a large scale application, which I think very few of us are actually working on, they would be used in tandem, each for a different purpose.
  7. A good rant can help prevent a murderous rampage, although a murderous rampage could be considered chicken soup for the soul.
  8. Your problem could be this: <?php // Create a class class BuyNow{ var $dealer; var $web; var $site; var $rank; } // Create the Function function BuyNow($dealer, $web, $site, $rank){ //... ?> Constructors are named after the class in PHP4, so I'm guessing you intended for: function BuyNow($dealer, $web, $site, $rank){ to define a constructor. However, you have a closing curly brace after your var $rank; which effectively ends the class declaration. This means you've create a class named BuyNow which has only four member variables and no methods or functions. Here is a simple class declaration: <?php class BuyNow { // <-- THIS CURLY BRACE BEGINS THE CLASS var $var1, // <-- Some properties (or member variables) $var2, $var3; // Define a constructor function BuyNow( /* params */ ){ <-- THIS CURLY BRACE BEGINS THE CONSTRUCTOR } <-- THIS CURLY BRACE CLOSES THE CONSTRUCTOR } // <-- THIS CURLY BRACE ENDS THE CLASS ?> Now let's take a look at your function that you declared: <?php function BuyNow($dealer, $web, $site, $rank){ // Define the variables $dealer, $web, $site and $rank $New[] = BuyNow('dealer1', 'web1', 'http://www.site1.com', '1'); $New[] = BuyNow('dealer2', 'web2', 'http://www.site2.com', '1'); $New[] = BuyNow('dealer3', 'web3', 'http://www.site3.com', '1'); $New[] = BuyNow('dealer4', 'web4', 'http://www.site4.com', '1'); $New[] = BuyNow('dealer5', 'web5', 'http://www.site5.com', '1'); $New[] = BuyNow('dealer6', 'web6', 'http://www.site6.com', '1'); $New[] = BuyNow('dealer7', 'web7', 'http://www.site7.com', '1'); $New[] = BuyNow('dealer8', 'web8', 'http://www.site8.com', '1'); $New[] = BuyNow('dealer9', 'web9', 'http://www.site9.com', '1'); $New[] = BuyNow('dealer10', 'web10', 'http://www.site10.com', '0'); $New[] = BuyNow('dealer11', 'web11', 'http://www.site11.com', '0'); $New[] = BuyNow('dealer12', 'web12', 'http://www.site12.com', '0'); $New[] = BuyNow('dealer13', 'web13', 'http://www.site13.com', '0'); $New[] = BuyNow('dealer14', 'web14', 'http://www.site14.com', '0'); } ?> This function is next to useless. It takes four parameters, none of which are used anywhere. You've declared a variable in the function named $New and assigned values to it, but the variable itself is never returned. Even if you had correctly placed this function inside the class as a constructor, it would be useless; you can tell this from the lack of the $this keyword. Looking at the rest of your code, which effectively sits in the global namespace (unless this file is itself called through include): <?php / Define Plug in Variables $Top['dealer'] = $dealer; // <-- $dealer, $web, $site ALL LOOK LIKE THEY'RE $Top['web'] = $web; // UNDEFINED. YOU DIDN'T SET THEM ANYWHERE $Top['site'] = $site; // IN THE SCRIPT YOU PASTED return $Top; // YOU'RE NOT IN A FUNCTION, WHAT IN THE HELL ARE YOU RETURNING // FROM? // Technically this code won't execute since you just returned early in the above statement $Bottom['dealer'] = $dealer; // <-- SEE THE NOT ABOVE ABOUT UNDEFINED $Bottom['web'] = $web; // VALUES $Bottom['site'] = $site; return $Bottom; // SAME NOTE ABOUT RETURNING ABOVE REPLIES $Tpl = new clsTinyButStrong ; // Make Blocks 'Top' and 'Bottom' $Tpl->MergeBlock('Top', $Top); $Tpl->MergeBlock('Bottom', $Bottom); $Tpl->Show(); ?> I suggest you read up in the PHP manual about classes as you look to be way over your head here: http://php.net/oop Notice how if you had done the debugging process with echo sooner your original post could have been: "There's something wrong with this class, please help" and you probably would have gotten a lot of useful input sooner.
  9. FYI, whenever I add temporary statements that don't belong in the program, I always append an // %% to them. This way I can do a search for %% and remove the temporary lines I've added.
  10. echo is a PHP command so it has to be somewhere the PHP interpreter can parse it. Since it doesn't appear your template file is working correctly, I wouldn't put it in the template file but in a .php file instead.
  11. Well, if you're using a custom template engine written internally by your company, it would be very hard for us to tell you why it's not working just by seeing some very "high level" code. Basically you're going to have to learn how to debug something on your own without any external help. Here is the most useful tool in doing that: echo Even better: echo "<pre>" . print_r($SomeVal, true) . "</pre>"; Start tossing echo statements everywhere. Make sure the data you're receiving is the data you're expecting. Track the programs execution with it. I've seen coders with fancy IDEs, syntax high lighting, debuggers, and all sorts of other crap that couldn't figure out why their program didn't work. 99% of all my debugging is done with simple echo statements; it rarely let's me down.
  12. I leave it on. The site I develop pretty much requires it. I'd love to take the time to make sure everything works with or without Javascript but the bottom line is the site is intended for a very specific audience and we can pretty much tell them, "You have to have Javascript turned on." It really doesn't matter if robots can crawl our site as they can't really get to much without logging in to start with. Basically when I have an impatient project manager jumping up and down behind me going, "Is it ready, is it ready? When can I sell it?" and I have to make a choice between cool (read asynchronous requests) or accessible, I have to lean towards cool. As far as being a security concern, I think there's just too big of a market of people who don't know how to use their PC. I've always been into PC games so performance is always a top priority for me. As such I've never run any firewall or anti-virus software. It's been years since I've done it, but back in college I downloaded my fair share of multimedia and cracked software. I've spent probably at least $1000 / year online since 1998, some years more, and I do my banking and pay bills online. Number of problems I've had: Zero. Maybe once a year I'll run AdAware and it'll pick up one or two spyware things and about as often I'll run AVG and it never finds anything. People just need to learn to be careful what they click on.
  13. If you look at the page source does it have the content of your template "as-is," meaning does it actually have the strings: [Top_2.dealer], [Top_2.site], etc? I've never used a template engine but I may be able to help you track down the source of the problem.
  14. LOL. Body check him into the wall and then stand over him: "Hey asshole, now that I have your attention there's a problem with the software our company produces and my boss seems to think you can fix it."
  15. Boo! I want to see special content too.
  16. Are you repeating the question? Or did you forget to type a body in your post? If you're repeating the question: A singleton is an object which is intended to be instantiated only once during a programs execution. When the program requests a singleton object, let's say the DB, it first checks if the object is instantiated. If it is, it returns the existing instance. If it is not, it instantiates the object (via new) and returns the instance; it also has to save a reference to that instance in case the program requests the singleton again later.
  17. The application is entirely custom. I inherited this project last March when I was hired for my first programming job. Since our program is basically "outsourced" from our client's perspective and also because our clients are homebuilders dealing directly with home owners and home buyers, allowing our clients to brand the product has always been a concern. Initially when I inherited the project, we allowed customization of the following: top left logo top right banner top menu the entire page header (logo, banner, menu) CSS various text blocks within the site (login page, home page, contact page, etc.) However, I noticed that the majority of our clients only ever changed the login page (because we have that stupid CRT monitor on it), the logo, and the banner. Some of them have updated the CSS to be similar to their regular company web pages, but like I said in my OP the transition was never very seamless. So a few months ago the idea hit me we could probably allow them to just embed our application into their current homepage via iframe and only recently did I have time to look into the actual implementation. There are some hurdles to overcome dealing with Javascript and cookies though. I'll quickly explain the Javascript problem first. We didn't want any scroll bars on the iframe which means the iframe has to change heights depending on the size of the content. This is can be tricky to set up for newer JS programmers, but is fairly straight forward when the site in the iframe is on the same domain as the container site. However, in our situation, the sites are hosted by different domains. What I had to do in this scenario was give our clients an administrator setting where they can specify a script hosted on their domain. The script is very simple, it takes a height URL parameter and outputs a small HTML document with some Javascript. The Javascript grabs the iframe via document.getElementById("wvIFrame"); and sets the iframe.style.height equal to the height passed via the URL. Then I added an onload page handler to all of the pages coming out of our site if its hosted in an iframe. This onload handler calculates the content height and then uses the DOM to create an invisible iframe and call the resizing script hosted by our client's domain. This allows our application to pass the height of its content back to our client and because the client page is on their domain it has access to the iframe in the top level container page. Once the dynamic iframe is loaded it is destroyed to avoid having multiple invisible iframes hanging around. The last issue deals with cookies. Our site uses sessions to track user activity which means cookies. However, when visitors to our clients home pages are viewing our application in the iframe, the cookies are considered third party because of the differing domains. Depending on the user's browser security settings, it may or may not accept these cookies. There are two ways to combat this problem. The quick and easy solution, the one we took, is to recommend that users set their browser to always accept cookies from our server (ibswebview.com). The second solution is to set up a privacy policy on our site explaining how the information in the cookies is used. I read up on this a little and theres a little extra you have to do but what it boils down to is the typical default setting for IE is to accept third party cookies only if a privacy policy exists. I imagine I'll be doing this at some point in the future.
  18. Your situation is very similar to mine actually. We have a web product for home builders and we support multiple clients on one server. Each of our clients is given their own database. Our URLs look like: www.ibswebview.com/wv/<client> where client is the client's name and maps to an appropriate database. We also use mod_rewrite to map all requests through a single entry point which handles the URI parsing and database connection before passing off control to the proper segment of the program. We provide our clients with an interface in the application to customize the logo, banner, and CSS of the site so to some extent they can match the our site to their own. Of course, the transition isn't entirely transparent to users. Recently, I added functionality that allows our clients to embed our site into their own using an iframe. The src attribute of the iframe should be like the URL above but with an appended /IFrameRender/. I've also added Javascript to the page load to detect if it is sitting within an iframe. In either of these cases, the header and footer of our site are not rendered so all that appears in the iframe is the content. Providing a direct link or helping our clients assist in setting up the iframe approach seems to be satisfactory for most people. You can see an example of our site here: http://www.ibswebview.com/wv/beta Username: beta1 Password: beta1 And here is the same page served in an iframe: http://www.rbredlau.com/test/ponderosa.html Hope that helped.
  19. There's a couple of reasons why I don't like them. The first is they complicate an already complicated process. From initial request to final output, the code will travel and branch through several layers of abstraction before the final output is sent back to the browser. The second reason is they force you to learn a new syntax. You will soon find that template engines have special syntax for repeating portions of code, testing conditionals, setting temp variables, etc. By the time you get through with them you've set up a bunch of extra stuff that PHP already handles for you. I agree with you 100% that direct PHP can be very messy, but it doesn't have to. When I first started programming PHP I kept all of my HTML separate from my PHP. I essentially did the following: small_template.html <!-- a small example html template --> <p>{MSG}</p> small_script.php <?php $html = file_get_contents("small_template.html"); $msg = "Hello, World!"; $html = str_replace("{MSG}", $msg, $html); echo $html; ?> This worked fine for a while. It kept my HTML and PHP separate which made it handy if I needed to view my HTML in a web browser. However, I quickly learned that I rarely looked at the plain .html file in a web browser. Also, I was having to type str_replace() many, many times. And lastly I couldn't do any form of conditional testing or looping within the template itself. If I wanted to repeat a section of a template I'd have to create a new .html file, loop over it many times building a bigger string of HTML, and finally embed that in another HTML template. I designed / developed my first site like that which was fine; it was a site for a gaming guild and nothing professional. When I was hired where I currently work a year ago, I was supposed to take over an existing project. The project I inherited had many files that were extremely long, some well over 500 lines, that were procedural code with very few function calls that constantly jumped back and forth between PHP and HTML. It's programming like this that makes me agree when you say using straight PHP can be messy. Imagine trying to find the matching curly brace on an if statement when its 200 lines down the page and there are almost 100 <?php's in between. An impossible situation. Realizing I didn't want to keep using my original solution and I certainly didn't like the solution the developer before me used, I reached a middle ground. I came up with what I call components. Components, to me, represent a single unit of user interface; i.e. I only turn something into a component when it will be displayed on the screen. employee_table.php <?php /** * Example component that generates an employee table. */ /** * Expects vars: * array $People; Array of arrays, where each internal array has keys: * fname, lname, phone */ if(!isset($People) || !is_array($People) || !count($People)){ // Nothing to do here $txt = "There are no people to display."; echo CreateStandardText($txt, "left"); return; } ?> <table> <tr class="titles"> <td>Last</td><td>First</td><td>Phone</td> </tr> <?php foreach($People as $p){ ?> <tr> <td><?=$p["lname"]?></td> <td><?=$p["fname"]?></td> <td><?=$p["phone"]?></td> </tr> <?php } ?> </table> This component is very simple, it just generates a table. It may be called like so: <?php function showPeople(){ $People = PeopleDAO::GetPeopleFromDatabase(); include("employee_table.php"); } ?> This is overly simplified, but look at the component file again. You will notice that the top portion is entirely PHP and the bottom is mostly HTML with some PHP. This is how all of my components are designed. I do any processing before the HTML portion of the component and I limit myself to only echoing values, testing conditionals, and looping in the HTML portion. Now you might ask why I didn't just put the call to PeopleDAO::GetPeopleFromDatabase() inside the component. This is a matter of preference. Let's say that I had four more functions that also returned people from the database. By assigning $People outside of the component, I can pass the result of any of the functions to the component; therefore I can use the same component to display many sets of data (as long as the data has the same format). There's a little more that goes into it in the stuff I use day to day, but that gives you an idea.
  20. Assign an onload handler to the iframe that sets the designMode property to "on". Take note there are differences between IE and Mozilla as to which object is the owner of designMode. If you follow the link in my signature I have a couple of blog posts about creating RTEs with Javascript. I can't guarantee that it'll help you but it might.
  21. Are you calling session_start() at the top of the script the AJAX is pointing at?
  22. You can do this with Javascript and a regular expression. function validateMAC(){ var field = document.getElementById("mac_fld_id"); var regexp = /([0-9]{2}-){5}[0-9]{2}/; // Now check field.value against the regexp, which I can't remember how to do // off the top of my head. I think it's regexp.test(field.value) }
×
×
  • 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.