Re: [PHP] PHP Source code protection

2008-02-08 Thread Per Jessen
Greg Donald wrote:

> Deductive reasoning leads to two possible options:
> 
> 1) Don't give the code to anyone.
> 2) Give the code to the client and accept the fact that it may get
> pirated.

Yep, that's all there is to it.  


/Per Jessen, Zürich

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



Re: [PHP] PHP Source code protection

2008-02-08 Thread Per Jessen
Casey wrote:

> 
> Why not just translate it to C#?

Personally I'd just go for C - that way I can just distribute a binary
and be done with it.  No runtime, no JVM, no mono etc. 


/Per Jessen, Zürich

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



Re: [PHP] Re: Recommended ORM for PHP

2008-02-08 Thread Zoltán Németh
2008. 02. 7, csütörtök keltezéssel 13.15-kor Manuel Lemos ezt írta:
> Hello
> 
> on 02/07/2008 07:26 AM Zoltán Németh said the following:
> >>> When creating a LAMP app, I always start by writing ORM myself.
> >>> It's fun but it usually takes a  long time.
> >>> Besides, that always results in a toy-system,
> >>> I mean, that has not so many features, not so efficient non-bug-free.
> >>>
> >>> I started to think that now is the time  to throw away my rubbish
> >>> and use more effective Open source ORM.
> >>>
> >>> So my  question is what ORM are you using?
> >>> What ORM do you recommend?
> >>> There're lots of Web app frameworks out there
> >>> but I could't find simple ORM in PHP.
> >> A similar question was asked here a couple of days ago.
> >>
> >> I will be repeating myself, but what I said was that I use Metatsorage
> >> which is an ORM class generator tool. It is a different approach than
> >> others you may find. It generates persistent object classes that are
> >> smaller and more efficient.
> > 
> > that's exactly the same method all the ORMs we mentioned earlier
> > (Doctrine, Propel, Qcodo) work. all these generate classes. ;P
> > 
> > aside from that, metastorage might be as good as any of the others of
> > course
> 
> I don't know about Doctrine and QCodo, but once I looked at Propel and
> the way it works was not exactly better than Metastorage generated
> classes from my point of view.
> 
> What happens is that Propel relies on fat base classes that the
> generated persistent object classes need to inherit to do the actual
> Object-relational mapping.
> 
> Metastorage generates self-contained code. This means the generated
> classes are root classes that do only what you need. The generated code
> does the necessary database calls directly to store and retrieve objects.
> 
> It does not call base classes like Propel generated classes that waste
> time composing SQL queries at run-time. Metastorage generated classes
> already have the necessary SQL built-in to execute the queries without
> further analysis at run-time.
> 
> Another aspect is that Metastorage features what is called report
> classes. These are classes that perform queries that you define and
> generates SQL and PHP at compile time to retrieve data from the
> persistent objects for read-only purposes.

and what if you want to switch sql server from mysql to oracle or
whatever? in propel, you change 1 line in the config, you don't have to
regenerate or rewrite anything.

the base classes are useful too because if you change your schema, you
simply regenerate them and all your extensions remain the same in the
child classes.

> 
> For instance, if you want to send a newsletter to a million subscribers
> and you just need the e-mail address and names of the subscribers, you
> can tell Metastorage to generate a report class that queries the users
> objects and retrives just the name and e-mail address. The report
> classes return arrays just like plain SELECT queries.
> 
> If you use the Propel approach you would need to retrieve 1 million
> objects of the users class just to pick the name and e-mail address,
> which is totally inefficient in terms of memory and very slow.

not at all. you can build the criteria for the select and then run a
doSelectRS method which gives you only the result set in an array, no
objects involved.

> 
> There are more differences between Metastorage and Propel (and probably
> others approach). I just wanted to make the point that the fact that
> approaches use generated code, it does not mean that all provide the
> same efficiency.

yeah, sure. however there is a payoff between efficiency and portability
and maintainability, and of course not all these orms have the same
level of these. choose the one that fits your needs best.

> 
> If you are interested about more differences in the approaches, you may
> check the Metastorage documentaion:
> 
> http://www.metastorage.net/
> 

sure, I'll check it out when I have some free time

greets
Zoltán Németh

> -- 
> 
> Regards,
> Manuel Lemos
> 
> PHP professionals looking for PHP jobs
> http://www.phpclasses.org/professionals/
> 
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
> 

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



Re: [PHP] Profiling with register_tick_function / declare

2008-02-08 Thread Jochem Maas

Daniel Brown schreef:

On Feb 7, 2008 7:10 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:

McNaught, Scott schreef:

. Get profile results for novices without having to mess around
installing php binaries such as APD / zend debugger etc

I suppose that includes xdebug?


If xdebug works as a local binary (which it may, I'm not sure),
you'd still have to have a local php.ini and be allowed to override
the server php.ini by configuration, no?

What if both of the above are true, but a user has no permissions
to compile?

While I was going to point out this morning that he failed to
mention xdebug (which is my personal favorite), I still wouldn't
discount his script-based profiler, if he can get it to work.  Imagine
being able to drop that into a project on SourceForge.


indeed - I wasn't discounting his idea, if it works it could be very handy
for situtation where you don't have any server access.





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



Re: [PHP] PHP Source code protection

2008-02-08 Thread Richard Heyes

> accept the fact that it may get pirated.

It may do. But there's nothing wrong with making it as hard as possible 
to do so. Most people have better things to do than try to reverse 
engineer a piece of code.


Consider:

1. People who buy code will generally do so to solve a problem that they
   have in the process of making money.
2. Reverse engineering takes time, and therefore diverts their attention
   away from the process of making money.


--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

 ** New Helpdesk demo now available **

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen


On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen &
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user to
save to local disk.


Yes - have a link like this:

Get XLS file

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"filename\"");

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the parameters 
is mysql statement and it's very long. i don't think a good idea to pass 
this in the url. also, the page that i'm working on is a search page, 
therefore the mysql statement is very complicate and long.  that's why i 
don't want to pass via url.


is there way to do within this page???

t. hiep

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 10:25 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> On Feb 8, 2008, at 10:14 AM, tedd wrote:
>
> > Hi gang:
> >
> > From a variable with the name of $this_variable -- how do I get a
> > string 'this_variable' ?
>
>
> Hey tedd,
>
> What is the end result you want? for debugging and checking variable
> contents, I've simply: echo "this_variable = $this_variable";
>
> But that was just for debugging, in a large environment, it could be
> quite tedious to type all that out...


What Tedd means is this:  ;-P

 $v) {
if($v === $new) {
$vname = $p;
}
}
$var = $old;
return $vname;
}
?>


-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen

On Fri, 8 Feb 2008, Jason Pruim wrote:



On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:



On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen &
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user to
save to local disk.


Yes - have a link like this:

Get XLS file

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"filename\"");

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the parameters is 
mysql statement and it's very long. i don't think a good idea to pass this 
in the url. also, the page that i'm working on is a search page, therefore 
the mysql statement is very complicate and long.  that's why i don't want 
to pass via url.


is there way to do within this page???



I have actually done what you are looking for... Here is how I do it:

On the search page, write the search phrase into a session variable so you 
can access it from another page and then run this code:




What that does is it writes the current search pattern into an excel file 
called Export.xls and downloads it to your harddrive. I am in the process of 
re-writing it to work as a function, but have had mixed results so far. I'm 
learning functions right now :)


If you know functions, and want to take a stab at re-writing it, I can 
provide you with the code I have so far :)



thank you for the suggestion, but here is another problem that i try to 
avoid saving mysql statement to query from the table again.


let say that user searched and found 10 records,
in the meantime, other users may change any of these 10 records,
so if we saved mysql statement and re-run mysql statement again, the 
result might be different.  to prevent this problem, i only want to 
download records that returned on this page only.


thanks,
t. hiep

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Andrew Ballard
On Feb 8, 2008 10:14 AM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
>
> On Fri, 8 Feb 2008, Per Jessen wrote:
>
> > Hiep Nguyen wrote:
> >
> >> is there anyway to generate this into xls file w/o using fopen &
> >> fwrite to the server?  my goal is to have a link after the table and
> >> user can click on that link and a save window pop up to allow user to
> >> save to local disk.
> >
> > Yes - have a link like this:
> >
> > Get XLS file
> >
> > in yourscript.php, you evaluate the parameters given and build the XSL
> > file as output:
> >
> > header("Content-Type: application/excel");
> > header("Content-Disposition: attachment; filename=\"filename\"");
> >
> > print
> > .
> > .
> > .
> > .
> > .
> >
> >
> > done.
>
> i already got this method, but the problem that i have is the parameters
> is mysql statement and it's very long. i don't think a good idea to pass
> this in the url. also, the page that i'm working on is a search page,
> therefore the mysql statement is very complicate and long.  that's why i
> don't want to pass via url.
>
> is there way to do within this page???
>
> t. hiep
>
>

How are you passing the parameters to THIS page? The solution Per
presented would either require the same parameter list as the current
page (if going to a URL dedicated to sending the output in the format
you are using for the xls) or one additional parameter to the current
page if you the current page is written to vary the style of the
output based on that parameter's value.

