Re: [PHP] Re: SHOULD I NOT USE ELSE IN IF STATEMENTS....?

2009-06-09 Thread Craige Leeder
I'm not sure I agree with NEVER using else. Sometimes else is a very 
logical way to organize code. However, it should not be used for data 
validation IE:



function myValidatorFunc($data) {
   if (empty(data)) {
  return false;
   } else {
  if (!is_numeric($data)) {
 return false;
  } else {

  }
   }
}


It's all about how deep you nest your code, and keeping the flow clean. 
That code would be much more readable as such:


function myValidatorFunc($data) {
   if (empty(data)) {
  throw new BadMethodCallException(Paramater data missing);
   }
   if (!is_numeric($data)) {
  throw new InvalidArgumentException(Paramater data should be an 
integer.);

   }
}

See the difference?

- Craige

O. Lavell wrote:

adam.timberlake wrote:

  

Im reading this post and i donnot understand how i should write my code:
http://www.talkphp.com/absolute-beginners/4237-curly-


brackets.html#post23720
  

Does it mean that i am to not write else statements in my ifs? or is it
just saying it is something i should avoid to rite better code?

please help me...



I happen to not agree completely with the post, because it seems to 
propose the use of things like continue, break and return within 
control structures (the latter as opposed to at the end of a function, 
exclusively). Very bad practice in my opinion. Think of everything that 
has ever been said of goto, it's just as bad for structured programming.


(however the use of break in switch .. case statements is an 
unfortunate necessity in PHP)


Not that I am diagramming much nowadays, but I still try to write code 
such that it could fit into a Nassi-Shneiderman diagram (NSD):


http://en.wikipedia.org/wiki/Nassi-Shneiderman_diagram

If you have never learnt to draw these then you probably should. It can 
be fun to do and they are very helpful for planning ahead and writing 
uncluttered code that can be easily debugged. And you will know you are 
nesting too deep when the diagram doesn't fit on the piece of paper you 
started on :)


To more directly answer your question I would say that if there is a 
*logical* requirement to use else after if then yes, you should use 
it and certainly not try to avoid it. There is absolutely nothing wrong 
with else.




  


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



Re: [PHP] Reg-ex help

2009-02-07 Thread Craige Leeder

Thanks!

That's a big help.

- Craige

Jim Lucas wrote:

Craige Leeder wrote:

Hey guys,

I'm trying to write a regular expression to match a tag for my 
frameworks template engine.  I seem to be having some trouble.  The 
expression should match:


{:seg 'segname':}
{:seg 'segname' cache:}

What I have is...

$fSegRegEx = #\{:seg \'[a-z0-9\-\_]{3,}\'( cache)?:\}#i;

Which when run against my test data, seems to match:

{:seg 'segname' cache:}
 cache


Thanks guys.  This has been bugging me for a couple days.
- Craige




I used some of your code, but try this variant on for size.

plaintext
?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$dummyData = DATA

html
body
h1{:seg 'title':}/h1
h1{:seg 'title' cache:}/h1
/body
/html

DATA;

# For arguments sake, I'll provide the whole code snippet...

$fSegRegEx = |\{:(seg) \'([a-z0-9\-\_]{3,})\'\s?(cache)?:\}|i;

preg_match_all($fSegRegEx, $dummyData, $faSegMatches, PREG_SET_ORDER);
print_r($faSegMatches);

?

Not sure what your input is going to be (HTML, XML, etc...) so I used 
HTML


Anyways, output from the above code is this:

plaintext

Array
(
[0] = Array
(
[0] = {:seg 'title':}
[1] = seg
[2] = title
)

[1] = Array
(
[0] = {:seg 'title' cache:}
[1] = seg
[2] = title
[3] = cache
)

)

Hope this starts you down the right path.



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



[PHP] Reg-ex help

2009-02-04 Thread Craige Leeder

Hey guys,

I'm trying to write a regular expression to match a tag for my 
frameworks template engine.  I seem to be having some trouble.  The 
expression should match:


{:seg 'segname':}
{:seg 'segname' cache:}

What I have is...

$fSegRegEx = #\{:seg \'[a-z0-9\-\_]{3,}\'( cache)?:\}#i;

Which when run against my test data, seems to match:

{:seg 'segname' cache:}
 cache





For arguments sake, I'll provide the whole code snippet...

   preg_match($fSegRegEx, $this-msOpCont, $faSegMatches);

   /* faSegMatches ==

* array

* 0 = '{:seg 'users_online' cache:}'//

* 1 = ' cache'//

*/

 while ( $fMatch = current($faSegMatches) ) {

   /* 


* Expected:

* $fMatch[0] = {:seg 

* $fMatch[1] = Segment Name

* 


* $fMatch[2] =  cache:}

* or

* $fMatch[2] =  :}

*/

   $faMatch  = explode(', $fMatch);

   //...

   //...

   next($faSegMatches);

 }// End While


Thanks guys.  This has been bugging me for a couple days.
- Craige


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



Re: [PHP] getStatic

2008-11-30 Thread Craige Leeder

Yeti wrote:

I think PHP's string functions are pretty fast and even with large
documents we are talking about a couple of extra microseconds on a
modern machine. I once saw someone do pretty much the same as you are
trying to do with strtr() [1], but I don't know if that function is
faster than str_replace(). You should also consider that if you
framework is going to manage someone's site one day then it could
possibly be on a server with an older PHP version. I disagree with
those on the list saying one should just stick to an existing
templating framework, since it can be quite exciting to think some
neat thingy out. Of course, most people (including me) hardly have any
time at all to spend 1000s of hours on a more or less private project.

[1] http://in.php.net/manual/en/function.strtr.php

  



Hey Yeti,

Sorry I took so long to respond. Been a busy week or so.

I've decided, for ease of production, to go another route. I am for the 
time being, using Smarty's engine. This will likely change down the road 
to a custom template engine, but I believe at this time this is the best 
option in regards to time/ease.


Thanks for the help anyways. It was valuable information.

- Craige

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



Re: [PHP] Text To Speech Update

2008-11-30 Thread Craige Leeder

Daniel P. Brown wrote:

Any/All:

For those of you who were asking about the PHP Text-To-Speech
system I had running, it's back online now.  If you have a few free
seconds, please take a look at http://www.pilotpig.net/txt2wav.php and
let me know if it's working for sure in your browser and on your OS.

With a bit more time being available to devote to non-paid
projects, and hopefully getting a bit better still in the next week or
so, I've had time to be able to work more with the PHP project and the
PHP-VOX.  When I make enough improvements to the installation routines
so that folks can easily do it on their own servers, I'll have the
source available for download.

Thanks, everyone.  Hope you're all enjoying the weekend.
  


I have to say, that is REALLY cool, and defiantly useful too. How long 
have you spent on it now?


- Craige

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



[PHP] getStatic

2008-11-24 Thread Craige Leeder

Hey guys,

So, I was working on my framework today, and noticed unfortunately that 
PHP does not allow using the magic method __get for static variables. 
There is a patch available, but I'm not sure how long it will be before 
it makes it into the stable PHP release.


Anyway, my question is about what route I should take now.

The reason I was looking for this was for the built in template engine. 
I expected to be able to put in a page


{HTML::$variable1}
or
{self::$variable1}

and have it evaluate using native PHP variables, instead of doing a 
large number of PHP str_replace for text based variables, a process 
which is surely slower.


As I see it, my options are:

Create

public static function get($fpName)

And have my templates littered with the extra

{HTML::get(variable1)}

OR

use PHP str_replace based variable parsing creating what I imagine would 
be a significantly higher overhead.


What would you do?

- Craige



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



Re: [PHP] file_Exists() and case

2008-11-23 Thread Craige Leeder

Stan wrote:

If $basePicture = ../pictures/2008 west coast trip/2008-06-10 first week at
Chris'/DSC_0011.jpg
and the file actually is ../pictures/2008 west coast trip/2008-06-10 first
week at Chris'/DSC_0011.JPG
(uppercase extension) the following snippet of code

---
/* make sure the picture file actually exists */
if(!file_Exists($basePicture))
 {
 echo file = ' . $basePicture . ' doesn't exist.br\n;
 $extStartsAt = strrpos($basePicture, .) + 1;
 $extOfBasePicture = substr($basePicture, $extStartsAt);
 $basePicture =
substr_replace($extOfBasePicture,strtoupper($extOfBasePicture),$extStartsAt)
;
 }
else
 {
 echo file = \ . $basePicture . \ exists.br\n;
 }

---
generates

---
file = ../pictures/2008 west coast trip/2008-06-10 first week at
Chris'/DSC_0011.jpg exists.

---
The script is running on an UBUNTU v8.04 LAMP server.  Case is supposed to
matter, isn't it?

Thanks,
Stan
  
Yes, case matters, but only of the file name, not the extension (I 
think). The extension is simply a secondary file-type identifier.


.jpg = .JPG = .jPg

I could be wrong.

- Craige


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



Re: [PHP] Open Project

2008-11-22 Thread Craige Leeder

Hi Nathan,

Are you fluent with OOP concepts?

I'm working on a framework called Ember, and wouldn't mind some help. I 
literally JUST started the re-code though


- Craige

Nathan Rixham wrote:

Evening All,

I'm feeling the need to either start or contribute to something 
opensource and in PHP.


Anybody have any worthy causes or projects they'd like to collab on to 
get off the ground; open to all options preference going to anything 
framework, orm, webservice or basically anything without an html front 
end :)


Regards,

Nathan




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



Re: [PHP] Hi,

2008-11-22 Thread Craige Leeder

idan72 wrote:

I would like to write code where the user  will input directory name.
I want it to be able to browse to directory and choose it.

With HTML if can only choose file.

Can I do that in PHP ?

Thanks
 
  
I have to say I have NO idea what you just said besides you want to 
build a file-system browser in PHP. It can be done very well in PHP, but 
what exactly are you going to do with it? Is it going to be for 
downloading files or something? What happens when you get all the way 
down the directory tree?


- Craige

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



Re: [PHP] Model Web Site

2008-11-20 Thread Craige Leeder
As Daniel mentioned, I would recomed building it upon an existing 
system. I've seen whole sites custom built around PHPBB.


This might be something you want to look into. Google for PHPBB 
programming tutorials; it's pretty well documented. I think it's your 
best bet if you don't want to spend forever building it from the ground-up.


PHPNuke might be a good option too, but I never liked it myself. It's 
all provided out of the box though.


- Craige

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



Re: [PHP] NetBeans xdebug

2008-11-19 Thread Craige Leeder

Gishaust wrote:

Are using  linux as an os  because if you are I am having trouble with getting 
xdebug to talk to netbeans
  

Nope, sorry. Vista

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



Re: [PHP] mysql_fetch_object and modulo %

2008-11-19 Thread Craige Leeder

Alain Roger wrote:

Hi,

how can i do to test if the row number (record number) sent by
mysql_fetch_object is odd or even ?
i mean that:
while ($row = mysql_fetch_object($result))
{
 if($row%2 == 1)
 {
  ...
 }
}

the $row doesn't return a value... like 1, 2 or 6 for example...
thx.
F

  
That's because $row is an object. Return your row uid (unique 
identifier; primary key w/ auto increment) and do:


while ( $row = mysql_fetch_object($result) )
   {
if( $row-UID % 2 == 1 )
{
 ...
}
   }



replacing UID with whatever you called the field in the database.

Hope this helps,
- Craige

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



Re: [PHP] HTTP Authentication

2008-11-19 Thread Craige Leeder

Thiago H. Pojda wrote:

Guys,

I have to access a WS that uses HTTP auth directly with PHP.

I've tried using the usual http://user:[EMAIL PROTECTED]/ but I couldn't get it
working. I believe it has something to do with the password containing a #
(can't change it) and the browser thinks it's an achor or something.

All I've seen were scripts to implement HTTP Auth in PHP, nothing about
actually logging in with PHP.

Is it possible to send the authentication headers the first time I access
the link? I could send all necessary headers to the page I'm trying to
access and retrieve it's content at once.


Thanks,
  



Why don't you let yourself in regardless of the credentials and print 
them out to make sure they're being evaluated as you expect.


- Craige

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



Re: [PHP] fread() behaviour

2008-11-19 Thread Craige Leeder

Rene Fournier wrote:
So my question is, why does fread wait if there is nothing more to 
read? Shouldn't it return immediately? (That's what I want.) And as 
for the delay, it's there so that if the incoming data is a little 
slow, it has time to catch up with fread. Thanks.


...Rene


I do believe:

No, because fread reads to EOF, which is not present. Just because there 
is no text being sent over the steam, does not mean EOF is present.


I could be wrong, but that's the general idea if I recall correctly.

- Craige

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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

just for laughs .. given the 'dabble' thread Cleeder is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.
  
Haha, now that does make me laugh. Out of curiosity, what is the actual 
word for it?


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



Re: [PHP] $_POST in header

2008-11-18 Thread Craige Leeder

Hi Alain,

In short, you can't. It's the users computer that remembers what headers 
it sent last time, and when you refresh, it WILL ask them to send those 
headers again.


The way this is typically handled from a programming perspective is to 
do all your processing on one page, and then jump away [via 
header(Location:  ) ] to another page for display. This is the only 
way I have come across to solve this problem.


You could use a Switch statement on the page to handle this, by passing 
it's case via querystring. e.g. Case 1: Process; Case 2: display;


Hope this helps,
- Craige


Alain Roger wrote:

Hi,

i have a PHP page with a form.
when user click on submit button, it sends form data to itself (so it sends
data $_POST to itself).
i would like to access to header itself to reset those $_POST data to avoid
(in case of F5 under windows system) to resend the same data serveral time.
therefore how can i get the header data and change them ?
thx

F.

  



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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

klieder ... kliederen

the E sound is short.

  

Interesting to know. Thanks :D

- Craige

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



Re: [PHP] implode()

2008-11-18 Thread Craige Leeder

Terion Miller wrote:

I have read the whole forum at php.net on implode and I still don't get why
this one does not work

if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',');} else {$BannerSize = ;}

someone please help

  

Is $_POST['BannerSize'] an array?

e.g. IS there:

$_POST['BannerSize'][1]
$_POST['BannerSize'][2]

Or something similar?

- Craige

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



Re: [PHP] implode()

2008-11-18 Thread Craige Leeder

Can we see the form, please?

As well, try using print_r on the array and see what it outputs.

- Craige

Terion Miller wrote:
yes there is , the selections are coming from a form (which isn't 
working because its not inserting into the db---ah another post later 
I imagine)
do you think a mis used implode would keep any of the data from making 
it to the db? 
I'm more of a designer than a programmer and feel like I'm drowning 
over my head here...





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



Re: [PHP] Re: phpDesigner 2008?

2008-11-18 Thread Craige Leeder

Holografix wrote:

Hi
I tried PHPDesigner some time ago. It's not bad but now I'm using Netbeans 
and it's a good editor: http://www.netbeans.org/ (it's free!)


Best regards,
Holo
  


I never knew Netbeans had a PHP IDE. I'll have to try it
- Craige

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



Re: [PHP] Re: anchor name on URL

2008-11-18 Thread Craige Leeder

Micah Gersten wrote:

I'd rather all the engines follow the W3C standards so that you just
have to make sure your web page is compliant.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com

  
Though I always script to W3 Standards, I could care less if browsers 
follow those standards, so long as we wind up closer and closer to a 
general set of rules we can obide by.


If IE 9 does take on Webkit, that's one step closer. It means one less 
set of arbitrary rules to develop for, which is one step closer to a 
standard.


Just my opinion. I guess it's the same as the fact that I don't care so 
much for any given standards, as much as I do for the idea of those 
standards. Bad standards are still 7 steps ahead of no standards at all.


- Craige

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



[PHP] NetBeans xdebug

2008-11-18 Thread Craige Leeder

Hi Guys,

So after somebody mentioned that NetBeans supports PHP development, I 
decided to give it a try. I'm liking it thus far, but I have a question 
if anybody happens to know the answer.


I have created a project group containing two projects (One for the site 
framework, one for the site frontend), but I'd like some help using 
xdebug across two projects.


NetBeans has built in breakpoints and watches which it co-ordinates with 
the script when run with xdebug, but I cannot seem to get these to work 
in the framework project if I'm testing front end.


IE:
- Add breakpoint to front-end page.
- Add watch to front-end variable

- Add breakpoint to back-end framework
- Add watch to back-end member variable

NetBeans does not show me anything have set to do on the back-end.

Note, I'm not using the xdebug breakpoint function, but rather expecting 
NetBeans to take care of those for me, so I don't litter code with those 
function calls.


It has something to do with the multiple projects, but I wondered if 
there was a way around it. As I said, I've added both projects to the 
same project group.


- Craige

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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Alain Roger wrote:

Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i = $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.
  
While you teacher technically is wrong, you probably could implement 
something using the next() and current() array functions, though you're 
best to just use a foreach loop. foreach was designed specifically as an 
array looping construct, so it's optimized pretty well.


Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige



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



Re: [PHP] Date Issue

2008-11-17 Thread Craige Leeder

Boyd, Todd M. wrote:

Are you sure this isn't like Javascript's getMonth function? Its index may begin at 0, making 
day 0 the first day of the year.

HTH,


Todd Boyd
Web Programmer

Hmm, though I know us programmers love to start counting at zero, why 
would something as static as a date start counting at zero? I would have 
imagined something like that would start at 1.


Guess it's just me.
- Craige

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



Re: [PHP] Variable Argument List

2008-11-17 Thread Craige Leeder

Richard Heyes wrote:

yup..
bWarning/b:  func_get_args():  Called from the global scope - no
function context



