Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

ShaolinF's Achievements

Advanced Member

Advanced Member (4/5)



  1. When using DateTime() create a date from a string I encounter one problem. In the UK the date is structured as dd/mm/yy but the date method only accepts the mm/dd/yy format. How can I change this ? $date = new DateTime('31/05/10'); // fails $date = new DateTime('05/31/10'); // works
  2. doh, forgot about the mysql function. thanks guys.
  3. The solution is simple, just use a cryptographic hash like SHA2, you will have no collisions. You can use the customer name, RMA primary key id, and a timestamp, hash them and there you have an RMA. If its too long then you can trim it. One major benefit (in this case) is hash calculations are very light on the CPU, you can performs 1000s per second and collisions are extremely extremely unlikely. <?php $rma_primarykey_id = 12831; $customer_name = 'namehere'; $microtime = microtime(); $rma_number = hash('sha256', ($rma_primarykey_id.$customer_name.$time); // 256bits of pure randomness ?>
  4. I have a MySQL column which holds the date in DATETIME format. When I pull it and try and format it in php using the DATE function the times are wrong. See code below: <?php print date("d/m/y @ G:H:s A", strtotime($pt->transaction_date)); ?> Anyone know why this is the case ?
  5. Hi Guys, Theres always been one issue that I just cannot overcome (maybe because I keep pushing it to the backburner). Whenever debugging other peoples code I do the usual var_dump() or print_r() or vars which (sometimes) displays a monolithic array. I just find it very intimdating and can never really figure out whats going on. Is anyone else like this ? Any good reads on how to 'decode' such large arrays ?
  6. That works outside an input value but not inside. <input value="<? echo htmlspecialchars("this is & that");?>" /> Are there any workarounds other than stripping?
  7. Hi Guys, I am trying to use htmlentities and htmlspecialchars to convert a ampersand (&) to the html markup eqivalant (&) to no avail. any ideas ? htmlentities("this is & that");
  8. Yes, I copy/pasted it into my editor. Bare in mind the 'content here' bit being wrapped in the blockquotes will hold data pulled from a WYSIWYG editor. BTW, the space is meant to be there.
  9. Thanks but that didnt work either
  10. Hi Guys I am trying to get some content between some div tags but cannot do so thus far. Code and regex below: <blockquote class="postcontent restore "> content here </blockquote> Regex: /<blockquote class=\"postcontent restore \">(.*?)<\/blockquote>/ Returns nothing.. Any ideas on where I am going wrong ?
  11. Thanks - That does work but what Im trying to do is remove everything other than the href="test.htm" bit. How would I do that ? The only way I can think of doing this is using something like [^(expression here)] but that will match on a per letter basis.
  12. Hi Guys, I have the following URL: <a href="test.test"></a> I want to remove everything except the href="test.test" bit so I did the following: [^(href=\"(.*)\")] but this returns href="e.e". Any ideas?
  13. Hi Guys, Is there anyway I can use the trim() function to remove P tags from the beginning AND end ? So far I can only get it to remove one P tag but not both. trim($content, '<p>'); I tried the following but it didn't work: trim($content, '<p>..</p>'); trim($content, array("<p>", "</p>"));
  14. Hi Guys, I do the following to GET an id: $id = $_GET['id']; There needs to be some filtering/sanitization. I have noticed that many people just cast it as an int and leave it at that. Is that really the best way to approach this issue ? It doesnt look right to me. Im hoping someone can shed some light on this from a secure coding POV.
  15. Hi Guys I have been doing some DB mapping to link two tables to no avail. Everytime I run the code I get the following error: Message: File "Role.php" does not exist or class "Role" was not found in the file Stack trace: #0 C:\wamp\www\zend\library\Zend\Db\Table\Row\Abstract.php(867): Zend_Db_Table_Row_Abstract->_getTableFromString('Role') #1 C:\wamp\www\uw\application\models\admin\User.php(56): Zend_Db_Table_Row_Abstract->findDependentRowset('Role') #2 C:\wamp\www\uw\application\controllers\AdminController.php(110): Application_Model_Admin_User->getUsers() #3 C:\wamp\www\zend\library\Zend\Controller\Action.php(513): AdminController->usersAction() #4 C:\wamp\www\zend\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('usersAction') #5 C:\wamp\www\zend\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #6 C:\wamp\www\zend\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() #7 C:\wamp\www\zend\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #8 C:\wamp\www\uwi\public\index.php(26): Zend_Application->run() #9 {main} Code & DB below: application/models/admin/User.php <?php class Application_Model_Admin_User extends Zend_Db_Table_Abstract { protected $_name = 'user'; protected $_dependentTables = array('Role'); public function getUsers() { $rows = $this->fetchAll($this->select()->where('active = ?', 1)); $rows1 = $rows->current(); $rows2 = $rows1->findDependentRowset('Role'); return $rows2; } } application/models/admin/Role.php <?php class Application_Model_Admin_Role extends Zend_Db_Table_Abstract { protected $_name = 'role'; protected $_referenceMap = array ( 'Role' => array( 'columns' => array('id'), 'refTableClass' => 'User', 'refColumns' => array('role_id') ); } DB tables CREATE TABLE role ( id integer auto_increment NOT NULL, name varchar(120), PRIMARY KEY(id) ); CREATE TABLE user ( id integer auto_increment NOT NULL, username varchar(120), PRIMARY KEY(id), FOREIGN KEY(role_id) REFERENCES role(id) );
  • 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.