Re: [PHP] Fwd: Is it possible???

2013-06-24 Thread Marco Behnke



Am 24.06.2013 18:17, schrieb Maciek Sokolewicz:

On 24-6-2013 14:27, n...@nobswolf.info wrote:

You should give a complete programm so we can run exactly
the same you do, like this:


Please please please please don't do this!

First of all, I don't know why you would use the print *function* when
you can also use the echo language construct (better and faster). But



read and learn http://de2.php.net/manual/en/function.print.php

print is not actually a real function (it is a language construct)

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] Having a problem with clone.

2013-05-11 Thread Marco Behnke
Am 10.05.13 11:35, schrieb Richard Quadling:
> Trying to clone an uncloneable object of class Smarty_Variable
Different PHP versions maybe?

Look at this thread I found:
http://wordpress.org/support/topic/fatal-error-trying-to-clone-an-uncloneable-object-of-class-reflectionclass

The last post

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Need a tool to minimize HTML before storing in memecache

2013-05-03 Thread Marco Behnke



Am 03.05.2013 21:34, schrieb Daevid Vincent:



-Original Message-
From: Marco Behnke [mailto:ma...@behnke.biz]
Sent: Friday, May 03, 2013 12:01 PM
To: Daevid Vincent; php >> "php-general@lists.php.net"
Subject: Re: [PHP] Need a tool to minimize HTML before storing in memecache

If you really have that much traffic, then memcache isn't your answer to
caching. It is as slow as a fast database.


That's not entirely true.


There are many comparisions all around the web and we did a benchmark 
for ourselves when we evaluated what the fastest solution is. Memcache 
is slower than APC. It gets worse when you start communicating over the 
network with memcache.



If you want to go with tidy and surf around the php issues you could
optimize the single html parts, before glueing everything together.


That would require much more work than simply getting < and > to work. And 
honestly I've been hacking around Tidy so much at this point with regex to minify the 
output, that I'm even wondering if Tidy is worth the both anymore. Not sure what else 
it will give me.


Maybe it is the best solution to think about optimizations you want and 
code them by hand like stripping comments, too much whitespace, empty 
tags, linebreaks and whatever. I guess it will save a lot of time.


Or you download the tidy sourcecode and put in your wanted changes? 
Maybe suggest a change request or submit a patch?





Maybe google page speed is worth a look for you too?


We have over 1,000 servers in house and also distributed across nodes in 
various cities and countries.


Don't know if this is an answer to my question? You know what google 
page speed is about?





smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] Need a tool to minimize HTML before storing in memecache

2013-05-03 Thread Marco Behnke
=%20$layout_id%20?%3E/css/styles.css">
>>>>> >>>> href="/templates/%3C?=%20$layout_id%20?%3E/css/retina.css" media="only
>>>>> screen and (-webkit-min-device-pixel-ratio: 2)">
>>>>>
>>>>> I found ['fix-uri' => false] which gets closer:
>>>>>
>>>>> >>>> href="/templates/<?= $layout_id ?>/css/styles.css">
>>>>> >>>> href="/templates/<?= $layout_id ?>/css/retina.css" media="only
>>>> screen
>>>>> and (-webkit-min-device-pixel-ratio: 2)">
>>>>>
>>>>> I've tried about every option I can think of. What is the solution to
>> make
>>>>> it stop trying to be smarter than me and converting my < and > tags??
>>>>>
>>>>> //See all parameters available here:
>>>>> http://tidy.sourceforge.net/docs/quickref.html
>>>>> $tconfig = array(
>>>>>//'clean' => true,
>>>>>'hide-comments' => true,
>>>>>'hide-endtags' => true,
>>>>>'drop-proprietary-attributes' => true,
>>>>>//'join-classes' => true,
>>>>>//'join-styles' => true,
>>>>>//'quote-marks' => true,
>>>>>'fix-uri' => false,
>>>>>'numeric-entities' => true,
>>>>>'preserve-entities' => true,
>>>>>'doctype' => 'omit',
>>>>>'tab-size' => 1,
>>>>>'wrap' => 0,
>>>>>'wrap-php' => false,
>>>>>'char-encoding' => 'raw',
>>>>>'input-encoding' => 'raw',
>>>>>'output-encoding' => 'raw',
>>>>>'newline' => 'LF',
>>>>>'tidy-mark' => false,
>>>>>'quiet' => true,
>>>>>'show-errors' => ($this->_debug ? 6 : 0),
>>>>>'show-warnings' => $this->_debug,
>>>>> );
>>>>>
>>>>>
>>>>> From: Joseph Moniz [mailto:joseph.mo...@gmail.com]
>>>>> Sent: Wednesday, April 17, 2013 2:55 PM
>>>>> To: Daevid Vincent
>>>>> Cc: php-general General
>>>>> Subject: Re: [PHP] Need a tool to minimize HTML before storing in
>>>> memecache
>>>>> http://php.net/manual/en/book.tidy.php
>>>>>
>>>>>
>>>>> - Joseph Moniz
>>>>> (510) 509-0775 | @josephmoniz <https://twitter.com/josephmoniz>  |
>>>>> <https://github.com/JosephMoniz> GitHub |
>>>>> <http://www.linkedin.com/pub/joseph-moniz/13/949/b54/> LinkedIn | Blog
>>>>> <http://josephmoniz.github.io/>  | CoderWall
>>>>> <https://coderwall.com/josephmoniz>
>>>>>
>>>>> "Wake up early, Stay up late, Change the world"
>>>>>
>>>>> On Wed, Apr 17, 2013 at 2:52 PM, Daevid Vincent 
>> wrote:
>>>>> We do a lot with caching and storing in memecached as well as local
>> copies
>>>>> so as to not hit the cache pool over the network and we have found
>> some
>>>>> great tools to minimize our javascript and our css, and now we'd like
>> to
>>>>> compress our HTML in these cache slabs.
>>>>>
>>>>>
>>>>>
>>>>> Anyone know of a good tool or even regex magic that I can call from
>> PHP to
>>>>> compress/minimize the giant string web page before I store it in the
>>>> cache?
>>>>>
>>>>>
>>>>> It's not quite as simple as stripping white space b/c obviously there
>> are
>>>>> spaces between attributes in tags that need to be preserved, but also
>> in
>>>> the
>>>>> words/text on the page. I could strip out newlines I suppose, but then
>> do
>>>> I
>>>>> run into any issues in other ways? In any event, it seems like someone
>>>> would
>>>>> have solved this by now before I go re-inventing the wheel.
>>>>>
>>>>>
>>>>>
>>>>> d.
>>>>>
>>>> --
>>>> Marco Behnke
>>>> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
>>>> Zend Certified Engineer PHP 5.3
>>>>
>>>> Tel.: 0174 / 9722336
>>>> e-Mail: ma...@behnke.biz
>>>>
>>>> Softwaretechnik Behnke
>>>> Heinrich-Heine-Str. 7D
>>>> 21218 Seevetal
>>>>
>>>> http://www.behnke.biz
>> --
>> Marco Behnke
>> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
>> Zend Certified Engineer PHP 5.3
>>
>> Tel.: 0174 / 9722336
>> e-Mail: ma...@behnke.biz
>>
>> Softwaretechnik Behnke
>> Heinrich-Heine-Str. 7D
>> 21218 Seevetal
>>
>> http://www.behnke.biz
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] A little confused

