OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 19 Oct 2005 16:08:40 -0000 Issue 3746

php-general-digest-helplists.php.net
Date: Wed Oct 19 2005 - 11:08:40 CDT


php-general Digest 19 Oct 2005 16:08:40 -0000 Issue 3746

Topics (messages 224313 through 224333):

Re: Java editor
        224313 by: Robert Cummings
        224329 by: John Taylor-Johnston
        224330 by: Jay Blanchard
        224331 by: John Taylor-Johnston

Re: fckeditor and PDF and pesky users
        224314 by: Torgny Bjers

fetching words
        224315 by: Jad Madi
        224323 by: Jim Moseby

Help needed / failed to open stream: Permission denied
        224316 by: Ndagi Mutiri
        224317 by: David Robley
        224325 by: Mark Rees
        224327 by: Jim Moseby
        224328 by: Jochem Maas

Re: PHP DOM XHTML - let me set my own javascript from code
        224318 by: Rob
        224319 by: Rob
        224326 by: Petr Smith

Re: OPTIMIZING - The fastest way to open and show a file
        224320 by: Ruben Rubio Rey

Re: White background with imagecreatetruecolor()
        224321 by: £ukasz 'nostra' Wojciechowski

Pb to change "accountexpires" attribute in Active Directory
        224322 by: Joel d

Re: PHP and files Upload
        224324 by: Mark Rees

PHP to read news
        224332 by: Steve

Imap, reading the email-body
        224333 by: Bruno Gola

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Tue, 2005-10-18 at 23:52, John Taylor-Johnston wrote:
> Is there a OS java (or other) html editor I can implement on a Web page.
> I want a user to type text, use bold, italics, etc.
> I would then store the html in a MySQl record and then use php to insert
> the edited text.
> I've seen some packaged, in Moodle for example.

Here's a couple of popular ones.

    http://tinymce.moxiecode.com/example_full.php?example=true
    http://www.fckeditor.net/demo/default.html

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Looks good. But I was hoping for open source.
John

Torgny Bjers wrote:

>John Taylor-Johnston wrote:
>
>
>
>>Is there a OS java (or other) html editor I can implement on a Web
>>page. I want a user to type text, use bold, italics, etc.
>>I would then store the html in a MySQl record and then use php to
>>insert the edited text.
>>I've seen some packaged, in Moodle for example.
>>John
>>
>>
>
>I heartily recommend InnovaStudio WYSIWYG editor:
>http://www.innovastudio.com/editor.asp
>
>It comes with both PHP, ASP, and ASP.NET implementation examples.
>
>It doesn't support XHTML, but you solve that by using the PHP tidy module.
>
>Warm Regards,
>Torgny
>
>
>
>
>

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

  ' ' ' Collège de Sherbrooke:
 ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
    - 819-569-2064

  °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
 /(_)\ Université de Sherbrooke
  ^ ^ http://compcanlit.ca/ T: 819.569.2064

attached mail follows:


[snip]
>>Is there a OS java (or other) html editor I can implement on a Web
>>page. I want a user to type text, use bold, italics, etc.
>>I would then store the html in a MySQl record and then use php to
>>insert the edited text.
[/snip]

Sorry I missed this earlier. Have you looked at htmlArea?

http://www.htmlarea.com/

attached mail follows:


Thanks Rob. They are hard to choose between?! I'll play with both. I
only want the very basics.
Thanks!
John

>On Tue, 2005-10-18 at 23:52, John Taylor-Johnston wrote:
>
>
>>Is there a OS java (or other) html editor I can implement on a Web page.
>>I've seen some packaged, in Moodle for example.
>>
>>
>Robert Cummings wrote:
>Here's a couple of popular ones.
> http://tinymce.moxiecode.com/example_full.php?example=true
> http://www.fckeditor.net/demo/default.html
>
>
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

  °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
 /(_)\ Université de Sherbrooke
  ^ ^ http://compcanlit.ca/ T: 819.569.2064

attached mail follows:


Jochem Maas wrote:

> and the next site that displays a PDF when I wasn't expecting it
> and I have to spend the next five minutes waiting for the b'std to load
> (with the alternative being to KILL the browser - losing all open pages
> in the process) ... might just make me snap ;-)