Andrew

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Eric Butera
On Feb 8, 2008 10:14 AM, tedd <[EMAIL PROTECTED]> wrote:
> Hi gang:
>
>  From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

There really isn't a way to do this.  Maybe you could do some
get_defined_vars hackery, but that really isn't practical.

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 8:41 AM, Hiep Nguyen <[EMAIL PROTECTED]> wrote:
> hi friends,
>
> i have a php page with the following logic:
>
> 
> 
> Download
> 
> 
>Title>Author
> null"; ?>
>
>

Hiep,

You should also put all of the code you can into one block.  Each
time you  it will take longer to load.  Not
noticeably on a single page with one user accessing it, but with full
sites and many simultaneous users, it will be noticeable.  This is
because PHP is "stepping in and out" of parse mode.  So simply
concatenate that code as follows:

Title>Author
".$row[0]."".$row[1];."\n";
}
?>
Download Into Excel File
-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Per Jessen
Hiep Nguyen wrote:

> is there anyway to generate this into xls file w/o using fopen &
> fwrite to the server?  my goal is to have a link after the table and
> user can click on that link and a save window pop up to allow user to
> save to local disk.

Yes - have a link like this:

Get XLS file

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"filename\"");

print 
.
.
.
.
.


done.


/Per Jessen, Zürich

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



Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta:
> On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote:
> > I think I may have written the question wrong. I only want to display the
> > first line. It is a news story with a headline. I only want to display the
> > headline in the link.
> >
> > The output I want is:
> >
> > The
> >
> > But I am getting:
> >
> > The file looks like this.
> >
> > Does that make more sense?
> 
>  $handle = fopen($filename);
> $data = fgets($handle);
> echo $data."\n";
> ?>
> 
> So long as you don't do a while() loop or something similar,
> fgets() will only read the first line.

sure, and much more efficient than my last letter, so ignore that...
its friday, and late, and I'm still at work, so my mind is not on the
top now... :)

greets
Zoltán Németh

> 

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



Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote:
> I think I may have written the question wrong. I only want to display the
> first line. It is a news story with a headline. I only want to display the
> headline in the link.
>
> The output I want is:
>
> The
>
> But I am getting:
>
> The file looks like this.
>
> Does that make more sense?



So long as you don't do a while() loop or something similar,
fgets() will only read the first line.

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] Name of variable to string

2008-02-08 Thread Adrian Bruce

tedd wrote:

Hi gang:

From a variable with the name of $this_variable -- how do I get a 
string 'this_variable' ?


Cheers,

tedd
At some point or the other you will have to define $this_variable as 
$this_variable, so at that point you will have access to the string 
'this_variable'.  Even if you define it using variable vairables or 
within or for each loop (e.g. get_definied_vars, $_POST) you will have 
an oppertunity to get the 'this_variable' string.






Ade

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Adrian Bruce

Hiep Nguyen wrote:

hi friends,

i have a php page with the following logic:



Download


  Title>Author
  author != null"; ?>

  
  
  
  
  Download Into Excel File




is there anyway to generate this into xls file w/o using fopen & 
fwrite to the server?  my goal is to have a link after the table and 
user can click on that link and a save window pop up to allow user to 
save to local disk.


appreciate very much for any input.

t. hiep



Somthing like this works ok, you can further refine it for the purpse 
you want. 




Ade

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



Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:19 PM, Zoltán Németh <[EMAIL PROTECTED]> wrote:
> 2008. 02. 8, péntek keltezéssel 12.17-kor Daniel Brown ezt írta:
> > On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]> wrote:
> > > I think I may have written the question wrong. I only want to display the
> > > first line. It is a news story with a headline. I only want to display the
> > > headline in the link.
> > >
> > > The output I want is:
> > >
> > > The
> > >
> > > But I am getting:
> > >
> > > The file looks like this.
> > >
> > > Does that make more sense?
> >
> >  > $handle = fopen($filename);
> > $data = fgets($handle);
> > echo $data."\n";
> > ?>
> >
> > So long as you don't do a while() loop or something similar,
> > fgets() will only read the first line.
>
> sure, and much more efficient than my last letter, so ignore that...
> its friday, and late, and I'm still at work, so my mind is not on the
> top now... :)

Zoltan, if you're sticking around, zip me a message off-list.  I
have a favor to ask of you.

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 11.11-kor Pastor Steve ezt írta:
> I think I may have written the question wrong. I only want to display
> the first line. It is a news story with a headline. I only want to
> display the headline in the link.
> 
> The output I want is:
> 
> The
> 
> But I am getting:
> 
> The file looks like this.
> 
> Does that make more sense?

in that case why not read the file as an array of lines and display the
first line?
$f = file('whatever.txt');
echo $f[0];

http://hu.php.net/file

greets
Zoltán Németh

> 
> Thanks,
> 
> --
> Steve M.
> 
> on 2/8/08 11:03 AM Zoltán Németh ([EMAIL PROTECTED]) wrote:
> 
> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt
> írta:
> > Is it possible to read each line of data from a file?
> > 
> > I have a text file that has several lines on it. I only want
> to display the
> > first line only.
> > 
> > The 
> > file I have 
> > looks like this.
> > 
> > But outputs:
> > 
> > "The file I have looks like this."
> 
> you need nl2br()
> http://hu.php.net/nl2br
> 
> greets
> Zoltán Németh
> 
> > 
> > Here is my code:
> > 
> >  > 
> > 
> > 
> > $dir = "path/to/files/";
> > 
> > // set pattern
> > $pattern = ".txt*|.TXT*";
> > 
> > // open directory and parse file list
> > if (is_dir($dir))
> > {
> > if ($dh = opendir($dir))
> > {
> > 
> > echo " Roman, Times,
> > serif; font-size: 12px; width: 290px;\">
> >  padding: 3px;\">
> > Breaking News
> > Please check here often for breaking news
> stories.
> > 
> > 
> > 
> > ";
> > 
> > // iterate over file list
> > while (($filename = readdir($dh)) !== false)
> > {
> > // if filename matches search pattern, print it
> > if (ereg($pattern, $filename))
> >if(strpos($filename,'.')>0)
> >
> > //  if ($filename = str_replace('.html','',$filename))
> > 
> > {
> > $fh = fopen($dir . $filename, 'r');
> > $filehead = fread($fh, 72);
> > fclose($fh);
> > echo " > href=\"/breaking_news/$filename\">".$filehead."";
> > }
> > }
> > echo "
> > 
> > ";
> > 
> > // close directory
> > closedir($dh);
> > }
> > }
> > 
> > ?>
> > 
> 
> 

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



Re: [PHP] Passing object reference to session

2008-02-08 Thread Richard Lynch
On Thu, February 7, 2008 1:15 am, Michael Moyle wrote:
> I am new to the list and have a question that inspired me to join the
> list as I can not find any answer online.
>
> When a object reference is passed to the $_SESSION array what happens
> to
> the object? Is the object serialized and saved in session (in this
> case
> file)? Or just the reference with the object in memory remaining on
> the
> heap?

When a PHP script ends, nothing, and I mean nothing, is left on the heap.

The conclusion is left as an exercise for the reader.

:-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] re: php file extension

2008-02-08 Thread Per Jessen
MaryAnn Woodall wrote:

> Just starting to use php  on my webpages. If I save a file as .php
> or .php4 are they the same file. For example is index.php the same as
> index.php4?

If you save the same file with two different names, the contents will
remain the same.  How the different extensions are interpreted at
runtime will depend on your browser config.


/Per Jessen, Zürich

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



Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...

2008-02-08 Thread Richard Lynch
You probably do not have GD installed...

Does  list "GD" as one of your extensions?

If not, install it.

On Thu, February 7, 2008 6:57 am, Legolas wood wrote:
> Hi
> Thank you for reading my post
> I am trying to run a php based application using php5 and apache.
> but I receive an error like:
>
>
> *Fatal error*:  Call to undefined function imagefontwidth() in
> */var/www/v603/includes/functions.php* on line *28*
>
>
> when line 28 and its surrounding lines are:
>
> ## create an image not a text for the pin
>
> $font  = 6;
>
> $width = imagefontwidth($font) * strlen($generated_pin);
>
> $height = ImageFontHeight($font);
>
>
>
> $im = @imagecreate ($width,$height);
>
> $background_color = imagecolorallocate ($im, 219, 239, 249);
> //cell background
>
> $text_color = imagecolorallocate ($im, 0, 0,0);//text color
>
> imagestring ($im, $font, 0, 0,  $generated_pin, $text_color);
>
> touch($image_url . 'uplimg/site_pin_' . $full_pin . '.jpg');
>
> imagejpeg($im, $image_url . 'uplimg/site_pin_' . $full_pin .
> '.jpg');
>
>
>
> $image_output = '';
>
>
>
> imagedestroy($im);
>
>
>
> return $image_output;
>
>
>
> Can you tell me what is wrong with this code and how I can resolve the
> problem.
>
> Thanks
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] fgets???