2013-04-23 Thread Marco Behnke
Am 23.04.13 12:07, schrieb Chris Knipe:
> Hi All,
>
> $_SESSION['ExpiryDate'] = "2013-04-23";
> echo date_format($_SESSION['ExpiryDate'], "D, \t\h\e jS \o\f M Y");
>
> Required Result: Mon, the 23rd of Apr 2013
>
> I get however:  PHP Warning:  date_format() expects parameter 1 to be
> DateTime, integer given in
>
> I've had a look at the date/time function list, but I cannot seem to find
> any way to convert $_SESSION['ExpiryDate'] to an DateTime??

Take a look at this:
http://de3.php.net/manual/en/datetime.createfromformat.php

Or try this

http://de3.php.net/manual/en/function.strtotime.php

$_SESSION['ExpiryDate'] = "2013-04-23";
$int_timestamp = strtotime($_SESSION['ExpiryDate']);
echo date('D, \t\h\e jS \o\f M Y', $int_timestamp );

Use SINGLE QUOTES!


>
> --
> Chris.
>
>
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] self operator within a double quoted string

2013-04-17 Thread Marco Behnke
Am 17.04.13 20:59, schrieb Matijn Woudt:
> On Wed, Apr 17, 2013 at 7:47 PM, NaMarPi  wrote:
>
>> I would like to use self and static operators inside a double quoted
>> string,
>> but do not find the way to accomplish that. Could you give me a right
>> direction?
>>
>>
>> http://3v4l.org/NDkdA
>>
>>
>> class Foo {
>>
>> public static $class_prop = 'Class_Property';
>> public $object_prop = 'Object_Property';
>>
>> static function printClassProp() {
>> print 'prefix_' . self::$class_prop . '_postfix' . PHP_EOL;
>> print "prefix_{\\self::$class_prop}_postfix" . PHP_EOL;   //
>> <-- issue here
>> }
>>
>> function printObjectProp() {
>> print "prefix_{$this->object_prop}_postfix" . PHP_EOL;
>> }
>> }
>>
>>
>> $foo = new Foo;
>> $foo->printObjectProp();
>>
>>
>> Foo::printClassProp();
>>
>>
> Hi,
>
> This is a bug/feature in php and is just not possible. Either use the
> syntax you've used on the single quotes, or store the variable in a
> temporary var before using the print.
Or use printf which is much more readable.
>
> - Matijn
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Lasting syntax error when there's none

2013-04-09 Thread Marco Behnke



Am 09.04.2013 17:00, schrieb fr...@me.com:

Hi everyone,

I have some weird problem with PHP compiler or something of this sort of 
things. We have some PHP files which are generated during the first request to 
the site. These files are normally executed via PHP then. For some reason PHP 
thinks that they contain syntax errors (verified using HTTP request, or `php 
-l`). I've found out it is extremely easy to resolve this issue manually when 
developing - simply renaming or touching that file resolves the issue. So, 
apparently those generated PHP files don't contain any syntax error. However, 
PHP thinks they do even across different SAPIs (CLI and FPM). Since fixing the 
issue in this manner doesn't seam reasonable even by some script on production, 
I'd like to know whether do you have any suggestion what settings to tweak or 
what might be the problem.



If touching resolves the error, maybe it is some kind of bytecode cache.
Do you use APC or something like that?

Touch the file after creating it
http://www.php.net/touch



Here is some information about the environment (feel free to ask for more):
- PHP version: 5.3.10-1ubuntu3.6
- SAPI: FPM and CLI
- OS: Ubuntu 12.04
- Software: Ubuntu packages only (updated)
- HTTP request handling: nginx load balancer → PHP FPM daemon
- Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3


Thanks,



--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] Session variable not persisting

2013-03-18 Thread Marco Behnke
Am 18.03.13 19:46, schrieb Éric Oliver Paquette:
> Hi all, 
>
> I'll be swift in my explanation as I can't find in any way the source of the 
> problem; it seems to be installation-related. 
>
> At execution, sometimes (randomly it seems at first), variable session aren't 
> properly stored. 
>
> =
>
> First things first, about installation : 
>
> uname -a -m -p yields :
>
> Linux cl-t180-253cl.privatedns.com 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 
> 04:16:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
>
> php -v yields :
>
> PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:48) 
> Copyright (c) 1997-2010 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
>
> =
>
> To make sure it is not caused by any other part of my scripts, I just created 
> two scripts that have replicated the problem :
>
> SCRIPT #1 [ping.php] 
>
> 
> session_start();
>
> if(count($_SESSION['in'])==0){
> $_SESSION['in'][0]='0-initiate';
> } else {
> $_SESSION['in'][] = count($_SESSION['in']).$_GET['push'];
> }
>
> if(count($_SESSION['in'])<1000){
> $rand = rand(0, 100);
> ?>
> 
>  } else {
> var_dump($_SESSION);
> }
>
> ?>
>
> SCRIPT #2 [pong.php]  
>
> 
> session_start();
>
> if(count($_SESSION['in'])==0){
> $_SESSION['in'][0]='0-initiate';
> } else {
> $_SESSION['in'][] = count($_SESSION['in']).$_GET['push'];
> }
>
> if(count($_SESSION['in'])<1000){
> $rand = rand(0, 100);
> ?>
> 
>  } else {
> var_dump($_SESSION);
> }
>
> ?>
>
> ##
>
> In fact, when I run this on my server I randomly have empty entries in the 
> $_SESSION array. Any thoughts on this? Is this a known bug (haven't found it…)
>
> Thanks!

Just a thought that came to my mind: Have you disabled browser caching?

And about the "push" is undefined in the logs: How do you call the
script for the first time? With or with push parameter?

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] mysql custom global defined variable

