php-general Digest 3 Jul 2009 03:27:48 -0000 Issue 6208
Topics (messages 294828 through 294840):
Re: Dom PDF Problem
294828 by: Paul M Foster
generally, where in cPanel can one set the default page to load?
294829 by: Govinda
294830 by: Daniel Brown
294831 by: Michael A. Peters
294833 by: Govinda
294834 by: Daniel Brown
294838 by: Govinda
namespace keyword
294832 by: Martin Scotta
294835 by: Greg Beaver
Implode a 2D Array
294836 by: salmarayan
294837 by: Shawn McKenzie
Re: cannot figure out permissions for fopen/fwrite
294839 by: Waynn Lue
Sessions
294840 by: Jason Carson
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Thu, Jul 02, 2009 at 04:29:01PM +0530, Pravinc wrote:
> Hey all,
>
> I am working with generating PDF using Dom PDF.
>
> My problem is when I generate a single PDF , Its working fine.
>
> But when I code it in a loop for generating more than one PDF it gives some
> error.
>
> $DomObj = new DOMPDF();
>
> $DomObj->load_html_file($pth);
>
> $DomObj->render();
>
> $pdf = $DomObj->output();
>
> file_put_contents($MainDir."/Order-".$rsOrder[$ro]['OrderNumber']."/packing_
> slip.pdf", $pdf);
>
> the above code is in a loop
>
> I come to know that ,there is problem with memory leak.
>
> Also I thought that it was because I had not destroy the previously created
> Object.
>
> So I also tried destroying it using unset.. I don't know whether its
> destroying or not.
>
> Error is something like
>
> "Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No
> block-level parent found. Not good.' in
> D:\foldername\project\control\dompdf\include\inline_positioner.cls.php:68
> Stack trace: #0 D:\foldername\ project
> \control\dompdf\include\frame_decorator.cls.php(381):
> Inline_Positioner->position() #1 D:\foldername\ project
> \control\dompdf\include\inline_frame_reflower.cls.php(56):
> Frame_Decorator->position(".........
>
> Can anyone please give me some way to solve this.
>
I had an error something like this when using FPDF. It would hack up the
second PDF. I didn't investigate it a lot, but my solution was to
instantiate the class *once*, and loop on the *rest* of it.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
Dear list-members
I am using what I assume is a pretty standard cPanel setup (?)
I would like to be able change the mime types/extension so that
".html" gets sent through the PHP interpreter, but I see the cPanel
docs say "...(note that you can not alter the system defined mime type
values)..".
So as a workaround, I need to *at least* be able to change the default
file to return to the browser when someone hits my domain (or a
subdirectory) without specifying the page in that dir/ to load.
I cannot find where in cPanel to set that. The default now is the
standard "index.html". I want to change it to "index.php".
I realize this is really basic stuff, but I can't find it in my cPanel.
Can someone point me to this?
-Govinda
--- End Message ---
--- Begin Message ---
On Thu, Jul 2, 2009 at 12:40, Govinda<govinda.webdnat...@gmail.com> wrote:
>
> Can someone point me to this?
Wrong list. ;-P
In fact, check Google for .htaccess MIME aliasing. It's nothing
to do with PHP, nor cPanel, really.
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!
--- End Message ---
--- Begin Message ---
Govinda wrote:
Dear list-members
I am using what I assume is a pretty standard cPanel setup (?)
I would like to be able change the mime types/extension so that ".html"
gets sent through the PHP interpreter, but I see the cPanel docs say
"...(note that you can not alter the system defined mime type values)..".
So as a workaround, I need to *at least* be able to change the default
file to return to the browser when someone hits my domain (or a
subdirectory) without specifying the page in that dir/ to load.
I cannot find where in cPanel to set that. The default now is the
standard "index.html". I want to change it to "index.php".
I realize this is really basic stuff, but I can't find it in my cPanel.
Can someone point me to this?
-Govinda
If you have mod_rewrite installed - put the following in your .htaccess
file:
RewriteEngine on
RewriteRule ^index\.html$ index.php [L]
That will cause index.php to be called when index.html is requested.
If you want it to forward to index.php then use [R] instead of [L]
If you want all .html to be sent to php equivalents -
RewriteRule (^.*)\.html$ $1.php [L]
should do the trick.
btw - with those rules, the .html files do not need to exist. If/when
they are requested, whether they exist or not, the link or redirect is made.
mod_rewrite rocks
--- End Message ---
--- Begin Message ---
If you have mod_rewrite installed - put the following in
your .htaccess file:
RewriteEngine on
RewriteRule ^index\.html$ index.php [L]
That will cause index.php to be called when index.html is requested.
If you want it to forward to index.php then use [R] instead of [L]
If you want all .html to be sent to php equivalents -
RewriteRule (^.*)\.html$ $1.php [L]
should do the trick.
btw - with those rules, the .html files do not need to exist. If/
when they are requested, whether they exist or not, the link or
redirect is made.
mod_rewrite rocks
Thanks to you both Michael & Dan,
I must not have mod-rewrite installed (I am 98% uneducated about
apache/server admin).
I will save your post though MIchael, for when I get more to that
level.. you gave a good lead.
Meanwhile, Dan you gave me the quick fix lead I was after.
DirectoryIndex index.php
works.
Found it at
http://httpd.apache.org/docs/1.3/mod/mod_dir.html#directoryindex
-G
--- End Message ---
--- Begin Message ---
On Thu, Jul 2, 2009 at 13:38, Govinda<govinda.webdnat...@gmail.com> wrote:
>
> I must not have mod-rewrite installed (I am 98% uneducated about
> apache/server admin).
> I will save your post though MIchael, for when I get more to that level..
> you gave a good lead.
You've got mod_rewrite on there. If you're getting an error of
some kind, you can let me know privately again. (Sorry to keep
sending you back and forth!)
> Meanwhile, Dan you gave me the quick fix lead I was after.
> DirectoryIndex index.php
> works.
> Found it at
> http://httpd.apache.org/docs/1.3/mod/mod_dir.html#directoryindex
--
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Ask me about our fully-managed servers and proactive management
clusters starting at just $200/mo.!
--- End Message ---
--- Begin Message ---
On Jul 2, 2009, at 11:40 AM, Daniel Brown wrote:
On Thu, Jul 2, 2009 at 13:38, Govinda<govinda.webdnat...@gmail.com>
wrote:
I must not have mod-rewrite installed (I am 98% uneducated about
apache/server admin).
I will save your post though MIchael, for when I get more to that
level..
you gave a good lead.
You've got mod_rewrite on there. If you're getting an error of
some kind, you can let me know privately again. (Sorry to keep
sending you back and forth!)
my error.
sorry/thanks!
-G
--- End Message ---
--- Begin Message ---
Hil all
I'm a 5.2.0 user (WINXP)
I have a class like this...
Class IsThisBad
{
const NAMESPACE = 'something';
/* code */
function __construct( $other=self::NAMESPACE )
{
/* do stuff */
}
}
Recently the version 5.3 was released, so... should I change the const
"NAMESPACE" in the class? Is it a reserved word?
--
Martin Scotta
--- End Message ---
--- Begin Message ---
Martin Scotta wrote:
> Hil all
>
> I'm a 5.2.0 user (WINXP)
> I have a class like this...
>
> Class IsThisBad
> {
> const NAMESPACE = 'something';
> /* code */
> function __construct( $other=self::NAMESPACE )
> {
> /* do stuff */
> }
> }
>
> Recently the version 5.3 was released, so... should I change the const
> "NAMESPACE" in the class? Is it a reserved word?
Yes.
Greg
--- End Message ---
--- Begin Message ---
Can any one tell me how can i implode a two D Array.
i can implode normal arrays, but when i try to implode multidimensional
Arrays, the result is empty.
can some one tell me how to implode an array Like This
$x=array ( [0] => array ( [side] => sell [stock_code] => AFMC.CA [quantity]
=> 200 ) ,
[1] => array ( [side] => buy [stock_code] => AFMC.CA [quantity] => 200 );
i want to implode it in a way, the later one i can seperate rows, meaning i
can seperate [0] from [1] and the elements in each row, like the side stock
code using the SPLIT function.
Thanks in Advance. :)
--
View this message in context:
http://www.nabble.com/Implode-a-2D-Array-tp24313886p24313886.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
salmarayan wrote:
> Can any one tell me how can i implode a two D Array.
> i can implode normal arrays, but when i try to implode multidimensional
> Arrays, the result is empty.
> can some one tell me how to implode an array Like This
>
>
> $x=array ( [0] => array ( [side] => sell [stock_code] => AFMC.CA [quantity]
> => 200 ) ,
> [1] => array ( [side] => buy [stock_code] => AFMC.CA [quantity] => 200 );
>
> i want to implode it in a way, the later one i can seperate rows, meaning i
> can seperate [0] from [1] and the elements in each row, like the side stock
> code using the SPLIT function.
> Thanks in Advance. :)
You'll have to be more specific in what you want the end result to be
becuse I'm confused. You already have 0 and 1 separated. How do you
want to glue them? Maybe you don't really want to implode() them? If you
really want to implode each one, then:
foreach($x as $array) {
$row[] = implode(',', $array);
}
Or maybe (not tested):
$rows = array_map('implode', array_fill(0, count($x), ','), $x);
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
The tmp folder isn't accessible from the web though, right? Someone
would first have to get access to your server for that.
On 7/1/09, Mari Masuda <mbmas...@stanford.edu> wrote:
>
> On Jul 1, 2009, at 12:54, Shawn McKenzie wrote:
>
>> Mari Masuda wrote:
>>> On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:
>>>
>>>> Shawn McKenzie wrote:
>>>>> Mari Masuda wrote:
>>>>>> Hello,
>>>>>>
>>>>>> This is probably a dumb newbie question. I am running PHP
>>>>>> 5.2.5 and
>>>>>> Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and
>>>>>> Apache
>>>>>> from source a while ago (as opposed to using the built-in web
>>>>>> server
>>>>>> that is included w/ Mac OS X). I have written the below PHP whose
>>>>>> purpose is to read an existing comma separated (CSV) file and
>>>>>> save the
>>>>>> data into a text file that I can later copy and paste from into my
>>>>>> website content management system. The problem is that on my
>>>>>> Mac, I
>>>>>> cannot seem to figure out what permissions I need to set in
>>>>>> order to
>>>>>> make the input CSV and the initially non-existant output text file
>>>>>> readable and writable by Apache/PHP. I have Googled and come
>>>>>> across
>>>>>> many pages about different ways to set permissions and different
>>>>>> permissions to set but none of the ways suggested that I tried
>>>>>> seemed to
>>>>>> work for me. As a temporary solution, I uploaded my PHP file to a
>>>>>> Windows 2003 server running Apache and PHP and it worked
>>>>>> flawlessly
>>>>>> (and
>>>>>> makes me suspicious that there is some huge security hole with the
>>>>>> Windows box since it was able to execute with no permissions
>>>>>> modifications). Any tips would be greatly appreciated. Thanks!
>>>>>>
>>>>>> Mari
>>>>>>
>>>>>> --- start my code ---
>>>>>> <?php
>>>>>>
>>>>>> $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r");
>>>>>> $out =
>>>>>> fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt",
>>>>>> "w");
>>>>>> $counter = 0;
>>>>>>
>>>>>>
>>>>>> fwrite($out, "<table>\n");
>>>>>>
>>>>>> while(($data = fgetcsv($in)) !== FALSE) {
>>>>>> $paperNumber = $data[0];
>>>>>> $authors = $data[1];
>>>>>> $title = $data[2];
>>>>>> $filename = $paperNumber . ".pdf";
>>>>>>
>>>>>> if(($counter % 2) == 0) {
>>>>>> fwrite($out, "<tr>\n");
>>>>>> } else {
>>>>>> fwrite($out, "<tr style=\"background: #cccccc;\">\n");
>>>>>> }
>>>>>>
>>>>>> fwrite($out, "<td><a
>>>>>> href=\"http://www.example.com/workingpapers/getWorkingPaper.php?
>>>>>> filename=$filename\">$paperNumber</a></td>\n");
>>>>>>
>>>>>>
>>>>>> fwrite($out, "<td>$authors</td>\n");
>>>>>> fwrite($out, "<td>$title</td>\n");
>>>>>> fwrite($out, "</tr>\n");
>>>>>>
>>>>>> $counter++;
>>>>>> }
>>>>>>
>>>>>> fwrite($out, "</table>\n");
>>>>>>
>>>>>>
>>>>>> fclose($in);
>>>>>> fclose($out);
>>>>>>
>>>>>> ?>
>>>>>> --- end my code ---
>>>>>
>>>>> What are the permissions on /Applications/apache/htdocs/wp-php/ ?
>>>>>
>>>>> Apache needs write permissions on that dir in order to create
>>>>> the file
>>>>> tableToCutAndPaste.txt.
>>>>>
>>>>> It's probably not a secure idea to give write permissions to
>>>>> that dir,
>>>>> so maybe create a subdir of tmp and change those permissions
>>>>> (one way):
>>>>>
>>>>> mkdir /Applications/apache/htdocs/wp-php/tmp
>>>>> chmod a+w /Applications/apache/htdocs/wp-php/tmp
>>>>>
>>>>
>>>> Also, turn on error reporting so that you can see the exact
>>>> problem. It
>>>> may not be what you think.
>>>>
>>>> --
>>>> Thanks!
>>>> -Shawn
>>>> http://www.spidean.com
>>>
>>>
>>> Thanks for the suggestions. I added the following lines to the
>>> very top
>>> of my code:
>>>
>>> error_reporting(E_ALL);
>>>
>>> mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
>>> chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");
>>>
>>> and I also changed the line where it tries to open the file to
>>> write to
>>> to go to the new directory:
>>>
>>> $out =
>>> fopen("/Applications/apache/htdocs/wp-php/tmp/
>>> tableToCutAndPaste.txt",
>>> "w");
>>>
>>> Below are the errors I got:
>>> --- start errors ---
>>> Warning: mkdir() [function.mkdir]: Permission denied in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 5
>>>
>>> Warning: chmod() [function.chmod]: No such file or directory in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 6
>>>
>>> Warning:
>>> fopen(/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt)
>>> [function.fopen]: failed to open stream: No such file or directory in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 9
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 13
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 22
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 27
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 28
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 29
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 30
>>>
>>> Warning: fwrite(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 35
>>>
>>> Warning: fclose(): supplied argument is not a valid stream
>>> resource in
>>> /Applications/apache/htdocs/wp-php/generateTable.php on line 39
>>> --- end errors ---
>>>
>>> The permissions are as follows (sorry I didn't think to include
>>> them in
>>> my original message):
>>>
>>> [Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/wp-php/
>>> total 64
>>> drwxr-xr-x 5 mari admin 170 Jun 29 16:47 .
>>> drwxr-xr-x 24 mari admin 816 Jun 29 16:47 ..
>>> -rw-r--r-- 1 mari admin 6148 Jun 28 21:11 .DS_Store
>>> -rwxr--r-- 1 mari admin 827 Jul 1 12:26 generateTable.php
>>> -rwxr--r-- 1 mari admin 17532 Jun 28 20:53 wp.csv
>>> [Wed Jul 01 12:29:01] ~:
>>>
>>> Thank you,
>>> Mari
>>
>> That's because the apache user doesn't have permissions to create the
>> dir or change the permissions. The commands I gave you need to be run
>> from the command line.
>>
>> --
>> Thanks!
>> -Shawn
>> http://www.spidean.com
>
> Oh, duh, thank you. Doing it on the command line like you said
> worked great. I also had to edit my .csv file in TextWrangler to
> change the line breaks from \r to \r\n before it would work.
> Although the Mac's built-in firewall is set to block incoming traffic
> except for network time and something installed by Adobe when I
> installed CS4, I was wondering about the security of this technique
> if done on a production server. I only run this script by pointing
> my browser to http://localhost/wp-php/generateTable.php and I think
> with my firewall settings nobody else would be able to execute this
> script, but it seems if the tmp folder is set to world writable on a
> production server that anybody might be able to somehow upload a
> malicious file if they knew the location of tmp. Any thoughts? Thanks!
>
> Mari
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hello all,
Do I have to add session_start() at the beginning of every page so that
the $_SESSION variables work on all pages or do I use session_start() on
the first page and something else on other pages?
Thanks
--- End Message ---