Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Destramic

  1. good point...ok i did just that use MVC\View\View as View; $view = new View; $view->head->script(array( 'src' => 'test4' ))->append(array( 'scr' => 'hi4' )); $view->head->script->append(array( 'src' => 'test3' ))->append(array( 'scr' => 'hi3' )); echo $view->head->script; use MVC\View\Helper as Helper; $helper = new Helper; $helper->head->script(array( 'src' => 'test4' ))->append(array( 'scr' => 'hi4' )); $helper->head->script->append(array( 'src' => 'test3' ))->append(array( 'scr' =&
  2. hey guys i'm currently writing a head helper and probably down to my bad design i'm unable to return array stored in my placeholder here is my head helper: <?php namespace View\Helper; use Exception\Exception as Exception; class Head { private $_tags = array( 'script' => 'Helper\Head\Script', 'link' => 'Helper\Head\Link' ); public function __get($key) { if (isset($this->_tags[$key])) { if (is_object($this->_tags[$key])) { return $this->_tags[$key]; }
  3. it's hard to build a good framework in my opinion...i'm currently re-designing mine which i made 3 years ago....but with mine you have the view, modlel, controller but also the module which i get quite confused at and have yet to understand fully what's used for...that aside as you questions are not too specific and i'd suggest to download a framework such as zend (like i did) and spending time reading the manuel and stripping apart the code to understand the logic and the design of a framework first of all i have a router class which matches routes to a specific uri, then the controller,
  4. well i've learned something here had a read and this seems to do the trick on duplicate posts, unless i missed something <?php session_start(); if (isset($_SESSION['form'])) { print_r($_SESSION); print_r($_POST); // use data unset($_SESSION['form']); } else if (isset($_POST['submit'])) { $_SESSION['form'] = $_POST; header("Location: " . $_SERVER['REQUEST_URI']); exit; } else { ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Demo</titl
  5. your not going to achieve $conf->test when selecting multiple rows. i'd stick with $config['test'] mate
  6. doh!...sorry i read something wrong, you are correct....i just got the manuel up a function like this would be great...a loop with preg_match is is then...i'm not sure it's going to save time caching it this way though...time will tell
  7. if i'm correct the PREG_GREP_INVERT allows it to work this way also
  8. i tried that but even then it returns the same array i did just realised that /register/(?P<activation_code>[^\s]+) didnt have a ) at the end still the same problem though $uri = '#^/register/aqwrgj73ffgsegr2h$#'; $routes = array( '/register', '/register/(?P<activation_code>[^\s]+)' ); $match = preg_grep($uri, $routes, PREG_GREP_INVERT); print_r($match);
  9. hey guys i'm currently trying to create a cache system for my router, which i think i'm always there but i'm having a slight problem with preg_grep() here is how it goes...the routes are added Router::add_route('/register', array()); Router::add_route('/register/:activation_code', array()); (this is an example - i wouldnt really need to add two routes for /register page) the routes get added to my router class and then get passed to the route pattern class where the patterns will get phased. <?php namespace Router; use Exception\Exception as Exception; class Route_Pattern {
  10. i only gone and nailed it #/([ahis])?(\w+))?(?\(([\w-+]+(?:\|[\w-]+)+)*\))|(\*)|(?<=:\w))(?![^\[\]]*\])# thanks you for pointing me into the right direction requinix
  11. that is what i need...i come up with: #(?<=/)([ahis])?(?:(\w+))?\(([\w-]+(?:\|[\w-]+))*\)|((\w+))?\*)|\w+))(?![^\[\]]*\])# which is a bit spicy...i don't like how i've had to add (\w+)) to every options, also a:var(a) will come with a match althoght it shouldn't i think i'm gonna stop over complicating the pattern and just do each pattern individually thank you for your help again on this matter
  12. sorry i meaning zero or one time ---> ? this returns my match perfectly $pattern = '#(?<=/)(([ahis]?)\w+))?(\(([\w-]+(?:\|[\w-]+)*)\))?(\*)?(?![^\[\]]*\])#'; if (preg_match_all($pattern, '/news/:action(add|delete|edit)/:type', $matches)) { print_r($matches); } but becuase of the ? zero or one, this subject (/test[/hello[/bye]]) will return matches because of the / $pattern = '#(?<=/)(([ahis]?)\w+))?(\(([\w-]+(?:\|[\w-]+)*)\))?(\*)?(?![^\[\]]*\])#'; if (preg_match_all($pattern, '/test[/hello[/bye]]', $matches)) { print_r($matches); } what i'm asking is there a
  13. is the directory you trying to move the file to writable? or does the dir exist?...do you have any errors?
  14. in my regex pattern i have a lot of none or many operators (?) , which has caused a bit of a problem, as a string containing a forward slash will come back with a result. (?<=/)(([ahis]?)\w+))?(\(([\w-]+(?:\|[\w-]+)*)\))?(\*)?(?![^\[\]]*\]) is it possible to match with a string containing at lease on for the one or many groups? and not just a forward slash? $pattern = '#(?<=/)(([ahis]?)\w+))?(\(([\w-]+(?:\|[\w-]+)*)\))?(\*)?(?![^\[\]]*\])#'; if (preg_match_all($pattern, '/news/:action(add|delete|edit)/:type', $matches)) { print_r($matches); // wanted match } if (preg_m
  15. sounds like you havent got jquery included https://developers.google.com/speed/libraries/ latest: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
  16. thanks guys for you replies...just what i'm after! @phscho yours returned an error strange really as my workbench is up to date also i had to turn off safe updates on my mysql workbench...not sure if that is a mysql workbench thing or i would still have gotten the same error if i hadn't of turned off and executed from my php script? thanks again much appreciated
  17. hey guys i'm trying to delete all rows but the latest 6 but i'm having some trouble with the query if you could please help. i've done some reading and have been llooking at simular queries to what i'm after, but i'm not succeeding. here is what i have so far: DELETE FROM benchmarks WHERE ( SELECT count(benchmark_id) FROM benchmarks WHERE name = 'Framework' ORDER BY timestamp ASC ) < 6 the error i get is: any help on where i'm going wrong would be great. thank you guys
  18. wel i feel a lot wiser now...thank you for the breakdown and all your help requinix
  19. for 4:30am you've come up with some good solutions i do like the first option and it does get rid of the bother caused by the brackets and you've openned my mind up to another soltion, thank you...options 2 is what i'm currently doing at the moment. although my regex knowledge is poor could you please explain to me how i can make this pattern match multiple please? $uri = "/i:news_id/:hello"; if (preg_match_all('/^\/(i|a|h)?[A-Za-z0-9_]+)$/', $uri, $parameters)) { print_r($parameters); } thank you for your great information
  20. well my routing system may contain something like this: /search/xbox[/category/:category] matching: /search/xbox /search/xbox/category/consoles so i decided to make my pattern a bit stonger so it match uri vars which are not inside brackets...so yeah my pattern has changed slightly...with the regex in this posts and the others i'm working on i get the problem of matching multiple patterns in the same string...this is my only problem. can you please tell me where i'm going wrong...thank you
  21. i'm sorry for having to post a simular thread but i'm really struggling to get my pattern to work after many attempts...i've tried playing around with it but its just not matching multiple patterns this will work great $uri = "/i:news_id"; if (preg_match_all('/(??!\[\/).)*^\/(i|a|h)?[A-Za-z0-9_]+)$(??!\]))/', $uri, $parameters)) { print_r($parameters); } but when chaging this part of the code it won't work $uri = "/i:news_id/:hello"; examples of matching are: /:test /i:test /a:test /b:test but i only want a match as long as the pattern isn't wrapped inside brak
  22. brilliant thank you very much requinix. i used this pattern which seems to work fine /(i|s)+:+([A-Za-z0-9_-]\w*)/
  23. hey guys, i'm trying to get back in to the swing of things after a lot of time out from programming, and i'm struggling with this simple regex pattern if i could get some help please. i've decided to go over some of my code and try and re-write things better....starting with my framework. here is my pattern: /^\/?(i|s)?:+([A-Za-z0-9_-])$/ what im trying to do is match: news/i:news_id - returning strings i (if there) and news_id as the string is uri it could contain a forward slash at the beginning. if (preg_match_all('/\/?(i|s)?:+([A-Za-z0-9_-])/', 'my-page/i:foo/:bar
  24. well i have no real exprience what so ever when it comes to api's...but if someone is paying for a key then it makes sense to register the key to a site...ie: phpfreaks.com = phpfreakskey this way you can ensure the key is correct and also that the request for your api is phpfreaks.com, ensuring another site isn't using the key. you'd simply have to create a page www.yoursite.com/api.php?key=phpfreakskey and then validate the key and where the request is sent from....if all checks out then the data can be sent process seems simple to me but i may be overlooking things..
  25. ok firstly you would need to set a cookie for the page your talking about....here is a example setcookie ('time_visited', time(), 3600, '/' , 'domain.com', true, false); when revisiting this page again you can do something like this: if (isset($_COOKIE['time_visited'])) { $time_visited = $_COOKIE['time_visited']; $last_visited = date('m/d/Y H:i:s', $time_visited); echo "Hi User, you last visited: " . $last_visted; } you may want to look at the manuel here regarding cookies: http://php.net/manual/en/function.setcookie.php i hope this is what you are looking for
  • 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.