Doesn't the name of the function give you a clue as to its use? You
need to call it inside a function.

  
He was answering Nathan's question regarding what would happen IF you 
called it outside a function. He wasn't actually stupid enough to call 
it outside a function in actual code.


- Craige

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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach($array as $a) {}
  


Close. It actually looks like this:

foreach ($array as $key = $value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige



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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?
  


I'm 100% self taught for now. I'm just out of higschool, and hopefully 
going off to collage next year.


Everything I've learned at this stage is from books, tutorials, and 
experience.


- Craige

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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

Jochem Maas wrote:

must  . resist 

I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?

 dang it, failed. ;-)
  



Haha! 'high' was just my 'h' key not pressing, and college is just one 
of those words I have trouble with.



I'm not illiterate; promise :p

- Craige

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



[Fwd: Re: [PHP] Recursive Static Method]

2008-11-13 Thread Craige Leeder


---BeginMessage---

Hi Guys,

I found the problem. I was using the error suppression operator on my 
include, and thus I could not see the syntatic error on the page.


Problem Solved,
- Craige

Yeti wrote:

Some code would be quite helpful here. But your scenario should not
make any problem.

EXAMPLE:
?
class foo {
static function test() {
static $count;
$count++;
echo Call {$count}br /;
include_once('test.php');
}
}
foo::test();
?

EXAMPLE (@file: test.php):
?php
if (class_exists('foo')) {
foo::test();
}
exit();
?

OUTPUT:
Call 1br /Call 2br /

//A yeti

  



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

[PHP] Strange results

2008-11-13 Thread Craige Leeder


So, I have this class which contains a method LoadIO. I was doing some 
debugging as to why a condition wouldn't pass like I thought it would, 
and It's starting to piss me off.


The three echo's near the bottom are not printing what it should. The 
middle echo is not even printing static text.


Here's the definition:

/***
  * Public Method LoadIO
  * INCOMPLETE
  * @param $fpType Integer
  * @param $fpName String
  * @throws FileException
  * @return Object
  ***
  * LoadIO handles the loading of IO modules. IO modules are stored in
  * - /system/IO/ // System IO files
  * - /IO/// User defined third party modules
  ***/
  
 const mciInput  = 0;

 const mciOutput = 1;
  
 public function loadIO($fpType, $fpName) {

   global $gcIOPath, $gcSystemPath;
   
   //

   // Check paramaters for syntatic validity
   //
   if ( $fpType != Ember::mciInput  $fpType != Ember::mciOutput ) {
 throw new Exception('Invalid \'fpType\' paramater', 1002);
   }
   
   
   //

   // Variable assignment
   //
   $fType = ($fpType == self::mciInput) ? 'Input' : 'Output';
   $fFile  = $gcIOPath . $fType . '/' . $fpName . '.php';
   
   
   // Check User IO Path first.

   // If it does not exist there, check the System IO Path
   if ( !file_exists($fFile) ) {  
 $fFile  = $gcSystemPath . 'IO/' . $fType . '/' . $fpName . '.php';
 
 if ( !file_exists($fFile) ) {  
   throw new Exception(File '$fpName.php' not found., 1001);

 }
   }
   
   if ( !(include_once $fFile) ) throw new Exception(File '$fFile' 
could not be included.);


   echo 'stage 1br /';
   echo -  $fpType  - is equal to   self::mciInput  br /;
   echo 'stage 2br /';
   
   if ( $fpType == self::mciInput ) {

 echo 5;
 array_push($this-maInput, new $fpName);
 echo 'it\'s done';
   }
   
   
 }



The Call:

$Page-loadIO(Ember::mciOutput, 'html');


The Output:

stage 1
0stage 2

HELP!

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



Re: [PHP] Strange results

2008-11-13 Thread Craige Leeder

Micah Gersten wrote:


I think you meant this:
echo -  $fpType  - is equal to   self::mciInput  br /;
to be
echo - . $fpType . - is equal to  . self::mciInput . br /;
  

And this is how you know you've been doing too much ASP, lol

Thanks Micah!

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



[PHP] Recursive Static Method

2008-11-12 Thread Craige Leeder

Hi Guys,

Quick question: can a static method in PHP be recursive, or is there 
some sort of weird law against this? Ihave my method setPrereq that can 
essentially call itself (well, it includes a file which may call the 
setPrereq method, so essentially it is recursive).


I've done some tests, and it seems my setPrereq method is only getting 
called once. I'm not getting any errors under E_STRICT


Regards,
- Craige

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



Re: [PHP] Re: PreReq Index

2008-11-01 Thread Craige Leeder


Richard Lynch wrote:

So set up include_path to have all those directories and call it done.
  
The problem I see with with this is what if there is are two files of 
two different types (thus in different directories) which have the same 
file name?


Forgive me, I'm just trying to shoot out scenarios.

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



Re: [PHP] Re: PreReq Index

2008-10-31 Thread Craige Leeder
No can do. The files are stored in separate directories based on their 
usage/type. They're not all just in one directory.


Regards,
- Craige

Jochem Maas wrote:

try autoload()ing. what your trying to do is reinvent a wheel ...
and chances are yours will be less round.

  



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



[PHP] PreReq Index

2008-10-30 Thread Craige Leeder

Hi Guys,

So here's what I'm looking for as a result(ex):

array ('html'   = array('iOutput'  = array('iIO' = array() )),

  'xml'= array('iInput'   = array('iIO' = array() )),
  'database'   =  array('iData',
 'aMySQL',
 'aFile',
 'iOutput' = array('iIO' = array())
)
 );

This is a requirement tree which will be populated via my method 
Ember::setPreReq(). I'm not sure how to develop this method properly, 
however.


Ember::setPreReq() is a method I'm using as part of my framework that 
includes files needed by components in a clean manner, as well as 
allowing me map the requirements in an array that can be used for 
debugging purposes.


Definition thus far:

/***
  * Public Static Method getPrereq
  * INCOMPLETE
  * @param fpaFiles Array(String, Integer)
  **
  * Allows files to get prerequisite files to be included and initilized
  * if required.
  *
  * fpaFiles format:
  * array( 'test.php'  = Ember::mciSystem,
   'test2.php' = Ember::mciModule );
  **/
 
 const mciSystem= 0;

 const mciModule= 1;
 const mciLibrary   = 2;
 const mciInterface = 3;
 const mciException = 4;
 
 
 public static function setPrereq($fpaFiles) {

   global $gcSystemPath, $gcLibaryPath, $gcInterfacePath;
  


   foreach ( $fpaFiles as $fFile = $fType ) {
 switch ($fType) {

   //

   // mciSystem
   //
   case 0:

   break;
  
   //

   // mciModule
   //
   case 1:

   break;
  
   //

   // mciLibrary
   //
   case 2:
  
 $fFile = $gcLibraryPath . $fFile . '.php';


   break;
  
   //

   // mciInterface
   //
   case 3:
  
 $fFile = $gcInterfacePath . $fFile . '.php';

 if ( !file_exists($fFile) ) {

   throw new Exception(File '$fFile' does not exist, 1003);
 }

 @include_once $fFile or ( throw new Exception(File '$fFile' 
could not be included., 1003) );

 $this-maReqTree

   break;
  
   //

   // mciException
   //
   case 4:

   break;

 }
   }
 
 }


Example Call:


Ember::setPrereq( array('iOutput' = Ember::mciInterface) );

Any help is apreceated. I'm not sure where to go next to build this array.

Regards,
- Craige

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



[PHP] Re: PreReq Index

2008-10-30 Thread Craige Leeder
I forgot to mention, the calls to setPreReq() would occur in each file 
in place of an include() to get prerequisite components. IE:


html.php :
Ember::setPrereq( array('iOutput' = Ember::mciInterface) );

class html implements iOutput {
...
}


iOutput.php:
Ember::setPrereq( array('iIO' = Ember::mciInterface) );

interface iOutput implements iIO {
...
}

iIO.php:
interface iIO {
}

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



Re: [PHP] Interntet Explorer 8 beater 2

2008-09-08 Thread Craige Leeder

No, I'm not. I didn't even know it was in Beta until this email.

I probably wont download it until final release. I'm not the biggest MS 
fan, and pretty much the only reason I use IE is for cross-browser testing.


- Craige.

Richard Heyes wrote:

Hi,

Anyone using it?

  


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



Re: [PHP] render html

2008-09-08 Thread Craige Leeder

Can we see your parsing code, please?

BTW, are you parsing for br and br /, because you have given both as 
an example here.


- Craige

VamVan wrote:

hello,

i have html tags in the bod of text like:

$body = hellobr/ulier/ulhellohello;

print $body;

Some how it does not render html properly in a html page , what might be
going wrong?  br still get displayed as br instead of line breaks.

How can I render my HTML properly. Please note that it happens in  my cms.

Thanks

  



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



Re: [PHP] Large/unreliable file uploading over HTTP

2008-09-08 Thread Craige Leeder
The only concern I would have is that you are using a third party 
software/applet to do these uploads. I'm not a fan of MAKING users have 
a piece of software enabled to allow them basic web-standard 
functionality on a site.