2013-03-13 Thread Marco Behnke
Am 13.03.13 10:35, schrieb Kevin Peterson:
> In my database design, I tend to store some variable that is meant to be 
> acting as a ROLE or TYPE as SMALLINT. For example : 
>
> CREATE TABLE `house` (
>`id` int(11) NOT NULL AUTO_INCREMENT,
>`type` smallint(11) NOT NULL,
> )
>
>
> And in php, I do
>
> define('HOUSE_SMALL_TYPE', '0');
> define('HOUSE_MEDIUM_TYPE', '1');
>
> So in php, in SELECT queries I do :
>
> $this->db->query("SELECT * FROM house  
> WHERE type=?;", HOUSE_SMALL_TYPE);
>
> My questions are : 
> 1. In the php part, is there is a better way to do this ? 

I stopped using define in favor of somehow "namespaced constants" as
const in classes. But basically there is no difference.
Advantages of using constants (which ever) are code completion to avoid
spelling errors. I see no possible improvements here.

> 2. In the mysql itself, does mysql also has global define functionality (like 
> the define in php) ? I also want to do kind of SELECT * FROM house WHERE type 
> = HOUSE_SMALL_TYPE in mysql query.

Maybe this is what you are looking for?
http://forums.mysql.com/read.php?98,273432,273432


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Re: Generating CRUD code for normalized db

2013-03-13 Thread Marco Behnke
Am 13.03.13 12:57, schrieb Gary:
> ma...@behnke.biz wrote:
>
>> Do us all a favor abnd stay away from open source if you do not honor
>> the work
>> us wannabes put into it.
> As I said before "I wasn't aware you would feel that the cap fitted."
> If you do feel that, then perhaps instead of complaining at me for
> pointing it out, you would be better off employing that time increasing
> the quality of what you produce.
>
So you said you tried Yii. But have you wasted some of your precious
time trying out the extension that "extends" Yii in a way, that creating
models and views with Gii get proper SELECT Boxes and stuff for
relations? If I understood you correct, this is what you were looking for?

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Mystery foreach error

2013-03-12 Thread Marco Behnke
Am 12.03.13 20:45, schrieb Angela Barone:
>   I've been getting the following error for awhile now, but I can't 
> figure out why it's happening:
>
> Invalid argument supplied for foreach() in ... sample.php on line 377
>
>   Here's that portion of code:
>
> include("states_zipcodes.php");
>
> // Check if Zip Code matches from states_zipcodes
> $zip_short = substr($zip, 0, 3);
> foreach ($states[$state] as &$zip_prefix) {   // <-- line 377

what is in $states?
Looks like $states[$state] is not an array.

And don't use & reference operator in foreach loop, there can be strange
side effects if you don't act carefully with it.

> if ($zip_prefix == $zip_short) {
> break;
> } else {
> $match = 'no';
> }
> }
>
>   It doesn't happen all the time, so I'm thinking that some spambot is 
> populating the HTML form with something the script doesn't like(?).  However, 
> I tested that myself by entering text, or by entering just 2 digits, but 
> there was no error.  FYI, I do have code in the script that catches faulty 
> input and warns people in their browser to go back and re-enter the correct 
> data, so I'm at a loss as to why this is happening.
>
>   How can I see what's triggering this to happen?  I have the following 
> line in my php.ini:
>
> error_reporting = E_ALL & E_STRICT & E_NOTICE & E_DEPRECATED
>
> Thank you,
> Angela


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] OOP to run sequential SQL queries?

2013-02-17 Thread Marco Behnke
Am 17.02.13 17:00, schrieb AmirBehzad Eslami:
> Dear list,
>
> We have a bunch of SQL-queries, they should be executed in
> a sequential order, with a defensive programming style in mind.
I don't understand what you want?
Queries are executed sequentially or do you plan to create a
multi-process PHP application?
>
> We were thinking to implement the solution as "Stored Procedures"
> instead of a PHP solution that runs SQL queries, but an article in
> Coding Horro recommendeds to avoid SP for good reasons:
>
> http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
>
> Now we're going to carry on in PHP, and my experience says that
> we should write the solution in a procedural-style, instead of OOP.
>
> Is there any benefit to use OOP in these situations?
>
> Please share your thoughts.
>
> Thanks,
> -behzad
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] APC opcode cache behavior

2013-02-14 Thread Marco Behnke
Am 14.02.13 16:05, schrieb Camilo Sperberg:
>
> You can also write a little script that clears the APC cache, something in 
> the line of: 
>
> #!/usr/bin/php
>  apc_clear_cache();
>
> And execute this script each time you deploy. (can also be a command such as 
> php -r "apc_clear_cache();"). This way you'll avoid restarting the webserver 
> and it will clear all APC cache forcing APC to cache everything again.

since apache and cli do not share the same apc, it will not work.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Rewrite Help

2012-12-28 Thread Marco Behnke

On 28.12.2012 17:13, Floyd Resler wrote:

On Dec 28, 2012, at 11:09 AM, Marco Behnke  wrote:


On 28.12.2012 16:30, Floyd Resler wrote:

I'm having a perplexing problem with a rewrite rule (it's off topic but it's 
Friday!).  My initial path is  
piccDetails/index/0/linetypes/2012-01-01/2012-12-31/Successful and that works 
great.  However, in my script I want to change the zero in the path to a 1.  
This tells it to generate a spreadsheet.  When my new link is clicked on I wind 
up with  
piccDetails/index/0/linetypes/2012-01-01/2012-12-31/Successful/piccDetails/index/1/linetypes/2012-01-01/2012-12-31/Successful.
  Each click just adds to the end of the URL instead of replacing it.  My 
.htaccess file looks like this:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

where is the rewrite rule from 0 to 1?
And can not see it here?
Have you set a rewrite base? Do you use relative or absolute links on 
your page?


You know, with seeing all of the relevant code, nobody can point out the 
error


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



Re: [PHP] Rewrite Help

