deadonarrival
-
Posts
284 -
Joined
-
Last visited
Never
Posts posted by deadonarrival
-
-
Am I alone in thinking that the PHP Help section/category could do with being further broken down, rather then the "oop/maths/anything else" sections we have now?
I can only come on for a fairly short time every day, and I just find there's too many new topics each day in each section to keep track of, and I don't have time to go through finding the ones I help with.
I just think that if it was split up it would be easier to find the area you specialise in and help with that, rather than having to sift through and find the ones you can help with. a lot of topics dissappear with few or no answers at the moment, and I suspect this could in part be the problem - forum users have a natural tendancy to look at the top 10-20 topics and no further, or just simply dont have time to get further down.
Any agreements/disagreements/comments?
-
Additionally:
I've got the following working regexp
^([a-zA-Z0-9_-]+(/[a-zA-Z0-9]+(.[a-zA-Z0-9]*?)*/?)?$
0 or 1 of the following
(a string) / (a string).(optional string) optional /
But now it crashes (server error)
-
Right, my root is
www.site.com/path/to/application/
But it could also be
www.site.com/
or
www.site.com/path/n/n+1/... .../end/of/the/world/
Basically - it could be the root on the site, or could be 5000 levels in.
The url itself (assuming we're in the root www.site.com) I want to be
www.site.com/modulename/key/val/key/val/
so we might end up with
www.site.com/blog/id/4/reply/5/add/
but I was aiming for
www.site.com/blog/id.4/reply.5/add/
I'm trying to get /blog/ as a variable, and any key.value pair as $key = value (or $arg['key'] = value).
As a last twist, I'm trying to make any thing with no period into a $key = true or $arg['key'] = true;
I've played with my regexp and got this:
^(.+)/(((.*)\.(.*))*)$
Which should allow
/(any string of 1 or more chars)/(any string).(any string)/
Where the (any string).(any string) can be 0 or more repetitions.
I think my regexp will work, but I'm not sure how to implement it, or if there's a better way to do it.
(Admins - this might be better moved into regexp, the topic's changed a little)
-
Thanks for the reply. I've gotten home now, so I'm able to actually try some of this instead of just thinking about it, and I've hit on a problem so to speak.
I've got this .htaccess
<IfModule mod_rewrite.c> RewriteEngine on # RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?r=$1 [L,QSA] </IfModule>
Obviously the r variable contains almost everything.
I want to try to extract the code, but keep key=>value pairs seperate, so I've managed to get this code.
$path = explode("/",$_GET['r']); foreach($path as $key=>$val) { $split = explode(".",$val); $arg[$split['0']] = $split['1']; }
Which outputs
$path = Array (
[0] => modulename
[1] => 1.val1
[2] => two.v2
[3] => (blank)
)
$arg = Array (
[modulename] =>
[1] => val1
[two] => v2
[] =>
)
Two obvious problems here are that I can't just extract the module from the arg array, and that the 4th value (id 3) is superflous.
I can see that the second problem arises from my first explode (it goes if I take out the trailing slash). But is there any way to sort the first problem? I thought of just using $module = path[0] and then doing the rest as arguments, but that leaves my code a little messy.
-
Store a "last edited" timestamp along with the list. (Make it when the thread is created, then update whenever there's a post/edit
Then when you show the threads, simply do
print $name; if($last_edited > ($now - 60200)) { print "image tag"; }
(Make $now = time(); somewhere above, I tend to define it on page load)
-
He means that if you throw a PROBLEM at a forum, people aren't likely to help - we have our own work to do, without doing everything for someone else, especially if the problem isn't very well explained.
What is your database layout? What have you tried? In what context are you trying to re-order.
If you want to display 3 before 2, you're looking at re-ordering an array. If you know which you want to move to where, it's fairly simple. There are several techniques (moving then re-ordering etc)
On the other hand you could just have a seperate table "homepage items", and just put in the ID's of the news items you want?
That would give a shorter array, all useful. You can just swap items into and out of the array, have as many or as few as you want and more easily order them to any order you want.
-
I'm finding MOD_REWRITE to be a bit of a pain, so I'll just fire out a couple of questions
1) Is it possible to/how can I detect if MOD_REWRITE is enabled or not via PHP.
2) Is it possible to make PHP set .htaccess values (namely RewriteBase)
3) realpath(); and mod_rewrite - will the extra "folders" confuse the realpath function?
Not quite related but
4) Is there any way to find the directory one above the document root - I want to save my sqllite database one level above, without knowing how many levels down the app is.
-
$world = world::getInstance();
$myWorld = new World;
$world->activateDoomsdayMachine("fire","true",1,50000);
unset($world);
-
Just to agree with roopert - you could get the same seperation with "normal" procedural PHP
Just stick the functions in one file, and make it one person's responsibility, and you're done.
-
CSS = sexy.
I've never made a form class, but I'd strongly suggest making it output only the elements, with no formatting, and let the style sheet control the rest.
Go beyond seperating data and logic from design, by seperating style from structure.
Sort of a
MC-SS system (Model, Controller, Style, Structure)
[Yes, I just overcomplicated an already complicated paradigm, oops!]
-
Step 1) Decide what information you want users to be able to search by.
-
Yes it is possible -- but a really bad idea in my opinion. From a security issue most people don't want to allow the writing and deleting of files from webspace, as this is a good way to get exploited. Some systems require this in order to allow full functionality (Joomla/Mambo for example) but they are CMS systems with modules.
You might also consider using sqllite which is a really lightweight embedded db that comes with PHP, and would require no installation by the end users.
It's imperative that the user be able to install the script with no required admin input. I'm assumiing that they have a fully set up web server, but (unless there is a problem) I want a non-technical user to be able to install the script 9 times out of 10.
SQLlite might be an option - is there any performance loss once you get into bigger databases or other problems to watch for? I want the application very scaleable. And this will also be a modulated CMS/framework to an extent.
On the other hand, SQLlite might be a option for storing settings and the installation process. Thanks for the suggestion
-
That's not a bad idea.
Again I'd assume not foolproof - but I like it more than writing a value to that file and checking it.
Is it possible to delete a file from PHP? More importantly, is it possible for a script to delete itself?
That way, I could attempt to delete the install script - and if that doesnt work write the file. If I can't delete my install file, neither can anyone else delete my created file.
The more I think about it, the more I like it. Thanks guys
Any other thoughts welcome
-
I'm looking at ways to allow my script to be used, with a minimum of fuss, on any server.
I'm going to use an install script, but I don't want to require the user to touch any server settings or delete the file after use due to the security risk)
Can anyone suggest any methods of allowing a script to be run once, and only once. Once the user hits submit, it's done.
Caveats:
I can't use mysql for checking - I want the setup procedure completely database independant.
Any suggestions?
-
Glad to be a little help. I had big problems understanding it too. It's just a case of reading everything about it until someone finally explains it in a way that clicks. Get a book from a shop, rather than a website - it's easier to find a style you like that way
Read websites, books, anything you can get hold of.
-
If you have a way of knowing which video you're on, use that.
If you know you're on video 50, pass that as a variable, not the page, then work out what page you're on.
-
It's more a case of "what's it worth"
If you're on a project where you need one form, it's not worth the overhead. If you're going to need to creat forms on-the-fly, it might be worth your time to create/modify one. Make it nice and re-usable and keep it for future projects
-
Static classes are usually to be avoided. It's usually better to make a singleton class (a class with only one instantiation) or use a registry if you find you're using too many singletons.
so in each "car" you use $cars = cars::getinstance(); to get the instance of car. That way you don't have to worry about passing it to every method you need, or the constructor.
It's debated - but I'd prefer to use the constructor of car to get the instance of "cars", rather than passing it as an argument to allow you to only change it in the constructor, rather than whenever you instantiate a "car" object.
-
Any thoughts/tips/suggestions on how to integrate third party templating/code editing engines with a custom made framework?
Any thoughts, any sneaky suggestions?
Eg how to include smarty/flexy with a vaguely MVC controller. I've not even attempted it yet, and would really appreciate any thoughts from anyone experienced in this sort of thing.
Much appreciated
-
The microsoft like is dead (wouldn't you believe it)
-
The best way to think of it is a way of ORGANISING your code.
OOP code doesn't produce a different output to procedural code, and it's not necessarily faster (in fact, it can be slower)
Its main advantage is the ability to encapsulate. The ability to make everything about one thing, in one place.
Everything to do with database access can be done through a database object, everything purporting to sessions through a session object, everything to do with the layout through a view controller.
The idea is that one script calls up the methods of various objects, rather than trying to do everything itself.
If done properly, it makes your code tidier and easier to use, modify and add to. It's also usually considered more useful for making frameworks or API's, you can more easily set up a user interface to allow other people to build on your code without having a deep understanding of it. They don't need to know your database structure (or even whether you use mysql, postgre or any other database system), or how you generate passwords, just that $db->getRow(table,field,where); gets the field they want, and that $auth->passwordEncrypt(plaintext,salt); produces a password they want. They don't need to know how you encrypt the password, just that it returns a nice hash for them to use.
-
As a company they're fine... as a website to use on a daily basis it's appalling. The tools are no good whatsoever, IMO.
-
I've just been looking at the glubble extension for firefox... it looks quite good (http://www.glubble.com/)
Secures FF anyway, but I think your kid is a bit more inquisitive, and its not much good for securing XP as a whole
-
Docblocks for every class/function
Basically package/version/copyright for everything, a brief description, and on functions the arguments and returns.
Also I put a lot of //comments in my code, as a description to whoever's reading it.
The docblocks help advanced users and for documenting, and are useful when in your IDE if it shows the docblock on function calls (can see what arguments I need a lot easier)... the inline comments are for anyone wanting to learn from/understand/change my code, rather than just use it. They describe anything non-straightforward.
Eg I don't do
//print name
print $username;
but anything more complex, or a quick description of what's going on, gets put in.
Finally
/** **/ docblocks for those using the interface of the function/class
// and /* */ inline comments of what's going on
# for "working" comments. These are the comments for me when I leave/come back to a function, just to tell me what needs to be done. A "todo" so to speak. Eg when I close the package I leave one where I'm up to, with what I'm doing. And if I want to change/optimise anything it gets one. These are always gone by the beta, since I'll have dealt with them before then.
[SOLVED] "Break it down" now, y'all
in PHPFreaks.com Website Feedback
Posted
My bad, I did have a look but I must've missed that one