2008-02-08 Thread Pastor Steve
I think I may have written the question wrong. I only want to display the
first line. It is a news story with a headline. I only want to display the
headline in the link.

The output I want is:

The

But I am getting:

The file looks like this.

Does that make more sense?

Thanks,

--
Steve M.

on 2/8/08 11:03 AM Zoltán Németh ([EMAIL PROTECTED]) wrote:

> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
>> > Is it possible to read each line of data from a file?
>> > 
>> > I have a text file that has several lines on it. I only want to display the
>> > first line only.
>> > 
>> > The 
>> > file I have 
>> > looks like this.
>> > 
>> > But outputs:
>> > 
>> > "The file I have looks like this."
> 
> you need nl2br()
> http://hu.php.net/nl2br
> 
> greets
> Zoltán Németh
> 
>> > 
>> > Here is my code:
>> > 
>> > > > 
>> > 
>> > 
>> > $dir = "path/to/files/";
>> > 
>> > // set pattern
>> > $pattern = ".txt*|.TXT*";
>> > 
>> > // open directory and parse file list
>> > if (is_dir($dir))
>> > {
>> > if ($dh = opendir($dir))
>> > {
>> > 
>> > echo "> > serif; font-size: 12px; width: 290px;\">
>> > 
>> > Breaking News
>> > Please check here often for breaking news stories.
>> > 
>> > 
>> > 
>> > ";
>> > 
>> > // iterate over file list
>> > while (($filename = readdir($dh)) !== false)
>> > {
>> > // if filename matches search pattern, print it
>> > if (ereg($pattern, $filename))
>> >if(strpos($filename,'.')>0)
>> >
>> > //  if ($filename = str_replace('.html','',$filename))
>> > 
>> > {
>> > $fh = fopen($dir . $filename, 'r');
>> > $filehead = fread($fh, 72);
>> > fclose($fh);
>> > echo "> > href=\"/breaking_news/$filename\">".$filehead."";
>> > }
>> > }
>> > echo "
>> > 
>> > ";
>> > 
>> > // close directory
>> > closedir($dh);
>> > }
>> > }
>> > 
>> > ?>
>> > 
> 




Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
> Is it possible to read each line of data from a file?
> 
> I have a text file that has several lines on it. I only want to display the
> first line only.
> 
> The 
> file I have 
> looks like this.
> 
> But outputs:
> 
> "The file I have looks like this."

you need nl2br()
http://hu.php.net/nl2br

greets
Zoltán Németh

> 
> Here is my code:
> 
>  
> 
> 
> $dir = "path/to/files/";
> 
> // set pattern
> $pattern = ".txt*|.TXT*";
> 
> // open directory and parse file list
> if (is_dir($dir))
> {
> if ($dh = opendir($dir))
> {
> 
> echo " serif; font-size: 12px; width: 290px;\">
> 
> Breaking News
> Please check here often for breaking news stories.
> 
> 
> 
> ";
> 
> // iterate over file list
> while (($filename = readdir($dh)) !== false)
> {
> // if filename matches search pattern, print it
> if (ereg($pattern, $filename))
>if(strpos($filename,'.')>0)
>
> //  if ($filename = str_replace('.html','',$filename))
> 
> {
> $fh = fopen($dir . $filename, 'r');
> $filehead = fread($fh, 72);
> fclose($fh);
> echo " href=\"/breaking_news/$filename\">".$filehead."";
> }
> }
> echo "
> 
> ";
> 
> // close directory
> closedir($dh);
> }
> }
> 
> ?>
> 

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



Re: [PHP] fgets???

2008-02-08 Thread Nirmalya Lahiri

--- Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Feb 8, 2008 12:11 PM, Pastor Steve <[EMAIL PROTECTED]>
> wrote:
> > I think I may have written the question wrong. I only want to
> display the
> > first line. It is a news story with a headline. I only want to
> display the
> > headline in the link.
> >
> > The output I want is:
> >
> > The
> >
> > But I am getting:
> >
> > The file looks like this.
> >
> > Does that make more sense?
> 
>  $handle = fopen($filename);
> $data = fgets($handle);
> echo $data."\n";
> ?>
> 
> So long as you don't do a while() loop or something similar,
> fgets() will only read the first line.
> 
> -- 
> 
> 
> Daniel P. Brown
> Senior Unix Geek
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


Another method
 



---
Nirmalya Lahiri
[+91-9433113536]


  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

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



[PHP] fgets???

2008-02-08 Thread Pastor Steve
Is it possible to read each line of data from a file?

I have a text file that has several lines on it. I only want to display the
first line only.

The 
file I have 
looks like this.

But outputs:

"The file I have looks like this."

Here is my code:



Breaking News
Please check here often for breaking news stories.



";

// iterate over file list
while (($filename = readdir($dh)) !== false)
{
// if filename matches search pattern, print it
if (ereg($pattern, $filename))
   if(strpos($filename,'.')>0)
   
//  if ($filename = str_replace('.html','',$filename))

{
$fh = fopen($dir . $filename, 'r');
$filehead = fread($fh, 72);
fclose($fh);
echo "".$filehead."";
}
}
echo "

";

// close directory
closedir($dh);
}
}

?>

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Jason Pruim


On Feb 8, 2008, at 10:14 AM, tedd wrote:


Hi gang:

From a variable with the name of $this_variable -- how do I get a  
string 'this_variable' ?



Hey tedd,

What is the end result you want? for debugging and checking variable  
contents, I've simply: echo "this_variable = $this_variable";


But that was just for debugging, in a large environment, it could be  
quite tedious to type all that out...



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Jason Pruim


On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:



On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen &
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user  
to

save to local disk.


Yes - have a link like this:

Get XLS file

in yourscript.php, you evaluate the parameters given and build the  
XSL

file as output:

header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"filename\"");

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the  
parameters is mysql statement and it's very long. i don't think a  
good idea to pass this in the url. also, the page that i'm working  
on is a search page, therefore the mysql statement is very  
complicate and long.  that's why i don't want to pass via url.


is there way to do within this page???



I have actually done what you are looking for... Here is how I do it:

On the search page, write the search phrase into a session variable so  
you can access it from another page and then run this code:




What that does is it writes the current search pattern into an excel  
file called Export.xls and downloads it to your harddrive. I am in the  
process of re-writing it to work as a function, but have had mixed  
results so far. I'm learning functions right now :)


If you know functions, and want to take a stab at re-writing it, I can  
provide you with the code I have so far :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Directory

2008-02-08 Thread Richard Lynch


On Thu, February 7, 2008 12:30 pm, Steve Marquez wrote:
> Greetings,
>
> Could someone please point me in the right direction? I am trying to
> have
> PHP find out if a directory has files in it and then if it does,
> display and
> include, if it does not, then not display the include.
>
> I have looked at the Manual and did not really know where to look.

http://php.net/opendir
http://php.net/readdir
";
include $f;
  }
?>
-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Name of variable to string

2008-02-08 Thread David Giragosian
On 2/8/08, Richard Lynch <[EMAIL PROTECTED]> wrote:
>
> On Fri, February 8, 2008 9:14 am, tedd wrote:
> >  From a variable with the name of $this_variable -- how do I get a
> > string 'this_variable' ?
>
> You don't...
>
> Consider this:
>
> function foo($bar){
> //what would your function output?
> }
>
> $baz = 3;
> foo($baz);
>
> --


If you dynamically created the variable:

${ 'something' . '_' . 'somethingElse' };

then you'd have access to it via the variable name parts.

David


Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...

2008-02-08 Thread Børge Holen
On Thursday 07 February 2008 17:17:30 David Giragosian wrote:
> On 2/7/08, Daniel Brown <[EMAIL PROTECTED]> wrote:
> > On Feb 7, 2008 8:23 AM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > > Legolas wood schreef:
> > > > Hi
> > > > Thank you for reading my post
> > > > I am trying to run a php based application using php5 and apache.
> > > > but I receive an error like:
> > > >
> > > >
> > > > *Fatal error*:  Call to undefined function imagefontwidth() in
> >
> > */var/www/v603/includes/functions.php* on line *28*
> >
> > > mostly likely you'll have to ask your sys admin to install/activate
> > > this extension ... and if you have cheaphosting then likely the answer
> > > will
> >
> > be
> >
> > > "no we don't do that" - in which case find other hosting?
> >
> >
> > PilotPig has GD, ImageMagick, and all kinds of other things
> > already installed, and will install any server software (when
> > reasonable) upon request at no charge.  Check it out:
> > http://www.pilotpig.net/
> >
> >
> >;-P
> >
> > --
> > 
>
> I can attest to what Daniel is saying about PilotPig. I've had a site
> hosted there for about 5 months now and have been really happy with
> everything: costs are reasonable, lots of modules available, respectful and
> timely reponses to questions and/or concerns. Just a great overall
> experience.
>
> David

am I readin an comercial


-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Name of variable to string

