Jump to content

Destramic

Members
  • Posts

    969
  • Joined

  • Last visited

Everything posted by Destramic

  1. no the string just contains letters only...but yeah your right to use other functions other than regex when possible...thank you for your help...was just what i needed
  2. when trying to call get_class($this) it will return the namespace of my class Application\Models\User_Model But what im really after is just User_Model... is there a way of actually getting the class name and not the namespace itself? thought i'd ask before making a class for that...thank you
  3. hey im tring to match words which contain double s at the end...ie. address, business, class etc...so that is so i can put a ' at the end... class' if (preg_match("/ss$/", $name)) { $name = $name . "'"; } any help with the regular expression would be great thank you
  4. hey guys im in a bit trouble trying to use window offset() function. basically i have a fixed header and what im trying to accomplish is for when the user scroll past a certain point the header content will change...im not sure if im going about this the right way or even sure if it is possible with a fixed header. any help would be grateful thank you <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <style type="text/css"> body{ margin:0px; background:#FFFFFF; } .header-cont { width:100%; position:fixed; top:0px; } .header { height:50px; background:#F0F0F0; border:1px solid #CCC; width:960px; margin:0px auto; } .content { width:960px; background: #F0F0F0; border: 1px solid #CCC; height: 2000px; margin: 70px auto; } </style> <script> $(window).scroll(function(){ var position = $('#position').offset().top; if ($(window).scrollTop() > position) { alert('hey'); // Change header content } }); </script> </head> <body> <div class="header-cont"> <div>FIXED HEADER</div> </div> <br /> <div id='position'></div> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> CONTENT HERE! </body> </html>
  5. hey guys im having a problem aligning a div so its vertically aligned middle...the objects im having the difficulty with is "search-bar" and "quick-links" which are apart of the "search_bar_container"...i;ve been fiddling about with it but have had no luck...css isn't really my thing so any pointer will be greatly appreciated thank you <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#list-icon").click(function() { if ($('#top-bar-media-menu').is(":visible")) { $('#top-bar-media-menu').hide("fast"); } else { $('#top-bar-media-menu').show("fast"); $('#top-bar-media-menu').focus(); } }); }); </script> <style> body { margin: 0px; } div#top-bar-media-menu { display: none; } div#header #left-link { display: inline-block; vertical-align: middle; padding: 5px; } div#header #right-link { float: right; line-height: 45px; padding-right: 10px; } div#header #list-icon { background-image: url('list.png'); vertical-align: middle; display: inline-block; height: 48px; width: 48px; } div#header #home-icon { background-image: url('home.png'); background-color: #505050; vertical-align: middle; display: inline-block; height: 48px; width: 48px; } div#header #arrow-down { background-image: url('arrow_down.png'); vertical-align: middle; display: inline-block; height: 16px; width: 16px; } div#header #top-bar-container { background-color: #000000; width: 100%; border-radius: 3px; position:relative } div#header #top-bar-desktop { background: -moz-linear-gradient(top, #505050, #343434); border: 1px solid #080808; width: 85%; height: 48px; margin-left: auto; margin-right: auto; border-top-right-radius: 3px; border-bottom-right-radius: 3px; font-family: Verdana,Arial,sans-serif; font-size: 12px; color: #FFFFFF; vertical-align: middle; } div#header #top-bar-media { display: none; } div#search_bar_container { width: 85%; height:80px; margin-left: auto; margin-right: auto; position:relative; } div#search_bar_container #logo { display: inline-block; background-image: url('logo.png'); height: 80px; width: 220px; } div#search_bar_container #search-bar { line-height: 45px; display: inline-block; position:absolute; width: 50%; height: 40px; } input#search { position: relative; width: 40%; border: 1px solid #080808; height: 30px; border-radius: 20px; font-family: Verdana,Arial,sans-serif; font-size: 14px; color: #000000; vertical-align: middle; } div#search_bar_container #quick-links { display: inline-block; vertical-align: middle; } @media all and (max-width:500px) { div#header #top-bar-desktop { display: none; } div#header #top-bar-media { display: block; background: -moz-linear-gradient(top, #505050, #343434); border: 1px solid #080808; width: 85%; height: 45px; margin-left: auto; margin-right: auto; border-top-right-radius: 3px; border-bottom-right-radius: 3px; font-family: Verdana,Arial,sans-serif; font-size: 11px; color: #FFFFFF; } } </style> </head> <body> <div id='header'> <div id='top-bar-container'> <div id='top-bar-media'> <div id="list-icon"></div> </div> <div id='top-bar-desktop'> <div id='home-icon'></div> <span id='left-link'>Register / Login</span> <span id='left-link'>News</span> <span id='left-link'>My Account</span> <div id='arrow-down'></div> <span id='right-link'>Language</span> </div> </div> <div id='search_bar_container'> <div id='logo'></div> <div id='search-bar'><input id='search' type='text'/></div> <div id='quick-links'>quick links here<div> </div> </div> <div id='top-bar-media-menu'>menu here</div> </body> </html>
  6. hey guys im wdondering if there's a magic method which works like __GET() but allows you to put a parameter in...thank you <?php class test { public function run() { $this->object->('string'); // __get with parameter? } public function __get($value) { return $this->{$value} } } ?>
  7. using the code above will remove all sessions and data set...im only want to unset a particualr session not all...i tried using session_unset which worked great...although the function unappreciated
  8. Well I use a name space which will make my sessions look like $_SESSION['authentication']['id']; Would I put that instead of session_name()? Thank you
  9. hey guys im having a spot of botter unsetting, destroying a session which has been given a cookie lifetime...i know it is possible to destroy all sessions using session_destroy() but i want to destory a particials session and not all of them. here is my method if anyone can give some advice on how i could do this please...thank you public function destroy($name = null) { $namespace = $this->_namespace; $sessions = $_SESSION[$namespace]; if ($name == null) { foreach ($sessions as $name => $value) { $session = $sessions[$name]; unset($sesion); if (isset($session)) { // sessions with lifetime ini_set('session.cookie_lifetime', 0); ini_set('session.gc_max_lifetime', 0); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 1); $session; } } } else { unset($sessions[$name]); } session_regenerate_id(true); }
  10. altough i do have a problem calling static methods $auth = new \Authentication\Authentication::singleton(); with static i'll work fine...does namespacing also allow you to call self and parent? thank you
  11. how my customer model looks: namespace Libray\Models; use MVC\Model\Model as Model; class Index_Model extends Model { } autoloader: use Exception\Autoloader as Exception_Handler; class Autoloader { protected $_class_prefix = ''; protected $_class_paths = array(); protected $_ignore_directories = array('.', '..', '.settings'); public function __construct() { spl_autoload_register(array($this, 'load_class')); $this->get_class_paths(); } protected function is_collision($file) { $paths = $this->_class_paths; $file = $file . '.class.php'; $matches = 0; foreach ($paths as $class_path => $file_name) { if (substr($class_path, -strlen($file)) === $file) { $matches++; if ($matches > 1) { return true; break; } } } return false; } protected function load_class($file) { $file = strtolower($file); $paths = $this->_class_paths; try { if (preg_match('/\\\\/', $file)) { $file = str_replace('\\', DS, $file) . '.class.php'; foreach ($paths as $class_path => $file_name) { if (substr($class_path, -strlen($file)) == $file) { require_once $class_path; break; } } } else { $path = array_search($file, $paths); if (!$this->is_collision($file)) { if (!class_exists($file, false) && file_exists($path)) { require_once $path; } else { throw new Exception_Handler(sprintf("Class '%s' not found.<br />\n", $file)); } } else { throw new Exception_Handler(sprintf("Unable to load '%s' due to name collision.<br />\n", $file)); } } } catch (Exception_Handler $e) { echo $e->getMessage(); } } protected function get_class_paths($path = PARENT_DIRECTORY_PATH) { $ignore_directories = $this->_ignore_directories; $dh = opendir($path); if ($dh) { while (false !== ($file = readdir($dh))) { if (!in_array($file, $ignore_directories)) { if (is_dir($path . DS . $file)) { $this->get_class_paths($path . DS . $file); } else if (preg_match('/\.class\.php$/i', $file)) { $entry = $path . DS . $file; $file = substr($file, 0, -10); $this->_class_paths[$entry] = $file; } } } closedir($dh); } } } autoloader works sweet altough i still have a few alterrations to make like cache and prefix...hope im on the right track...thanks guys
  12. thanks you guys...just a few more things I wanna ask if you don't mind me picking you brains if I namespace a class and call a call inside that class' method like so $class = new hello; it comes back with a error: cannot find class my\namespace\hello; is that because its only looking in the my\namespace directory and I would need to call the hello class (eg. utilities\hello) by its actually namespace?...but what happens if the class hello doesn't have a namespace?...is it impossible to load it?
  13. But what I'm confused at is...I've started to adapt my framework classes to being namespaced but I'd also have to add namespaces to my customer controllers:/...should my controllers and models be called without being namespaced?...so should all classes be namespaced in reality...thank you
  14. hey guy I've just recently re-altered my autoloader class which works with namespaces but it also calls classes which aren't namespaced, like so: $class = new myclass(); instead of $class = new Class\Myclass; im wondering have i defeated the whole point of namespacing and if all my classes should actually be namespaced hope its not such a pointless question
  15. wow well that's some great information...SSL is new to with a lot of other things :/...but im looking forward to playing around with it when I buy my server in the next couple of months... thank you...you help is much appreciated *bookmarked
  16. @jacques1, thank you for your information...that has helped me greatly ...one more thing I want to implement SSL to my site...would I have to put SSL into my auth class or would that be a completely different security that would works along side my auth class? if you know of a good tutorial about this so I can understand more please?...the articles ive read just don't seem to sink in thank you again for your help
  17. well this is why im asking the question...but anyways that was the way I used to do it by using the session id but back on the point about storing the username as a session or possibly as a cookie if the user wishes to be remembered...do I then just select the user in the database via just the username which will then get me his/her credentials like email and access level? I read up about whirlpool hashing which suppose to be the best to encrypt passwords...what do you think? function getPasswordSalt() { return substr( str_pad( dechex( mt_rand() ), 8, '0', STR_PAD_LEFT ), -8 ); } // calculate the hash from a salt and a password function getPasswordHash( $salt, $password ) { echo $salt . ( hash( 'whirlpool', $salt . $password ) ); } // compare a password to a hash function comparePassword( $password, $hash ) { $salt = substr( $hash, 0, 8 ); return $hash == getPasswordHash( $salt, $password ); } // get a new hash for a password $hash = getPasswordHash( getPasswordSalt(), "hello" );
  18. hey guys im after a bit of information regarding user authentication please... now I have previously save a users session id in my database after they have logged in so when leaving and coming back to the site im able to compare session id's to get username etc...is this still the way or am I now a little old fashioned? a few more things...do I save information such as username, access level as a session or cookie?...and what is the best way to encrypt passwords please? thank you
  19. thanks @barand oh ok so if I do LEFT JOIN categories c ON c.category_id = sc.category_id WHERE c.name = 'test' and something similar for users? regarding concat() it was the only way I could get the query working as the field list_duration is a enum just using the value of the field wasn't working
  20. SELECT i.item_id, i.title, i.price, i.p_and_p, SUM(i.price + i.p_and_p) AS `total_price`, i.listing, i.condition, i.start_date_time, i.listing_duration, CONVERT_TZ(DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY), '+00:00', u.time_zone) AS `end_date_time` FROM items i LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id LEFT JOIN categories c ON c.name = 'test' JOIN users u WHERE u.username = 'Destramic' AND i.start_date_time < NOW() AND DATE_ADD(i.start_date_time, INTERVAL concat(i.listing_duration) DAY) >= NOW() I'm having a problem with my query returning more than 1 rows...I've even copied the row which is returning to see if that'll return 2 rows but it doesn't can anyone explain why this is happening please?
  21. im trying to get this ajax function working but for some reason it runs the error function...I've corresponded with the manual and I can't see a fault...any advise would be great...thanks $(document).ready(function() { $.ajax( { url: "items.php", dataType: "json", data: '<?php echo $data; ?>', timeout: '2000', cache: false, error: function(data) { alert('error'); }, success: function(data) { $.each(data, function() { $("#table").append('<div class="row"><span class="cell">'+ data.title +'</span><span class="cell"></span><span class="cell"></span></div>'); }); } }); });
  22. SELECT i.item_id, i.title, i.price, @end_date_time := DATE_ADD(i.start_date_time, INTERVAL 10 DAY), CONVERT_TZ(@end_date_time, '+00:00', u.time_zone) AS `end_date_time` FROM items i LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id LEFT JOIN categories c ON c.name = 'Video Games & Consoles' JOIN users u WHERE u.username = 'Destramic' AND i.start_date_time < NOW() AND DATE_ADD(i.start_date_time, INTERVAL 10 DAY) >= NOW() works like a charm...thank you
  23. ok I've taken out the unix_timestamp()...but the query isn't producing a result @end_date_time = 2014-08-05 22:51:45 @start_date_time = 2014-07-26 22:51:45 now obviously these vars match my WHERE's clause...which should bring a result back.... @end_date time >= now() @start_date_time < now() confused....
  24. im having problem comparing timestamps in my where clause for some strange reason...my query works perfect but when adding WHERE it doesn't bring up a result although it should...I've been playing about with it for almost a day now...and it doesn't make sense unix_timestamp values start_date_time 1406411505 end_date_time 1407275505 now 1406461573 my query SELECT i.item_id, i.title, i.price, @start_date_time := CONVERT_TZ(i.start_date_time, '+00:00', u.time_zone), @end_date_time := DATE_ADD(@start_date_time, INTERVAL 10 DAY), @end_date_time AS `end_date_time` FROM items i LEFT JOIN sub_categories sc ON sc.sub_category_id = i.sub_category_id LEFT JOIN categories c ON c.category_id = sc.category_id JOIN users u ON username = 'Destramic' WHERE UNIX_TIMESTAMP(@start_date_time) < UNIX_TIMESTAMP(NOW()) AND UNIX_TIMESTAMP(@end_date_time) >= UNIX_TIMESTAMP(NOW()) if anyone can diagnose my problem I'd it would be much appreciated
  25. I've been reading a few tutorials on how the best way to search key words in a database and at the moment im trying to get this query to work but its coming back with a error: #1191 - Can't find FULLTEXT index matching the column list query: SELECT title, description FROM items WHERE MATCH(title, description) AGAINST('xbox') any help or advise on how the best way to search 2 columns on matching words...thank you
×
×
  • 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.