Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Łukasz Hejnak

Zareef Ahmed napisał(a):

Hi,

Hi

what is not working in this code?

That's how I see it
?
$defaultpage = http://lom.game-host.org/uploads/erik/;;
// yes the isset is ok here
If(!isset($page)) {
$page = one;
}


if($page == one) {
// as far as I know echo is all low case written but maybe it's not a 
must in all instalations
echo htmlheadtitlePage One/title/headbodyIt 
works!!bra href=\ . $defaultpage . 
index.php?page=two\Nice.../a/body/html;

}

// else space_here if, not elseif !
else if($page == two) {
echo htmlheadtitlePage Two/title/headbodyThis is page 
.$page. -- a 
href=\.$defaultpage.index.php?page=\;D/a/body/html;

}

//  instead of || (and instead of or) here to have the opposite!
else if( ($page != one)  ($page != two)  ($page != NULL) ) {
echo htmlheadtitleUndefined!/title/headbodypage isn't 
defined correctly!/body/html;

}

if($page == ) {
Echo brbrbrbrbrbrbrbra href=.$defaultpage.Main 
Page../a;

}
?

Thank you,

You're welcome :)

--
Best wishes
Łukasz 'Szift' Hejnak

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



Re: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Łukasz Hejnak

Erik Johnson napisał(a):

Okay.. I was just wondering; What's the difference between = and ==? Would
it matter if I changed them?  It seems as though if I put = instead of the
=='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
instead of =='s, then it comes up with only page one no matter what $page
equals.

It's a *BIG* difference!
Because single '=' means that whatever stands at the right side of the
'=' should be assigned to whatever stands at the left side,
ie.
$a=5
doesn't compare if a is equal 5, only assignes the variable 'a' it's
value which will be 5 after this code
so if You write
if ($a=5) {...}
it will always be executed (therefore else isn't executed), as
assignment always returns true :]
so when using 'if' You always need to do
if ($a==5) {...}
unless of course Youd want to do an assingment and some code, but then
why not do
$a=5;
...
? :)

--
Best wishes
Łukasz 'Szift' Hejnak

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



Re: [PHP] Security question

2005-12-07 Thread Łukasz Hejnak

Andy Pieters napisał(a):
Is it possible for someone who does not have access to the server to edit 
arbitary accounts?


well this depends on the forum You use, there're many many exploits out 
there.

The best way to know is to try and keep up with places like
the bugtraq@securityfocus.com list, or other security websites/mailing 
lists and such.



--
Best wishes
Łukasz

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



Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread Łukasz Hejnak

Jeff McKeon napisał(a):

Hey all,

Forever now I've been using Frontpage for all my web work including php.
I'm sure there's better software out there that is more suited to
writing and editing PHP pages.  What do you all use?


I use Bluefish, it's a very nice GTK+ based editor, with all types of 
code highlightning (html, php, c/c++, pascal, java, python are just a 
part of it). And that's pretty much all the features of it I use, maybe 
also the well written replace method. Besides that I use it as a typical 
text editor, I'm not too keen on template's.


--
Best wishes
Łukasz Hejnak

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



Re: [PHP] Problem with the fwrite function (not as simple as it sounds though)

2005-11-20 Thread Łukasz Hejnak
Hello again, here's some more extra info on my case that came out while 
Suhas Pharkute was helping me find a resolution:

So the safe-mode is off, that's for sure, I turned it off at compile stage.

I delete the file after each run of the script, the folder  where the 
script is located has 777 permissions and the ownership is given to uid 
1027 gid 1020, whereas these are the uid/gid set for apache to run with 
(and it does!).

The script:

$data=some data;
$file=file.txt;
$handle = fopen($file,w);
fwrite($handle,$data);
fflush($handle);
fclose($handle);
if (is_writable($file))
echo Is writablebr;
else
echo Isn't writablebr;

works when I run it as root, from the shell (php script.php),
but when it's run from the server, it doesn't.
I mean, the output _IS_ in _BOTH_ cases Is writable
but that doesn't change a thing, cause when executed from the apache, it 
just creates an empty file without content.


The other thing I was supposed to check was stat($file); with 
clearstatcache(); called beforehand. The output of this is:


device number: 777
inode number: 1142470
inode protection mode: 33188
number of links: 1
_userid_of_owner:_1027_
groupid of owner: 1020
device type, if inode device *: 0
_size_in_bytes:_0_
time of last access (Unix timestamp): 1132482491
time of last modification (Unix timestamp): 1132482505
time of last inode change (Unix timestamp): 1132482505
blocksize of filesystem IO *: 4096
_number_of_blocks_allocated:_0_

and of course when executed as root:

device number: 777
inode number: 1142470
inode protection mode: 33188
number of links: 1
_userid_of_owner:_0_
groupid of owner: 1020
device type, if inode device *: 0
_size_in_bytes:_9_
time of last access (Unix timestamp): 1132482980
time of last modification (Unix timestamp): 1132482980
time of last inode change (Unix timestamp): 1132482980
blocksize of filesystem IO *: 4096
_number_of_blocks_allocated:_8_


Can anybody help me?