2008-02-08 Thread David Giragosian
On 2/8/08, Eric Butera <[EMAIL PROTECTED]> wrote:
>
> On Feb 8, 2008 1:53 PM, David Giragosian <[EMAIL PROTECTED]> wrote:
> > On 2/8/08, Richard Lynch <[EMAIL PROTECTED]> wrote:
> > >
> > > On Fri, February 8, 2008 9:14 am, tedd wrote:
> > > >  From a variable with the name of $this_variable -- how do I get a
> > > > string 'this_variable' ?
> > >
> > > You don't...
> > >
> > > Consider this:
> > >
> > > function foo($bar){
> > > //what would your function output?
> > > }
> > >
> > > $baz = 3;
> > > foo($baz);
> > >
> > > --
> >
> >
> > If you dynamically created the variable:
> >
> > ${ 'something' . '_' . 'somethingElse' };
> >
> > then you'd have access to it via the variable name parts.
> >
> > David
> >
>
> That is ridiculous.
>


This is what I meant, as was posted just yesterday by someone (Jim Lucas?)

for ( $i = 0 ; $i < 20 ; $i++ )
{

$theVariableAsString = 'something_' . $i;

 ${ 'something' . '_' . $i } = "Assign something here";

}

String value available here -> $theVariableAsString.

I have no idea why tedd wants to have the string value of the variable nor
how he will use it.


David


Re: [PHP] Name of variable to string

2008-02-08 Thread Jason Pruim


On Feb 8, 2008, at 2:41 PM, Paul Scott wrote:



On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:

On Feb 8, 2008 2:18 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
   And look who chimes in with some helpful advice!  ;-P



lol

(now isn't that even more useless?)


Not worse then this... :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Paul Scott

On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:
> On Feb 8, 2008 2:18 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> And look who chimes in with some helpful advice!  ;-P
> 

lol

(now isn't that even more useless?)

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

Re: [PHP] shopping carts

2008-02-08 Thread Richard Lynch
On Thu, February 7, 2008 9:51 am, Eric Butera wrote:
> On Feb 7, 2008 9:59 AM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>> On Feb 7, 2008 9:24 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
>>
> If you look at plugin architectures of projects such as drupal,
> phorum, or serendipity you can see there are better ways of doing
> things rather than messing up the source code.  I recently found

In zenCart, you are supposed to put your modified file[s] into a
different include dir, and keep the original source pristine.

It worked pretty well for me.

The biggest problem I had was that the payment gateway had a "test"
checkbox that was supposed to do something different in the code, but
it didn't, so I ended up hacking that directly anyway -- it was too
broken to worry about not messing it up... :-v

I can't say I've ever liked any of the full-blown shopping cart apps
out there...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 2:45 PM, David Giragosian <[EMAIL PROTECTED]> wrote:
> On 2/8/08, Eric Butera <[EMAIL PROTECTED]> wrote:

Did you see the function that I published in this thread this
morning?  I'm nearly positive that's what he's looking for, and it
worked for me.

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] Name of variable to string

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 2:18 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> That is ridiculous.

And look who chimes in with some helpful advice!  ;-P

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] Name of variable to string

2008-02-08 Thread Eric Butera
On Feb 8, 2008 1:53 PM, David Giragosian <[EMAIL PROTECTED]> wrote:
> On 2/8/08, Richard Lynch <[EMAIL PROTECTED]> wrote:
> >
> > On Fri, February 8, 2008 9:14 am, tedd wrote:
> > >  From a variable with the name of $this_variable -- how do I get a
> > > string 'this_variable' ?
> >
> > You don't...
> >
> > Consider this:
> >
> > function foo($bar){
> > //what would your function output?
> > }
> >
> > $baz = 3;
> > foo($baz);
> >
> > --
>
>
> If you dynamically created the variable:
>
> ${ 'something' . '_' . 'somethingElse' };
>
> then you'd have access to it via the variable name parts.
>
> David
>

That is ridiculous.

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



[PHP] Name of variable to string

2008-02-08 Thread tedd

Hi gang:

From a variable with the name of $this_variable -- how do I get a 
string 'this_variable' ?


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php 4.x + mysql 5

2008-02-08 Thread Jim Lucas

ahlist wrote:

Hi,

I have a client who requires php 4.x with mysql 5 (cannot use php 5
for this project).


Too bad...



Can anyone confirm that it is possible to use this combination without
setting mysql to use old-style passwords.


Not sure



I have a clean php 4.4.7 compile but it still shows the old mysql lib
version. I can't find where it is picking that up at. Is it just built
into the php sources that way?


Yes, it is included with the php source.  If you want it to use newer libs, then 
download the devel packages for the newer mysql version and at compile time, 
point the configure script for php use the newer devel libs instead.  That 
should be all that is needed.




Thanks.




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] problem with imagefontwidth function, It looks to be unavailable...

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 2:50 PM, Børge Holen <[EMAIL PROTECTED]> wrote:
> am I readin an comercial

 but wait, there's more!  Order within the next 6.3 seconds
and you'll receive a cloned version of my first born, ABSOLUTELY FREE!

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread nihilism machine

that was just an example. yes they both provide 5 input variables.

On Feb 8, 2008, at 4:18 PM, Jim Lucas wrote:


nihilism machine wrote:
i have a method called CreateUser() which is public and takes 5  
variables as its data, then adds them to a db. it only executes the  
first method not the other although its all the same but the  
variable.


Here you say that the method takes five (5) variables.


ex:
$auth = new auth();
$auth->CreateUser("fake email", 1, "fake name", 4);
$auth->CreateUser("fake email", 2, "fake name", 4);
$auth->CreateUser("fake email", 3, "fake name", 4);
$auth->CreateUser("fake email", 4, "fake name", 4);
$auth->CreateUser("fake email", 5, "fake name", 4);


But here, you are only putting 4 variables in the method call.

Are you missing something that is required?  The fifth field perhaps?


any ideas? only the first method gets executed?



--
Jim Lucas

  "Some men are born to greatness, some achieve greatness,
  and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
   by William Shakespeare



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



Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread Nathan Nobbe
On Feb 8, 2008 4:10 PM, nihilism machine <[EMAIL PROTECTED]> wrote:

> i have a method called CreateUser() which is public and takes 5
> variables as its data, then adds them to a db. it only executes the
> first method not the other although its all the same but the variable.
>
> ex:
>
> $auth = new auth();
> $auth->CreateUser("fake email", 1, "fake name", 4);
> $auth->CreateUser("fake email", 2, "fake name", 4);
> $auth->CreateUser("fake email", 3, "fake name", 4);
> $auth->CreateUser("fake email", 4, "fake name", 4);
> $auth->CreateUser("fake email", 5, "fake name", 4);
>
> any ideas? only the first method gets executed?


whats going on inside CreateUser(), have you tried tracing the logic?
are the successive calls raising any errors?

-nathan


Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread Jim Lucas

nihilism machine wrote:
i have a method called CreateUser() which is public and takes 5 
variables as its data, then adds them to a db. it only executes the 
first method not the other although its all the same but the variable.


Here you say that the method takes five (5) variables.



ex:

$auth = new auth();
$auth->CreateUser("fake email", 1, "fake name", 4);
$auth->CreateUser("fake email", 2, "fake name", 4);
$auth->CreateUser("fake email", 3, "fake name", 4);
$auth->CreateUser("fake email", 4, "fake name", 4);
$auth->CreateUser("fake email", 5, "fake name", 4);


But here, you are only putting 4 variables in the method call.

Are you missing something that is required?  The fifth field perhaps?



any ideas? only the first method gets executed?




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] php 4.x + mysql 5

2008-02-08 Thread ahlist
Hi,

I have a client who requires php 4.x with mysql 5 (cannot use php 5
for this project).

Can anyone confirm that it is possible to use this combination without
setting mysql to use old-style passwords.

I have a clean php 4.4.7 compile but it still shows the old mysql lib
version. I can't find where it is picking that up at. Is it just built
into the php sources that way?

Thanks.

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



[PHP] issues with calling methods twice in a row

2008-02-08 Thread nihilism machine
i have a method called CreateUser() which is public and takes 5  
variables as its data, then adds them to a db. it only executes the  
first method not the other although its all the same but the variable.


ex:

$auth = new auth();
$auth->CreateUser("fake email", 1, "fake name", 4);
$auth->CreateUser("fake email", 2, "fake name", 4);
$auth->CreateUser("fake email", 3, "fake name", 4);
$auth->CreateUser("fake email", 4, "fake name", 4);
$auth->CreateUser("fake email", 5, "fake name", 4);

any ideas? only the first method gets executed?

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



Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread Nathan Nobbe
On Feb 8, 2008 4:25 PM, nihilism machine <[EMAIL PROTECTED]> wrote:

> that was just an example. yes they both provide 5 input variables.


well theres something preventing successive calls from doing what you
expect.  php has no issue in calling the same instance method successively,
which you could verify with a simple test case.