2012-12-28 Thread Marco Behnke

On 28.12.2012 16:30, Floyd Resler wrote:

I'm having a perplexing problem with a rewrite rule (it's off topic but it's 
Friday!).  My initial path is  
piccDetails/index/0/linetypes/2012-01-01/2012-12-31/Successful and that works 
great.  However, in my script I want to change the zero in the path to a 1.  
This tells it to generate a spreadsheet.  When my new link is clicked on I wind 
up with  
piccDetails/index/0/linetypes/2012-01-01/2012-12-31/Successful/piccDetails/index/1/linetypes/2012-01-01/2012-12-31/Successful.
  Each click just adds to the end of the URL instead of replacing it.  My 
.htaccess file looks like this:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

where is the rewrite rule from 0 to 1?
And can not see it here?

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



Re: [PHP] Session ?

2012-12-13 Thread Marco Behnke
Am 13.12.12 14:49, schrieb Jim Giner:
>
>> Ok, that is a different answer from the previous one where you said "it
>> points to a folder within my main domain's structure"
>>
>> Are you running on error_reporting(E_ALL) and ini_set('display_errors',
>> 'On')?
>> Just to be sure that there are no hidden notices or warnings.
>>
>>
> my sub points to a folder within my domain's structure.  My session's
> store point (?) is \tmp.  You asked two different questions.
>
point taken ;)

I will try to do a setup like yours and check which code works for me.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Session ?

2012-12-12 Thread Marco Behnke
Am 12.12.12 15:58, schrieb Jim Giner:
> On 12/12/2012 8:08 AM, ma...@behnke.biz wrote:
>>
>>
>> Jim Giner  hat am 12. Dezember 2012 um
>> 02:53
>> geschrieben:
>>> On 12/11/2012 7:27 PM, Marco Behnke wrote:
>>>> Am 08.12.12 19:08, schrieb Jim Giner:
>>>>> All my debugging messages indicagte that I have the same session id,
>>>>> yet I don't have the same variables, ie, they're missing.
>>>> Just to be sure ... the webspace is on the same server and has
>>>> access to
>>>> the same directory where the session data is stored?
>>>> (session_save_path)?
>>>>
>>>>
>>> Yes - it points to a folder within my main domain's structure.
>>
>> which is accessible from your subdomains?
>>
>>>
> They are all pointing (re the ini file) to the default of /tmp so I
> presume that they all have access to that folder.

Ok, that is a different answer from the previous one where you said "it
points to a folder within my main domain's structure"

Are you running on error_reporting(E_ALL) and ini_set('display_errors',
'On')?
Just to be sure that there are no hidden notices or warnings.


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Session ?

2012-12-11 Thread Marco Behnke
Am 08.12.12 19:08, schrieb Jim Giner:
> All my debugging messages indicagte that I have the same session id,
> yet I don't have the same variables, ie, they're missing.
Just to be sure ... the webspace is on the same server and has access to
the same directory where the session data is stored? (session_save_path)?


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Storing passwords in session variables

2012-12-11 Thread Marco Behnke



Am 11.12.2012 20:51, schrieb Peet Grobler:

On 2012/12/11 2:46 PM, Paul Halliday wrote:

Client <-> Server is encrypted,  can I toss these into session variables?



Do note your full url (including &user=xx&pass=yy will be logged in
apache logs, and depending on configuration in squid logs in-between too.


Normally you would pass credential as post variables or even better use 
http auth for that. (read about http code 401


How to send in HTTP: 
http://en.wikipedia.org/wiki/Basic_access_authentication


Read in auth vars in PHP: http://php.net/manual/de/features.http-auth.php





--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] Question

2012-11-03 Thread Marco Behnke
Am 03.11.12 01:30, schrieb Silvio Siefke:
> Hello,
>
> i have compile PHP 5.4.8 on my Debian System. I have before Version 5.4.7. 
> I delete before all old Files from PHP and then run the commands:
>
> ./configure --sysconfdir=/usr/local/etc --with-pear --enable-bcmath 
> --with-bz2=/usr --disable-calendar --enable-ctype --without-curl 
> --without-curlwrappers --enable-dom --without-enchant --enable-exif
> --enable-fileinfo --enable-filter --disable-ftp --with-gettext=/usr 
> --without-gmp --enable-hash --with-mhash=/usr --with-iconv --disable-intl 
> --disable-ipv6 --enable-json --without-kerberos --enable-libxml 
> --with-libxml-dir=/usr --enable-mbstring --with-mcrypt=/usr --without-mssql 
> --with-onig=/usr --with-openssl=/usr --with-openssl-dir=/usr --disable-pcntl 
> --enable-phar --enable-pdo --without-pgsql --enable-posix --with-pspell=/usr 
> --without-recode --enable-simplexml --disable-shmop --without-snmp 
> --enable-soap 
> --enable-sockets --with-sqlite3=/usr --without-sybase-ct --disable-sysvmsg 
> --disable-sysvsem --disable-sysvshm --without-tidy --enable-tokenizer 
> --disable-wddx --enable-xml --disable-xmlreader --disable-xmlwriter 
> --without-xmlrpc --without-xsl --enable-zip --with-zlib=/usr --disable-debug 
> --without-cdb --disable-flatfile --disable-inifile --without-qdbm 
> --with-freetype-dir=/usr --with-t1lib=/usr --disable-gd-jis-conv 
> --with-jpeg-dir=/usr --with-png-dir=/usr --without-xpm-dir --with-gd 
> --with-imap=/usr --with-imap-ssl=/usr --with-mysql=/usr 
> --with-mysqli=/usr/bin/mysql_config --without-pdo-dblib --with-pdo-mysql=/usr 
> --without-pdo-pgsql --with-pdo-sqlite=/usr --without-pdo-odbc 
> --with-readline=/usr 
> --without-libedit --without-mm --with-pcre-regex=/usr --with-pcre-dir=/usr 
> --disable-embed --disable-cli --disable-cgi --enable-fpm --without-apxs2 
> --with-kerberos
>
> make -j3 ; make install
>
> But when i look in the directorys i miss pear and the php-cgi.
>
> root:/usr/local/src/php-5.4.8# ls /usr/local/bin
> php-config  phpize
>
> root:/usr/local/src/php-5.4.8# ls /usr/local/sbin
> php-fpm
>
> Must under bin not be php-cgi and pear, or is my thinking wrong?
maybe because of

--disable-cgi


>
>
> Thank you for help and Greetings
> Silvio
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] TURBOPY cloud framework + IDE beta available NOW