It is however, an interesting concept. It would really come in handy for 
extremely large files.


- Craige

mike wrote:

Let's face it - HTTP is not very good for file uploads. It's stateless
nature, slow connections, inability to resume (technically), etc, etc.

What I've been thinking about is a way to skip all the normal
annoyances with file uploading - multipart form encodings, file upload
tools with specific needs, PUT vs POST, connection resets, ... the
list goes on and on.

Usenet and BitTorrent and other protocols have the right idea - split
up the workload into smaller sets of data. It's easier to operate on.
Usenet has NZB files. BitTorrent splits everything up into chunks. Not
only would it make working with the data more portable (no need to set
your PHP memory limit or POST limits to insane amounts to support
large files) but it could also support multiple segments of the file
being transferred at once...

Here's somewhat of a process braindump of what I'm thinking. It still
requires a 'smart' applet (Flash, Java, anything that can split a file
up and send data over HTTP/HTTPS) - no special socket needs, no PUT
support needed, don't even need to use multipart POST encoding (as far
as I know) - just send the data in chunks over the wire and have a PHP
script on the other side collect the data and reassemble it.

Does this sound insane? I think this is a pretty good approach - no
PUT needed, no large POST configuration required, anything could
upload to it as long as it sends the information properly (I'm
thinking HTTP POST for the header info, and the data could be sent as
another POST field maybe base64 encoded or something that will stay
safe during transit...)



- take input file, checksum it (md5 / sha1)
- calculate number of chunks to split it up based on $chunk configured
size (for example 128k chunks)
- split the file into chunks of $chunk size and create checksums for
all (could use sfv?)
- send request to the server - with the info - use JSON?
action=begin
filename=$filename
filesize=$filesize
checksum=$checksum
segments=list of segments (unique segment id, checksum, bytes)
- server sends back a server ready and unique $transaction_id
- start sending to the server, send header with transaction key and
unique chunk identifier in it
action=process
transaction=$transaction_id
segment=$unique_segment_id
   data=base64_encode($segment_data)
- when done, server sends back $transaction_id, $segment_id, $status
(okay, fail)
- client compares checksum for identifier, if okay, move to next chunk
- if it does not match, retry uploading to server again
- when all chunks are done, send request with transaction key and
action=finish
transaction=$transaction_id
   - when the server receives this, it assembles the file
from the segments and does a final checksum, and reports the checksum
back to the client (warning: on a large file this could take a bit?)
and sends back $transaction_id, $checksum
- client does one last check against the file's original checksum, if
it matches report success, otherwise report failure (would need to
determine why though - if all segments match this should not be able
to happen...)

I'd appreciate everyone's thoughts. This would also allow for file
upload progress, more or less, as the server and client are constantly
communicating when chunks are done and in progress (but again, that
has to be done with an applet)

I can't think of any method to do it in-browser, but doing it this way
could open the gates for things like Google Gears to possibly work
too...

  



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



Re: [PHP] Help with a foreach statement

2008-05-11 Thread Craige Leeder
Hi Ron,

This code should work:

?php

$path_to_shopping_cart = './';
$iLength = count($cart);

foreach ($cart as $product_name = $quantity)
{
  echo lia href=\ . $path_to_shopping_cart . product/ .
  $cart[$product_id] . /\ . $product_name . /a -  . $quantity .
/li\r\n;
}

?

Though I'm not sure about $cart[$product_id]. Where is that coming
from?. It makes no sense here. Perhaps you want to do a
tri-demensional array in $_session, so you will have a
dual-demesnional array in $cart.

Let me know,
- Craige

On Sun, May 11, 2008 at 2:54 PM, Ron Piggott [EMAIL PROTECTED] wrote:
 I am writing a shopping cart.

 Products assigned in the following fashion:
 $_SESSION['selection'][$product]=$quantity;

 I am wanting to display the list of products in the shopping cart in a
 list for the user to see as they continue shopping.

 I put the SESSION variable into $cart

 $cart = $_SESSION['selection'];

 then I start the foreach and this is where I get messed up.  I am trying
 to ECHO the following syntax to the screen with each selected product:

 The part I need help with is to write the foreach loop to give me
 $product (so I may query the database to find out the product name) and
 the $quantity (so I may show the user what they are purchasing).  The
 part that is messing me up is that this is an array.

 My ECHO statement should look like this:

 echo lia href=\ . $path_to_shopping_cart . product/ .
 $cart[$product_id] . /\ . $product_name . /a -  . $quantity .
 /li\r\n;


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



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



Re: [PHP] Re: unsubscribe

2008-05-11 Thread Craige Leeder
 You've even had to resort to using classes and other strange stuff to
 program. Clearly signs of mental fatigue. :-)

:o. I think mental fatigue might be evident by one not using it. But
that's just me ;)

- Craige

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



Re: [PHP] $_SESSION v. Cookies

2008-05-11 Thread Craige Leeder
I can't see PHP sessions slowing down your site by that amount. As
someone said, it should be no more than a split second. If you are
having that much of a problem with them, then I would say it is either
your implementation, or another determining factor.

I would not, personally, stray away from PHP's GC of sessions. I would
imagine that any third-party concoction could not be any faster. I
would however, check to see how long PHP takes to clean up defunct
sessions, and also monitor how many sessions are lying around at any
given time.

Regards,
- Craige

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



Re: [PHP] Execute command from web browser

2008-05-04 Thread Craige Leeder
Well, you're missing a semi-colin after the exec() statement, and the echo.

If it wasn't the syntax error, make sure the program exists with file_exists();

- Craige

On Sat, May 3, 2008 at 11:28 PM,  [EMAIL PROTECTED] wrote:

  Hi all


  I try write a code to execute service in my server from web browser

  I write next

  /var/www/html/squidup.html
  ?
  exec ('/usr/bin/squid/sbin/squid')
  echo Squid UP
  ?

  but, don't work from web browser.

  What is wrong

  Thanks,

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



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



Fwd: [PHP] php page scrapping challenge!

2008-05-04 Thread Craige Leeder
Hey Paragasu,

 Sounds like fun, though not really that difficult. It is a very
 horrible site, but it shouldnt' take that much to create the script
 for. They do not, in-fact, use Javascript to pull the movie times from
 the database. They reload the page with the added querystring
 variables (for my run through):

 isSearchBy=cin // How are we searching
 visCinID=1000  // What is the cinema ID
 visMovieName=Iron+Man// What movie do we want to see?

 I'd give it a try, but I am not setup to use curl at the moment, and
 don't anticipate having done so in time to do this.

 What you need to do is access the url that assigns you your session
 ID, and store that for subsequent curl calls to the server. You should
 pass it with all of them. You also need to find out where they
 generate the (what I assume is) dynamic part of their url so you can
 use that to access the actually movie url. The part in my url was:
 .../(3yujtbmepau3jb45a22gju55)/...

 Good luck with this project, and let us know how it goes.
 - Craige


On Sun, May 4, 2008 at 11:26 PM, paragasu [EMAIL PROTECTED] wrote:
  well, this going to be fun.
 
   the website i am trying to scrapped is http://www.cathayholdings.com.my/
   it is a movie cinema website with very irritating design. They really tried
   to imposed the
   security to the point it is really not user friendly. The whole website
   written in asp.
 
   I really hate to go around looking for the show time for the latest movie
   and decided to
   build my own simple website to display the movie and show time from the
   cathay cinema
   my own way.
 
   But, it is proven not so easy to do. The datetime buried deep inside the
   online booking. Thus
   user will be able to see the showtimes only when the user click the online
   booking. Then, after
   user click the online booking, the link open on a new window and generate a
   cookies. this cookies
   will be part of the URL. So basically, there is two cookie value pass to the
   server. (one GET request  one in HTTP header)
 
   Apart from that, they use javascript (AJAX?) to pull the showtime from the
   server after you have to
   click 3 times. OMG.. i only wan't to know the time and have to go thus whole
   step.
 
   using  php curl library to simulate the request just to get the movie name
   and show time list from the
   server. it is possible? post your code..
 
   ** no reward, just for php programming fun..
 

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



Re: [PHP] Complex escape string

2008-05-03 Thread Craige Leeder
Why exactly are you doing this? While variable-variables can be of use
at times, I don't think this is one of them. How do you use this newly
created variable.

- Craige

On Sat, May 3, 2008 at 1:20 PM, cyaugin [EMAIL PROTECTED] wrote:
 I have this line of code:

  $q = This is the string that will go into the query:
  {${mysql_real_escape_string($_GET['searchstring'])}};

  What happens then is the user supplies 'foo' as the search string, and I get
  a debug notice Undefined variable: foo. Why is it treating the value as an
  identifier and how do I make it do what I actually want it to do? This is on
  PHP5, latest release.



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



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



[PHP] Re: problem with for loop

