Jump to content

micha8l

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

micha8l's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. When coding I sometimes forget about coding standards, both in syntax and action. For example, I'll often forget to use upper camel casing for class names - stupid things like this waste a lot of my time. So I was wondering if there's some type of program that'll analyse what I type in real time and check my code not only for errors, but alert me off syntax and such?
  2. Hello, Just wondering if you php freaks would like to share some of the ways you learn new things. I'm here 'cos half way through reading a reference manual for the Zend Framework I suddenly stopped and realised I had partially lost the will to live . I'm no stranger to reference manuals, but they aren't very concise and generally takes me a long time to get through one - even if I go through the contents and decides what's relevant and what's not to me and read from that. So when it comes to programming, what methods of learning do you have?
  3. Hello AbraCadaver, I just wanted to thank you. Changing the permission on my /var/www/captcha directory for user Zend did indeed work.
  4. Hello, I'm working with Zend Framework on Linux, and I'm trying to generate a CAPTCHA using Zend_Form_Element_Captcha. Whenever the CAPTCHA page loads I get this error: [12-Jan-2011 18:14:54] PHP Warning: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: Unable to open '/var/www/square/application/../public/captcha/ebf44d292149b3ebda05571c54c463a8.png' for writing: Permission denied in /usr/local/zend/share/ZendFramework/library/Zend/Captcha/Image.php on line 563 Here's my code for generating the CAPTCHA: // create captcha $captcha = new Zend_Form_Element_Captcha('captcha', array( 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'width' => 300, 'height' => 100, 'imgUrl' => '/captcha', 'imgDir' => APPLICATION_PATH . '/../public/captcha', 'font' => APPLICATION_PATH . '/../public/fonts/LiberationSansRegular.ttf', ) )); I've checked permissions, and all directories mentioned above are accessible to root. Has anyone had a similar problem or have an idea how I can fix this? Kind Regards, Mike
  5. Hey, Read your little question. What you want to do is in download the Zend_Mail class. And the make a script like this: [code=php:0] <?php require_once('Zend/Mail.php'); $config = array( 'auth' => 'login', 'username' => 'you@gmail.com', 'password' => 'gmailPassword', 'port' => 465 ); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); $mail = new Zend_Mail(); $mail->setBodyText( "email message" ); $mail->setFrom( recipientEmail, recipientName); $mail->addTo( $email ); $mail->setSubject('form submission'); $mail->send( $transport ); [/code] have fun
  6. Hey, I've been coding in PHP and OOP for a little over two years. I've always created my applications using my own code, and I'm very reluctant even installing some packages from the PEAR repository. But something has come up, a project, a very large project that requires all kinds of APIs: Amazon, Twitter, Facebook etc. Not wanting to reinvent the wheel -- so to speak -- I've decided I'll have to learn a Framework, so I chose Zend. I'm wondering if anyone could give me some inight into working with this Framework: Is it really difficult to develop projects with, I'm just starting to learn now and it does seem very difficult. Do many successful websites use Zend Framework? Just stuff like that. Kind Regards Mike
  7. Maq's right, in theory you could do that, but don't be expecting your email to arrive in their inbox, more like their spam folder. Go with my method, if a user's interested in your E-mail they'll click the link.
  8. I believe this could help you: http://www.boutell.com/gd/
  9. Nope, the web's stateless. However you could assign each E-mail sent an ID and then have them click a link, with the email ID hardcoded into the query string, to your landing page where you could check for the email ID in a query string.
  10. Thanks for the reply man. The method (no pun) isn't just about security though, as some other methods in the project are going to depend on it.
  11. Hey guys, I'm working a project that requires sessions be stored within the database, as the project I'm working on is on a shared host. But I'm having a problem with getting the data of a session in the database, the other fields like session_id, session_updated, session_created are working fine. I think I've got a bug in my code, but I just can't detect it (frustrating). Database connection class db extends mysqli { private $host; private $user; private $pass; private $db; function __construct( $host='localhost', $user='user', $pass='pass', $db='website' ) { $this -> host = $host; $this -> user = $user; $this -> pass = $pass; $this -> db = $db; parent::connect( $host, $user, $pass, $db ); if( mysqli_connect_error( ) ) { die( 'Connection error ('.mysqli_connect_errno( ).'): '.mysqli_connect_error( ) ); } } function __destruct( ) { $this -> close( ); } } Session handler class sessionHandler { private $database; private $dirName; private $sessTable; private $fieldArray; function sessionHandler() { // save directory name of current script $this -> database = new db; $this -> dirName = dirname(__file__); $this -> sessTable = 'sessions'; } function open( $save_path, $session_name ) { return TRUE; } function close() { //close the session. if ( !empty( $this -> fieldarray ) ) { // perform garbage collection $result = $this->gc( ini_get ( 'session.gc_maxlifetime' ) ); return $result; } return TRUE; } function read( $session_id ) { $sql = " SELECT * FROM sessions WHERE session_id=( '$session_id' ) LIMIT 1 "; $result = $this -> database -> query( $sql ); if( $result -> num_rows > 0 ) { $data = $result -> fetch_array( MYSQLI_ASSOC ); $this -> fieldArray = $data; $result -> close(); return $data; } return ""; } function write( $session_id, $session_data ) { //write session data to the database. if ( !empty( $this -> fieldArray ) ) { if ( $this -> fieldArray['session_id'] != $session_id ) { // user is starting a new session with previous data $this -> fieldArray = array(); } } $this -> fieldArray['session_id'] = $session_id; $this -> fieldArray['session_data'] = $session_data; $this -> fieldArray['session_updated'] = time(); $this -> fieldArray['session_created'] = time(); $session_id = $this -> database -> escape_string( $session_id ); $session_data = $this -> database -> escape_string( $session_data ); $session_updated = time(); $session_created = time(); $sql = " INSERT INTO sessions ( session_id, session_data, session_updated, session_created ) VALUES ( '$session_id', '$session_data', '$session_updated', '$session_created' ) "; if( $this -> database -> query( $sql ) !== TRUE ) { return FALSE; } return TRUE; } function destroy( $session_id ) { $sql = " DELETE FROM sessions WHERE session_id=('$session_id') "; if( $this -> database -> query( $sql ) !== TRUE ) { return FALSE; } return TRUE; } function gc( $max_lifetime ) { return TRUE; } function __destruct() { //ensure session data is written out before classes are destroyed //(see http://bugs.php.net/bug.php?id=33772 for details) @session_write_close(); } } The call $session_class = new sessionHandler; session_set_save_handler( array( &$session_class, 'open' ), array( &$session_class, 'close' ), array( &$session_class, 'read' ), array( &$session_class, 'write' ), array( &$session_class, 'destroy' ), array( &$session_class, 'gc' ) ); if( !session_start() ) { exit(); } Any help at all would be appreciated. Kind Regards Mike
×
×
  • 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.