-nathan


Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 4:17 PM, tedd <[EMAIL PROTECTED]> wrote:
> At 10:31 AM -0500 2/8/08, Daniel Brown wrote:
> >  > On Feb 8, 2008, at 10:14 AM, tedd wrote:
> >>
> >>  > Hi gang:
> >>  >
> >>  > From a variable with the name of $this_variable -- how do I get a
> >  > > string 'this_variable' ?
> >>
> > What Tedd means is this:  ;-P
>
> BINGO! We have a winner!
>
> For those of you who want to know what I'm doing with the solution,
> please review:
>
>   http://www.webbytedd.com//var-string/index.php
>
> Warning: Geek meters should be worn at all times and exposure should
> be limited. All code is shown.
>
> The "problem" that I was seeking a solution for was simply an easier
> way to grab POST and GET variables and place them into SESSIONs while
> keeping the most current values current.
>
> I'm a little disappointed in the solution because I wanted the
> statements to be:
>
> $post_var = sessionize_post($post_var);
> $get_var = sessionize_get($ger_var);
>
> But, the function provided by Daniel (and found in the literature)
> would not work from within my session_post and session_get functions
> -- I think it's probably something to do with the scope of the
> variable.
>
> In any event, I had to alter the calls to:
>
>  $post_var = @sessionize_post($post_var, vname($post_var));
>  $get_var = @sessionize_get($get_var, vname($get_var));
>
> You see, there can be reasons why someone would want to know the
> variable's name.
>
> Thanks Daniel and to all who commented.

And thank you for putting credit where it was really due.  I knew
I had gotten that code a couple of years ago from somewhere, but
couldn't remember where.  I hadn't written it, only modified it.  I'm
going to update my code now to put the "thanks to" section in there to
the person who deserves the credit: Lucas Karisny (lucas dot karisny
at linuxmail dot org).

I had tried to find that each time I referenced the code or used
it myself, but never did.  If only I had R'd TFM.  :-\

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] fgets???

2008-02-08 Thread Richard Lynch
The first possible issue is that the "newline" character[s] is
different for Mac, Windows, and Linux...

So if your file is one format, and fgets is expecting the other, it
won't do what you want.

The next is that if your code is wrong, and is showing it all as one
line, it PROBABLY means you are using a browser, and you PROBABLY
aren't using nl2br to change the newlines (assuming again that nl2br
looks for the right OS newline).  Another option is "View Source" in
the browser to see the newlines.

On Fri, February 8, 2008 11:11 am, Pastor Steve wrote:
> I think I may have written the question wrong. I only want to display
> the
> first line. It is a news story with a headline. I only want to display
> the
> headline in the link.
>
> The output I want is:
>
> The
>
> But I am getting:
>
> The file looks like this.
>
> Does that make more sense?
>
> Thanks,
>
> --
> Steve M.
>
> on 2/8/08 11:03 AM Zoltán Németh ([EMAIL PROTECTED]) wrote:
>
>> 2008. 02. 8, péntek keltezéssel 10.54-kor Pastor Steve ezt írta:
>>> > Is it possible to read each line of data from a file?
>>> >
>>> > I have a text file that has several lines on it. I only want to
>>> display the
>>> > first line only.
>>> >
>>> > The
>>> > file I have
>>> > looks like this.
>>> >
>>> > But outputs:
>>> >
>>> > "The file I have looks like this."
>>
>> you need nl2br()
>> http://hu.php.net/nl2br
>>
>> greets
>> Zoltán Németh
>>
>>> >
>>> > Here is my code:
>>> >
>>> > >> >
>>> >
>>> >
>>> > $dir = "path/to/files/";
>>> >
>>> > // set pattern
>>> > $pattern = ".txt*|.TXT*";
>>> >
>>> > // open directory and parse file list
>>> > if (is_dir($dir))
>>> > {
>>> > if ($dh = opendir($dir))
>>> > {
>>> >
>>> > echo ">> Roman, Times,
>>> > serif; font-size: 12px; width: 290px;\">
>>> > >> padding: 3px;\">
>>> > Breaking News
>>> > Please check here often for breaking news stories.
>>> > 
>>> > 
>>> > 
>>> > ";
>>> >
>>> > // iterate over file list
>>> > while (($filename = readdir($dh)) !== false)
>>> > {
>>> > // if filename matches search pattern, print it
>>> > if (ereg($pattern, $filename))
>>> >if(strpos($filename,'.')>0)
>>> >
>>> > //  if ($filename = str_replace('.html','',$filename))
>>> >
>>> > {
>>> > $fh = fopen($dir . $filename, 'r');
>>> > $filehead = fread($fh, 72);
>>> > fclose($fh);
>>> > echo ">> > href=\"/breaking_news/$filename\">".$filehead."";
>>> > }
>>> > }
>>> > echo "
>>> > 
>>> > ";
>>> >
>>> > // close directory
>>> > closedir($dh);
>>> > }
>>> > }
>>> >
>>> > ?>
>>> >
>>
>
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] fgets???

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 12.46-kor Daniel Brown ezt írta:
> On Feb 8, 2008 12:35 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> 
> I knew it.   After silence, Lynch comes back with a vengeance
> three hours before the week's stats come out.
> 
> And not only that he top-posts.  ;-P

Wait, this might not be the real Lynch, but his new AI instead, not
programmed yet for bottom posting :)

greets
Zoltán Németh

> 
> -- 
> 
> 
> Daniel P. Brown
> Senior Unix Geek
> 
> 

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



Re: [PHP] Re: Recommended ORM for PHP

2008-02-08 Thread Zoltán Németh
2008. 02. 8, péntek keltezéssel 11.38-kor Manuel Lemos ezt írta:
> Hello,
> 
> on 02/08/2008 06:15 AM Zoltán Németh said the following:
> >> Another aspect is that Metastorage features what is called report
> >> classes. These are classes that perform queries that you define and
> >> generates SQL and PHP at compile time to retrieve data from the
> >> persistent objects for read-only purposes.
> > 
> > and what if you want to switch sql server from mysql to oracle or
> > whatever? in propel, you change 1 line in the config, you don't have to
> > regenerate or rewrite anything.
> >
> > the base classes are useful too because if you change your schema, you
> > simply regenerate them and all your extensions remain the same in the
> > child classes.
> 
> Metastorage generates totaly database independent code . You don't need
> to regenerate the code to support multiple databases nor have fat base
> classes to access your database or do any other ORM operations.
> 
> Currently it generates code that uses Metabase database abstraction
> layer, although it can support other database abstraction layers. It
> supports many databases like MySQL, PostgreSQL, Oracle, Microsoft SQL
> server, SQLite, etc..

ok, so there is not much difference in that :)

> 
> Metabase also generates a separate class for installing or upgrading
> your database schema. If you change the definition of you objects, you
> just need to call that class to install, upgrade, downgrade your
> database schemas, safely without loosing any data that was already in
> the database.
> 
> This is something very secure, as it does not do any schema changes if
> the underlying database does not support certain things you want to
> change. If you ask for a change that is not possible, it simply fails
> without changing anything. It is not that error prone migrations method
> of Ruby on Rails, that you have to write "SQL" manually to do your
> migrations, and if you made a mistake, your database data is lost.
> 
> 

schema versioning is cool, AFAIK it is missing from propel but of course
it can transform your schema without data loss.

> 
> >> For instance, if you want to send a newsletter to a million subscribers
> >> and you just need the e-mail address and names of the subscribers, you
> >> can tell Metastorage to generate a report class that queries the users
> >> objects and retrives just the name and e-mail address. The report
> >> classes return arrays just like plain SELECT queries.
> >>
> >> If you use the Propel approach you would need to retrieve 1 million
> >> objects of the users class just to pick the name and e-mail address,
> >> which is totally inefficient in terms of memory and very slow.
> > 
> > not at all. you can build the criteria for the select and then run a
> > doSelectRS method which gives you only the result set in an array, no
> > objects involved.
> 
> That is not exactly what I am talking about. Metastorage has an Object
> Query Language (OQL) that lets you express whatever query conditions you
> want. It generates PHP code with the necessary SQL queries you need. You
> do not have to build any queries programatically at run-time.

in propel you do not touch SQL too ;)
you initialize an object of class Criteria and define whatever you want.
e.g.
$c = new Criteria();
$c->add('whatevercolumn', 'whatevervalue');

of course it can do much more, joins and everything you may need

> 
> The generated code can return full SQL statements if you want to execute
> them separately by some other application code, but usually I just use
> the generated report classes directly, as they take care of many things
> like pagination, so I do not have to deal with SQL directly. That is one
> of the great benefits of ORM.
> 
> With Metastorage I just do not have to deal with SQL manually nor I am
> forced to retrieve all as objects, not even when I am retrieving just a
> few variables of multiple classes. I do not have to SQL joins manually.
> That would be walking backwards in productivity.
> 
> 
> >> There are more differences between Metastorage and Propel (and probably
> >> others approach). I just wanted to make the point that the fact that
> >> approaches use generated code, it does not mean that all provide the
> >> same efficiency.
> > 
> > yeah, sure. however there is a payoff between efficiency and portability
> > and maintainability, and of course not all these orms have the same
> > level of these. choose the one that fits your needs best.
> 
> Exactly. I choose to develop my own because nothing that existed in PHP
> matched my needs and code quality code requirements. Of course doing it
> yourself is an expensive measure because it takes time and skill to
> reach a mature solution. I have been developing Metastorage for 6 years.
> It is very mature and reliable, but there is always room for improvement.