2012-10-31 Thread Marco Behnke
Am 31.10.12 18:13, schrieb Adam Richardson:
> While OOP is one way to approach programming, it's not the only way. Even
> Rasmus has said he leans procedurally:
> http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Found another interesting discussion on that topic:

http://stackoverflow.com/questions/1185605/when-to-use-static-vs-instantiated-classes

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] TURBOPY cloud framework + IDE beta available NOW

2012-10-31 Thread Marco Behnke
Am 31.10.12 18:13, schrieb Adam Richardson:
> On Tue, Oct 30, 2012 at 7:33 AM, ma...@behnke.biz  wrote:
>
>> In times of testability and several design patters, the use of static
>> calls is
>> really outdated.
>> I understand that you can read and write the invocations of the methods
>> much
>> faster, but you should think more to the future on that point.
>
> What?
>
> Where is it written that the use of static calls is really outdated?
> Functional programming is on the rise, and this is largely because of the
> virtues of testability, scalability, and simplified patterns. Using a class
> to organize a set of static functions can benefit the code in PHP (allow
> for autoloading in PHP because functions can't be autoloaded, essentially
> serves as a child namespace, etc.) whilst maintaining the benefits of a
> more functional approach (unit testing purely written static functions is
> much easier, putting all IO tasks in separate components makes for cleaner
> modules, etc.)
I mentioned in an earlier post on the list, why I - and "some others" -
think, the use of static methods is somehow outdated.

1. If you have code using static methods and members and use phpunit for
testing it, you have to either make sure, that everything is properly
resetted after use OR have to run phpunit in a mode where every test is
run in a single php call for itself. One is potentially harmful to the
test if you forgot some side effects and one is time consuming.

2. When thinking about dependency injection (give everything you use
inside, from the ouside in), show me how one can do this with classes
WITHOUT passing strings around? And without DI, how do you keep your
application flexible to different environments and conditions?
>
> I try to emulate functional approaches in PHP, such as what you'd find in
> Scala, Clojure, or Haskell, and static calls in PHP can facilitate this
> approach.
>
> While OOP is one way to approach programming, it's not the only way. Even
> Rasmus has said he leans procedurally:
> http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html
Are you serious quoting that post?
Posted by Rasmus <http://toys.lerdorf.com/authors/1-Rasmus> on Monday,
February 27. 2006

>
> Adam
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Rest

2012-10-27 Thread Marco Behnke
Am 27.10.12 19:47, schrieb Adam Tong:
> Hi,
>
> I need to develop a rest API.I want your feedback on how you develop
> rest apis. I don't want to use a heavy framework just for that, and I
> find url rewriting time consuming.
>
> Any suggestions?
>
> Thank you
>
Let us see what you have done so far towards your goal, so we can
discuss on how we can improve it.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] TURBOPY cloud framework + IDE beta available NOW

2012-10-27 Thread Marco Behnke
Am 27.10.12 16:22, schrieb Johannes Reichardt:
> Hi developers,
>
> I would like to invite you to test a public beta of the hybrid nosql
> PHP framework with IDE
> that has been developed by me within the last 10 years (don't be
> afraid, most time it was rebuilt
> from scratch to make it more simple).

From what I see most of your concepts are not up to date of how you
would do things now.
This starts with simple "leave brackets on if else single line
conditions" which is from my point of view a no go and ends with using
static calls instead of instances.

And why PHP 5.2?

And I am curious if you have developed a real templating engine or if
you are going by eval()? From what I see, it looks a bit like that.

But these are only my points. I browsed the pages, had no insight on the
code.

But I like your concept on the in place editing, that looks pretty cool
and handy.


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Differences

2012-10-04 Thread Marco Behnke
Am 04.10.12 02:48, schrieb David McGlone:
> Hi everyone, I have been playing around with some code the list helped me 
> with 
> a while back and I'm not grasping the concept between return and echo and the 
> PHP manual doesn't answer this, unless I'm missing something. There is an 
> example at the very bottom of PHP's return manual, but it's confusing.
Basically there is only difference, they have nothing in common.

http://de.php.net/echo
echo --- Output one or more strings

http://de.php.net/return
If called from within a function, the /return/ statement immediately
ends execution of the current function, and returns its argument as the
value of the function call. /return/ will also end the execution of an
eval()  statement or
script file.




signature.asc
Description: OpenPGP digital signature


Re: RES: [PHP] fets() escaping some characters

2012-09-11 Thread Marco Behnke
Or, if that string is the only thing you want to output and nothing else
you will set the correct content type for your output by putting

header('Content-Type: text/plain; charset=utf-8');

at the beginning of your script