I agree, those moments are annoying. That's why one needs to make sure
that the user expects, and is aware, that a PDF is going to open down
there in that little <iframe/>. I do not see any motivated use for a PDF
in this fashion on a normal site, but, in a document versioning system
or a CMS, sure, that would be awesome. Otherwise I side with Jochem.

This is not an approach that should be used in any normal web page, it
should be utilized with care, where it is needed, and the user has to be
made aware that when clicking on a specific link, a PDF will be loading.
Otherwise, some poor webmaster's going to have to answer to Jochem, and
they don't want that. ;)

Regards,
Torgny

attached mail follows:


Hi,
guys I have two tables, articles and keywords, what I want to do is to
scan articles and grab every single word
used in an article to the keyword table
any idea how to do that
--

Regards
Jad madi
Blog
http://EasyHTTP.com/jad/
Web standards Planet
http://W3planet.net/

attached mail follows:


>
> Hi,
> guys I have two tables, articles and keywords, what I want to do is to
> scan articles and grab every single word
> used in an article to the keyword table
> any idea how to do that
> --

Vague question, and I suspect that there is a much better way to do what you
are trying to do, but since you didn't elaborate, here goes:

<?php
// code here to select article_number, article_text from table

$article_number=$row['article_number'];
$article_words=explode($row['article_text']);
foreach($article_words as $word){
  $sql="insert into keywords (article_number, keyword) values
($article_number, '$keyword')";
  //code here to toss out common words ('a', 'the', etc), execute 'insert'
query, error check, whatever else
}
?>

JM

attached mail follows:


Hello,

Trying to read a binary file in MySQL database, i have the following error :

Warning: fopen(./) [function.fopen]: failed to open stream: Permission denied in d:\...\download.php on line 57

This is line 57 $file_handle = fopen("./" . $file_name, "r");

and my function

function db_download_file($dbname, $file, $idreunion) {
                //Sélectionne la base de données
        mysql_select_db($dbname);

        //Requête SQL
        $select = "SELECT " . $file . " FROM inter_vertaaldienst WHERE id_reunion = '" . $idreunion . "'";

        //Exécution de la requête
        $file_records = mysql_query($select);

        //En cas d'erreur, on affiche un message
        if (!$file_records){echo('<p>Erreur :' . mysql_error().'<p>');}
        //Autrement, on affiche le fichier
        else{
                if($file_record = mysql_fetch_array($file_records)){
                        $file_handle = fopen("./" . $file_name, "r");
                        $file_bytes = $file_record[0];
                        fwrite($file_handle, $file_bytes, strlen($file_bytes));
                        $return_value = "./" . $file_name;
                }
        }
        return($return_value);
}

Thank for your help.
Ndagi

attached mail follows:


Ndagi Mutiri wrote:

> Hello,
>
> Trying to read a binary file in MySQL database, i have the following error
> :
>
> Warning: fopen(./) [function.fopen]: failed to open stream: Permission
> denied in d:\...\download.php on line 57
>
> This is line 57 $file_handle = fopen("./" . $file_name, "r");

It seems that the user your web server runs as may not have permission to
open that file. Also, you might want to double check that ./$ile_name is a
valid path.
 
> and my function
>
> function db_download_file($dbname, $file, $idreunion) {
> //Sélectionne la base de données
> mysql_select_db($dbname);
>
> //Requête SQL
> $select = "SELECT " . $file . " FROM inter_vertaaldienst WHERE id_reunion
> = '" . $idreunion . "'";
>
> //Exécution de la requête
> $file_records = mysql_query($select);
>
> //En cas d'erreur, on affiche un message
> if (!$file_records){echo('<p>Erreur :' . mysql_error().'<p>');}
> //Autrement, on affiche le fichier
> else{
> if($file_record = mysql_fetch_array($file_records)){
> $file_handle = fopen("./" . $file_name, "r");
> $file_bytes = $file_record[0];
> fwrite($file_handle, $file_bytes, strlen($file_bytes));
> $return_value = "./" . $file_name;
> }
> }
> return($return_value);
> }
>
> Thank for your help.
> Ndagi

Cheers
--
David Robley

A cat will go "quack" - if you squeeze it hard enough.

attached mail follows:


>
> > This is line 57 $file_handle = fopen("./" . $file_name, "r");
>
> It seems that the user your web server runs as may not have permission to
> open that file. Also, you might want to double check that ./$ile_name is a
> valid path.

And if you're planning to write to the file, you need to specify that. "r"
means "open for reading only". Read up on the possibilities here:

http://uk2.php.net/fopen

attached mail follows:


>
> Hello,
>
> Trying to read a binary file in MySQL database, i have the
> following error :
>
> Warning: fopen(./) [function.fopen]: failed to open stream:
> Permission denied in d:\...\download.php on line 57
>
> This is line 57 $file_handle = fopen("./" . $file_name, "r");
>
> and my function
>
> function db_download_file($dbname, $file, $idreunion) {
> //Sélectionne la base de données
> mysql_select_db($dbname);
>
> //Requête SQL
> $select = "SELECT " . $file . " FROM
> inter_vertaaldienst WHERE id_reunion = '" . $idreunion . "'";
>
>
> //Exécution de la requête
> $file_records = mysql_query($select);
>
> //En cas d'erreur, on affiche un message
> if (!$file_records){echo('<p>Erreur :' . mysql_error().'<p>');}
> //Autrement, on affiche le fichier
> else{
> if($file_record = mysql_fetch_array($file_records)){
> $file_handle = fopen("./" . $file_name, "r");
> $file_bytes = $file_record[0];
> fwrite($file_handle, $file_bytes,
> strlen($file_bytes));
> $return_value = "./" . $file_name;
> }
> }
> return($return_value);
> }

Place an:

echo "./" . $file_name;

...just above line 57 and make sure that the filename is what you expect it
to be. If it is, make sure the user the webserver is running as has
permissions sufficient to open the file for reading. You could, as a test,
temporarily chmod 777 the file to rule out permission issues.

JM

attached mail follows:


Ndagi Mutiri wrote:
> Hello,

I can't be of any help here but couldn't help noticing
that th OP (Ndagi) is dealing with dutch language DB entities and
comments/output in french and code (vars etc) in english ....

bet that can be a PITA :-)

>
> Trying to read a binary file in MySQL database, i have the following error :
>
> Warning: fopen(./) [function.fopen]: failed to open stream: Permission denied in d:\...\download.php on line 57
>
> This is line 57 $file_handle = fopen("./" . $file_name, "r");
>
> and my function
>
> function db_download_file($dbname, $file, $idreunion) {
> //Sélectionne la base de données
> mysql_select_db($dbname);
>
> //Requête SQL
> $select = "SELECT " . $file . " FROM inter_vertaaldienst WHERE id_reunion = '" . $idreunion . "'";
>
> //Exécution de la requête
> $file_records = mysql_query($select);
>
> //En cas d'erreur, on affiche un message
> if (!$file_records){echo('<p>Erreur :' . mysql_error().'<p>');}
> //Autrement, on affiche le fichier
> else{
> if($file_record = mysql_fetch_array($file_records)){
> $file_handle = fopen("./" . $file_name, "r");
> $file_bytes = $file_record[0];
> fwrite($file_handle, $file_bytes, strlen($file_bytes));
> $return_value = "./" . $file_name;
> }
> }
> return($return_value);
> }
>
> Thank for your help.
> Ndagi
>

attached mail follows:


Petr Smith wrote:
> but it encloses it to CDATA section automatically like this:
>
> <script type="text/javascript"
> language="Javascript"><![CDATA[alert('ddd');]]></script>
>
> but I need it like this (because otherwise the javascript don't work):
>
> <script type="text/javascript" language="Javascript">
> //<![CDATA[
> alert('ddd');
> //]]>
> </script>

First, script was using some bogus method names.
Secondly, you try to do anything like the following (which do work)?

$html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n".
" \n".
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"
lang=\"en\">\n".
"<head>\n" .
" <script type=\"text/javascript\" language=\"Javascript\" />\n" .
         "</head>\n" .
         "<body>hello\n" .
         "</body>\n" .
         "</html>";
$dom = new DomDocument();
$dom->preserveWhiteSpace = true;
$dom->loadXML($html);
$params = $dom->getElementsByTagName('script');
foreach ($params as $param) {
     $dat = $dom->createTextNode("\n//");
     $param->appendChild($dat);
     $dat = $dom->createCDATASection("\n\nalert('ddd');\n\n//");
     $param->appendChild($dat);
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
}
echo $dom->saveXML();

Could also do it using <!-- --> through a comment node (following adds
some linefeeds too):
foreach ($params as $param) {
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
     $dat = $dom->createComment("\n\nalert('ddd');\n\n");
     $param->appendChild($dat);
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
}

attached mail follows:


Petr Smith wrote:
> but it encloses it to CDATA section automatically like this:
>
> <script type="text/javascript"
> language="Javascript"><![CDATA[alert('ddd');]]></script>
>
> but I need it like this (because otherwise the javascript don't work):
>
> <script type="text/javascript" language="Javascript">
> //<![CDATA[
> alert('ddd');
> //]]>
> </script>

First, script was using some bogus method names.
Secondly, you try to do anything like the following (which do work)?

$html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n".
" \n".
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"
lang=\"en\">\n".
"<head>\n" .
" <script type=\"text/javascript\" language=\"Javascript\" />\n" .
         "</head>\n" .
         "<body>hello\n" .
         "</body>\n" .
         "</html>";
$dom = new DomDocument();
$dom->preserveWhiteSpace = true;
$dom->loadXML($html);
$params = $dom->getElementsByTagName('script');
foreach ($params as $param) {
     $dat = $dom->createTextNode("\n//");
     $param->appendChild($dat);
     $dat = $dom->createCDATASection("\n\nalert('ddd');\n\n//");
     $param->appendChild($dat);
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
}
echo $dom->saveXML();

Could also do it using <!-- --> through a comment node (following adds
some linefeeds too):
foreach ($params as $param) {
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
     $dat = $dom->createComment("\n\nalert('ddd');\n\n");
     $param->appendChild($dat);
     $dat = $dom->createTextNode("\n");
     $param->appendChild($dat);
}

attached mail follows:


Thanks a lot Rob, it's so simple! I don't know why I did't find it myself.

Petr

Rob wrote:
> Petr Smith wrote:
>
>> but it encloses it to CDATA section automatically like this:
>>
>> <script type="text/javascript"
>> language="Javascript"><![CDATA[alert('ddd');]]></script>
>>
>> but I need it like this (because otherwise the javascript don't work):
>>
>> <script type="text/javascript" language="Javascript">
>> //<![CDATA[
>> alert('ddd');
>> //]]>
>> </script>
>
>
> First, script was using some bogus method names.
> Secondly, you try to do anything like the following (which do work)?
>
> $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
> \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n".
> " \n".
> "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"
> lang=\"en\">\n".
> "<head>\n" .
> " <script type=\"text/javascript\" language=\"Javascript\" />\n" .
> "</head>\n" .
> "<body>hello\n" .
> "</body>\n" .
> "</html>";
> $dom = new DomDocument();
> $dom->preserveWhiteSpace = true;
> $dom->loadXML($html);
> $params = $dom->getElementsByTagName('script');
> foreach ($params as $param) {
> $dat = $dom->createTextNode("\n//");
> $param->appendChild($dat);
> $dat = $dom->createCDATASection("\n\nalert('ddd');\n\n//");
> $param->appendChild($dat);
> $dat = $dom->createTextNode("\n");
> $param->appendChild($dat);
> }
> echo $dom->saveXML();
>
> Could also do it using <!-- --> through a comment node (following adds
> some linefeeds too):
> foreach ($params as $param) {
> $dat = $dom->createTextNode("\n");
> $param->appendChild($dat);
> $dat = $dom->createComment("\n\nalert('ddd');\n\n");
> $param->appendChild($dat);
> $dat = $dom->createTextNode("\n");
> $param->appendChild($dat);
> }

attached mail follows:


:(

Its not working

$bytes = readfile($filename);
if ($bytes === false){
  //error-handling code
}

There is not any output ?

Richard Lynch wrote:

>On Fri, October 14, 2005 6:29 am, Ruben Rubio Rey wrote:
>
>
>> if(file_exists($filename)){
>> $modified_date=filemtime($filename);
>> if(time()<($modified_date+1 * 24 * 60 * 60)){
>> $handle = fopen($filename, "r");
>> $contents = fread($handle, filesize($filename));
>> fclose($handle);
>> echo $contents;
>> }
>> }
>>
>>
>
>Checking both file_exists and then doing fopen seems a bit silly.
>
>Trap the error from fopen, and just use that as your file_exists test.
>
>I suspect http://php.net/file_get_contents will be SLIGHTLY faster
>than doing all of this code, though:
>
>if (filemtime($filename) > time()) $contents =
>file_get_contents($filename);
>if ($contents === false){
> //error-handling code
>}
>else{
> echo $contents;
>}
>
>Then, of course, we have to wonder if you NEED $contents for later use
>in the script.
>
>If not, something like this will clock in better:
>
>$bytes = readfile($filename);
>if ($bytes === false){
> //error-handling code
>}
>
>The difference here is that you don't even stuff the file into the PHP
>string. It's all read and passed out to stdout in low-level internal
>PHP C code, and the data never needs to hit "PHP" variables which are
>"more expensive" to setup and maintain.
>
>Note that which is REALLY fastest will probably depend on the size of
>the files, your OS system cache, your hardware, and maybe which
>version of PHP you are using, if the underlying functions changed.
>
>Must be nice to be worried about 0.0x milliseconds -- I'm fighting a
>mystery 3.0 seconds in a data feed for a search engine myself :-)
>
>
>

attached mail follows:


W odpowiedzi na maila (21:21 - 18 pa¼dziernika 2005):

> $im = imagecreatetruecolor ( 140, 140 );
> $bg = imagecolorallocate ( $im, 255, 255, 255 );
> $orgimg = imagecreatefromjpeg ( $image_data['image'] );

> imagecopyresampled ( $im, $orgimg, $thumb_x_offset, $thumb_y_offset, 0,
> 0, $new_thumb_x, $new_thumb_y, $image_data['image_x'],
> $image_data['image_y'] );

try to add imagefill($im, 0, 0, $bg); after defining $bg ... (line 2?)

--
pozdrawiam
£ukasz "nostra" Wojciechowski
gg.1028640 * icq.23059512

attached mail follows:


 Hi all,

I'm currently setting up a php site to control my Active Direcory, and I'm struggling with the "Accountexpire" field.

After extending the expiration date, I can't set it back in AD, because it is in scientific format (1.2774158851E+017). And I can't find how to transform this into an integer before making the AD request !

I've tried inval, double, sprintf, ... without success ! I event tried to use a string: $ADtime = ($PHPtime + 11644524000)."0000000", with no luck... I'm suspecting something inside the ldap_mod_replace function, but can't be sure

Here's what my code looks like:

            $PHPtime = time();

            $newExpiration = $PHPtime + (7 * 24 * 60 * 60); //add 1 week (7 days * 24 hours * 60 minutes * 60 seconds)
            $ADtime = ($PHPtime + 11644524000) * 10000000 ;
                  
            $userdata["accountexpires"] = $ADtime;
            $result = ldap_mod_replace($ad, $myaccount->dn, $userdata);

Any idea how to fix this ?

thanks a lot,

                
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !

attached mail follows:


> the script always says it was sucessful to upload the file, but the
destination
> directory was always empty...
> even when checking the $_FILES global
>
> $_FILES['var_name']['tmp_name'] and
> $_FILES['var_name']['name'] and
> $_FILES['var_name']['size'], the vars alwyas return empty values...
>
> is there any issue with php5 about files uploads ?

I have it working on Windows, Apache, PHP5

A few checks you could make:

Are you sure that var_name is the name of the file upload field in your
form?
Have you set the form enctype to "multipart/form-data"?
Have you set the maxfilesize attribute, and does the file you are trying to
upload exceed that size?

Good luck

Mark

attached mail follows:


Hi,

I'm looking for some help with reading freely available news files like
this: news://newsclip.ap.org/NY16310182138news.ap.org
<news://newsclip.ap.org/NY16310182138news.ap.org%22/%3E%3C/media>.
I'm able to connect to the newsgroup with the IMAP functions just file,
but this type of news url can be placed in a browser like mozilla and
the message will be pulled, so i'm thinking it should be much easier
than that. Has anyone ever pulled a news url like this with php and
parsed it? If so, what functions were you using?

Thanks in advance,

Steve

attached mail follows:


Hi guys,

I need some help with the imap_body function and how to work with the
string that this function returns...

Im working on a mailing list archive website and i'm using the imap_*
functions to handle this, the header works fine (and other things too)
but the Body of the message dont work as expected. It came as one-line
string, the "\n" character (or <br> in html) is simple ignored. I dont
know how to make the function translate the "\n" to <br>.

You can understand better what i'm saying looking:

http://www.brunogola.com.br/testeimap.php

Look the main page and try to read any message... I dont know what can i
do to fix it...

Thanks for any help and sorry any mistakes about my english...

Bruno Gola