I too had thought about implementing my own ORM, because none of them
fits my needs exactly, however I don't have the time for that..

[PHP] Order directory output

2008-02-08 Thread Pastor Steve
Hi, thanks for all your help today.

I have the following code and I am trying to order the output. Currently it
seems really random. Can anyone point me in the right direction?



Breaking News
Please check here often for breaking news stories.




";

// iterate over file list
while (($filename = readdir($dh)) !== false)

{

// if filename matches search pattern, print it
if (ereg($pattern, $filename))
   if(strpos($filename,'.')>0)

{
$fh = fopen("$dir" . "$filename", "r");

$filehead = fgets($fh);

fclose($fh);
echo "

$filehead
";
}
}
echo "


";

// close directory
closedir($dh);
}
}

?>

Thank you,

--
Steve Marquez



Re: [PHP] Name of variable to string

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 2:41 PM, Paul Scott <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2008-02-08 at 14:37 -0500, Daniel Brown wrote:
> > On Feb 8, 2008 2:18 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> > And look who chimes in with some helpful advice!  ;-P
> >
>
> lol
>
> (now isn't that even more useless?)

That's why I threw the ;-P at the end.  Not only to indicate that
I was playing around, but also because it held double meaning (in
words and action).

TFGIF, brother!

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread tedd

At 4:56 PM -0500 2/8/08, Robert Cummings wrote:

On Fri, 2008-02-08 at 16:51 -0500, tedd wrote:

 At 10:42 PM +0100 2/8/08, Jochem Maas wrote:
 >$post_var = @sessionize_post('post_var');
 >
 >so why exactly is that not an option (or good idea)?

 It IS an option -- and that's what I was doing (except for the
 suppress error) via this:

 $post_var = sessionize_post('post_var');

 I just wanted to make it simpler and do this:

 $post_var = sessionize_post($post_var);

 But, it turned out to be much more involved. It's just an adventure
 in key punching.


It takes inefficiency to a whole new level.

Cheers,
Rob.


Thanks Rob.  :-)

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread Jim Lucas

tedd wrote:

At 10:31 AM -0500 2/8/08, Daniel Brown wrote:

 > On Feb 8, 2008, at 10:14 AM, tedd wrote:


 > Hi gang:
 >
 > From a variable with the name of $this_variable -- how do I get a

 > > string 'this_variable' ?



What Tedd means is this:  ;-P


BINGO! We have a winner!

For those of you who want to know what I'm doing with the solution, 
please review:


 http://www.webbytedd.com//var-string/index.php

Warning: Geek meters should be worn at all times and exposure should be 
limited. All code is shown.


The "problem" that I was seeking a solution for was simply an easier way 
to grab POST and GET variables and place them into SESSIONs while 
keeping the most current values current.


I'm a little disappointed in the solution because I wanted the 
statements to be:


$post_var = sessionize_post($post_var);
$get_var = sessionize_get($ger_var);

But, the function provided by Daniel (and found in the literature) would 
not work from within my session_post and session_get functions -- I 
think it's probably something to do with the scope of the variable.


In any event, I had to alter the calls to:

$post_var = @sessionize_post($post_var, vname($post_var)); 
$get_var = @sessionize_get($get_var, vname($get_var));


You see, there can be reasons why someone would want to know the 
variable's name.


Thanks Daniel and to all who commented.

Cheers,

tedd



So, how is this any better then just doing this

$_SESSION = array_merge(array_merge($_SESSION, $_POST), $_GET);

If I replace the two calls to sessionize_*() with the above line, I get the same 
results.  Not sure what I am missing.


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Re: Recommended ORM for PHP

2008-02-08 Thread Manuel Lemos
Hello,

on 02/08/2008 06:15 AM Zoltán Németh said the following:
>> Another aspect is that Metastorage features what is called report
>> classes. These are classes that perform queries that you define and
>> generates SQL and PHP at compile time to retrieve data from the
>> persistent objects for read-only purposes.
> 
> and what if you want to switch sql server from mysql to oracle or
> whatever? in propel, you change 1 line in the config, you don't have to
> regenerate or rewrite anything.
>
> the base classes are useful too because if you change your schema, you
> simply regenerate them and all your extensions remain the same in the
> child classes.

Metastorage generates totaly database independent code . You don't need
to regenerate the code to support multiple databases nor have fat base
classes to access your database or do any other ORM operations.

Currently it generates code that uses Metabase database abstraction
layer, although it can support other database abstraction layers. It
supports many databases like MySQL, PostgreSQL, Oracle, Microsoft SQL
server, SQLite, etc..

Metabase also generates a separate class for installing or upgrading
your database schema. If you change the definition of you objects, you
just need to call that class to install, upgrade, downgrade your
database schemas, safely without loosing any data that was already in
the database.

This is something very secure, as it does not do any schema changes if
the underlying database does not support certain things you want to
change. If you ask for a change that is not possible, it simply fails
without changing anything. It is not that error prone migrations method
of Ruby on Rails, that you have to write "SQL" manually to do your
migrations, and if you made a mistake, your database data is lost.



>> For instance, if you want to send a newsletter to a million subscribers
>> and you just need the e-mail address and names of the subscribers, you
>> can tell Metastorage to generate a report class that queries the users
>> objects and retrives just the name and e-mail address. The report
>> classes return arrays just like plain SELECT queries.
>>
>> If you use the Propel approach you would need to retrieve 1 million
>> objects of the users class just to pick the name and e-mail address,
>> which is totally inefficient in terms of memory and very slow.
> 
> not at all. you can build the criteria for the select and then run a
> doSelectRS method which gives you only the result set in an array, no
> objects involved.

That is not exactly what I am talking about. Metastorage has an Object
Query Language (OQL) that lets you express whatever query conditions you
want. It generates PHP code with the necessary SQL queries you need. You
do not have to build any queries programatically at run-time.

The generated code can return full SQL statements if you want to execute
them separately by some other application code, but usually I just use
the generated report classes directly, as they take care of many things
like pagination, so I do not have to deal with SQL directly. That is one
of the great benefits of ORM.

With Metastorage I just do not have to deal with SQL manually nor I am
forced to retrieve all as objects, not even when I am retrieving just a
few variables of multiple classes. I do not have to SQL joins manually.
That would be walking backwards in productivity.


>> There are more differences between Metastorage and Propel (and probably
>> others approach). I just wanted to make the point that the fact that
>> approaches use generated code, it does not mean that all provide the
>> same efficiency.
> 
> yeah, sure. however there is a payoff between efficiency and portability
> and maintainability, and of course not all these orms have the same
> level of these. choose the one that fits your needs best.

Exactly. I choose to develop my own because nothing that existed in PHP
matched my needs and code quality code requirements. Of course doing it
yourself is an expensive measure because it takes time and skill to
reach a mature solution. I have been developing Metastorage for 6 years.
It is very mature and reliable, but there is always room for improvement.


>> If you are interested about more differences in the approaches, you may
>> check the Metastorage documentaion:
>>
>> http://www.metastorage.net/
>>
> 
> sure, I'll check it out when I have some free time



-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen

hi friends,

i have a php page with the following logic:



Download


  Title>Author
  
  
  
  
  
  Download Into Excel File




is there anyway to generate this into xls file w/o using fopen & fwrite to 
the server?  my goal is to have a link after the table and user can click 
on that link and a save window pop up to allow user to save to local disk.


appreciate very much for any input.

t. hiep

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Per Jessen
Hiep Nguyen wrote:

> let say that user searched and found 10 records,
> in the meantime, other users may change any of these 10 records,
> so if we saved mysql statement and re-run mysql statement again, the
> result might be different.  to prevent this problem, i only want to
> download records that returned on this page only.

This is more of a caching issue - then you determine how long you want
to keep the results for, and only re-run the mysql query when the
results have gone stale.


/Per Jessen, Zürich

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



Re: [PHP] re: php file extension

2008-02-08 Thread Richard Lynch
On Thu, February 7, 2008 1:49 pm, MaryAnn Woodall wrote:
> Just starting to use php  on my webpages. If I save a file as .php
> or .php4 are they the same file. For example is index.php the same as
> index.php4?

They are not the same file at all, unless you use really old Windows
that only let you have 3 characters in the extension, or some other
program is converting to the 8.3 filename...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Name of variable to string

2008-02-08 Thread Richard Lynch
On Fri, February 8, 2008 9:14 am, tedd wrote:
>  From a variable with the name of $this_variable -- how do I get a
> string 'this_variable' ?

You don't...

Consider this:

function foo($bar){
  //what would your function output?
}

$baz = 3;
foo($baz);

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread tedd

At 1:39 PM -0800 2/8/08, Jim Lucas wrote:

So, how is this any better then just doing this

