Jump to content

5kyy8lu3

Members
  • Posts

    257
  • Joined

  • Last visited

Everything posted by 5kyy8lu3

  1. ok well I found another solution, but I'd still like some advice from a guru on the 'proper way' to go about this. so i basically realized the construct of the child class won't run unless i manually run it or create an object from that class. it won't run simply from extending the class. so... i made an extra method in the child class with the same contents of the construct, and manually ran that method from within my parent class's construct. there a better way to do this? thanks =)
  2. Hi. I have a mysql class that I use to access my database with. It's nothing crazy, just some simple methods with error handling. I wanted to play around with extending a class, so I made a new class and extended my mysql class. Bam, errors of "mysql parameter 1 needs to be mysqli" that sort of error, meaning i didn't have a connection. makes sense, since my connection is set up in the __construct. this leads me to believe that the child class construct only runs if i manually create an object of that class. is there any way to run the construct? would it be better for me to just create an object of that class within my parent class intead of extending it? just seems to defeat the purpose of being able to extend a class if the construct doesn't run to set up my connection lol. thanks =)
  3. you'll probably want to post that in [ php ] [ /php ] tags to get helped =) p.s. those tags only without the spaces
  4. looks like you have an extra comma after afbeelding that's causing the error.
  5. hmm I'm not exactly sure what you do with your site or how it works but it sounds like you need a way to tell your clients apart by using a login system or by giving them a customer code that they put in a url variable $_GET just a thought
  6. oh I know, but I want my code to be more modular, so anything that would benefit from being OO I would like to rewrite, but I'm just having a hard time wrapping my head around how I would take advantage of OOP.
  7. aight i'll take a look, thanks EDIT: not sure you'd even have an answer for this, but out of those you just listed, are there any that you think would be easier to read than others? it's hard to read and follow code that was written by someone else, especially when it's OOP i'm not sure familiar with, so if one is less complex than another, it would be invaluable info for me lol. thanks
  8. Hello! I'd consider myself fairly seasoned with procedural php. I would, however, like to start switching over to OOP. I don't even know where to begin! I know how to create a class, and how to instantiate an object from that class, and how to get and set variables with getter/setter methods, etc. I know the bare basics of OOP and the reasoning behind why it's better to code with it, but I guess I just don't understand it well enough to just start using it. I have a cms I wrote to manage my sites, and it works. It's procedural at the moment, and I would like to rewrite it using OOP. The thing is, I don't even know where to begin. I don't know what to make objects, and how to go about doing anything. What I really don't understand is how to get around the fact that when I leave the page, my objects die. If I use session variables, I completely go around the whole process of using a getter/setter, right? Which is against typical OOP standards? I just don't understand alot of this and it's hard to me to even write a single line of code when I have no idea how to go about it. Any insight on where I should start, what I should turn into objects, what kind of methods to write, and for what purposes, would be great. TLDR; In a nutshell, I know the very basics of OOP in php and want to rewrite my cms with OOP but I don't even know where to begin or what to turn into objects. HELP! Thanks if anyone is able to even help my helpless soul lol.
  9. it's not safe to remove ALL restrictions, so you should instead remove restrictions from the functions you're calling. for example, if you wanted to remove root prerequisite for fdisk, you'd type 'sudo visudo' in terminal and add this line: www-data ALL=(root) NOPASSWD: /sbin/fdisk then you can do a shell_exec("sudo fdisk"); and get results. now i haven't tested it but i add the entire command, including arguments in the sudoers (the file you edit when you do a sudo visudo) might unlock just the command with that specific set of arguments, but i'm not sure of this, i didn't feel like testing it. make sure you only edit sudoers with sudo visudo from terminal, if you do a gksudo gedit sudoers, and you edit it incorrectly and save it, you're going to be in ALOT of trouble lol good luck
  10. I don't use <h#> tags often so I don't know for sure but try removing those tags, I think they're used for headings so they get their own line, and line break for the proceeding content.
  11. I'm not sure what exactly you're asking, but if I were to have coded that, this is how I prefer to do it. Then again your code didn't make much sense to me so anyways. include("vars.inc.php"); while ( $row = mysql_fetch_array($result) ) { echo ' <div class="blah"> <span>blah blah</span> </div>'; }
  12. well I found the problem. I'm an idiot and I used localhost for my domain for apache so zen-cart was using localhost as teh domain when it generated links, which obviously won't work for anyone else. it's amazing how much trouble such a simple little thing can cause lol thanks for the reply though, much appreciated
  13. Hi. I'm fairly new to Linux. I'm working on a project with my buddy but his server died so we're gonna host it on my ubuntu box while we work on it. We're going to use Zen Cart. It installed just fine. It even loads. The only problem is that the stylesheets won't load. On my ubuntu box, the one with LAMP and Zen Cart installed, the stylesheets load, but on any other computer on my network (or outside) the stylesheets won't load. Any ideas? I've tried TONS of google searching and have had no luck. I've tried renaming .htaccess to .htaccess_OFF and no luck. Even saw some sites mentioning editing httpd.conf to add "Limit" to AllowOverride or some crap but I have no idea what that means. I found that file and opened it to find it blank. This is obviously a permissions problem since it loads fine on this machine (ubuntu box) but no on any other one. I really hate how root acct works. I guess that's why it's secure though. Any help would be much appreciated, and keep in mind, I'm very new to linux. Thanks ahead of time!
  14. I'm thinking an IF statement at the top of each page that you DON'T want to be using the ssl certificate would work. i can't remember which server variable gives you the parent document but just check that for http or https. if it's https, use header to redirect them to the same page only without the 's'. i do the same kinda deal to force "www" for session variable consistency.
  15. heya. looks like you already got some great advice, but I'll share how I do it just for funsies. I basically check one thing at a time. If there's a field that doesn't validate, I set the session variable to a custom message for that field. Example, if the name field is empty, I set: $_SESSION['FormValidation'] = 'Error. The name field is required.'; Then I send them back to the form page. Then on the form page, I have an if statement that checks to see if that session variable is empty or not. If it's not emtpy, I echo it out. I also wrap my form boxes with a span or div with a couple pixels of padding, and change the class that sets the background color to be the color red if that session variable contains the message tied to that field. That way, the field the error was in is highlighted with red so they can find it quicker. After checking it I always unset that session variable so if they reload the page it'll clear the errors. Also, since I save ALL my fields to session variable, when they get sent back, I autofill the information they had when they submitted so they don't have to type it all again. That's as easy as checking to see if each session variable is emtpy or not, if it's not, then you set value="' . $_SESSION['Name'] . '" etc etc Lots of ways of doing it, that's just my method. Good luck!
  16. like the last page of your pagination? or last page you were viewing?
  17. no problem man, glad I was somewhat helpful lol as far as spoofing it, you could use this as the key: md5($_SERVER['REMOTE_ADDR']); that way it's a hash of their ip address, which would be hard to know just from seeing the hash. just an idea to throw out there, it's what I use, it's dynamic yet it works.
  18. at the top of index.php: <?php session_start(); $_SESSION['FromIndex'] = 'yes'; ?> then at the top of 1.php: <?php session_start(); if ( $_SESSION['FromIndex'] != 'yes' ) { header("Location: 404.php"); } unset($_SESSION['FromIndex']); ?> sorry i replied so late, I had to go run a quick errand. that code should work. it's not the most elegant solution, but if it works...
  19. you could set a session variable in index.php and check to see that it's set in 1.php (then immediately unset it) else you redirect to 404
  20. yea sorry I assume jquery was INCLUDING 1.php, but if it's just linking to it then what I originally suggested won't work. you can try if ( $_SERVER['HTTP_REFERER'] != '/index.php' ) { header("Location: 404.php"); } but this is just a wild guess lol edit: (basically, the original script i said you should try would only work if index.php included 1.php, but instead, you're linking to it, so that original script won't work... but checking referer might work, it's worth a shot lol)
  21. As I said several replies ago it simply makes a http request, just as someone would if they browsed to the file. There isn't really anything you can do. you couldn't use $_SERVER['HTTP_REFERER'] then and check to see that it came from index.php? EDIT: i guess if it's just a plain http request even that won't work huh, that sucks
  22. Correct. Tried this: die($_SERVER['PHP_SELF']); and it echos this: /php/1.php so i made the edit: <?php if ( $_SERVER['PHP_SELF'] != '/php/1.php' ) { header("Location: 404.php"); } ?> and put that at the top of 1.php. I don't know JS very well, so does jquery INCLUDE 1.php or does it link to it? like if you're viewing 1.php, does your address bar show index.php or does it show 1.php? if it "includes" or "loads" 1.php but index.php remains in the address bar, then you need to change the script to '/php/index.php'. that way, only index.php can load 1.php.
  23. As I typed the statement I immediately wanted to eliminate ajax as the problem. I then made the exact link somewhere else on the page without any JS interaction and same result. Is there no way around this? I gave you a solution... Here... read how I use the script, and you might see it's the same scenario as you: index.php on my website is the backbone... it loads all my content pages with includes depending on a value i set in my session variable. so... if I click a link for "home", it reloads index.php and then index.php include()'s home.php. the problem is, I have index.php load a header for each page, so I don't want people directly accessing my php files, home.php for example. so... i put that script at the top of home.php and then if someone try's to directly access it, the script sees that index.php isn't he parent document so it redirects them to 404. if index.php accesses it on the other hand, the script sees that the parent document IS index.php so it doesn't redirect and everything works just fine. I'm pretty sure this would work for your situation. Heck, tell me the name of the html file and I'll even write the exact script you can copy/paste into the top of 1.php. The actual names of the files are: index.php /php/1.php which contains (require("/journal/round-one.php") ../../journal/Round_one.php I've tried all of the following: <?php if ($_SERVER['PHP_SELF'] != '1.php') { header("Location: 404.php"); } require("/journal/round-one.php") ?> <?php if ($_SERVER['PHP_SELF'] != 'php/1.php') { header("Location: 404.php"); } require("/journal/round-one.php") ?> <?php if ($_SERVER['PHP_SELF'] != 'index.php') { header("Location: 404.php"); } require("/journal/round-one.php") ?> Nothing on all three. Access to the file is prevented on the index.php but when called via hyperlink its a no go. Access denied. so let me get this straight... index.php uses jquery to open 1.php then 1.php uses include() or require() to open Round_one.php is this right? if so... your code should be: <?php if ( $_SERVER['PHP_SELF'] != '/index.php' ) { header("Location: 404.php"); } ?> BUT.... I'm pretty sure you have to include subdirectories... so if these files are running at: www.yoursite.com/Directory1/Directory2/index.php then you'd want to change the script to: <?php if ( $_SERVER['PHP_SELF'] != '/Directory1/Directory2/index.php' ) { header("Location: 404.php"); } ?> if you need to, just put a die($_SERVER['PHP_SELF']); at the top of 1.php then access 1.php via your jquery and see what it echo's out. whatever it echo's out is what you want to put into the script as the php_self you're checkin against. so basically, if the parent document isn't index.php, you redirect to 404, else it requires round_one.php
×
×
  • 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.