--
Best wishes
Łukasz Hejnak

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



Re: [PHP] Problem with the fwrite function (not as simple as it sounds though)

2005-11-20 Thread Łukasz Hejnak

Brian V Bonini napisał(a):

You are saying:
From the CLI you can write to a file all day long, no prob.

Yes, the shell command php test.php works fine when executed as root
(any other user has the same problem as from the web)

From the web, if the file does not exist it is created, however, no
content is appended to it. Furthermore, IF there is content in the file
it can be appended to via web, but if it's an empty file it will not get
written too. Am I following correctly?


Exactly, as strange as it sounds, it's just like it is.

And another thing, the whole instalation was working perfectly for the 
past month or two, and now (friday-saturday) suddenly the above symptom 
have appeared.
No config changes, no updates or anything else I could relate was 
happening on the server, and there is no info in the log files on this 
behaviour, the is_writable says it is writable. The safe mode is disabled.


Hope this tells You something, and gives You an idea on how to solve this.

--
Best wishes
Łukasz Hejnak

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



Re: [PHP] Problem with the fwrite function (not as simple as it sounds though)

2005-11-20 Thread Łukasz Hejnak

Brian V Bonini napisał(a):
 What does 'df -h' say on your system?

!!!
The simplest of all is the most unforseen..
Wow. that's it ;) I NEVER EVEN Imagined to check for that, in fact that 
_IS_ the thing.
I feel so totaly stupid right now, I checked everything except this, 
although I think the fwrite _SHOULD_ return false on this, and it should 
print out an error saying that there's no space available..
The thing is that my system has a few partitions, one of them is the one 
containing wwwroot. I never even once got a msg that the filesystem is 
full, as most of my operations (recompiling etc.) were conducted on a 
seperate partition. Now I see it and can take it all together, as there 
is one script doing backup of the www sites, it does so every night, and 
that was the thing that made it full.
BIG ENORMOUS Thanks for the help to all of You, and sorry for the 
problem, I would never ever thought about this, until You suggested it.


a modification to the topic of this message,
Simpler the You could've thought ;]

--
Best wishes
Łukasz Hejnak

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



[PHP] Problem with the fwrite function (not as simple as it sounds though)

2005-11-19 Thread Łukasz Hejnak


Hello,
First of all sorry for my english, trying my best :]

The story is: I'm running a small webserver and to monitor the amount of 
people going trough my pages, I've made a simple counter (storing the 
data in a text file), no matter the details, the important thing is that 
it WORKED just the way I wanted it to. Till yesterday evening.
Today I noticed that all of the counters, that were modyfied since 
yesterday, have been blanked. I started looking trough the logs and 
found a large amount of

 PHP Warning:  fread(): Length parameter must be greater than 0.
which was the expected behaviour when reading an empty file.
After a while of checking, I got to the fact that something's wrong with 
the fwrite() function.

I've writen a 'test' script only to see if I can write files.
When writing to the /tmp dir, all went fine, but when I tried to write 
to any of the other directories within my $WWWroot the result was an 
empty file.

This is the script:

$data=some data;
$file=/wwwroot/file
$handle=fopen($file,w);
fwrite($handle,$data);
fflush($handle);
fclose($handle);

And as written above, the output was only an empty  file /wwwroot/file 
nothing more.
I thought about premissions, but after setting the wwwroot a+rwx, 
setting the owner and group as the same as the apache server works under 
I got the idea that's not it.

I reinstalled the apache and php.
Now I'm using httpd-2.1.9 and php-4.4.0 (as a module) but the problem is 
still there, before I was using httpd-2.1.8, but as I said, the problem 
appeared out of nowhere, when the server was just running on it's own, 
without upgrades, patches, config changes, or anything other.
In fact all it was doing trough the night was serving the websites and 
receiving mail.


I runned out of ideas. The logs don't show anything related to this. I 
tried to enable all debug logging, but despite the fact that I'm 
receiving now 3 times more info on everything else, there's nothing on 
the fwrite() attempt or related.


Can anybody help?
If any more data is required on my side, I will gladly cooperate to get 
the thing solved.


--
Best wishes
Łukasz Hejnak

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



Re: [PHP] Problem with the fwrite function (not as simple as it sounds though)

2005-11-19 Thread Łukasz Hejnak

Hello again, some extra info on my case:
the fwrite is completely fine, when fopen is in 'a' mode!
Thus leading to a temporary workaround like this:

$file = /wwwroot/file
$countt = explode(., fread(fopen($file,r), filesize($file)));
$count=$countt[1];
$count++;
$handle=fopen($file,a);
ftruncate($handle, 1);
fwrite($handle,$file);
fclose($handle);

Now having a file with content in the form:
.15
makes it possible to use the above as a workaround..
but still I need to find out what's the problem here. The counter isn't 
exactly the only thing I use fwrite for..


The clue I got is, non-empty files are ok to be written in (appended), 
empty on the other hand, are totaly uncool for that.

So using a ftruncate($handle,0); is just as I'd use fopen($file,w);
(gives the same result).

--
Best wishes
Still hoping for Your help
Łukasz Hejnak

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