2008-05-02 Thread Craige Leeder
I think Peter is probably right. In the case he is not however, can
 you post a print_r of $multiArray.

 - Craige



 On Fri, May 2, 2008 at 7:24 AM, Peter Ford [EMAIL PROTECTED] wrote:
 
  Richard Kurth wrote:
 
   Way does my for loop not complete the task if there are 4 emails it only
  process 3 emails through the foreach loop if there is 3 it only process 2
  
  #  Connect up
  $host =domain.com;
  $port =110;
  $mailtype = pop3;
  $mailbox =INBOX;
  $username =[EMAIL PROTECTED];
  $password =boat1234;
 $conn = @imap_open({ . $host . : . $port . / . $mailtype .
  /notls} . $mailbox, $username, $password);
  
   $number=imap_num_msg($conn);
   for($i = 1; $i = $number; $i++) {
   $file=C:\web\bouncehandler\eml\em$i;
   imap_savebody($conn,$file,$i);
  
  
   $file=file_get_contents(C:\web\bouncehandler\eml\em$i);
   $multiArray = Bouncehandler::get_the_facts($file);
  
   $EMAIL = $the['recipient'];
   foreach($multiArray as $the){
 switch($the['action']){
 case 'failed':
 $sql=UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE
  emailaddress = '$EMAIL';
 mysql_query($sql) or die(Invalid query:  . mysql_error());
  break;
 case 'transient':
 $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress
  = '$EMAIL';
 mysql_query($sql) or die(Invalid query:  . mysql_error());
 break;
 case 'autoreply':
 $sql=UPDATE contacts SET emailstatus = 'Bounced' WHERE emailaddress
  = '$EMAIL';
 mysql_query($sql) or die(Invalid query:  . mysql_error());
 break;
 default:
 //don't do anything
 break;
 }
 }
  
   }
  
  
  
 
   I think you need to check the boundary conditions on your loop.
   As you write it,
 
 
  for($i = 1; $i = $number; $i++)
 
   if $number is 4 then $i will have the values 1,2,3,4.
 
   Perhaps message list is zero-based, and you actually need to count from
  zero:
 
  for($i = 0; $i  $number; $i++)
 
   so you would get $i to read 0,1,2,3
 
   The manual page doesn't explicitly say the the message number is one-based,
  and most real programming languages these days use zero-based arrays...
 
   --
   Peter Ford  phone: 01580 89
   Developer   fax:   01580 893399
   Justcroft International Ltd., Staplehurst, Kent
 
 
 
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



[PHP] Any Running Simple Ajax Sample for Php

2008-05-02 Thread Craige Leeder
Hi Heysem,

 So what you want is an ajax script that will call a php page every
 minute, and check for a result (assuming boolean) of 1 or 0? That
 shouldn't be too hard. First, I need to know more information about
 the page, such as the id tag of the element you want updated, and how
 severe the change. If it's a simple word, it's easy to do.

 If you could post more information (and possible what you have tried
 already, and maybe we can just fix that), I should be able to help you
 out more.

 Regards,
 - Craige



 On Fri, May 2, 2008 at 5:13 AM, Heysem KAYA
[EMAIL PROTECTED] wrote:
  Hi,
 
   I would like to check each minute whether the user credit is finished and
   update the relevant place on page. So I have downloaded however was not able
   to run some sample ajax code.
 
   Is there anyone who has such a simple code to implement?
 
 
 
   Thanks,
 
 
 
   Heysem Kaya
 
 

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



Re: [PHP] set_error_handler help

2008-05-02 Thread Craige Leeder
I beleive you can also do

set_error_handler(array('classname', 'myMethod'));

for static methods.

- Craige
On Fri, May 2, 2008 at 2:26 PM, Richard Heyes [EMAIL PROTECTED] wrote:

  Is there any way to use a class to handle errors? I've tried some stuff
 like
  set_error_handler(Error_Handler::logError and such, but with no luck.
 

  It accepts a callback type, which is a pseudo type. Basically an array
 containg the object and the method to use. Eg.

  $obj = new ErrorHandlingObject();
  set_error_handler(array($obj, 'myMethod'));

  --
  Richard Heyes

  ++
  | Access SSH with a Windows mapped drive |
  |http://www.phpguru.org/sftpdrive|
  ++

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



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



Re: [PHP] Assigning functions

2008-05-02 Thread Craige Leeder
Hello Philip

First thing first: design patterns are your friend. A good reference
for which, is:

http://www.fluffycat.com/PHP-Design-Patterns/

Second of all. What is the situation in which you are trying to do
this? I can't really think of one where you would do such a thing.

- Craige

On Fri, May 2, 2008 at 3:09 PM, Philip Thompson [EMAIL PROTECTED] wrote:
 Hi all. I have several classes. Within each class, a new class is called. Is
 there a way to assign a function in a *deeper* class to be called in the
 first class? Example to follow..

  ?php
  class A {
 function __construct () {
 $this-b = new B ();
 // I want to do the following. This does not work, of course.
 $this-doSomething = $this-b-c-doSomething;
 }
  }

  class B {
 function __construct () {
 $this-c = new C ();
 }
  }

  class C {
 function __construct () { }
 function doSomething () { echo ¡Hi!; }
  }

  $a = new A ();
  // Instead of doing this,
  $a-b-c-doSomething();

  // I want to do this.
  $a-doSomething(); // ¡Hi!
  ?

  Basically, it's just to shorten the line to access a particular function.
 But, is it possible?!

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



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



Re: [PHP] Assigning functions

2008-05-02 Thread Craige Leeder
ons here) as a simple example something like this

  class B {
   //...
   function doSomething() {
   return $this-c-doSomething();
   }
  }

  which allows you this in A instances

  $this-b-doSomething();

  this is the preferred approach, since A and C instances are loosely coupled.

  of course, if you wanted a to 'know' about c then you could do something
  like this,

  class B {
   // ..
   function getC() {
  return $this-c;
   }
  }

  giving you the ability to do this in A instances

  $this-b-getC()-doSomething();

  of course now A's knows about C's and your system is more tightly coupled.

  -nathan


Why don't you just do a registry pattern instance then? IE:

class Registry
{
  private satic objs;

  public function __construct()
 {

self::$objs = function_get_args();
  }

  public static function __get($obj)
  {
return self::$objs[$obj];
  }
}

class A
{
...
}

class B
{
...
}

$reg = new Registry( new A(), new B());

Now A and B can access each other through Registry::A and Registry::B