$_SESSION = array_merge(array_merge($_SESSION, $_POST), $_GET);

If I replace the two calls to sessionize_*() with the above line, I 
get the same results.  Not sure what I am missing.


First, I didn't say it was better.

Second, you're not missing anything.

Third, if I wanted to merge the arrays, I could use REQUEST and 
forget the merge.


I was just trying to get the "check the current value of post or get 
variable and put it into a session" with a single simple statement of:


$whatever = serialize($whatever);

Now, I've have to continue with my original:

$whatever = serialize('whatever');

When dealing with just a few variables, it's not a big deal. But, 
with the numbers I've been dealing with lately, I was looking to 
create something simple to cut and paste into.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread Robert Cummings

On Fri, 2008-02-08 at 16:51 -0500, tedd wrote:
> At 10:42 PM +0100 2/8/08, Jochem Maas wrote:
> >$post_var = @sessionize_post('post_var');
> >
> >so why exactly is that not an option (or good idea)?
> 
> It IS an option -- and that's what I was doing (except for the 
> suppress error) via this:
> 
> $post_var = sessionize_post('post_var');
> 
> I just wanted to make it simpler and do this:
> 
> $post_var = sessionize_post($post_var);
> 
> But, it turned out to be much more involved. It's just an adventure 
> in key punching.