Am 11.09.12 19:54, schrieb Samuel Lopes Grigolato:
> This issue has to do with HTML markup. You need to properly "escape"
> characters before sending them as text to the browser. Try to use this PHP
> function to escape your string: echo htmlspecialchars($yourstringhere);
>
> Regards,
> Samuel.
>
> -Mensagem original-
> De: sunil meena [mailto:sunil.extc2...@gmail.com] 
> Enviada em: terça-feira, 11 de setembro de 2012 14:49
> Para: php-general@lists.php.net
> Assunto: [PHP] fets() escaping some characters
>
> Hello Everyone,
>
> Very new to the list.
>
> So I am trying to echo a string to the browser as follows -
>
> $str = "0x100092000 -0x1000b7fff +com.apple.com (2.0 - 56)
>  /Library/PrivateFrameworks";
>
> echo $str;
>
> However the text between "<" and ">" i.e
> "BB91F4F8-3B1B-93C6-0D1A-E431E96F1BA3" doesn't get echoed instead all I get
> is "0x100092000 -0x1000b7fff +com.apple.com (2.0 - 56)
> /Library/PrivateFrameworks";
>
> Anyone knows why this is happening?
>
> This happened while I was getting a line using fgets and hence I tried
> storing that string into a variable and outputting but it still doesn't show
> the characters between the "<>".
>
> Any help is highly appreciated.
>
> Thanks
>
> --
> Best Regards,
> Sunil Meena
>
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread Marco Behnke
Am 19.08.12 06:59, schrieb tamouse mailing lists:
> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
>  wrote:
>> I want to parse this text and count the occurrence of each word:
>>
>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>> #Can I do this?
>> $stripping = strip_tags($text); #get rid of html
>> $stripping = strtolower($stripping); #put in lowercase
>>
>> 
>> First of all I want to start AFTER the expression "News Releases" and stop
>> BEFORE the next occurrence of "-30-"
>>
>> #This may occur an undetermined number of times on
>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>
>>
>> 
>> Second, do I put $stripping into an array to separate each word by each
>> space " "?
>>
>> $stripping = implode(" ", $stripping);
>>
>> 
>> Third how do I count the number of occurrences of each word?
>>
>> Sample Output:
>>
>> determined = 4
>> fire = 7
>> patrol = 3
>> theft = 6
>> witness = 1
>> witnessed = 1
>>
>> 
>> > $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>> #echo strip_tags($text);
>> #echo "\n";
>> $stripping = strip_tags($text);
>>
>> #Get text between "News Releases" and stop before the next occurrence of
>> "-30-"
>>
>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
>> occurrences of double spaces
>>
>> #$stripping = strtolower($stripping);
>>
>> #Where do I go now?
>> ?>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> This is usually a first-year CS programming problem (word frequency
> counts) complicated a little bit by needing to extract the text.
> You've started off fine, stripping tags, converting to lower case,
> you'll want to either convert or strip HTML entities as well, deciding
> what you want to do with plurals and words like "you're", "Charlie's",
> "it's", etc, also whether something like RFC822 is a word or not
> (mixed letters and numbers).
>
> When you've arranged all that, splitting on white space is trivial:
>
> $words = preg_split('/[[:space:]]+/',$text);
>
> and then you just run through the words building an associative array
> by incrementing the count of each word as the key to the array:
>
> foreach ($words as $word) {
> $freq[$word]++;
> }

Please an existence check to avoid incrementing not set array keys

foreach ($words as $word) {
  if (array_key_exists($word, $freq)) {
$freq[$word] = 1;
  } else {
$freq[$word]++;
  }
}


>
> For output, you may want to sort the array:
>
> ksort($freq);
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] PHP session variables

2012-08-12 Thread Marco Behnke
Am 09.08.12 23:16, schrieb Jim Lucas:
> On 08/09/2012 01:45 PM, Tedd Sperling wrote:
>> On Aug 8, 2012, at 5:41 PM, Jim Giner 
>> wrote:
>>
>>> On 8/8/2012 11:24 AM, Ansry User 01 wrote:
>>>> I am setting the _SESSION variables in one of my file, but whenever
>>>> I leave the php page session variables are not accessible. Not sure
>>>> what I need to do additionally other then defining _SESSION[].
>>>> Any pointer.
>>>>
>>> You must make it a habit to start each script with
>>>
>>> session_start();
You should definitely not make that a habbit!
Why create/open a session and send a cookie everytime script call even
if you won't need it? Why access a hard disk to create/open a session
file even if there is no use for it?

Only call session_start() if you need it and call session_write_close()
as early as possible to avoid write locks on the users session file.

And up from PHP 5.4 you can use

http://de2.php.net/manual/de/function.session-status.php

to check a session status.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] php safe mode no more?

2012-08-04 Thread Marco Behnke
Am 04.08.12 11:51, schrieb Lester Caine:
> tamouse mailing lists wrote:
>> What I've noticed running apache suexec + fastcgi is that the memory
>> requirements increased over running nonsuexec and mod_php under
>> apache. when i went to a nginx + fastcgi, things worked much better
>> overall with limited memory (i'm on 1GB limited slice, non-burstable).
>
> Funny you should mention nginx ... that one is on my todo list as well
> ...
>
I can definetly recommend that one.
I tested nginx + php-fpm against apache2 + mod_php. Since then every
server setup for PHP appliactions is done with nginx + php-fpm. It is
faster and uses less memory.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] PDO: extend or encapsulate?

2012-07-14 Thread Marco Behnke
Am 14.07.12 10:09, schrieb Tony Marston:
> wrote in message
> news:1535031289.371987.1342162338279.javamail.open-xcha...@email.1und1.de...
>>
>>
>>
>>
>> tamouse mailing lists  hat am 13. Juli 2012
>> um 07:06
>> geschrieben:
>>
>>> It's Friday, so...
>>>
>>> Yes, it's true, I have just started looking at using PDO instead of
>>> mysqli -- a bit behind the times...
>>>
>>> My question at this stage, is do people tend to extend the PDO class
>>> for their own use, or encapsulate it in a class (or do most people use
>>> it mostly in procedural code?)
>>
>> I stick to use it as components as it is said "Do not use inheritance
>> for code
>> re-use" :)
>>
>
> The idea that you shouldn't use inheritance for code reuse is absolute
> nonsense as it makes a mockery of one of the fundamental principles of
> object oriented programming. If you make a mess of inheritance it's
> because your implementation is flawed, not that the concept is flawed.
> Next you'll be saying "don't use encapsulation"or "don't use
> polymorphism". What a bunch of idiots!
No, I disagree with you.
Don't use inheritance for code re-use, use it for class extension!

If you have a class and want to add something extra to it but what does
stays in the same topic, then extend from it.

If you simply extend PDO to use the PDO methods and add your own stuff,
then inheritance is a bad idea. If you think of what you are doing here:
You USE Pdo. So it is a component.

This way you get the following benefits:

- You can extend your class in your system from another class AND use PDO
- You can easily exchange PDO with another abstraction layer if you
like, without changing the interface, just changing the implmentation


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Exception Handling

2012-06-01 Thread Marco Behnke
Am 01.06.12 17:08, schrieb James Colannino:
>
> Hey Marco,
>
> Thanks for the reply!  That was the first thing I checked.
>
> class Database_Exception extends \FuelException {}
> class Fuel_Exception extends \Exception {}
>
> It's extending Exception, as expected.  Also, can you throw classes
> that don't extend Exception?  It was always my understanding that
> doing so would cause a fatal error.

Ah, I guess that is the problem. Your application framework uses namespaces.
I guess you should try

catch (\Exception $e)

instead of

catch (Exception $e)

:-)

>
> James
>


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?

2012-05-04 Thread Marco Behnke



Am 04.05.2012 16:09, schrieb Ethan Rosenberg:

function handle_data()
{
global $cxn;


What does this function? It neither takes any parameters nor returns any 
value. And it does not write back anything to its global $cxn. So it is 
quite useless and can be deleted.



$query = "select * from Intake3 where 1";



if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )


there is no variable $_Request, it is $_REQUEST.
Why do you test on $_REQUEST and compare it with trimmed $_POST?


{
if ($_REQUEST['Sex'] === "0")
{
$sex = 'Male';
}
else
{
$sex = 'Female';
}


Why do you set a variable that is never used?


$allowed_fields = array
( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' =>
$_POST['Fname'], 'Lname' => $_POST['Lname'] ,
'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' =>
$_POST['Height'] );
if(empty($allowed_fields))
{
echo "ouch";
}
$query = "select * from Intake3 where 1 ";
foreach ( $allowed_fields as $key => $val )
{
if ( (($val != '')) )
{
$query .= " AND ($key = '$val') ";


Why the hell do you put unverified data into an sql query?


DISPLAY THE INPUT3 DATA:

 >>> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<<


What fails?
I do not have access to your database, so I can not run your code to see 
what fails.



n1 ";echo $n1;
{
if (($n1 > 2) && ($MDRcheck == $row1[1]))


What is $MDRcheck and what does this comparision mean?


SELECT AND DISPLAY DATA FROM VISIT3 DATABASE



Quotes around mdr missing


$result2 = mysqli_query($cxn, $query2);
$num = mysqli_num_rows($result2);


global $finished;
$finished = 0;


while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH))
{
global $finished;


No need to global that twice.
And why ndo you use global and $_GLOBALS? STick to one or better skip it 
anyways. Globals are not to be used!



switch ( @$_POST[next_step] )


Remove all @ from your code or you won't see any errors on this.
Do proper checking and do NOT suppress errors or warnings.


echo "";
echo "";
echo "";
echo "Medical Record:  ";


Quotes.


$Weight = $_POST['Weight'];
$Notes = $_POST['Notes'];
$sql2 = "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI,
Date) VALUES(null, '$Site', '$MDRold', '$Notes',


Do NOT NEVER put data that is user input unchecked into a query.


?>

?>


Double closing tag?


echo " $_GLOBALS[mdr] \n";


Quotes.


$flag = 1;


What's this?

You really really should seperate your code from HTML.
Please truncate your apache and php error log.
Add

error_reporting(E_ALL);
ini_set('display_errors', 'On');

at the top of every php file right after Remove all @ from your lines and execute your script another time and 
see what errors are appear into your browser and your logfiles. Post 
them and the codelines for these errors on the list.


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] PHP Mailto() - Google now displaying HTML as Plain Text

2012-05-01 Thread Marco Behnke



Am 29.04.2012 22:31, schrieb Terry Ally (Gmail):

Hi all,

I have been using a mailto() script for the last three years and from April
25, 2012 incoming HTML email in Goggle mail is displaying as Plain Text.
  Something clearly changed with Google. Perhaps there is some change I need
to make with my script??

$message .= "Message:  ".$m."";



As far as I can see your main html tags are missing?

$message = '' . $message . '';


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] SimpleXML and the Single String (SOLVED)

2012-02-22 Thread Marco Behnke
Am 22.02.12 16:04, schrieb Jay Blanchard:
> On 2/22/2012 8:32 AM, ma...@behnke.biz wrote:
>>   There is another nice way.
>> You can pass a second value to the simple xml constructor which is a
>> class
>> name to be used instead of SimpleXMLElement.
>> You can write your own class that extends SimpleXMLElement and
>> override the
>> magic methods to skip the casting
>>
> I don't really see a need to add an extra layer or class extension
> when casting works fine. Am I wrong? Why add several lines of code in
> an extension class?
>
To keep the code readable?

$value = $xml->node;

vs.

$value = (String)$xml->node;

I like the first one. Plus you handle it to dynamically to the right type

function __get($value)
{
if is float return float casted value
if is boolean ...
and so on
}

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Wrong POSTFIELDS Posted

2012-02-17 Thread Marco Behnke
Am 18.02.12 01:54, schrieb Brian Smither:
> I have a script that accepts four POST variables. Three are used and five 
> more are added for a total of eight keys and their urlencode() values all 
> strung together in the proper format.
>
> Then cURL is initialized with the field string given to:
> curl_setopt($ch, CURLOPT_POST,8);
> curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
>
> But that's not the string arriving at cURL's target URL! What's arriving at 
> the target is exactly the POST array that this script received in the first 
> place.
>
> Here's what I don't understand...
> The cURL request is coming from this script on domainA, but the target 
> address is also domainA. Does everybody play nice in this situation?
>
> PHP 5.3.5
> Apache 2.2
>
> Note: CURLOPT_POST evaluates to true, regardless that I use an integer. All 
> other curl* commands are set.
>
>
>
Maybe you could provide a bit more of information.

var_dump($_POST); // at the beginning of the script
// the code that assembles $string
// the target url for your curl request from curl_init or CURLOPT
// the other curloptions not mentioned here but used

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Turning a string into a condition

2012-02-16 Thread Marco Behnke
Am 16.02.12 22:37, schrieb Marc Guay:
> 2) The range of possibilities are broader than I indicated. They would
> like to be able to enter conditions of all sorts. i.e. ($x / $y) > 0.5
> (($a+$b+$c) / $d) < .75 etc. If you have any suggestions on how to
> increase the security while maintaning the flexibility, I'd be happy
> to hear it. Marc 

Is math all you want to use? Parsing will be an easy doing and I am
pretty sure there are a lot of examples around the web.
E.g.:
http://www.phpclasses.org/package/2695-PHP-Safely-evaluate-mathematical-expressions.html



-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] handle file_get_contents timeout including dns lookup time

2012-02-14 Thread Marco Behnke
Am 14.02.12 14:55, schrieb Matijn Woudt:
> On Tue, Feb 14, 2012 at 1:28 PM, nik600  wrote:
>>
>> *** server.php *** placed on www.foo.com at
>> http://www.foo.com/server.php
>> > sleep(15);
>> echo "OK";
>> ?>
>>
> I don't think this is possible with file_get_contents, but it should
> work if you use cURL and set the CURLOPT_CONNECTTIMEOUT option.
>
> - Matijn
That won't help. When you reach the sleep with your request, the
connection is already established.
What you want is curl with