(that code may not function. It's just a general example)

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



Re: [PHP] Re: Assigning functions

2008-05-02 Thread Craige Leeder
On Fri, May 2, 2008 at 7:27 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
  Why are you using OOP?  That's insane.

  -Shawn

I  believe that's a matter of opinion. Some people like OOP, others
don't. Why criticize the man because he likes to use it? I like to use
it as well.

Regards,
- Craige

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



Re: [PHP] XHTML Validation problem

2008-05-02 Thread Craige Leeder
html_entities()

http://ca.php.net/manual/en/function.htmlentities.php

Hope this helps
- Craige

On Sat, May 3, 2008 at 12:13 AM, It Maq [EMAIL PROTECTED] wrote:
 Hi,

  I have a page that displays data entered by the user. There is one user that 
 entered the character  inside the text he typed. For this case the xhtml 
 validation fails and gives me the following error:
  character  is the first character of a delimiter but occurred as data.

  I'm wondering if there is a way to avoid this error. The page itself is 
 valid and fails just in the case the user enters the  character.

  Thank you


   
 
  Be a better friend, newshound, and
  know-it-all with Yahoo! Mobile.  Try it now.  
 http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



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



Re: [PHP] Upload and resize file

2007-08-23 Thread Craige Leeder
While I'm not 100% sure, I'd say something's wrong with this line:

system(pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50
$imgfile);

I would say that Linux is not writing the output to the location
stored in $imgfile, and thus there is no file there to delete.
However, I can not really be sure. Can someone support or deny this
claim?

- Craige

On 8/22/07, Beauford [EMAIL PROTECTED] wrote:
 I downloaded this 'upload and resize image' script, and since I have no idea
 what I am looking at as this is something I have never done, could someone
 have a look and see what the problem might be.  I've been searching around
 but haven't come across anything that makes any sense yet.

 When a picture needs to be resized I am getting the following error. If it
 is the same size or under I don't get this error.

 Warning: unlink() [function.unlink]: No such file or directory in
 /usr/local/apache/htdocs/website/upload.php on line 92

 The full code is below.

 Thanks

 --

 html

 head
 titleweb.blazonry : PHP : Upload and Resize an Image/title

 ?php

 if ($_SERVER['REQUEST_METHOD'] == POST)
 {

 /* SUBMITTED INFORMATION - use what you need
  * temporary filename (pointer): $imgfile
  * original filename   : $imgfile_name
  * size of uploaded file   : $imgfile_size
  * mime-type of uploaded file  : $imgfile_type
  */

  /*== upload directory where the file will be stored
   relative to where script is run ==*/

 $uploaddir = images;


 /*== get file extension (fn at bottom of script) ==*/
 /*== checks to see if image file, if not do not allow upload ==*/
 $pext = getFileExtension($imgfile_name);
 $pext = strtolower($pext);
 if (($pext != jpg)   ($pext != jpeg))
 {
 print h1ERROR/h1Image Extension Unknown.br;
 print pPlease upload only a JPEG image with the extension .jpg or
 .jpeg ONLYbrbr;
 print The file you uploaded had the following extension:
 $pext/p\n;

 /*== delete uploaded file ==*/
 unlink($imgfile);
 exit();
 }


 //-- RE-SIZING UPLOADED IMAGE

 /*== only resize if the image is larger than 250 x 200 ==*/
 $imgsize = GetImageSize($imgfile);

 /*== check size  0=width, 1=height ==*/
 if (($imgsize[0]  250) || ($imgsize[1]  200))
 {
 /*== temp image file -- use tempnam() to generate the temp
  file name. This is done so if multiple people access the
 script at once they won't ruin each other's temp file ==*/
 $tmpimg = tempnam(/tmp, MKUP);

 /*== RESIZE PROCESS
  1. decompress jpeg image to pnm file (a raw image type)
  2. scale pnm image
  3. compress pnm file to jpeg image
 ==*/

 /*== Step 1: djpeg decompresses jpeg to pnm ==*/
 system(djpeg $imgfile $tmpimg);


 /*== Steps 23: scale image using pnmscale and then
  pipe into cjpeg to output jpeg file ==*/
 system(pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50
 $imgfile);

 /*== remove temp image ==*/
 unlink($tmpimg);

 }

 /*== setup final file location and name ==*/
 /*== change spaces to underscores in filename  ==*/
 $final_filename = str_replace( , _, $imgfile_name);
 $newfile = $uploaddir . /$final_filename;

 /*== do extra security check to prevent malicious abuse==*/
 if (is_uploaded_file($imgfile))
 {

/*== move file to proper directory ==*/
if (!copy($imgfile,$newfile))
{
   /*== if an error occurs the file could not
be written, read or possibly does not exist ==*/
   print Error Uploading File.;
   exit();
}
  }

 /*== delete the temporary uploaded file ==*/
unlink($imgfile);


 print(img src=\images\\$final_filename\);

 /*== DO WHATEVER ELSE YOU WANT
  SUCH AS INSERT DATA INTO A DATABASE  ==*/

 }
 ?


 /head
 body bgcolor=#FF

 h2Upload and Resize an Image/h2

 form action=?php echo $_SERVER['PHP_SELF']; ? method=POST
 enctype=multipart/form-data
 input type=hidden name=MAX_FILE_SIZE value=5

 pUpload Image: input type=file name=imgfilebr
 font size=1Click browse to upload a local file/fontbr
 br
 input type=submit value=Upload Image
 /form

 /body
 /html

 ?php
 /*== FUNCTIONS ==*/

 function getFileExtension($str) {

 $i = strrpos($str,.);
 if (!$i) { return ; }

 $l = strlen($str) - $i;
 $ext = substr($str,$i+1,$l);

 return $ext;

 }
 ?

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



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



Re: [PHP] Outputting a PDF.

2007-08-23 Thread Craige Leeder
Rob,

This has to be a browser problem. I cannot see it being anything else.

For arguments sake however, would you mind showing us your code. While
I'm sure it is a browser issue, it may have something to do with what
PHP is returning to the browser.

- Craige

On 8/22/07, Rob Adams [EMAIL PROTECTED] wrote:
 I have a pdfs saved in a database (created with pdflib).  When I output them
 in firefox, it works just great everytime.  But when I try in IE, it doesn't
 always work.  I know, I know, it sounds like a browser issue, but here's the
 problem.  I figured out that when I run session_start(), the pdf never shows
 up in IE.  When I don't run it, it works just as well as in firefox.  When I
 put my header calls to set the content type to application/pdf before the
 session_start() call, IE spits out an error:

 Internet Explorer cannot display the webpage

Most likely causes:
 You are not connected to the Internet.
 The website is encountering problems.
 There might be a typing error in the address. 

 Anyone know of a fix for this?

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



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



Re: [PHP] using disable_functions silently

2007-08-23 Thread Craige Leeder
Are you *running* a shared hosting environment? If so, what is to stop
you from adding the exec() function to the list in php.ini?

- Craige

  Don't think so. The code just needs to handle it better. I do it like
  this:
 
  $disabled_functions = explode(',', str_replace(' ', '',
  ini_get('disable_functions')));
 
  if (!in_array('set_time_limit', $disabled_functions)) {
  set_time_limit(0);
  }
 
  Works every time :)
 

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



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



Re: [PHP] using disable_functions silently

2007-08-23 Thread Craige Leeder
Oh, okay. He simply wants to ignore them without raising any flags to
say it has been done. I get what he wants. However, as you stated,
there is no way to do this (to the best of my knowledge).

- Craige

On 8/23/07, Chris [EMAIL PROTECTED] wrote:
 Craige Leeder wrote:
  Are you *running* a shared hosting environment? If so, what is to stop
  you from adding the exec() function to the list in php.ini?

 He wants php to automatically ignore functions listed in the
 'disabled_functions' list - which there is no way to do.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/


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



Re: [PHP] ignore-user-abort and connection-handling

2007-08-23 Thread Craige Leeder
Hi Jason,

If you have a lengthy script with several queries throughout it, it is
possible you could end up with a scrambled database. However, with
short scripts, there is not much of a threat of this. Generally, your
scripts will probable execute in  2 seconds (and 2 seconds is
lengthy), with an average of 1 second or less. In these cases, by the
time the user makes the request to the server, it will take longer
than the length of your script execution for the termination request
to be sent from the browser to the web server, and then to php.
Therefor, php will simply halt returning output(assuming output
buffering), but all script execution will be complete.

That being said, if you wanted extra peace of mind, you could enable
ignore-user-abort. Odds are though, that you will never really need it
unless you are writing lengthy scripts that take several seconds to
execute.

Hope this helps,
- Craige

On 8/23/07, Jason Pruim [EMAIL PROTECTED] wrote:
 Hi Everyone :)

 One of these days someone is going to get sick of hearing from me,
 but until that day comes I have another question :)

 I asked on a MySQL list about wether it's better to have 1 database
 with many tables, or many databases with 1 table for my address list
 application I'm writing.

 One of the people there asked me about terminating the TCP
 connections and ensuring that each PHP script runs to completion to
 keep the database in good condition.

 He recommened looking at the ignore-user-abort and connection-
 handling functions in php...

 So now the question, Do I have to worry if a user hits the stop
 button in their browser before the script finishes? Will It corrupt
 the database or causing undo havoc to my system?

 This is far past my knowledge, so references to how I would use
 something like that properly would be greatly appreciated! :)


 --

 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] using disable_functions silently

2007-08-23 Thread Craige Leeder
You can't overwrite PHP's built-in functions, nor any function that
has been defined for that matter.

- Craige

On 8/23/07, Samuel Vogel [EMAIL PROTECTED] wrote:
 That'd be at least some kind of a solution.
 I'm thinking of overwriting the functions I want to block with one, that
 just returns true and does nothing.
 How would I do that?

 Jay Blanchard schrieb:
 [snip]
 Unfortunately we would need a solution without changing the PHP code of
 our users.
 No way to do that?
 [/snip]

 Not really. You could auto-prepend all of the PHP files with the
 necessary PHP files, but that may not be a really good solution.

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



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



Re: [PHP] Social Networking Sites OT

2007-07-13 Thread Craige Leeder

On 7/14/07, Richard Lynch [EMAIL PROTECTED] wrote:

If somebody wants the next Web 2.0 killer app, build a
meta-social-networking site that lets the user manage all the big
social networking sites through a single central interface. :-)


Is it sad that I thought of that while reading this topic?

Anyway, I always told myself I'd never sign up for any of those sites,
and for the longest time, I didn't. However, a few weeks ago I
registered for my Facebook account, and it's not as bad as I thought.
I have had random people I've only met once try to add me as a friend,
but I simply ignore them.

So my thoughts? I say that they're fine in moderation. Don't let it
become an addiction, and it's fine.

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



Re: [PHP] Alter an Array Key

2007-07-13 Thread Craige Leeder

1. Don't modify $_POST
2. You controll the name of the array keys with the form. Why is there
any need to change them form PHP's side of things?
3. I'm not sure Roberts solution would work. I think it might result
in an endless loop, and timeout your script.

- Craige

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



Re: [PHP] New Menu Bar - Can people test it for me?

2007-02-23 Thread Craige Leeder

I like it, but it's pretty image intensive.

- Craige

On 2/23/07, Daevid Vincent [EMAIL PROTECTED] wrote:

Very nice - sorta.

