[PHP] Secure redirection?

2008-11-05 Thread Zoran Bogdanov
Hi,

I'm building a login system with AJAX/PHP/MySQL.

I have worked everything out... AJAX is sending request to a php login 
script (login.php) who if authentication passes initializes the session and 
sends the header using header("Location : registered_user_area.php");

The whole system works great without AJAX, but when I put AJAX in the story 
I ahve one problem:

1.When the user is successfully authenticated the login.php sends the 
header, but the AJAX XMLHttpRequest call is still in progress waiting for a 
PHP response. So when PHP using the header function redirects to another 
page that page is outputed to the login form...

My PHP login snippet is:
if ($res_hash == $u_pass) {

$logged_user = $sql_execution->last_query_result->user;

$sql_execution->exec_query("DELETE FROM seeds",false);

$sql_execution->db_disconnect();

session_start();

$_SESSION['user'] = $logged_user;

$host = $_SERVER['HTTP_HOST'];

$url = rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/mpls/index.php';

header("Location: http://$host$url";);//--That page 
($host$url) is outputed in the login form...

exit();

}

else {

$sql_execution->exec_query("DELETE FROM seeds WHERE id=$row->id",false);

$sql_execution->db_disconnect();

echo 'BLS';//--This is sent when the password/username is 
wrong

exit();

}

???

Any help greatly appreciated

Thank you!



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



[PHP] PHP 24 hour processes?

2008-02-24 Thread Zoran Bogdanov
Hi,

How can you perform a timed event in PHP; for example:

Count 24 hours and then delete all rows in a database...

Thank you! 

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



[PHP] Deleting all rows in a database every 24 hours?

2008-02-21 Thread Zoran Bogdanov
The title says it all, how do I perform an action every 24 hours?

Thank you. 

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



[PHP] PHP Source code protection

2008-02-06 Thread Zoran Bogdanov
Hi,

I'm building a C# application that connects to a server that has PHP scripts 
on it.

We need to deliver the complete solution to a firm, the C# is no problem 
because it is compiled...

But PHP is a problem bacause it is interpreted and we will have to deliver 
pure, unprotected script...

Is htere a way to secoure my code so when they put it on the server, they 
can't see it!

Thank You! 

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



[PHP] PHP and VB.NET communication

2007-12-19 Thread Zoran Bogdanov
Hi,

I know this isn't purely php question but  if you know please reply.

I have a server with a PHP script on it. I need to write an app(VB.NET) that 
will connect to a server and request a script to process some info, and the 
php script will return  XML data, in which I need to process that data with 
VB.net

I'm currently using httpWebRequestMethod but no luck...

Thanks!

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



[PHP] Tracking visitor times

2007-12-18 Thread Zoran Bogdanov
Hi,

Is it possible to track how long has a single visitor been on my site?

example: I go to www.somesite.com at 5.am and I exit the page (close my 
browser or just go to another site) at 6.am. How do i track that 1 hour 
period using PHP?

Thanks alot! 

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



[PHP] Multi-language in script

2005-01-26 Thread Zoran Lorkovic
Hi
I'm interested, which is the best way to include multi-language support  in 
scripts?
By this I mean that with new version of script/program end-user don't need 
to translate whole site again...

With flat-file and "define" function or with "mysql" ?
Regards,
Zoran 

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


[PHP] Multi-language in script

2005-01-26 Thread Zoran Lorkovic
Hi

I'm interested, which is the best way to include multi-language support in 
scripts?
By this I mean that with new version of script/program end-user don't need to 
translate whole site again...

With flat-file and "define" function or with "mysql" ?

Regards,
Zoran

Re: [PHP] Removing strange chars from array (or string)

2004-09-15 Thread Zoran Lorkovic
> From: "Zoran Lorkovic" <[EMAIL PROTECTED]>
>
> > Well, when parsing html page data I want to save is saved in txt file.
> > But when saving in txt file I got some strange chars like small square
> > (this I see when open in NotePad).
> [snip]
> > Am I missing something?
>
> You forgot to post your code. If you're only using \n for newlines,
Notepad
> won't recognize them (it's expecting \r\n) and will mess up your layout.

Ok, here is one piece of code dealing with this:

$data[0] = preg_replace("/([<])+([^>])+([.])*([>])+/i","", $data[0]);
$data[0] = str_replace (" ", "", $data[0]);
$file = fopen ("data.txt", "wb");
fwerite ($file, $data[0]);
flocse ($file);

As you see, I'm not using any \n for new lines because this code deals with
HTML page.

I guess problem is in new line, and trim() only cuts whitespaces.

Regards.
Zoran

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



[PHP] Removing strange chars from array (or string)

2004-09-15 Thread Zoran Lorkovic
Hi

