php-general Digest 18 Sep 2005 04:27:37 -0000 Issue 3688

Topics (messages 222575 through 222587):

Php converting jpegs to pjpegs: Help
        222575 by: jnoyes

Re: email validation regex
        222576 by: bruce
        222586 by: Robert Paul

delete duplicates from array and insert statement
        222577 by: Ryan A
        222578 by: Jasper Bryant-Greene

phpdoc install trouble
        222579 by: James Benson

headers .vs javascript location.href
        222580 by: bruce

php guru!!!!!
        222581 by: bruce
        222582 by: James Benson
        222583 by: bruce
        222584 by: bruce

A dumb question - Regarding a php cms
        222585 by: Troy Pieterman
        222587 by: Jose Miguel

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
 Can someone tell me why, or better yet how I can make sure that PHP doesn't
turn my non-progressive jpegs to pjepgs on upload?  Using the code below, if
I upload a non-progressive jpeg, PHP tells me that the file uploaded
successfully, and the file is of type pjpeg. How can I avoid this problem?

************************MY CODE***************************************

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
// specify the file to write to
$filename = 'portfolio.xml';

//specify the content to write
$somecontent =
"\r\n<portfolioItem><image>".$HTTP_POST_FILES['userfile']['name']."</image><
/portfolioItem>";

//<portfolioItem><image>images/bride10.jpg</image></portfolioItem>


// specify the directory where the uploaded file should end up //$path =
'images/' ; $path = 'PHP_Library/'; 

// specify the filetypes allowed
$allowed = array('image/gif','image/pjpeg','image/jpeg','image/png'); 

// specify the max filesize in bytes
$max_size = 200000; 
   
///checks to see if file field is not null
if(isset($HTTP_POST_FILES['userfile']))
{
  if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
  { 
   if($HTTP_POST_FILES['userfile']['size'] < $max_size) 
   { 
    if(in_array($HTTP_POST_FILES['userfile']['type'],$allowed)) 
    { 
     if(!file_exists($path . $HTTP_POST_FILES['userfile']['name'])) 
     { 
 
if(@rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['
userfile']['name'])) 
      { 
          if (is_writable($filename)) {
             if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
                } if (fwrite($handle, $somecontent) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
   }
   
   echo "The file '".$HTTP_POST_FILES['userfile']['name']."' was uploaded
successfully";
   
   fclose($handle);

}
           //fopen($filename, 'a');
           //fwrite ($filename, $somecontent);
           //fclose($handle);
       $html_output = '<br>'; 
       $html_output .= 'File Name:
'.$HTTP_POST_FILES['userfile']['name'].'<br>'; 
       $html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].'
bytes<br>'; 
       $html_output .= 'File Type:
'.$HTTP_POST_FILES['userfile']['type'].'<br>'; 
           //echo "this is the name".['name'];
          
       $image = $HTTP_POST_FILES['userfile']['name'] ; 
      }else{ 
       $html_output = 'Upload failed!<br>'; 
       if(!is_writeable($path)) 
       { 
        $html_output = 'The Directory "'.$path.'" must be writeable!<br>'; 
       }else{ 
        $html_output = 'an unknown error ocurred.<br>';       
       } 
      } 
     }else{ 
      $html_output = 'The file already exists<br>'; 
     } 
    }else{ 
     $html_output = 'Wrong file type<br>'; 
    } 
   }else{ 
    $html_output = 'The file is too big<br>'; 
   }
  }
}else{
  $html_output = '<form method="post" enctype="multipart/form-data"
action="'.$_SERVER['PHP_SELF'].'">';
  $html_output .= '<input type="file" name="userfile">';
  $html_output .= '<input type="submit" value="upload">';
  $html_output .= '</form>';
} 

echo '<html><head><title>Uploader</title></head><body>';
echo $html_output;
echo '</body></html>'; 

?> 

</body>
</html>

--- End Message ---
--- Begin Message ---
i tried that one...

it doesn't do as well as the perl... "Email::Valid" mod...

i decided to write a quick perl script, and call it from the php app...
seems to satisfy my needs for now... i haven't run across any php
script/regex that's as comprehensive as the perl "Email::Valid"

-bruce