CURLOPT_TIMEOUT max execution time


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Marco Behnke
Am 06.02.12 21:55, schrieb Adam Richardson:
> On Mon, Feb 6, 2012 at 3:44 PM, Marco Behnke  wrote:
>
>> Am 06.02.12 17:23, schrieb Alain Williams:
>>
>> many places to see if things should be done. That is just as bad as
>> lots of GOTO -- often when having to write something like that I will
>> have a GOTO (in
>> Good code uses Exceptions and try catch for that kind of scenarios.
>>
> Marco,
>
> Do you know of any research (Human Factors, Bug Analysis, etc.) that
> supports this? I'm certainly not saying that your assertion is incorrect.
> However, I'm starting to compile relevant research related to this topic.

No, this actually a personal experience developed over several years.
Bad documentated @throws is a pain too, I admit that.

From time to time I stumble into that if/else/return scenario where a
method should return a boolean for example depending on the given
parameters. PHP does not offer type checking so what if you submit
garbage that makes no sense for our method.
What will I return? I use exceptions for these unexpected exits. The
caller can now check on true or false and offer an additional try/catch
around it to handle exception.

This is only one artificial example, but imho and if I read the
conversion up to know correct, offers a cleaner approach.
Sadly most IDE offer no support for @throws annotations, I don't know a
single one, and PHP does not support it too.

I haven't used GOTO since C64 days and haven't missed - well during
study days I used GOTO in Assembler :-)

Well, this is just my opinion on the topic and I think that this is in
favor of GOTO.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Marco Behnke
Am 06.02.12 17:23, schrieb Alain Williams:
> However: a few GOTOs can make things clearer. Think of a function that
> can fail in several different places (eg data validation, ...). But it
> is reading a file which needs to be closed before the function
> returns. I have seen code where some $IsError variable is tested in
> many places to see if things should be done. That is just as bad as
> lots of GOTO -- often when having to write something like that I will
> have a GOTO (in 

Good code uses Exceptions and try catch for that kind of scenarios.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Typecasting question

2012-02-03 Thread Marco Behnke
Am 03.02.12 17:11, schrieb jas:
> I am familiar with typecasting. Booleans, ints, strings, etc.
>
> However while using an extension, more specifically the OpenSSL
> extension I have come across a problem I am not entirely familiar with.
>
> I have an array that looks like...
>
> array('config' => 'config/openssl.cnf',
>   'encrypt_key'=> true,
>   'private_key_type'   => 'OPENSSL_KEYTYPE_RSA',

remove the quotes around the constant, it must be

'private_key_type'   => OPENSSL_KEYTYPE_RSA,

>   'digest_algorithm'   => 'sha256',
>   'private_key_bits'   => 512,
>   'x509_extensions'=> 'usr_cert',
>   'encrypt_key_cipher' => 'OPENSSL_CIPHER_3DES');

same here

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] Autoloading

2012-02-01 Thread Marco Behnke

Am 26.01.2012 15:44, schrieb Floyd Resler:
> As stated, when I change __autoload to spl_autoload_register I get 
the can't be redeclared error.  Any ideas?



Try

$callback = function($class_name) {
$path = dirname(__FILE__)."/../../lib/class.{$class_name}.php";
if (file_exists($path)) {
require_once $path;
}
};

spl_autoload_register($callback);



--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] passing variables to php script

2012-01-10 Thread Marco Behnke
Am 10.01.12 21:57, schrieb Ashley Sheridan:
>
>> o simply "callrecs.php" and see if that works.
>> > Q: would be referencing a filesystem path, rather a web address 
>> > interpreted by a  PHP processor. Make sure your .php target is within a 
>> > PHP supported web space.
>> If a default application is set within windows for php, the script
>> submitting to Q will be executed.
>>
>>
>
> But wouldn't Windows attempt to execute the PHP script as if it were a
> CLI script, not as if it were within a web server context? That would
> make posting a form pretty pointless.
Indeed. But isn't that the point? We are trying to figure out why his
posting the form does not work. I say, it can't work as long as long as
there is Q:\ ins his form action, no way it will do, because you leave
your webserver context anyways.

He must change it to a valid web url.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] passing variables to php script

2012-01-10 Thread Marco Behnke
Am 10.01.12 21:28, schrieb Mike Mackintosh:
>
> On Jan 10, 2012, at 15:12, Marco Behnke  wrote:
>
>> Am 10.01.12 21:07, schrieb Donovan Brooke:
>>> David Savage wrote:
>>>> OK...I admit I'm new at thisI have this html file:
>>>> 
>>>> 
>>>> Generate pdf file of LD, Toll Free, and Directory Assistance
>>>> calls>>> 
>>>> 
>>>> 
>> Stupid question . where have you copied your script? Is it lying on
>> a webserver? Then I would guess that you are submitting the form on your
>> webserver which hits the PHP script on your Desktop PC which in tunr
>> invokes the PHP command line interpreter who has no idea what you mean
>> by $_POST.
>>
>> Try changing the form action to simply "callrecs.php" and see if that works.
> Q: would be referencing a filesystem path, rather a web address interpreted 
> by a  PHP processor. Make sure your .php target is within a PHP supported web 
> space.
If a default application is set within windows for php, the script
submitting to Q will be executed.


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] passing variables to php script

2012-01-10 Thread Marco Behnke
Am 10.01.12 21:07, schrieb Donovan Brooke:
> David Savage wrote:
>> OK...I admit I'm new at thisI have this html file:
>> 
>> 
>> Generate pdf file of LD, Toll Free, and Directory Assistance
>> calls> 
>> 
>> 

Stupid question . where have you copied your script? Is it lying on
a webserver? Then I would guess that you are submitting the form on your
webserver which hits the PHP script on your Desktop PC which in tunr
invokes the PHP command line interpreter who has no idea what you mean
by $_POST.

Try changing the form action to simply "callrecs.php" and see if that works.

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: [PHP] re: More Error Reporting Problems

2012-01-02 Thread Marco Behnke



Am 30.12.2011 17:11, schrieb Floyd Resler:

On Dec 30, 2011, at 11:05 AM, Matt Graham wrote:

I'm still not sure why they aren't displaying.  But as long as I have a place 
to find them I'm cool with that.



Maybe anything in your web application overrides display_errors?

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



smime.p7s
Description: S/MIME Kryptografische Unterschrift