It takes inefficiency to a whole new level.

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.  |
`'

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



Re: [PHP] fgets???

2008-02-08 Thread Daniel Brown
On Feb 8, 2008 12:35 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:

I knew it.   After silence, Lynch comes back with a vengeance
three hours before the week's stats come out.

And not only that he top-posts.  ;-P

-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] issues with calling methods twice in a row

2008-02-08 Thread Jochem Maas

nihilism machine schreef:
i have a method called CreateUser() which is public and takes 5 
variables as its data, then adds them to a db. it only executes the 
first method not the other although its all the same but the variable.


ex:

$auth = new auth();
$auth->CreateUser("fake email", 1, "fake name", 4);
$auth->CreateUser("fake email", 2, "fake name", 4);
$auth->CreateUser("fake email", 3, "fake name", 4);
$auth->CreateUser("fake email", 4, "fake name", 4);
$auth->CreateUser("fake email", 5, "fake name", 4);

any ideas? only the first method gets executed?


no-one can smell the problem with the info you gave.

what is the code for createUser()?
what is does you error log contain?
are you displaying errors? (you should probably do so in a dev environment)
are the 2nd + subsequent calls being made and nothing is entering
in the DB OR are the 2nd + subsequent calls not occuring at all?





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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread tedd

At 10:31 AM -0500 2/8/08, Daniel Brown wrote:

 > On Feb 8, 2008, at 10:14 AM, tedd wrote:


 > Hi gang:
 >
 > From a variable with the name of $this_variable -- how do I get a

 > > string 'this_variable' ?



What Tedd means is this:  ;-P


BINGO! We have a winner!

For those of you who want to know what I'm doing with the solution, 
please review:


 http://www.webbytedd.com//var-string/index.php

Warning: Geek meters should be worn at all times and exposure should 
be limited. All code is shown.


The "problem" that I was seeking a solution for was simply an easier 
way to grab POST and GET variables and place them into SESSIONs while 
keeping the most current values current.


I'm a little disappointed in the solution because I wanted the 
statements to be:


$post_var = sessionize_post($post_var);
$get_var = sessionize_get($ger_var);

But, the function provided by Daniel (and found in the literature) 
would not work from within my session_post and session_get functions 
-- I think it's probably something to do with the scope of the 
variable.


In any event, I had to alter the calls to:

$post_var = @sessionize_post($post_var, vname($post_var)); 
$get_var = @sessionize_get($get_var, vname($get_var));


You see, there can be reasons why someone would want to know the 
variable's name.


Thanks Daniel and to all who commented.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread Jochem Maas

Daniel Brown schreef:

On Feb 8, 2008 4:17 PM, tedd <[EMAIL PROTECTED]> wrote:

At 10:31 AM -0500 2/8/08, Daniel Brown wrote:

 > On Feb 8, 2008, at 10:14 AM, tedd wrote:

 > Hi gang:
 >
 > From a variable with the name of $this_variable -- how do I get a

 > > string 'this_variable' ?
What Tedd means is this:  ;-P

BINGO! We have a winner!

For those of you who want to know what I'm doing with the solution,
please review:

  http://www.webbytedd.com//var-string/index.php

Warning: Geek meters should be worn at all times and exposure should
be limited. All code is shown.

The "problem" that I was seeking a solution for was simply an easier
way to grab POST and GET variables and place them into SESSIONs while
keeping the most current values current.

I'm a little disappointed in the solution because I wanted the
statements to be:

$post_var = sessionize_post($post_var);
$get_var = sessionize_get($ger_var);

But, the function provided by Daniel (and found in the literature)
would not work from within my session_post and session_get functions
-- I think it's probably something to do with the scope of the
variable.

In any event, I had to alter the calls to:

 $post_var = @sessionize_post($post_var, vname($post_var));
 $get_var = @sessionize_get($get_var, vname($get_var));


I don't see why this has to be so convoluted - it would be a heck of
a lot easier to do it with a string:

$post_var = @sessionize_post('post_var');

so why exactly is that not an option (or good idea)?



You see, there can be reasons why someone would want to know the
variable's name.

Thanks Daniel and to all who commented.


And thank you for putting credit where it was really due.  I knew
I had gotten that code a couple of years ago from somewhere, but
couldn't remember where.  I hadn't written it, only modified it.  I'm
going to update my code now to put the "thanks to" section in there to
the person who deserves the credit: Lucas Karisny (lucas dot karisny
at linuxmail dot org).

I had tried to find that each time I referenced the code or used
it myself, but never did.  If only I had R'd TFM.  :-\



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



Re: [PHP] Order directory output

2008-02-08 Thread Jim Lucas

Pastor Steve wrote:

Hi, thanks for all your help today.

I have the following code and I am trying to order the output. Currently it
seems really random. Can anyone point me in the right direction?



Breaking News
Please check here often for breaking news stories.




";


// iterate over file list
while (($filename = readdir($dh)) !== false)

{

// if filename matches search pattern, print it
if (ereg($pattern, $filename))
   if(strpos($filename,'.')>0)

{
$fh = fopen("$dir" . "$filename", "r");

$filehead = fgets($fh);

fclose($fh);
echo "

$filehead
";
}
}
echo "


";

// close directory
closedir($dh);
}
}

?>

Thank you,

--
Steve Marquez




A cut down version of what you are trying to do, I think.


Breaking News
Please check here often for breaking news stories.


';


// iterate over file list
foreach ( $files AS $file ) {

// if filename matches search pattern, print it
if ( in_array(array_pop(explode('.', $file) ), $allowed_ftypes ) ) {

// Open file for reading
if ( ( $fh = fopen($file, "r") ) !== false ) {

// Get the first line of the file
$filehead = fgets($fh);

// Extract file name for link
$filename = array_pop(explode('/', $file));

// Display Link
echo ''.
  htmlspecialchars($filehead).'';

fclose($fh);
}
}
}
echo '';
}
}

?>

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Name of variable to string [SOLVED]

2008-02-08 Thread tedd

At 10:42 PM +0100 2/8/08, Jochem Maas wrote:

$post_var = @sessionize_post('post_var');

so why exactly is that not an option (or good idea)?


It IS an option -- and that's what I was doing (except for the 
suppress error) via this:


$post_var = sessionize_post('post_var');

I just wanted to make it simpler and do this:

$post_var = sessionize_post($post_var);

But, it turned out to be much more involved. It's just an adventure 
in key punching.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php 4.x + mysql 5

2008-02-08 Thread ahlist
On Feb 8, 2008 4:16 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:
> ahlist wrote:
> > Hi,
> >
> >
> > I have a clean php 4.4.7 compile but it still shows the old mysql lib
> > version. I can't find where it is picking that up at. Is it just built
> > into the php sources that way?
>
> Yes, it is included with the php source.  If you want it to use newer libs, 
> then
> download the devel packages for the newer mysql version and at compile time,
> point the configure script for php use the newer devel libs instead.  That
> should be all that is needed.
>

Good idea! I may end up doing that.

My goal is to position this so that a move to php5 would work and not
be stuck with a bunch of old-style mysql passwords that need updated
by users (since the original passwords are not retrievable of course
for conversion unless I store plain text copies, which I do not want
to do).

Thanks for your input.

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



[PHP] Re: Order directory output

2008-02-08 Thread Shawn McKenzie
Pastor Steve wrote:
> Hi, thanks for all your help today.
> 
> I have the following code and I am trying to order the output. Currently it
> seems really random. Can anyone point me in the right direction?
> 
>  
> $dir = "content/current/breaking_news/";
> 
> // set pattern
> $pattern = ".txt*|.TXT*";
> 
> // open directory and parse file list
> if (is_dir($dir))
> {
> if ($dh = opendir($dir))
> {
> 
> //This is the div that contains the wrap around for the breaking news
> section.
> echo "
>  serif; font-size: 12px; width: 290px;\">
>  3px;\">
> Breaking News
> Please check here often for breaking news stories.
> 
> 
> 
> 
> ";
> 
> // iterate over file list
> while (($filename = readdir($dh)) !== false)
> 
> {
> 
> // if filename matches search pattern, print it
> if (ereg($pattern, $filename))
>if(strpos($filename,'.')>0)
> 
> {
> $fh = fopen("$dir" . "$filename", "r");
> 
> $filehead = fgets($fh);
> 
> fclose($fh);
> echo "
> 
> $filehead
> ";
> }
> }
> echo "
> 
> 
> ";
> 
> // close directory
> closedir($dh);
> }
> }
> 
> ?>
> 
> Thank you,
> 
> --
> Steve Marquez
> 
> 
How is the output random?  The text from the file, or the order the
files are read?

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



Re: [PHP] Order directory output

2008-02-08 Thread Nathan Nobbe
i hooked up an spl example; and the files are sorted by name.
also, did you want that  inside or outside the  w/
class=NormalText, because the opening and closing tags are
mixed up..

getInnerIterator()->current()->isFile()) {
return true;
}
}
}

class TextInfoIterator extends ArrayIterator {
public function __construct($array, $flags=0) {
$this->ksort();
parent::__construct($array, $flags);
}

public function current() {
return '' . parent::current() . '';
}
}

$fileMatchString = '/.*(\.txt|\.TXT)$/';
$resultData = array();

foreach(new RegexIterator(new FileIterator(new
DirectoryIterator('testDir')), $fileMatchString) as $curAllowedFile) {
try {
$theFile = $curAllowedFile->openFile('r');
$theFile->setFlags(SplFileObject::DROP_NEW_LINE);
$resultData[$curAllowedFile->getFilename()] =
$theFile->fgets();
unset($theFile);// close the file ??
} catch(RuntimeException $e) {
// do something here
}
}
?>


Breaking News
Please check here often for breaking news stories.












-nathan


Re: [PHP] Order directory output

2008-02-08 Thread Nathan Nobbe
On Fri, Feb 8, 2008 at 9:19 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:

> i hooked up an spl example; and the files are sorted by name.
> also, did you want that  inside or outside the  w/
> class=NormalText, because the opening and closing tags are
> mixed up..
>

damnit; i had a couple of mistakes; so sue me; its friday night!

to ensure the path is in the href; i added it
$resultData[$curAllowedFile->getPathname()] = $theFile->fgets();

to make sure the results are sorted; i sorted them after the parent
ArrayIterator was created
parent::__construct($array, $flags);
$this->ksort();

and lastly, i added the anchor tag


i could use a drink right about now..=/

-nathan


Re: [PHP] Order directory output

2008-02-08 Thread Paul Scott

On Fri, 2008-02-08 at 21:19 -0500, Nathan Nobbe wrote:
> i hooked up an spl example; and the files are sorted by name.
> also, did you want that  inside or outside the  w/
> class=NormalText, because the opening and closing tags are
> mixed up..
> 

Here is another, generic extension filter with SPL. Untested, and I have
just woken up, so if it doesn't work... :-P

class ExtensionFilter extends FilterIterator {

  private $ext; 
  private $it;

  public function __construct(DirectoryIterator $it, $ext) {
  parent::__construct($it);
  $this->it = $it;
  $this->ext = $ext;
  }
  public function accept() {
  if ( ! $this->it->isDir() ) {
$ext = array_pop(explode('.', $this->current()));
return $ext != $this->ext;
  }
  return true;
  }
}

--Paul
-- 
.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za   |
::

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

[PHP] Posting Summary for Week Ending 8 February, 2008: php-general@lists.php.net

2008-02-08 Thread PostTrack [Dan Brown]

Posting Summary for PHP-General List
Week Ending: Friday, 8 February, 2008

Messages| Bytes  | Sender
++--
391 (100%)  581347 (100%)   EVERYONE
32 (8.2%)  41862   (7.2%)  Daniel Brown 
27 (6.9%)  29259   (5%)Nathan Nobbe 
21 (5.4%)  23274   (4%)Paul Scott 
17 (4.3%)  26180   (4.5%)  Jochem Maas 
15 (3.8%)  23318   (4%)Richard Lynch 
15 (3.8%)  9331(1.6%)  Per Jessen 
14 (3.6%)  15963   (2.7%)  Eric Butera 
14 (3.6%)  11187   (1.9%)  Richard Heyes 
12 (3.1%)  52246   (9%)szalinski 
11 (2.8%)  27715   (4.8%)  Shawn McKenzie 
11 (2.8%)  9530(1.6%)  Greg Donald 
9  (2.3%)  14608   (2.5%)  Jim Lucas 
9  (2.3%)  15210   (2.6%)  Casey 
8  (2%)12953   (2.2%)  Andrew Ballard 
7  (1.8%)  11631   (2%)Robert Cummings 
7  (1.8%)  21742   (3.7%)  Manuel Lemos 
6  (1.5%)  14733   (2.5%)  Mad Unix 
6  (1.5%)  10924   (1.9%)  Zoltán Németh 
6  (1.5%)  11225   (1.9%)  Wolf 
6  (1.5%)  8139(1.4%)  Jason Pruim 
6  (1.5%)  4308(0.7%)  js 
5  (1.3%)  14543   (2.5%)  Robbert van Andel 
5  (1.3%)  5272(0.9%)  Chris 
5  (1.3%)  4450(0.8%)  Martin Marques 
4  (1%)4817(0.8%)  Prabath Kumarasinghe 
4  (1%)11452   (2%)Nathan Rixham 
4  (1%)7322(1.3%)  Warren Vail 
4  (1%)4249(0.7%)  Bastien Koert 
3  (0.8%)  2577(0.4%)  clive 
3  (0.8%)  3088(0.5%)  jeffry s 
3  (0.8%)  4269(0.7%)  Larry Garfield 
3  (0.8%)  2680(0.5%)  Pieter du Toit 
3  (0.8%)  3762(0.6%)  John Taylor-Johnston 
3  (0.8%)  9312(1.6%)  Louie Miranda 
3  (0.8%)  14240   (2.4%)  McNaught, Scott 
3  (0.8%)  1511(0.3%)  Ron Piggott 
2  (0.5%)  1786(0.3%)  John Taylor-Johnston 
2  (0.5%)  839 (0.1%)  AmirBehzad Eslami 
2  (0.5%)  1561(0.3%)  blackwater dev 
2  (0.5%)  841 (0.1%)  nihilism machine 

2  (0.5%)  2058(0.4%)  Michael Moyle 
2  (0.5%)  1147(0.2%)  ehl lhe 
2  (0.5%)  13541   (2.3%)  Andrés Robinet 
2  (0.5%)  2559(0.4%)  Nikolay Ananiev 
2  (0.5%)  2226(0.4%)  VamVan 
2  (0.5%)  1784(0.3%)  Alain Roger 
2  (0.5%)  3927(0.7%)  Mr Webber 
2  (0.5%)  2935(0.5%)  David Giragosian 
2  (0.5%)  1548(0.3%)  pobox at verysmall dot org 

2  (0.5%)  1661(0.3%)  Feris Thia C dot  
2  (0.5%)  1244(0.2%)  LKSunny 
2  (0.5%)  1662(0.3%)  Robert Fitzpatrick 
1  (0.3%)  365 (0.1%)  Brian Dunning 
1  (0.3%)  991 (0.2%)  Richard 
1  (0.3%)  2940(0.5%)  Fnutt 
1  (0.3%)  383 (0.1%)  Bruce Cowin 
1  (0.3%)  1327(0.2%)  Rob Gould 
1  (0.3%)  1041(0.2%)  zerof 
1  (0.3%)  860 (0.1%)  Fahad javed 
1  (0.3%)  586 (0.1%)  David Robley 
1  (0.3%)  845 (0.1%)  Leonard Burton 
1  (0.3%)  1258(0.2%)  Legolas wood 
1  (0.3%)  866 (0.1%)  Dare Williams 
1  (0.3%)  1043(0.2%)  Louie Henry 
1  (0.3%)  1623(0.3%)  Colin Guthrie 
1  (0.3%)  437 (0.1%)  Steve Marquez 
1  (0.3%)  1124(0.2%)  Rob G 
1  (0.3%)  1019(0.2%)  puneetjain 
1  (0.3%)  269 (0%)MaryAnn Woodall 
1  (0.3%)  1280(0.2%)  Floor Terra 
1  (0.3%)  1218(0.2%)  C dot R dot Vegelin 
1  (0.3%)  802 (0.1%)  mike 
1  (0.3%)  698 (0.1%)  Michael Fischer 
1  (0.3%)  2838(0.5%)  bruce 
1  (0.3%)  1115(0.2%)  chetan rane 
1  (0.3%)  721 (0.1%)  Siegfried Gipp 
1  (0.3%)  265 (0%)doc 
1  (0.3%)  742 (0.1%)