-----Original Message-----
From: Robert Paul [mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005 7:13 PM
To: [email protected]
Subject: [PHP] Re: email validation regex


http://www.iamcal.com/publish/articles/php/parsing_email/

The author goes through RFC822 in detail and writes up a regex that
validates emails based on that.  It's worked in my experience, but I
havn't exactly put it through its paces.

--Rob

bruce wrote:
> hi..
>
> looking for a good/working/tested php email validation regex that conforms
> to the rfc2822 standard.
>
> a lot of what i've seen from google breaks, or doesn't follow the
standard!
>
> any ideas/thoughts/sample code/etc...
>
> thanks
>
> -bruce
> [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- Well what does the aforementioned regex seem to miss that Email::Valid catches?

--Rob

bruce wrote:
i tried that one...

it doesn't do as well as the perl... "Email::Valid" mod...

i decided to write a quick perl script, and call it from the php app...
seems to satisfy my needs for now... i haven't run across any php
script/regex that's as comprehensive as the perl "Email::Valid"

-bruce


-----Original Message-----
From: Robert Paul [mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005 7:13 PM
To: [email protected]
Subject: [PHP] Re: email validation regex


http://www.iamcal.com/publish/articles/php/parsing_email/

The author goes through RFC822 in detail and writes up a regex that
validates emails based on that.  It's worked in my experience, but I
havn't exactly put it through its paces.

--Rob

bruce wrote:

hi..

looking for a good/working/tested php email validation regex that conforms
to the rfc2822 standard.

a lot of what i've seen from google breaks, or doesn't follow the

standard!

any ideas/thoughts/sample code/etc...

thanks

-bruce
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi,
I have a movie database with this structure:

    flick_name  text
   part_url  text
   part_size  varchar(50)
   time_length  varchar(50)
   part_format  varchar(10)

and my select statement is something like this:
insert into table values
("abba",http://...abba1.wmv,"3 mb","3
mins",".wmv"),("abba",http://...abba2.wmv,"3 mb","3 mins",".wmv")
and so on.

When we get new movies we get the whole sql to insert it....but the problem
is it contains all the movies we already have too

eg:
in the db we already have the album
but we get the abba album and the new movies in this kind of format
("abba",http://...abba1.wmv,"3 mb","3
mins",".wmv"),("abba",http://...abba2.wmv,"3 mb","3 mins",".wmv"),("Led
Zep",http://...led_zep1.wmv,"4 mb","2 mins",".wmv") etc etc

want i want to do is, do a select and get the data that is already in the
db, compare it, and if its in the insert statement delete those rows...
am getting screwed up in the logic for this...so far I have exploaded the
insert statement so its in a neat array, now i need to check in_array...

I have not written much code so i didnt include the code here, but if you
need it just reply to me.

Any ideas?

Thanks,
Ryan

--- End Message ---
--- Begin Message ---
Ryan A wrote:
want i want to do is, do a select and get the data that is already in the
db, compare it, and if its in the insert statement delete those rows...
am getting screwed up in the logic for this...so far I have exploaded the
insert statement so its in a neat array, now i need to check in_array...

If it was me I'd just use MySQL's INSERT IGNORE [1] which treats errors as warnings instead. So that way when you have a duplicate on your primary key, as you will when inserting a row that already exists, it will ignore the error and carry on. Of course, you'll want to make sure there's no SQL errors etc. before putting the IGNORE keyword in.

Note that you should only really use this in situations where you *know* that a primary or unique key may be duplicated in your INSERT. Sticking IGNORE in all your INSERTs is a Bad Thing since you usually want to know when an error has occurred.

[1] http://dev.mysql.com/doc/mysql/en/insert.html
--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

--- End Message ---
--- Begin Message --- Im trying to setup the pear phpdocumentor class but running into many problems, i think ive nearly got all the include directories setup correct now, modified some paths etc, now when i get to the end of a compile via the command line it always says the followig with different files when differnt converters are used:-

Fatal error: Call to undefined function: phpdocumentor_get_class() in /docs/www/phpDocumentor/Converters/HTML/Smarty/HTMLSmartyConverter.inc on line 1122



Also Tried with web interface but get the following two error messages:-

Parsing configuration file phpDocumentor.ini...
done
using experimental tokenizer Parser
File  Ignored
ERROR: nothing parsed

...

Parsing configuration file phpDocumentor.ini...
done
Directory '' not found



Using PHP4.4.0 Apache 1.3.33 - ubuntu 5 with tokenizer ext, my phpDocumentor.ini settings are as follows:-




Program_Root = /docs/www/FormGenie

;; uncomment this to set the path phpDocumentor looks in to find user files
userdir = user/

;; Use useconfig if you want to be able to run phpdoc with no command-line options (!!) ;; change the value of useconfig to an .ini file that is in users/ (like greg.ini)
;[_phpDocumentor_setting]
useconfig = demo




settings of demo.ini

target = /docs/www/FormGenie/docs


[Parse Data]
;; title of all the documentation
;; legal values: any string
title = FormGenie Documentation

;; parse files that start with a . like .bash_profile
;; legal values: true, false
hidden = false

;; show elements marked @access private in documentation by setting this to on
;; legal values: on, off
parseprivate = on

;; parse with javadoc-like description (first sentence is always the short description)
;; legal values: on, off
javadocdesc = off

;;target=/dev/null

;; add any custom @tags separated by commas here
;; legal values: any legal tagname separated by commas.
;customtags = mytag1,mytag2

;; what is the main package?
;; legal values: alphanumeric string plus - and _
defaultpackagename = FormGenie

;; output any parsing information?  set to on for cron jobs
;; legal values: on
;quiet = on

;; limit output to the specified packages, even if others are parsed
;; legal values: package names separated by commas
;packageoutput = package1,package2

;; comma-separated list of files to parse
;; legal values: paths separated by commas
;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory
;;filename =


;; comma-separated list of directories to parse
;; legal values: directory paths separated by commas
;directory = /path1,/path2,.,..,subdirectory
directory = /docs/www/FormGenie


;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore
;; legal values: any wildcard strings separated by commas
;ignore = /path/to/ignore*,*list.php,myfile.php,subdirectory/
;;ignore = templates_c/,*HTML/default/*,spec/

;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format ;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib ;; HTML:frames:phpedit,HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de ;; HTML:Smarty:default,HTML:Smarty:PHP,PDF:default:default,CHM:default:default,XML:DocBook:default
output=HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib,HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de,HTML:frames:phpedit,HTML:Smarty:default,HTML:Smarty:HandS,HTML:Smarty:PHP,PDF:default:default,XML:DocBook/peardoc2:default,CHM:default:default




Thanks for any help,

James

--- End Message ---
--- Begin Message ---
hi..

need to talk to someone to figure out how/what i need to do to use the php
'headers' function, as opposed to the javascript 'location.href'.

i've tried to implement the buffering functions, but still get the same
error...

is there someone that i can talk to about this, who ha
experience/understanding of what's going on. i've thought about rewriting
what i have to this point, but i've got code interspersed with html...

yeah.. i know... cleaning it up would probably make things easier/better,
but this is a quick/dirty  test.. and i don't claim to be a web developer!

thanks

-bruce
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
hi...

i'm playing with a script/class from phpclasses.org. the script/class is
user_class. the script is straight enough, but i'm trying to figure out how
i can include/incorporate the script into a test site i'm creating...

the user_access script more or less uses the entire page. for my app, i'd
like to basically use the user_access app/class and have the different pages
be displayed in specific areas of my pages...

given that the user_class script uses 'header', i'm not sure how to
accomplish this without generating the 'headers already sent...' err msg...

if there's someone that i can talk to regarding this, i'd appreciate it..

thanks

-bruce
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
http://php.net/ob_start

try something like...

<?php
// top of page
ob_start();


/* whole script goes here */


// bottom of page
ob_end_flush();

?>




bruce wrote:
hi...

i'm playing with a script/class from phpclasses.org. the script/class is
user_class. the script is straight enough, but i'm trying to figure out how
i can include/incorporate the script into a test site i'm creating...

the user_access script more or less uses the entire page. for my app, i'd
like to basically use the user_access app/class and have the different pages
be displayed in specific areas of my pages...

given that the user_class script uses 'header', i'm not sure how to
accomplish this without generating the 'headers already sent...' err msg...

if there's someone that i can talk to regarding this, i'd appreciate it..

thanks

-bruce
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
i already did...

i got the same error... which is why i was/am looking for a guru!!!!

-bruce



-----Original Message-----
From: James Benson [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 17, 2005 4:34 PM
To: [email protected]
Subject: [PHP] Re: php guru!!!!!


http://php.net/ob_start

try something like...

<?php
// top of page
ob_start();


/* whole script goes here */


// bottom of page
ob_end_flush();

?>




bruce wrote:
> hi...
>
> i'm playing with a script/class from phpclasses.org. the script/class is
> user_class. the script is straight enough, but i'm trying to figure out
how
> i can include/incorporate the script into a test site i'm creating...
>
> the user_access script more or less uses the entire page. for my app, i'd
> like to basically use the user_access app/class and have the different
pages
> be displayed in specific areas of my pages...
>
> given that the user_class script uses 'header', i'm not sure how to
> accomplish this without generating the 'headers already sent...' err
msg...
>
> if there's someone that i can talk to regarding this, i'd appreciate it..
>
> thanks
>
> -bruce
> [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
andre..

you can find the files/app at
http://olederer.users.phpclasses.org/browse/package/1906.html.

i'm basically trying to figure out how to do the following...

   +------------------------------------------------+
   |                                                |
   |                                                |
   |   header                                       |
   |                                                |
   |                                                |
   +------------------------------------------------+
   |              nav menu                          |
   +------------------------------------------------+
   |            |                                   |
   |            |              new                  |
   |            |          registration             |
   |  login     |             stuff                 |
   |  area      |                                   |
   |            |                                   |
   |            |                                   |
   |            |                                   |
   |            |                                   |
   |            |                                   |
   |            |                                   |
   |            |                                   |
   +------------------------------------------------+

 basically, i'd like to have the app display the traditional login in the
login area, as well as the 'new registration'. the app should allow the user
to enter the login user/passwd in the login area. selecting 'register new
user' should cause the 'registration form' to be displayed in the 'right
area'

the way i've quickly put this together is via a lot of includes based on the
user slection of the 'nav menu items' as well as the user selecting
different items within the various pages...

however, i'm now having an issue when i try to use the 'header' function to
redirect the user to another page after the given logic is completed.

-bruce



-----Original Message-----
From: André Medeiros [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 17, 2005 5:29 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: php guru!!!!!


Could you give us the full url of the class so we can look at it's
source code? :)

On 9/18/05, bruce <[EMAIL PROTECTED]> wrote:
> i already did...
>
> i got the same error... which is why i was/am looking for a guru!!!!
>
> -bruce
>
>
>
> -----Original Message-----
> From: James Benson [mailto:[EMAIL PROTECTED]
> Sent: Saturday, September 17, 2005 4:34 PM
> To: [email protected]
> Subject: [PHP] Re: php guru!!!!!
>
>
> http://php.net/ob_start
>
> try something like...
>
> <?php
> // top of page
> ob_start();
>
>
> /* whole script goes here */
>
>
> // bottom of page
> ob_end_flush();
>
> ?>
>
>
>
>
> bruce wrote:
> > hi...
> >
> > i'm playing with a script/class from phpclasses.org. the script/class is
> > user_class. the script is straight enough, but i'm trying to figure out
> how
> > i can include/incorporate the script into a test site i'm creating...
> >
> > the user_access script more or less uses the entire page. for my app,
i'd
> > like to basically use the user_access app/class and have the different
> pages
> > be displayed in specific areas of my pages...
> >
> > given that the user_class script uses 'header', i'm not sure how to
> > accomplish this without generating the 'headers already sent...' err
> msg...
> >
> > if there's someone that i can talk to regarding this, i'd appreciate
it..
> >
> > thanks
> >
> > -bruce
> > [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Im trying to run Syntax desktop which is a php cms (on my own server
win2003). 

In the installation readme it tells me to edit a cfg.php file, i have done
this but the cms still does not load, i have a feeling its becuase it dosnt
know where to load its files from, here is the code that tells it, its path
and relative path.

////////////////////////////////////////////////////////////////////////////
///
// AUTO CALCULATED VARIABLE
////////////////////////////////////////////////////////////////////////////
//

//phisical path. I.e. /var/www/html/site1/
$synRealBasePath=substr(dirname(__FILE__),0,strlen(dirname(__FILE__))-6);

//relative path. I.e. /site1/
$synBasePath="/".basename($synRealBasePath)."/";
////////////////////////////////////////////////////////////////////////////
//

How do i write in there its "phisical path and relative path" are
c:\www\syntax desktop\

thanks for your help

--- End Message ---
--- Begin Message ---
Regarding paths, in a Windows enviroment, you should use double slash, like:

c:\\www\\syntax desktop\\

Cheers.

On 18 Sep 2005 09:13:56 +1000, Troy Pieterman <[EMAIL PROTECTED]> 
wrote:
> 
> Im trying to run Syntax desktop which is a php cms (on my own server
> win2003).
> 
> In the installation readme it tells me to edit a cfg.php file, i have done
> this but the cms still does not load, i have a feeling its becuase it 
> dosnt
> know where to load its files from, here is the code that tells it, its 
> path
> and relative path.
> 
> 
> ////////////////////////////////////////////////////////////////////////////
> ///
> // AUTO CALCULATED VARIABLE
> 
> ////////////////////////////////////////////////////////////////////////////
> //
> 
> //phisical path. I.e. /var/www/html/site1/
> $synRealBasePath=substr(dirname(__FILE__),0,strlen(dirname(__FILE__))-6);
> 
> //relative path. I.e. /site1/
> $synBasePath="/".basename($synRealBasePath)."/";
> 
> ////////////////////////////////////////////////////////////////////////////
> //
> 
> How do i write in there its "phisical path and relative path" are
> c:\www\syntax desktop\
> 
> thanks for your help
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Jose Arce
http://sinexion.com - http://josearce.com

--- End Message ---

Reply via email to