It doesn't work for me in IE6, but does work in FF2.

 -Original Message-
 From: Richard Lynch [mailto:[EMAIL PROTECTED]
 Sent: Friday, February 23, 2007 2:03 PM
 To: Scott Gunn
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] New Menu Bar - Can people test it for me?

 On Wed, February 21, 2007 6:12 am, Scott Gunn wrote:
  http://www.thebigspider.co.uk/test/menu.html
 
  I'm going to write some php code which will build this menu from an
  XML
  file.
 
  Before I do, I want to know what sort of browser
 compatibility it has?
  could
  you guys test it and let me know if it worked ok and looked like the
  preview
  picture?
 
  If your on IE7 or Firefox2 and it works please don't email back as I
  know
  these work fine.

 http://browsercam.com/

 There are probably other similar solutions.

 PS I'll tell you for free, without even checking, that it probably
 doesn't work in lynx. :-)

 --
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some starving artist.
 http://cdbaby.com/browse/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



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




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



Re: [PHP] include file identifier

2007-02-05 Thread Craige Leeder

On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote:

If you want to avoid the overhead of include_once, it's a pretty
common practice (borrowed from C .h files) to do:


Just out of curiosity, how much additional overhead are we talking about?

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



Re: [PHP] who is online?

2007-02-05 Thread Craige Leeder

Ditto. There's really no reason it can't go here.

- Craige

On 2/5/07, benifactor [EMAIL PROTECTED] wrote:

I agree.

 hey.

 for my $0.02 worth.. these kinds of questions are not exactly only php.
 however, i still see them as being valuable, and belonging to the php
 list,
 as they get into areas the php developers of sites might grapple with. i'm
 of the opinion more, rather than less.

 so if you have more intelligent discussions regarding php/site development
 technologies that integrate with php, this is the place for it!!

 peace..


 -Original Message-
 From: Stut [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 05, 2007 5:31 AM
 To: benifactor
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] who is online?


 benifactor wrote:
 sorry if you misunderstood, i just wanted to know if it could be done
 with php alone.

 It can't, and this should be fairly obvious. If the client-side makes no
 contact with the server for a period of time, how do you expect it to
 know that the user hasn't moved to another page?

 The bottom line is that this needs some client-side code to work,
 whether it be Javascript or just an iframe with a meta refresh tag.

 -Stut

 - Original Message - From: Stut [EMAIL PROTECTED]
 To: benifactor [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Sent: Monday, February 05, 2007 5:18 AM
 Subject: Re: [PHP] who is online?


 benifactor wrote:
 i have built a function to tell me how many users are on my site at
 any given time... ?

 //define function

 function bc_who ($who, $location) {


 //first we erase any expired entries //entries will expire after 5
 mins $whoTime = time(); $whoTime = $whoTime - 300;
 mysql_query(Delete FROM bc_who where expire  $whoTime) or
 die(mysql_error());

 //here we difine the variables needed to preform the check $whoExpire
 = time(); $whoIp = $_SERVER[REMOTE_ADDR];

 //this will be changed as soon as user registration is finished
 $whoUser= Guest; //do the actual mysql queries

 mysql_query(Delete FROM bc_who where '$whoIp' = ip);
 mysql_query(Insert INTO bc_who (id, user, ip, location, expire,
 status) VALUES (NULL, '$whoUser', '$whoIp', '$location',
 '$whoExpire', '$whoStatus'));


 }

 //end who is function

 ?

 this fuction works fine, however, i want to know if what i am about
 to ask is possible.

 the problem i have is, this function assumes that after five minutes
 if the user has not refreshed the page, or gone onto another page the
 user must be gone. in reality, i have pages users might be on for an
 hour or so without refreshing. i want my whos online to as acurate as
 possible so is there a way to do this on the fly? like, forgetting
 about the expire time and using a server side peice of code to
 communicate to the database, when there is no more communication the
 entry is deleted? please tell me there is a way, thank you in
 advance.

 Assuming you actually mean client side not server side (because
 server-side is what you already have), you could do this in a number
 of ways with Javascript. You could periodically call the server using
 XmlHttpRequest, or you could keep it simple and reload an image which
 points at a PHP script. Either way this is not a question for a PHP
 list because it relates to client-side code. Google will almost
 certainly have several useful sites.

 -Stut

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



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

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


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




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



Re: [PHP] Billing client for studying documentation

2007-02-05 Thread Craige Leeder

Mike,

Talk to the client, and explain the situation. I'm sure that you will
be able to work out some sort of agreement. It may not be for all the
hours, but that's not unreasonable considering the fact that this was
not explained before you went ahead with your research.

If nothing else, you come out on top with knowledge of what you
learned during this experience.

Good luck,
- Craige

On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Sat, February 3, 2007 8:09 pm, Mike Mannakee wrote:
 I have a php project I have been working on for several months.  The
 client's requirements have expanded to include interfacing to an
 online
 service using xml, which I was familiar with but have never worked
 with
 prior to this project.  I have spent a good number of hours reading up
 on
 xml, and learning how to use it to integrate with this online service.
  I
 have also spent hours poring over hundreds of pages of documentation
 for the
 online service itself.

 My question is this - should I be billing the client for this time?
 It is
 needed to properly work with this framework, but it is not programming
 time
 in itself.  Googling the topic has been useless.

You should probably discuss it with the client...

Actually, you should have discussed it before you started researching.
:-v

That said, you can probably safely invoice for a few hours of XML
research, but it shouldn't be big enough to be more than a line item
in the whole project invoice.

On the plus side, acquiring knowledge is always expensive, and almost
always worth the expense. :-)

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/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




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



Re: [PHP] PHP book reviewers wanted

2007-02-05 Thread Craige Leeder

How many book reviews do you suppose Manuel has written in his life time?

- Craige

On 2/5/07, Tim [EMAIL PROTECTED] wrote:



 -Message d'origine-
 De: tedd [mailto:[EMAIL PROTECTED]
 Envoyé: lundi 5 février 2007 17:10
 À: Manuel Lemos; php-general@lists.php.net
 Objet: Re: [PHP] PHP book reviewers wanted

 At 1:05 AM -0200 2/5/07, Manuel Lemos wrote:
 Demonstrating good English writing skills and having published good book
 reviews in the past gets me preference.

 gets me preference ???


Quote: good English writing skills

:P

 Me get any money for this?

 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

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




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



Re: [PHP] is there socket.so file?

2007-02-05 Thread Craige Leeder

Yeni,

On Linux, it is necessary to compile php with the --enable-sockets
flag to be able to use php's socket functions.

Hope this helps,
- Craige

On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Sat, February 3, 2007 10:18 am, Yeni Setiawan wrote:
 Hi there,
 I'm currently writing an IRC bot using php (CLI) and get a little
 problem.

 For windows version, I need to enable socket extension (socket.dll)
 and
 my bot will be able to connect to an IRC server.

 But in linux version, it's unable to connect. So I wonder if there's a
 
 socket.so or something else
 to activate socket extension.

 And the question is, do I need socket extension in Linux?

The answer is Yes but the rest of the answer depends on your version
of PHP more than anything else...

http://php.net/sockets

lays that out rather nicely, actually.

Did you do *any* research at all on this?...

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/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




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



Re: [PHP] is there socket.so file?

2007-02-05 Thread Craige Leeder

On 2/5/07, Richard Lynch [EMAIL PROTECTED] wrote:

Unless it's PHP 4, and it's already in, or PHP 5 and it's in PECL or...

It's just not that simple.

Sorry.


Ah, I didn't realize they stopped bundling it with PHP as of PHP
5.3.0. That sucks. It used to be that simple.

- Craige

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



Re: [PHP] Who uses PHP

2007-02-04 Thread Craige Leeder

As has been said: It all depends on the developer. A skilled developer
is not restrained by how secure the particular language is. A
skilled developer will know the pitfalls of that language, and be able
to avoid them.

With php as an example, you have register_globals. Now,
register_globals is NOT a bad thing. However, due to incompetent
coders, it is one of the easiest exploits in many php applications. A
skilled developer is able to work unconditional of weather
register_globals is on on his/her server.

- Craige

On 2/3/07, Christopher Weldon [EMAIL PROTECTED] wrote:

 Well, if you do not know the answer to my particular question, I'm
 curious how might you respond to someone who says:

   PHP has to many security issues and should not be used with a
 user authentication system.
   We should use XXX.

 I think security mainly depends on the programmer and not on the
 language he uses...

 greets
 Zoltán Németh

I totally agree.



 You are not allowed to say 'Well, you're wrong. PHP is as secure as
 anything else.' without explaining why.
 Or, would you agree with the statement? Is there an 'XXX' that should
 be used instead of PHP?


Of course not. As Zoltan stated above, security is dependent upon the
programmer and not the language. But, if you aren't familiar with why
PHP is considered so insecure its a result of people who can't/
don't know how to properly program PHP applications. PHP is an easy
programming language to learn quickly and hit the ground running.
These people (typically) don't care to check to make sure writing
something like:

mysql_query('SELECT * FROM admins WHERE username = '.$_GET
['username'].' and password = '.$_GET['password'].'');

is safe and secure. This is one of the bigger issues I've seen on
some PHP applications. As you will (or perhaps already have read) on
Chris S.'s site that a big thing to do in PHP apps is FIEO (Filter
Input Escape Output). Applications written in this manner are
insecure; PHP isn't what's insecure.