Well, when parsing html page data I want to save is saved in txt file. But when saving 
in txt file I got some strange chars like small square (this I see when open in 
NotePad).

When I try to open in WordPad this strange chars (squares) are recognized as new lines 
so in my file I got many empty lines.

I've try to trim array (string) before saving to file but that didn't help (tried with 
trim, ltrim and rtrim).

Am I missing something?

Regards,
Zoran

[PHP] preg_replace question

2004-09-09 Thread Zoran Lorkovic
Hi

Sorry for issuing this again, but I need help with preg_replace. I manage to replace 
certain text between  in text with preg_replace but I want for every other 
 to be replaced by other text.
By this I mean when some text between  has been found that text is replaced 
with some Text, on second match, text between  is replaced by some other 
different text etc.

Btw, where I can find patterns that are valid?
(something like (\w+), (\d+)+i etc.

Thanks.
Regards.
Zoran

Re: [PHP] Web Fetch & Process

2004-09-06 Thread Zoran
Hi

How can I parse HTML page which I fetched by PHP so some part of text would
be replaced by other text.

Also, I managed to delete all HTML code from page (with this code
$data[0] = preg_replace("/([<])+([^>])+([.])*([>])+/i","", $data[0]);

but also would like to delete all chars except numbers from page, can this
be done?

Regards.
Zoran

Your first question:
To replace certain elements take a look at preg_replace()
http://us4.php.net/manual/en/function.preg-replace.php

Example:

$foo = 'stuff silly stuff more stuff';
echo preg_replace('/\(.*)\<\/b\>/', "$1 lookie now", $foo);

Your second question:
You could just use strip_tags()
http://us4.php.net/manual/en/function.strip-tags.php

Your last question:
To delete everything but numbers you could $content =
preg_replace('/[^\d]/','', $content);

Hope that helps

Jim Grill

Hi

This works great. One more question about preg_replace. Is it possible that for every 
match other text is replaced?
By this I mean when some text between  has been found that text is replaced 
with some Text, on second match, text between  is replaced by some other 
different text etc.

Btw, where I can find patterns that are valid?
(something like (\w+), (\d+)+i etc.

Thanks.
Regards.

[PHP] Web Fetch & Process

2004-09-03 Thread Zoran
Hi

How can I parse HTML page which I fetched by PHP so some part of text would be 
replaced by other text.

For example, if I have bold text on HTML page (Some text) how can I manage that 
all bold text on that page is replaced by some other text.

Also, I managed to delete all HTML code from page (with this code 
$data[0] = preg_replace("/([<])+([^>])+([.])*([>])+/i","", $data[0]);

but also would like to delete all chars except numbers from page, can this be done?

Regards.
Zoran


Re: [PHP] Re: Problem sending mail

2004-08-31 Thread Zoran Lorkovic
> Zoran Lorkovic wrote:
>
> > $file = file_get_contents("text.inc");
> > $start = "[start]";
> > $end = "[/end]";
> > $pos_start = strpos ($file, $start);
> > $pos_end = strpos ($file, $end);
> > $data = substr ($file, $pos_start, $pos_end);
> > mail ("[EMAIL PROTECTED]", "My Subject", $data);
> >
> >
> > This code works when I call it from browser, but when I call it from
command line, $data is not put into mail
> > (mail is send but it is empty, without any data in body).
> >
> that would depend from which place you run the script.
> file_get_contents("text.inc") will be looked for in:
> 1. the current working directory
> 2. the included dirs
>
> So, if you're running the script like:
> [EMAIL PROTECTED] /]# cd /
> [EMAIL PROTECTED] /]# php -q /var/www/html/scripts/mail.php
> then you're actually working in /, so it's looking for "text.inc" in:
> /text.inc and in all include-paths.

Yeah! Of course. This was the problem.
Script and text file were in 'mydir/public_html' but I call script from
'mydir' so I script looks for text file in 'mydir' because of $file =
file_get_contents("text.inc");
For the quick test I've changed this to:
$file = file_get_contents("public_html/text.inc");
and now it's working. Thanks a lot!

Regards.
Zoran

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



[PHP] Problem sending mail

2004-08-30 Thread Zoran Lorkovic
$file = file_get_contents("text.inc"); 
$start = "[start]"; 
$end = "[/end]"; 
$pos_start = strpos ($file, $start); 
$pos_end = strpos ($file, $end); 
$data = substr ($file, $pos_start, $pos_end); 
mail ("[EMAIL PROTECTED]", "My Subject", $data); 


This code works when I call it from browser, but when I call it from command line, 
$data is not put into mail
(mail is send but it is empty, without any data in body).

File text.inc looks like this: 
[start]some_text_goes_here[/end] 
[other_start]other_text_goes_here[/other_end]

Regards.