Jump to content

Nameless12

Members
  • Posts

    244
  • Joined

  • Last visited

    Never

Everything posted by Nameless12

  1. I would of posted this in the database section but there is no "general" database forum and my question regards pdo. Does anyone know if anyone has any open sourced classes that extend upon PDO. I like PDO and it is my db api of choice but It is lacking some features. I have extended pdo myself but I was wondering if anyone has solved this problem and open sourced the result as it would save me a bit of time.
  2. First bit: That's contradicting your other posts - you "could" abstract it? You are abstracting it. Infact you are forcing it to be abstract. Extensions are not optional. A class either extends another class, or it does not. There is no calculated decision. (This is of course refering to run-time, not you typing out the definitions.) I also fail to see why you have forced abstraction, because what else would this behaviour need? Everything is there! If you're books are suggesting to include multiple behaviours within a single object, I suggest you burn those books. That is bad OO practice, period. It's known as "Blob classes" or "God classes." Second part: That's the fundamentals of interface design. Objects that are observable should implement the same method for notification. Period. You will end up with a huge mess of "ok, which method is used for notification now?" 1. removal of abstract keyword is something i did 2. the books showed extended classes, extended classes are not god classes so wtf are you going on about 3. it wont be a big mess, documentation is a factor yes but that does not make it a mess.. it is very easy to remember that index() is default, if i have an index i can easily figure out what the states are. The idea of having it access methods based on the names will actually make my life a lot easier... 4. the Init() was there because you cannot add observers before you create an object and because i was extending the class at the time i realized I had to have a second constructor I have never had reason to implement the observer pattern in a real application before and i do realize adding it to $this->_state is a better solution at the time i was using gtk as inspiration #create a new window $w = new GtkWindow(); #connect it to a function $w->connect('destroy' array('gtk', 'main_quit'); #equivalent of init $w->show_all(); #loop gtk::main(); Interfaces are not required the way I plan on doing it I will remove the abstract keyword from this class, that is all, interfaces are not needed in this situation and if it was not for the fact php does not allow for extending multiple classes directly then the other implementation would be more valid. But like I said I over looked something I already knew for a stupid reason and partly because I have never had use to implement the observer pattern in a real app before the only real time i have used it a lot is in GTK and i did not write gtk! There are pros and cons to doing it both ways and I will want to be open to both ways and that is why I will remove the abstraction but If you want to connect objects from outside the object it is easier to do it my way and if you doubt me just ask your self why gtk does the same thing
  3. I think you miss understood a lot of what I was talking about. caching is just a way of saving stuff for later use, you can use it later to make different caching functions or methods to make your code faster. I am not even going to try to explain abstraction to you as you don't know OOP. Patterns are more important than you give them credit for, oop is also more important than you give it credit. But that aside you don't seem to realize that most good programmers will need no where near the same amount of time as a beginner needs to learn these things. You are not using all of the php language and i am not referring to the extensions but the actual language its self, how can you expect people not to treat you like a beginner when there are such obvious holes in your knowledge. It takes more than knowing all of the language (not extensions) to make someone an expert, and learning all of the php language will not make you an expert, but it is prerequisite to even considering calling your self more than a beginner. If you keep being in denial about the large holes in your knowledge you will never learn, you will be happy being ignorant and be a beginner forever. this is a bit rude for me to say this but its like I said earlier there are reasons people keep saying these things and it is the obvious holes in your knowledge.
  4. about your first point, my book shelf says otherwise. And if there is an instance where I cant or dont want to extend it, it will be very easy to make an exception where needed. All the books and documentation I have seen show an extended version. The classes I intend to use it on will be designed in a way they need the extra weight. because my adding the extra weight it allows me to just move code to the observers instead of the main class, I could use abstraction but there are a few things I am thinking about that would be quite better with the observable class. About the second point you are wrong because I don't want the default index method to be forced, I want it to be optional an interface would make this required. if I load an object with a method called something if I set the state to the name of the method to the name of the state the method will be executed, this behavior is dynamic and cannot be interfaced.
  5. I always thought it was meant to be abstract?? but that said I will continue to use it as abstract because I plan on using this class in multiple objects an it is just good to do for a code reuse and consistency point of view. yeah but the way I'm using method exists rules that out.
  6. if you are referring to what i said it was just an expression..
  7. how does everyone implement the observer pattern?? I am just curious if there are some possible approaches I may not be aware of, I want to refactor a lot of code so I can start to replace some of the abstraction with observers. I dont want this to be limited to the observer pattern, if you have another way that you manage the problem, im all ears. A code critique of my own implementation could also be good, here is my current observer implementation. an example <?php class Logger { public static $n; public function index() { ++self::$n; echo "<h1 style=\"margin:0\">this is constructor: called " . self::$n . " times</h1>\n"; } public function start($one) { echo "state:start<br />\n"; echo "arg_1:$one<br />\n"; echo "processing data<br /><br />\n"; } public function finish($one) { echo "state:finish<br />\n"; echo "arg_1:$one<br />\n"; echo "cleaning up data<br /><br />\n"; } } class Login extends Observable { public function init() { echo "<br />exec:<br />\n"; $this->start(); $this->finish(); } public function start() { $this->setState('start', 'this is the start'); } public function finish() { $this->setState('finish', 'this is the end'); } } $o = new Login(); $o->connect(new Logger()); $o->connect(new Logger()); $o->init(); ?> here is the output of the above code exec: this is constructor: called 1 times state:start arg_1:this is the start processing data this is constructor: called 2 times state:start arg_1:this is the start processing data this is constructor: called 3 times state:finish arg_1:this is the end cleaning up data this is constructor: called 4 times state:finish arg_1:this is the end cleaning up data here is the code for the Observable class <?php abstract class Observable { private $_state = ''; private $_observers = array(); public abstract function init(); public function connect($o) { $this->_observers[] = $o; } public function setState($state) { $default = 'index'; $args = func_get_args(); array_shift($args); $this->_state = $state; foreach ($this->_observers as $o) { if (method_exists($o, $default)) call_user_func_array(array($o, $default), $state); if (method_exists($o, $state)) call_user_func_array(array($o, $state), $args); } } } ?>
  8. I agree some people will just never learn math, for a whole bunch of reasons but everyone is capable. I think people think in a way that is OO and OO has inheritance! people that have a harder time learning something have a harder time because they have less to inherit from making them have to learn more than the person who inherited a few big classes. Everyone is capable the question is, is it worth the huge amount of effort and time to create the classes?? if they think it is they should just be a persistent little shit if they do that they will eventually get to the goal, but they wont get there unless they learn how to study\learn in a way that works for them I think this is one of businessman problems I used to find it harder to study on my own when i was much younger, now I find it second nature it is a skill that has to be learned and you don't learn it by posting topics in forums!
  9. the negative remarks are not because you are a beginner\noob but because you charge money are asking for donations and have released it as open source. People should write code as good or as bad as they want but if they are not going to do it properly they should not release it online in the multiple ways you have done. If someone does release it in the manner you have done they should at least make sure it has reached beta, your code is not even alpha. In fact your code has yet to be properly designed, so how can software thats not properly designed and implemented be released. The answer is it shouldnt be released. Dont ignore negative comments, there is a reason for negative comments and you should at least try to know the reason if you dont act upon it, you cannot do this if you ignore the negative comments. Denial is never a good thing, and I can assure you there are very good reasons for the negative things I have said. You just posted your last post why I was typing this message, ill give you a crique shortly.
  10. You are going about this all wrong, I have told you this before you need to learn more before you start releasing software and now you have moved on from "beta testing" to "open source". What you are doing is not a framework and it is not really a programmer assistant because it just creates more problems than it solves. what it lacks and what it needs?? 1. no method for automatic file loading, in my framework that i am refactoring at the moment I do not need to type an include line in a set file, i just dump the file in the right directory with the right file name and it is loaded automatically 2. poor naming conventions 3. no libraries of functions (yes you have more than one function, not enough to call a library) 4. no libraries of classes 5. ajax is javascript you don't need two directories for it 6. your configuration is overly complex and messy 7. most of your project is empty folders with a cut and paste index file 8. you force people to use session_start() on your own terms, not theirs <--- big mistake 9. poorly coded 10. you force people to use a database schema <-- frameworks don't do this you should not release empty directory structures with a poorly coded config\admin and if you do release it you should not release it as open source if anyone is using your code they must be a really bad programmer <-- im not being nasty, its just a fact no good programmer or half decent programmer would want to use that. You lack objects, you should be using a registry instead of a global variable and inside the registry object you should have error objects directory, objects database, objects time objects, uri manipulation objects, email objects, an encryption object, a pagination object, a header object for the <head></head> portion of your page. You should have a cache object, a controller, recursive directory iterators used for loading files.. There is much more your system lacks the above is just meant to be a small taste. You keep failing to realize that what you have released is a few scribbles placed in a dir structure that is a horrible directory structure and until you learn more you will never know what a good directory structure is yet you have chosen to commit your self to this horrible horrible code instead of learning what is needed to do stuff correctly. If you are not going to do it properly that is fine but you are talking about releasing to the public\open source PLUS its your job ffs. I read a topic the other day the one with your login script, not to be a real asshole to you but the code was sooo bad if you want a full critique and i doubt you do then just ask and ill pm you the critique. But it was ugly, unmaintainable it was not inside a class or function the code was poor and you used functions when not needed, there is more You talk about doing stuff in oop at various points in time, yet you never present any oop code... I have looked through your code quickly and I don't believe you properly know how to use functions let alone classes. To top it off most of your functions don't use return values this is a big mistake. Functions and classes should rarely "echo" anything unless it is very important Learn how and when to use functions before you learn oop and dont try to make a framework until you have both mastered oop but also the logic of many areas that are prerequisite to framework design. Seriously you talk about modules, interchangeable parts and this kind of thing is only possible with functions or classes, less so with functions but possible. THe reason I say this is input output. the functions and classes take input and return output if you know the input and output is the correct you can just plug things into one another, yes more complex site development is more complex then that but i think that should be enough to get you started. Do not create poorly coded "frameworks" that are not really "Frameworks" in the name of open source or for any cost to an employer otherwise you will look like an idiot to any programmer that reads your code. I have nothing against beginners but your changing money and have released it as open source and not only this but i have clearly given you pointers and said these same points in subtle ways to you previously yet you have ignored the points, that is fine ignore it all you want but after seeing your shitty login and your pp assistant getting its own web page\open source license i just felt like saying something. I think its about time someone was more direct with you about this as I am sure I am not the only one who thinks this. And to the admins who read this I know I should not be so direct, what can I say I have tried to be subtle and he has not got the "point". And to you business man, you constantly ask for advice yet you never take it.. what is with that.. EDIT the above is cut and paste from your webpage: Asking for donations, what a laugh... You call your self business man but I find most programmers I know or know of that are involved in "business" know very little. Your name originally grabbed my attention ages ago for a variety of reasons all to do with stupidity but then later to find you were ripping off clients it just confirmed everything. There is a lot wrong with the name, you can figure it out on your own but i will give you a big clue. business is the art of selling some bullshit to someone that knows less than you about what you are selling.... and you are right, you are a "businessman"
  11. ah it makes sense now I always use a controller so i have never really bothered with the other approach as I don't feel it centralizes my code enough for my liking. I don't get why people do it that way, is my bias warranted?? to me it makes no sense unless you are programming for speed.
  12. I dont quite get what you mean by load to var?? do you mean buffering the content? or adding the content of one template into a variable of the selected template? I dont quite get it. I have never really used Gzip compression with web design although I have heard about it, I might have to look into it a little. when you say a get method did you mean __get()? i find there is still use for __get even though i am extracting the values from the template data regardless I think its good for completeness. I dont quite get what you mean by the outer template because I just use my this class as a way of loading additional features The reason I chose to go for completeness is because I want to finally get a "final version" and want this template to come out of beta but one of the main reasons I have chosen to not really care about the performance loss in some areas is because unlike some other template engines i set mine up with the idea of only ever using one template object, i never really thought of using a singleton for a template engine before but it works quite well, no matter how many templates you use you have still created only one object, so i hope that makes up the difference in performance. I put a few basic examples in the readme file but here are some basic examples <?php #the false value turns off buffering template()->assign('name1', 'value1') ->assign('name2', 'value2') ->display('template.tpl', false); ?> <?php $t = template(); $t->assign('name1', 'value1'); $t->assign('name2', 'value2'); $t->display('template.tpl'); ?> <?php #sets the dir through the factory template('/some/dir/')->display('template.tpl'); ?> #loading the template and assigning data echo template()->assign('name1', 'value1'); ->assign('name2', 'value2'); ->display('template.tpl'); #inside the template.tpl <?php $this->debug()?> <?-- the tags are comments and $this->debug() displays all the assigned vars --?> <?-- displays name1 --?> <?=$this->name1?> <?-- also displays name1 --?> <?=$name1?>
  13. There are a few reasons why I think you are talking about session hijacking (if you arnt there are a few reasons why I think this would only be useful for session hijacking. But a better solution is to store the following session data $_SESSION['expire_time'] //gets updated each time you load a page and is compared against the time() $_SESSION['user_agent'] //holds the web browser info if someone has the same session on a different browser its probably a hack $_SESSION['user_ip'] //compare the ip to the $_SESSION['ip'] if it is set if any of the above information changes between requests just delete the session. regenerating the session ids each time they view a page also helps you said it was a big job to fix your site, try to bring stuff to a central point I loop through all $_COOKIE, $_REQUEST, $_GET, $_POST data and validate it, I convert the strings that are numeric to integers and clean the data. Try to bring all your code to central points so that you can maintain it easier. as well as letting you do more with less code. if you use prepared statements when doing database queries it will be impossible to do sql injection (I recommend using PDO) You do not need to ban all these things, just ban the user_id. you should be using constraints in your database combined with validation in your registration script to make sure each email address and username is unique. But yes banning ips as well as accounts is also a good move as not everyone you want to ban will have or be using an account. there has been some talk about not letting a user be logged in via multiple accounts there are various reasons why you should not do this, I have a laptop and a desktop pc i switch between them often if i did this i could get banned as i always tick the remember me button on sites and last but not least, record each page view and what user_id viewed the page along with their ip address if you do this you can create functions to easily allow you to see how often users view a specific page when they logged out, when they logged in, what areas a user likes, what areas they dont like and the data can be used for many reasons as well as helping identity problem users also when you do this you should record the request uri if someone is requesting pages that are not linked to multiple times in a way that is clearly offensive it will allow you to look at the logs or use some kind of automation to spot it and ban them
  14. I have been refactoring code and I thought I would release a little the code is pretty much exactly how I want it to be but it could use a little beta testing, I have smacked a bsd license on it and there is a more detailed read me in the file Charles_Template v0.98
  15. You are playing on technicalities in wording. My point was sessions are a primary key. Most 3rd party session handlers are designed for cookies and not $_GET and $_POST. Why I think $_POST would be a smart way to do it there is a reason why its not used. $_POST is not offered by phps session handler and $_GET is considered bad practice. Just because sessions happen to allow $_GET does not mean it should be used. Also sessions are not limited to php and I think you will find most of them are designed for cookies. The only exception is when people choose to allow another option. Sessions are nothing but a primary key, to say cookies that are used as primary keys are sessions is accurate. Why you may be anal about my wording or the fact you read it in a different context that is your problem. Learn how to make a session handler before you go around acting as if you know everything about them. I will not be replying to this topic anymore. If any of the admins feel like giving me a warning for being a little rude please ban me instead. goodbye
  16. I cant even be bothered responding to this. Please learn how to make a session handler\management before you continuing this topic. Bye. EDIT:: I said sessions can be implemented multiple ways, all sessions are is really a database and a primary key.... what you fail to realize is this topic is cookies V session, so when i said sessions are cookies it was in the context of the topic
  17. When I say sessions are cookies that is because it is just a technique that replies on cookies. There is one other way to do sessions but in the context of this convo no one is talking about sessions via $_GET. A user_id is a primary key to a list of users, a list of users is persistent data. If the cookie is a primary_key in any shape or form is it technically a session. Some will disagree because they are used to using session_start() but when you write a session handler on your own it is exactly how I am saying. The reason you constantly hear about session_start needing to be at the top of the page is becuase headers have to be at the top of the page and cookies are sent in the headers What I said is not overly simplified. when you run session_start() it sets a cookie and then creates a file with the cookie value as its name if the file\cookie does not exist already At the end of the page $_SESSION is serialized and placed inside the file. When the page is reloaded it does not need to create a new file so it unserializes the data and places it in the $_SESSION array. I am tired so i hope i wrote it all down properly. The point is the above process is using a cookie as a primary key whenever that happens it is a session... EDIT:: yes like i said in my last post there is the exception of using $_GET as a way of passing the session_id but seriously, who does that?? I already explained this was an exception prior to your last post.
  18. like i said, it is a cookie where the value of the cookie is a primary key to some data source. Any vulnerability that cookies have sessions have. You cannot do sessions without cookies unless you constantly put the session_id in the REQUEST_URI and that is not pretty. By default the php session handler is insecure and requires additional security to prevent things like session hijacking. But like I said a sessions are cookies. if ($_COOKIE['session_id'] == 'somekey') { $_SESSION['var1'] = 'val1'; $_SESSION['var2'] = 'val2'; $_SESSION['var3'] = 'val3'; } the above is probably the worlds simplest version of sessions, thats really all it is but all the real world implementations just happen to store the data inside a file or memory as opposed to inside the actually file. You could say that you are going to use a cookie as a user_id That would mean the user_id is a primary in a data source. Technically this is a session. sessions in the context of this conversation ARE cookies
  19. prototype and scriptaculous are great frameworks. Scriptaculous requires prototype, prototype is just a javascript framework. And yes it is prototype that provides the Ajax, scriptaculous just provides very cool effects. Prototype is worth using even if you dont use it for ajax.
  20. sessions are cookies A session is a cookie where the cookie value is a primary key to a data source
  21. In short mysqli is better than mysql_*, but I would not use either of these I would instead use PDO. If you dont know what pdo is, its one interface that can connect to a whole range of database not just mysql.
  22. I have seen some reseller plans online lately that I got interested in, they were about $30 a month.  Hosting is cheap if you find the right place if you host it your self with a large site it is obviously going to cost you more. I doubt you will find any hosting things for more than $35 a week. The reseller plan I looked at cost $30 a week. Just make sure you shop around, and if you host it your self you have to be ready to accept the cost.
  23. I know there is a proper way to make scripts work on multiple languages, have not read up on it though. If i were going to code it I would probably use error numbers are the numbers are not related to the specific language, then you can pass the number through an object and depending upon what language the user is using it will select a different string from the object. If you were just using errors for things like page not found you could do something like SetError(404); GetError(404); getErrors(); in this case, SetError adds the error messages into some type of registry, get error converts the number into a string and get Errors returns an array of whatever is in the registry. I dont like the idea of creating webpages in different languages it just seems so much trouble it is like making the webpage multiple times each time for the different language. another way you could do it is something like Templates/English/index.tpl Templates/OtherLanguage/index.tpl then use a config file to switch the selected language. There is no point in having the error messages and logging in a different language unless the WHOLE webpage will be in that same language. class Errors { public function __construct() {     $selected = 'english';     $selected .= '_errors';     $this->error_obj = new $selected  } public function E_404() {     return $this->error_obj->E_404();   } } Class English_Errors { public function E_404 {     return 'file not found'; } } class OtherLanguage {   public function E_404()   {       return 'otherErrorMessage';   } } I heard smarty has a way of handling multiple languages ages ago it might be worth a read, the above is just something i whipped up, there may be a better way but hopefully that should give you some ideas.
  24. [quote author=c4onastick link=topic=107138.msg517208#msg517208 date=1170178772] I can already see this turning into every other post I've read about the two. You're right, I haven't really programmed with Python too much. And the "better designed" argument? You still see old Chargers out on the street clobbering new Hondas. Even though the Honda's are better designed (by far) doesn't mean that the Charger is any less of a car. [/quote] you are the one making this seem like every other argument,  in every other argument the people that continue it are the ones that turn it into an argument all i did was state an opinion earlier and you continued it and treated it in this manner. Unlike all the other close minded people that makes flames on this subject I am just being objective. Dont talk about python the way you are till you learn more about it. Its people like you who make opinions before trying stuff out that start flames... I am just being objective. Why this might seem like I am starting a flame by saying these things and being direct I am just sick of the YOU CANT SAY THAT IT WILL START A FLAME, flames are not started by the people that start a topic but by the people who continue it.
  25. you look at this all wrong. Language design and Application design are separate issues. Python is a better designed language, and if you doubt this I just have to say that you have not used the language.. it is very very well designed. You can do everything you can do in most languages in other languages, but the fact is some are better than others the excuse they both produce the same output does not make them the same in terms of language quality. I never said perl or other languages have no use. They do, but we are talking about making a recommendation to someone wanting to learn a new language from scratch and its because of this I recommend the language with the best design. You say check out both of them but you have not checked out python, dont you feel like a hypocrite about that? I have checked out most of the languages out there including perl... Php is my current language of choice because 1. I am designing for the web 2. I am more fluent in it and I love Zend Studio. but this does not change the fact php is a very poorly designed language, it is useful and it has its place but it is poorly designed, yet I use it anyway... From a language design point of view Perl is better than php and python is better than perl..
×
×
  • 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.