However, with my limited Computer Science training, FIEO is something
that should be done in any application under any programming language
- for security's sake.

So, rather than consider the difference in security of a programming
language versus another, you should be asking the question What does
PHP offer me that XXX doesn't?. Alternatively, if the person on the
other end is still too concerned about security, then you should be
considering How much easier is it for me to program secure
applications in PHP than XXX? If you do it right from the start,
you'll find that PHP does not make it difficult to write secure apps.

 Given the limited number of options for maintaining state
 information, I would be hard pressed to see how any language could be
 inherently more security or why one could not write PHP code which
 implemented the same techniques as 'XXX'.

 (No, I do not know what 'XXX' might be.)


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



--
Christopher Weldon
President  CEO
Cerberus Interactive, Inc.
[EMAIL PROTECTED]
(866) 813-4603 x605

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




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



Re: [PHP] PHP5 Commercial Development

2007-02-04 Thread Craige Leeder

Eric,

PHP is fine for commercial environments. Many people are just afraid
of it due to the fact it is known to break some poorly written PHP 4
scripts, and the fact that many people don't think it's new features
are necessary. It is perfectly fine to use it in a commercial
environment however.

- Craige

On 2/2/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Thu, February 1, 2007 5:13 pm, Eric Gorr wrote:
 I haven't tracked this particular issue, but I know when PHP5 was
 first released is wasn't recommended in a commercial/production
 environment. However, a lot of time has passed and we're at v5.2
 now...have things changed? Have GoogleYahoo, for example, moved to
 PHP5? Or is PHP4 still the recommendation for such environments?

Do you need XML processing or SOAP?

What are your performance requirements?

Are there features in Apache 2 that you need?

Are you using only PHP extensions that are known to be [probably]
thread safe?

You've grossly under-documented your needs, to the point that nobody
can answer your question very well.

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/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




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



Re: [PHP] Select record by ID

2007-01-30 Thread Craige Leeder

atleast this part: $user_id = mysql_real_escape_string((int)
$_GET['user_id']);


I'm not sure who put this in there, but you don't need to use
mysql_real_escape_string() on that value if you're type casting it. If
you are forcing it to be an integer, there is nothing to escape.
Integers are perfectly fine to be put into a query as they are.

- Craige

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



Re: [PHP] Select record by ID

2007-01-28 Thread Craige Leeder

As someone else already stated, my best guess according to that error
is that $user_id has a null, or inappropriate value. The error occurs
at the last character of the query, so it has to be something like
hat. Echo the query and let us know what it outputs.

- Craige

On 1/28/07, Francisco M. Marzoa Alonso [EMAIL PROTECTED] wrote:

On dom, 2007-01-28 at 18:20 -0600, Larry Garfield wrote:
 On Sunday 28 January 2007 5:54 pm, Francisco M. Marzoa Alonso wrote:
  On dom, 2007-01-28 at 18:51 -0500, nitrox . wrote:
   I took the quotes off. I thought that quotes around numbers was wrong
   also.
 
  Quotes are no necessary around numeric values, but they aren't wrong
  neither, simply optional.

 Actually, I believe they are wrong in some database engines but not others.
 MySQL doesn't care.  Some others do.  Yes, it sucks. :-(

Good point, but he's using mysql in this case, and in mysql they're
simply optional but not wrong.

Regards,






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



Re: [PHP] Exceptions: How much is too much.

2007-01-07 Thread Craige Leeder

Thanks.

Does anybody else have any input? Not to be pushy, but I'm in the
middle of programming a framework for a site.

- Craige

On 1/5/07, Paul Scott [EMAIL PROTECTED] wrote:


On Fri, 2007-01-05 at 00:44 -0500, Craige Leeder wrote:
 The question is: How much is too much. Should I use Exceptions to
 handle all of my error reporting/triggering? How about catching them?
 I mean, if I'm using Exceptions for all of my error handling, I could
 easily end up wrapping my entire script in a try block(or at least
 having almost all my end-code within a number of them).

Not sure if I am doing it correctly either, but, what I do is use
try/catch blocks to instantiate all of the objects that I need and then
let the script take over. I also use exceptions to handle SQL errors in
my db abstraction object(s). That way, only real messes are caught and
the script then displays a graceful exit page to the user instead of
screen vomit that may scare them off.

--Paul



All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm





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



Re: [PHP] Port Block

2007-01-05 Thread Craige Leeder

You could do a hackish work around and write a small server program
that is hosted off your computer, maybe on a friend's host/server.
Then, you could have your application on your local machine open some
other port to connect to the off-site server, and have it send the
email data to that server, and have the off site server send the
emails.

It's a mean, hackish work around, but if your host wont unblock port
25, you don't have many options short of finding a new ISP.

- Craige

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



[PHP] Exceptions: How much is too much.

2007-01-04 Thread Craige Leeder

PHP Mailing List Listeners,

My question to you is about PHP 5's exception handling. I have looked
at it for a while, but never REALLY used it.

The question is: How much is too much. Should I use Exceptions to
handle all of my error reporting/triggering? How about catching them?
I mean, if I'm using Exceptions for all of my error handling, I could
easily end up wrapping my entire script in a try block(or at least
having almost all my end-code within a number of them).

What is your advice on this matter?

- Craige

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



Re: [PHP] Merry Christmas!

2006-12-25 Thread Craige Leeder

Merry Christmas everyone. I hope you have/had a great one. Enjoy your
turkey feasts this weekend, they comes only a few times a year.

On 12/25/06, Miles Thompson [EMAIL PROTECTED] wrote:

At 07:20 AM 12/25/2006, Robert Cummings wrote:

WhoooOO! Hope you all have a great Christmas day. If
you don't celebrate Christmas, then I hope you have a great Christmas
day anyways *lol*. If this post offends you due to it's promotion of
Christmas then I apologize and hope you have a great anal retentive
Christmas day!!! :B

Merry Christmas,
Rob.


Hey Rob,

It's now Christmas night here in Nova Scotia.

We had a  great day. The weather was mild, so we had apcnic lunch on the
way to visit my sister and her family; then had the big family get-together
there. We missed our oldest, he's in Ottawa visiting his girlfriend, but
then our job is to raise them to leave the nest. Besides, she's a lovely girl.

Merry Christmas to everyone - Miles


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.26/601 - Release Date: 12/24/2006

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




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



[PHP] Couple Problem.

2006-12-25 Thread Craige Leeder

PHP General Mailing List,

I have a few questions when it comes to installation of PHP, and a PHP
extension   I have been eyeing

The first question involves Installation of PHP-GTK with PHP 5, from
zip. Although I follow the simple instructions included in the zip, I
am not able to start the PHP executable. I get an error of a missing
library (php-gtk2.dll [not found], and a pop up saying intl.dll). Have
I done horribly wrong? I didn't think it would be that hard of a task.
I'm using the gtkpath batch file, as apposed to changing my  PATH
variable this time around.

The second question is about installation op PHP 6. I have tried, and
failed at the installation of PHP 6 on my windows machine. Apache will
not load the module. I am not sure my exact setup now, as I attempted
it a week and a half ago, but as I recall I did not change my PATH
variable, to avoid conflict with my existing stable PHP5 installation.
Therefor, I moved the dll into the apache folder.

Sorry if allot of this is a little cryptic. I am dead tired, and just
wanted to send this off tonight before I retired for the night.

Thanks for any help you may be able to give based on this message.

- Craige

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



[PHP] Error Display

2006-12-09 Thread Craige Leeder

I have been working with PHP5 since it's release, and until a few
months ago, have never experienced the problem I am about to describe
to you. I am not sure weather it has been discovered previously or
not, nor do I know exactly how to replicate it, but I would like to
know if you have encountered the problem as well. The problem is this:

I have noticed that there appears to be (fatal) errors that do not
show when they occur in an included file. The script simply halts
execution, and returns headers to the browser. I do not have a list of
the errors that do not display, but I do not believe it applies to all
fatal errors.

The errors show perfectly fine when the file is called directly from
the php parser (/through the browser), just not when included. This is
an extreme annoyance, and would like to know if it has been
discovered. As far as I can tell, the errors seem to apply mostly to
Objects and classes, but I cannot be certain. I have not run too many
tests on the problem.

Although it should not need to be stated, I do have error reporting
set to E_ALL.

- Craige

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



Re: [PHP] Embedded Video

2006-12-09 Thread Craige Leeder

You would need to use Java or Flash to load the video and check the
loaded size against the total size.

- Craige

On 12/9/06, Beauford [EMAIL PROTECTED] wrote:

Not sure if this can be done with PHP, or if I would need to use a java
script or something. If anyone has any ideas it would be appreciated.

I have a video on my site and I want something to say that the video is
loading and then disappear once the video starts.

Thanks again.

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




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