|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 31 Dec 2003 00:14:03 -0000 Issue 2503
php-general-digest-help
lists.php.net
Date: Tue Dec 30 2003 - 18:14:03 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 31 Dec 2003 00:14:03 -0000 Issue 2503
Topics (messages 173478 through 173510):
Problem with fmod() function
173478 by: Andy Higgins
Evaluating Variables at the correct time
173479 by: Ben Wrigley
Re: Is a while loop the most efficient way to send out multiple emails?
173480 by: lists.lindensys.net
best way to specify path to a file in a $variable?
173481 by: Danny Anderson
173482 by: Tristan.Pretty.risk.sungard.com
173483 by: Blake Schroeder
Still Racking My Brain
173484 by: stiano.optonline.net
173486 by: Richard Davey
Re: Migrating from SSI and Perl
173485 by: Philip Pawley
creating a very simple cms with one login and one mySQL database
173487 by: Charlie Fiskeaux II
173488 by: Jay Blanchard
Re: Problem with INSERT Query
173489 by: Hadi
looping problem?
173490 by: Jas
173491 by: Mike Migurski
173495 by: Hitek
A new PHP/JAVA module
173492 by: Jost Boekemeier
function problem?
173493 by: Jas
173494 by: Jay Blanchard
How do I protect downloadable files?
173496 by: news.php.net
173497 by: apz
173509 by: Kim Steinhaug
173510 by: Larry Brown
saving variables and including files.
173498 by: Joe
173499 by: Jay Blanchard
A hint...
173500 by: Jeremy Russell
173501 by: Jay Blanchard
"Secure programmer: Keep an eye on inputs"
173502 by: Mike Migurski
connecting to progress db
173503 by: php
Re: How to use anchor with php post string to jump to a page???
173504 by: Scott Fletcher
Flag Options before Compiling PHP...
173505 by: Scott Fletcher
MySQL Sub search - Is there such a thing?
173506 by: Vernon
What is the Basic function to encode the password upon the authentication..
173507 by: Scott Fletcher
Mysql management programme for windows?
173508 by: pehepe php
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Hello,
My understanding from the documentation is that the fmod() function should
work with floating point numbers however the following snippet of code:
<?php
//php 4.3 on Linux
$x = 1.05;
$y = 0.05;
echo "x: $x <br>";
echo "y: $y <br>";
echo "fmod: " . fmod($x, $y) . "<br>";
?>
outputs the following:
x: 1.05
y: 0.05
fmod: 0.05
I would have expected to get an answer of 0 i.e. no remainder. It works fine
for whole numbers.
Can any one shed any light on this please?
Thank you.
Regards,
Andy
P.S. I tried using the following function but I get the same results:
function fmodAddOn($x,$y)
{
$i = floor($x/$y);
// r = x - i * y
return $x - $i*$y;
}
attached mail follows:
Hi There,
I'm a bit of a newbie here I'm afraid so I'm sorry if this is an obvious
question.
I have a script which read includes an html file. The html makes a call
so a function in the main script. This call passes a string which
includes variables i.e. : <td>$title</td><td>$name</td>
in the function that gets called the variables $title and $name get
populated with values and then the script echos the html string to the
client.
The problem is that the variables in the html string get evaluated at
the point it is passed into the function not as the point it is echoed.
Can anyone help?
Thanks
Ben Wrigley
attached mail follows:
> I currently run a few newsletters that go out to small groups of
> % 50 to 100 people. I use a while loop to send out the emails. I chose
I have a module that does about about 100 emails (10Kb of data per email, which is a decent sized email) in 8 - 10 seconds. (Does around 610 - 625 emails per minute). This is accomplished by skipping PHP's internal mail functionality entirely and making a direct socket connection to the SMTP server. Another benefit of this is that any MySQL delay can be removed from the actual mail functionality by adding all the recipients to the class, and closing the MySQL query - before sending the emails. Ultimately, the speed really depends on the SMTP server. I'm sure with a little hacking, I may be able to get 650 - 675 emails per minute.
One faster method of sending bulk emails requires A) having direct access to the filesystem of the mail server, and B) hacking sendmail configuration - which both mean "root" access. I've gotten up to 850 emails per minute with this method.
The class is easy to use - basically:
$_Mailer = &new mod_sendmail();
$_Mail->setSubject( strText );
$_Mail->setBody( strText );
$_Mail->addRecipient( strName, strEmail );
$_log = $_Mail->sendAll();
The $_log var is an array in the format of:
$_log[ strEmail ] = strData
strEmail is the intended recipient, and and strData will either be A) the MsgID returned by the SMTP server on success or B) a "0" if failed. This makes it possible to add a function to re-send failed emails later.
If you want the socket-based code, just send me a private email to kode
kodekrash.com. I'm working on getting a code repository going, but for now, just have to send it to you directly.
-- James
kode
kodekrash.com
attached mail follows:
Hola, PHP folk-
I am using
$page_title="some page title here";
require('header.inc');
to include a common header for all my pages. I am using $page_title so
I can have unique names for the different pages.
//---header.inc
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $page_title; ?></title>
<link rel=stylesheet href="./some.css" type="text/css">
</head>
<body>
...
I want to be able to also define the path to the CSS file. For
instance, some pages will have the CSS in the same directory, so that
part would read
"./my.css"
If the page is located in a subdirectory, the path would then be
"../my.css"
I would like to use a php variable where I can define the path the same
way as the $page_title works. I have tried some experiments with a
$path_to_css variable, but I have not had much success. I think part of
the problem is that I might be stumbling over escaping everything properly.
Is there a better way to do what I am trying to do?
Thanks,
Danny
attached mail follows:
I personally link my css files using the root dir...
eg:
host/myaccount/mywebsite/mycssfile.css
That way, it's always pointing to the correct file...
hope it helps///
Danny Anderson <danderson
dfisystems.com>
30/12/2003 14:15
To
php-general
lists.php.net
cc
Subject
[PHP] best way to specify path to a file in a $variable?
Hola, PHP folk-
I am using
$page_title="some page title here";
require('header.inc');
to include a common header for all my pages. I am using $page_title so
I can have unique names for the different pages.
//---header.inc
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $page_title; ?></title>
<link rel=stylesheet href="./some.css" type="text/css">
</head>
<body>
...
I want to be able to also define the path to the CSS file. For
instance, some pages will have the CSS in the same directory, so that
part would read
"./my.css"
If the page is located in a subdirectory, the path would then be
"../my.css"
I would like to use a php variable where I can define the path the same
way as the $page_title works. I have tried some experiments with a
$path_to_css variable, but I have not had much success. I think part of
the problem is that I might be stumbling over escaping everything
properly.
Is there a better way to do what I am trying to do?
Thanks,
Danny
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
*********************************************************************
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
***********************************************************************
attached mail follows:
The way my server is setup it depends on your web root dir. If your css
dir and file are located in:
/userid/public_html/css/css1.css
My web root is:
/userid/public_html/
So the path I would use to get to the css file is:
/css/css1.css
-Blake
Danny Anderson wrote:
> Hola, PHP folk-
>
> I am using
>
> $page_title="some page title here";
> require('header.inc');
>
> to include a common header for all my pages. I am using $page_title
> so I can have unique names for the different pages.
>
> //---header.inc
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title><?php echo $page_title; ?></title>
> <link rel=stylesheet href="./some.css" type="text/css">
> </head>
> <body>
> ...
>
>
>
> I want to be able to also define the path to the CSS file. For
> instance, some pages will have the CSS in the same directory, so that
> part would read
>
> "./my.css"
>
> If the page is located in a subdirectory, the path would then be
>
> "../my.css"
>
> I would like to use a php variable where I can define the path the
> same way as the $page_title works. I have tried some experiments with
> a $path_to_css variable, but I have not had much success. I think
> part of the problem is that I might be stumbling over escaping
> everything properly.
>
> Is there a better way to do what I am trying to do?
>
> Thanks,
> Danny
>
--
+-----------------+-----------------+----------------+
| Blake Schroeder | Owner/Developer | lhwd.net |
+--(http://www.lhwd.net)------------+--/3174026352\--+
attached mail follows:
Okay, I got my pathname straightened out, but I'm still showing the
"unexpected $" message.
But that's after doing $[var name] = $_POST['var name']; for everything
with a $ in front of it. Can someone please let me know what I'm not
understanding here?
The code is, again, below.
Thank you very much.
Steve Tiano
-------------------------------------------
// image index
// generates an index file containing all images in a particular directory
//point to whatever directory you wish to index.
//index will be written to this directory as imageIndex.html
$dirName = "c:/csci/mm";
$dp = opendir($dirName);
chdir($dirName);
//add all files in directory to $theFiles array
while ($currentFile !== false){
$currentFile = readDir($dp);
$theFiles[] = $currentFile;
} // end while
//extract gif and jpg images
$imageFiles = preg_grep("/jpg$|gif$/", $theFiles);
$output = "";
foreach ($imageFiles as $currentFile){
$output .= <<<HERE
<a href = $currentFile>
<img src = "$currentFile"
height = 50
width = 50>
</a>
HERE;
} // end foreach
//save the index to the local file system
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//readFile("imageIndex.html");
print "<a href = $dirName/imageIndex.html>image index</a>\n";
?>
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
attached mail follows:
Hello stiano,
Tuesday, December 30, 2003, 3:24:04 PM, you wrote:
son> Okay, I got my pathname straightened out, but I'm still showing the
son> "unexpected $" message.
The following works fine for me (on a Windows XP box + PHP4 + Apache)
<?
$dirName = "D:\Graphics";
if (is_dir($dirName) == TRUE)
{
$dp = opendir($dirName);
chdir($dirName);
}
else
{
echo "Not a valid directory";
exit;
}
//add all files in directory to $theFiles array
while ($currentFile !== FALSE)
{
$currentFile = readDir($dp);
$theFiles[] = $currentFile;
}
//extract gif and jpg images
$imageFiles = preg_grep("/jpg$|gif$/", $theFiles);
$output = "
<html>
<head>
<title>Image List</title>
</head>
<body>
<p>
Images in: $dirName
</p>
";
foreach ($imageFiles as $currentFile)
{
$output .= "<a href=\"$currentFile\"><img src=\"$currentFile\" height=50 width=50></a>\n";
}
$output .= "
</body>
</html>";
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
// The following works, except that all the image links are broken because the directory is wrong
readFile("$dirName\imageIndex.html");
?>
--
Best regards,
Richard mailto:rich
launchcode.co.uk
attached mail follows:
Have I got this right?
I am doing
<?php
$BRPHP = $_SERVER['HTTP_USER_AGENT'];
$arr = array (1 => "$BRPHP" );
exec (' ../cgi-bin/browser.pl', $arr );
echo $arr[2];
echo $arr[3];
echo $arr[4];
echo $arr[5];
echo $arr[6];
?>
1. Am I passing $arr[1] to the perl script?
2. If no, what should I do instead?
3. If yes, how can I access it from the perl script?
(Yes, I know the last question is a perl question, so I'll be happy to just get an answer to the first two).
Thanks,
Philip Pawley
attached mail follows:
I'm new to php and am trying to create a very basic content
management system to let my client update a popup on their
homepage. I'm using mySQL and have a good idea of how to do
the login and set & read cookies, as well as accessing the
database during the admin process.
The part I'm not too clear on is how to implement the front
end for the general users. When someone visits the site and
the popup pops up, what happens on that page? Does it access
the database at the time it loads to load the information?
If so, is this possible without hardcoding the
username/password information (to access the database) in
the popup page code?
Is there a tutorial or article on stuff like this somewhere?
--
Charlie Fiskeaux II
Media Designer
Cre8tive Group
cre8tivegroup.com
859/858-9054x29
attached mail follows:
[snip]
Is there a tutorial or article on stuff like this somewhere?
[/snip]
Search for an article on evolt.org called the ABC's of CMS, it is a fair
starting point.
attached mail follows:
<irinchiang
justeducation.com> wrote in message
news:1072768171.3ff124abe14e8
www.justeducation.com...
>
>
> Hi all:
>
> Well, when i bring out the page with the drop down list it was able to
display
> all tutors' names from "tutor_name" column. Anyway here's a review of my
code
> (snip) again before i continue:
> --------------------------------------------------------------------------
-----
> <snip>
> $sql = "INSERT INTO class (class_code, tutor_name, edu_level,
timetable_day,
> timetable_time)
> VALUES
>
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time'
)";
>
>
> <?//retrieve data from DB & display in dynamic drop down ?>
>
> <SELECT class="textarea" name="tutor_name" />
> <?
>
>
$sqltutor = mysql_query("SELECT DISTINCT tutor_name FROM tutor ");
while ($row = mysql_fetch_array($sqltutor))
{
print "<OPTION VALUE=\"$row ["tutor_name"]. \" SELECTED> " .$row
["tutor_name"]. "</option> ";
> }
> $result = $db-> query($sql);
>
> ?>
> </select>
>
> <?
>
> while($selected_tutor_name == $tutor_name)
> echo $_POST["tutor_name"];
>
How about
if ($tutor_name ){
echo $_POST["tutor_name"];
$sql = "INSERT INTO class (class_code, tutor_name, edu_level, timetable_day,
timetable_time)
VALUES
('$class_code','$tutor_name','$edu_level','$timetable_day','$timetable_time'
)";}
is it working?
Hadi
> ?>
>
> </snip>
>
> --------------------------------------------------------------------------
-----
>
> so when i submit the form, i am suppose to echo the values i have entered
into
> the field and then INSERT the values into DB (Queries stated above).
However i
> was able to echo all other values eg. class_code, edu_level, etc...but
> not "tutor_name"....same thing happen when i do an INSERT, all other
values
> are inserted into DB but not $tutor_name....why is this so???Really need
some
> help here...Anyway i have already specify a name to be reference :
>
> <SELECT class="textarea" name="tutor_name" >
>
> and then I also did an echo of "tutor_name" being selected:
>
> while($selected_tutor_name == $tutor_name)
> echo $_POST["tutor_name"];
>
> All help are greatly appreciated =)
>
> Irin.
attached mail follows:
Problem with looping over a CSV file (3 results for each line)? Here is
the CSV file contents...
MTPC-01,00:02:B3:A2:9D:ED,155.97.15.11
MTPC-02,00:02:B3:A2:B6:F4,155.97.15.12
MTPC-03,00:02:B3:A2:A1:A7,155.97.15.13
MTPC-04,00:02:B3:A2:07:F2,155.97.15.14
MTPC-05,00:02:B3:A2:B8:4D,155.97.15.15
Here is the script...
<?php
$row = 1;
$file = "fa.csv";
$id = fopen("$file","r");
while($data = fgetcsv($id,100,",")) {
$num = count($data);
$row++;
for($c = 0; $c < $num; $c++) {
echo "host $data[0] {<br />\nhardware ethernet $data[1];<br
/>\nfixed-address $data[2];<br />\n}<br />\n"; }
}
fclose($id);
?>
And this is the output...
(notice 3 results for the first line in the CSV file)
host MTPC-01 {
hardware ethernet 00:02:B3:A2:9D:ED;
fixed-address 155.97.15.11;
}
host MTPC-01 {
hardware ethernet 00:02:B3:A2:9D:ED;
fixed-address 155.97.15.11;
}
host MTPC-01 {
hardware ethernet 00:02:B3:A2:9D:ED;
fixed-address 155.97.15.11;
}
Any help is appreciated...
Jas
attached mail follows:
>Problem with looping over a CSV file (3 results for each line)?
>
>Here is the script...
><?php
>$row = 1;
>$file = "fa.csv";
>$id = fopen("$file","r");
> while($data = fgetcsv($id,100,",")) {
> $num = count($data);
> $row++;
> for($c = 0; $c < $num; $c++) {
> echo "host $data[0] {<br />\nhardware ethernet $data[1];<br
>/>\nfixed-address $data[2];<br />\n}<br />\n"; }
> }
>fclose($id);
>?>
Remove the for-loop on the 8th line.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
attached mail follows:
Shorter version of the script:
<?
$line = file("fa.csv");
for($i=0;$i<count($line);$i++){
$data = explode(",", $line[$i]);
echo "host $data[0] {<br />\nhardware ethernet $data[1];<br
/>\nfixed-address $data[2];<br />\n}<br />\n";
}
?>
At 08:10 AM 12/30/2003, Jas wrote:
>Problem with looping over a CSV file (3 results for each line)? Here is
>the CSV file contents...
>
>MTPC-01,00:02:B3:A2:9D:ED,155.97.15.11
>MTPC-02,00:02:B3:A2:B6:F4,155.97.15.12
>MTPC-03,00:02:B3:A2:A1:A7,155.97.15.13
>MTPC-04,00:02:B3:A2:07:F2,155.97.15.14
>MTPC-05,00:02:B3:A2:B8:4D,155.97.15.15
>
>Here is the script...
><?php
>$row = 1;
>$file = "fa.csv";
>$id = fopen("$file","r");
> while($data = fgetcsv($id,100,",")) {
> $num = count($data);
> $row++;
> for($c = 0; $c < $num; $c++) {
> echo "host $data[0] {<br />\nhardware ethernet $data[1];<br
> />\nfixed-address $data[2];<br />\n}<br />\n"; }
> }
>fclose($id);
>?>
>
>And this is the output...
>(notice 3 results for the first line in the CSV file)
>
>host MTPC-01 {
>hardware ethernet 00:02:B3:A2:9D:ED;
>fixed-address 155.97.15.11;
>}
>host MTPC-01 {
>hardware ethernet 00:02:B3:A2:9D:ED;
>fixed-address 155.97.15.11;
>}
>host MTPC-01 {
>hardware ethernet 00:02:B3:A2:9D:ED;
>fixed-address 155.97.15.11;
>}
>
>Any help is appreciated...
>Jas
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Hi,
attached is a php/java bridge which uses sockets to communicate with
java instead of creating a new JVM for each request.
The protocol that is used is very simple but efficient and the
Apache/PHP/JAVA solution should be as efficient as Apache/Tomcat/Java
for example.
This module is based on Sam Ruby's original java code, but it is easier
to install.
Jost
attached mail follows:
Not sure why the last section won't work...
/* Function to search for hosts */
function search_dhcp() {
if ((empty($_POST['search'])) && (empty($_POST['hosts01'])) &&
(empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i']))
&& (empty($_POST['v']))) {
unset($_SESSION['search']);
$_SESSION['search'] = "<b>Search for individual computers to
edit</b><br><br><span class=\"copyright\">**This feature will search all
VLAN's for individual machines to make host configuration changes
to.<br>ex. 10.10.0.255 or dhcp-client<br> Wildcards are marked as a
'%'.</span><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\"
name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\"
maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\"
value=\"search\"></form>";
} elseif ((!empty($_POST['search_name'])) && (empty($_POST['hosts01']))
&& (empty($_POST['hn'])) && (empty($_POST['ma'])) &&
(empty($_POST['i'])) && (empty($_POST['v']))) {
unset($_SESSION['search']);
require 'dbase.inc.php';
$table = "hosts";
$x =
mysql_query("SELECT * FROM $table WHERE hostname LIKE
'$_POST[search_name]'")or die(mysql_error());
$num = mysql_num_rows($x);
if($num == "0") {
$_SESSION['search'] = "<b>Search for individual computers to edit by
hostname</b><br><br><span class=\"copyright\">**This feature will search
all VLAN's for individual machines to make host configuration changes
to.<br>(ex. dhcp_client_003) Wildcards are marked as a
'%'.</span><br><br><b><img src=\"images/error.jpg\"> No hosts
matched your search for $_POST[search_name].</b><br><br><form
action=\"$_SERVER[PHP_SELF]\" method=\"post\" name=\"search\"><input
name=\"search_name\" type=\"text\" size=\"30\"
maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\"
value=\"search\"></form>";
} elseif ($num != 0) {
$_SESSION['search'] .= "<b>Here are your search
results.</span><br><br><br><span class=\"copyright\">**Please select the
machine you wish to make changes to.</span><br><br><form name=\"hosts\"
action=\"$_SERVER[PHP_SELF]\" method=\"post\"><select name=\"hosts01\"
size=\"5\" multiple>";
while($v = mysql_fetch_array($x)) {
list($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v'])
= $v;
$_SESSION['search'] .= "<option name=\"$_SESSION[hn]\"
value=\"$_SESSION[hn]\">$_SESSION[hn] | $_SESSION[i] | $_SESSION[v]</option>";
}
$_SESSION['search'] .= "</select><br><br><INPUT TYPE=\"submit\"
NAME=\"submit\" VALUE=\"select\"></form>";
} else {
$_SESSION['search'] = "<b>Search for individual computers to edit by
hostname<br>(ex. dhcp_client_003)</b><br><br><span
class=\"copyright\">**This feature will search all VLAN's for individual
machines to make host configuration changes to.</span><br><br><b><img
src=\"images/error.jpg\"> No hosts matched your search for
$_POST[search_name].</b><br><br><form action=\"$_SERVER[PHP_SELF]\"
method=\"post\" name=\"search\"><input name=\"search_name\"
type=\"text\" size=\"30\" maxlength=\"45\"><br><br><input
name=\"search\" type=\"submit\" value=\"search\"></form>"; }
unset($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v']);
} elseif ((!empty($_POST['hosts01'])) && (empty($_POST['search'])) &&
(empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i']))
&& (empty($_POST['v']))) {
unset($_SESSION['search']);
require 'dbase.inc.php';
$table = "hosts";
$x = mysql_query("SELECT * FROM $table WHERE hostname =
'$_POST[hosts01]' OR ip = '$_POST[hosts01]' OR mac =
'$_POST[hosts01]'")or die(mysql_error());
$num = mysql_num_rows($x);
if($num == "0") {
unset($_SESSION['search']);
$_SESSION['search'] = "<b>Search for individual computers to edit by
hostname<br>(ex. dhcp_client_003)</b><br><br><span
class=\"copyright\">**This feature will search all VLAN's for individual
machines to make host configuration changes to.</span><br><br><img
src=\"images/error.jpg\"> <b>You did not select a host to
edit.</b><br><br><form action=\"$_SERVER[PHP_SELF]\" method=\"post\"
name=\"search\"><input name=\"search_name\" type=\"text\" size=\"30\"
maxlength=\"45\"><br><br><input name=\"search\" type=\"submit\"
value=\"search\"></form>";
} elseif ($num != 0) {
while($a = mysql_fetch_array($x)) {
list($_SESSION['id01'],$hn,$ma,$i,$v) = $a; }
$_SESSION['search'] = "<table width=\"100%\" border=\"0\"
cellspacing=\"2\">
<form name=\"hosts_done\" method=\"post\"
action=\"$_SERVER[PHP_SELF]\">
<tr>
<td width=\"40%\" colspan=\"2\"><b>You are about to make
changes to $hn | $i</b><br><br><span class=\"copyright\">** Please fill
out all fields and be carefull when entering the MAC address. The
proper format is as such XX:XX:XX:XX:XX</span></td>
</tr>
<tr>
<td width=\"40%\">Hostname</td>
<td><input name=\"hn\" value=\"$hn\" size=\"20\"
maxlength=\"45\"></td>
</tr>
<tr>
<td>MAC-Address</td>
<td><input name=\"ma\" value=\"$ma\" size=\"20\"
maxlength=\"45\"></td>
</tr>
<tr>
<td>IP-Address</td>
<td><input name=\"i\" value=\"$i\" size=\"20\"
maxlength=\"45\"></td>
</tr>
<tr>
<td>VLAN / Subnet:</td>
<td><input name=\"v\" value=\"$v\" size=\"20\"
maxlength=\"45\"></td>
</tr>
<tr>
<td> </td>
<td ><input name=\"Save\" type=\"submit\"
value=\"Save\"> <input name=\"reset\" type=\"reset\"
value=\"Reset\"></td>
</tr></form></table>";
} elseif ((empty($_POST['hosts01'])) && (empty($_POST['search'])) &&
(!empty($_POST['hn'])) && (!empty($_POST['ma'])) &&
(!empty($_POST['i'])) && (!empty($_POST['v']))) {
unset($_SESSION['search']);
// Will not get to this point!!!!!
$_SESSION['search'] = "<table width=\"100%\" border=\"0\"
cellspacing=\"2\">
<tr>
<td width=\"40%\" colspan=\"2\"><b>Your changes to
$_POST[hosts01] were successfull</b><br><br><span class=\"copyright\">**
To make your changes active you must use the \"UPDATE DHCP\" link on the
left</span></td>
</tr>
<tr>
<td width=\"40%\">Hostname</td>
<td>$_POST[hn]</td>
</tr>
<tr>
<td>MAC-Address</td>
<td>$_POST[ma]</td>
</tr>
<tr>
<td>IP-Address</td>
<td>$_POST[i]</td>
</tr>
<tr>
<td>VLAN / Subnet:</td>
<td>$_POST[v]</td>
</tr></table>";
} else {
unset($_SESSION['search']);
$_SESSION['search'] = "<img
src=\"images/error.jpg\"> Something broke, please try again."; }
} else {
unset($_SESSION['search']);
header("Location: login.hosts.php"); }
}
attached mail follows:
[snip]
Not sure why the last section won't work...
...so much code it made my head hurt ....
[/snip]
Not sure either. Did you have a question?
attached mail follows:
Hello, I have wrtten a PHP based web site with a MySql backend and now I
want to password protect downloadable files. I have logon and session
handling taken care of but I can't figure out how to only allowed those who
are currently logged in and above a certain security level to access the
downloadable content and prevent bookmarking of the file location for
redownloading.
Currently I have a .htaccess file to protect the files but then you need to
enter a User ID and password a second time. I would prefer a single signon
solution.
I have considered copying the files to a temporary area each time someone
wants to download it and then erase it when the session is killed but these
files can be large (20-100 mb) and I would rather not do all of that copying
if possible.
Creating unique symlinks would be easier but my development machine is
Windows and my server is FreeBSD and I can't create file links under
Windows. Plus, my FreeBSD server is not near me so remote development is
difficult.
Thanks to anyone with any ideas,
Andrew
attached mail follows:
On Tue, 30 Dec 2003, news.php.net wrote:
> Creating unique symlinks would be easier but my development machine is
> Windows and my server is FreeBSD and I can't create file links under
> Windows. Plus, my FreeBSD server is not near me so remote development is
> difficult.
1) windows has symlinks since win2000, however they are named Junctions.
I would recommend visiting sysinternals.com and getting junctions
tool (win2k/xp/2k3 -> miscalenous). Hey, it even comes with source!
2) another way is to make a redirect, so you do:
getFile.php?file=something.zip
and in your code you do:
<?
include "_mylibs.php"
if (userLoggedIn())
header "Location: ".$_REQUEST["file"];
else
echo "Only Valid People Can Login";
?>
3) final way is to pass through the file yourself. Safest way, but
potentially more resource hungry than the two above
in your code you do:
<?
include "_mylibs.php"
if (userLoggedIn())
{
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; ".
"filename=".$_REQUEST["file"]);
readfile($_REQUEST["file"]);
}
else
echo "Only Valid People Can Login";
?>
recommended reads:
http://www.php.net/manual/en/function.header.php
further recommended things to checkout:
freshmeat , and search for anti leecher scripts.
/apz, bringing joy to the world....
attached mail follows:
I would go for the 3rd alternative. There are several ways to
"stream" the file with the use of headers.
This way you can validate the user securely with your logon system,
and you can place the files outside the viewable web content.
Typically oputside your www / public_html folder.
I use this myself in an application I use, streaming files at 50MB
does not use alot of resources at all, atleast not the way I use.
My use for the script is to serve high resolution images to several
customers, often TIF images up to 50MB and larger.
Heres the code I use :
$distribution= "filepathonserver";
if ($fd = fopen ($distribution, "r")){
$size=filesize($distribution);
$fname = basename ($distribution);
header("Pragma: ");
header("Cache-Control: ");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$fname."\"");
header("Content-length: $size");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
print $buffer;
}
fclose ($fd);
exit;
}
--
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------
"Apz" <apz
nofate.com> wrote in message
news:Pine.LNX.4.50.0312301425320.28112-100000
binertia.com...
> On Tue, 30 Dec 2003, news.php.net wrote:
> > Creating unique symlinks would be easier but my development machine is
> > Windows and my server is FreeBSD and I can't create file links under
> > Windows. Plus, my FreeBSD server is not near me so remote development
is
> > difficult.
>
> 1) windows has symlinks since win2000, however they are named Junctions.
> I would recommend visiting sysinternals.com and getting junctions
> tool (win2k/xp/2k3 -> miscalenous). Hey, it even comes with source!
>
> 2) another way is to make a redirect, so you do:
> getFile.php?file=something.zip
>
> and in your code you do:
> <?
> include "_mylibs.php"
> if (userLoggedIn())
> header "Location: ".$_REQUEST["file"];
> else
> echo "Only Valid People Can Login";
> ?>
>
> 3) final way is to pass through the file yourself. Safest way, but
> potentially more resource hungry than the two above
> in your code you do:
>
>
> <?
> include "_mylibs.php"
> if (userLoggedIn())
> {
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; ".
> "filename=".$_REQUEST["file"]);
> readfile($_REQUEST["file"]);
> }
> else
> echo "Only Valid People Can Login";
> ?>
>
>
>
> recommended reads:
> http://www.php.net/manual/en/function.header.php
>
> further recommended things to checkout:
> freshmeat , and search for anti leecher scripts.
>
>
>
> /apz, bringing joy to the world....
attached mail follows:
You could have your authorization info in the mysql db including file
locations that are stored along with the authorization level necessary to
download them. If the person is authenticated to download the file, the php
script uses the file location info from the db to open the file and generate
the headers necessary to start the download. This way the end user never
has to have direct access to the download directory and you don't have to
copy the file into a temporary directory.
Larry
-----Original Message-----
From: news.php.net [mailto:news.php.net
akwebb.com]
Sent: Tuesday, December 30, 2003 2:13 PM
To: php-general
lists.php.net
Subject: [PHP] How do I protect downloadable files?
Hello, I have wrtten a PHP based web site with a MySql backend and now I
want to password protect downloadable files. I have logon and session
handling taken care of but I can't figure out how to only allowed those who
are currently logged in and above a certain security level to access the
downloadable content and prevent bookmarking of the file location for
redownloading.
Currently I have a .htaccess file to protect the files but then you need to
enter a User ID and password a second time. I would prefer a single signon
solution.
I have considered copying the files to a temporary area each time someone
wants to download it and then erase it when the session is killed but these
files can be large (20-100 mb) and I would rather not do all of that copying
if possible.
Creating unique symlinks would be easier but my development machine is
Windows and my server is FreeBSD and I can't create file links under
Windows. Plus, my FreeBSD server is not near me so remote development is
difficult.
Thanks to anyone with any ideas,
Andrew
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
I used to program in Miva some because it was fairly easy. I got used
to using some things and was wondering if there is a PHP equivalent.
<MvIF EXPR="{submit}">
<MvLET assignedto="(Unassigned)">
<MvASSIGN NAME="help" VALUE="len(description)">
<MvASSIGN NAME="bugnumber" VALUE="{random(1000)$time_t$random(help)}">
<MvLET description=glosub(description,asciichar(13),"<BR>")>
<MvASSIGN NAME="" VALUE="{fdelete('temp.dat')}">
<MvEXPORT FILE="temp.dat"
FIELDS="bugnumber,subject,description,reporter,assignedto,state, id"
DELIMITER="|$%">
<MvIMPORT FILE = "buglist.dat" FIELDS = "bugnumber, subject,
description, reporter, assignedto, state, id" DELIMITER = "|$%">
<MvEXPORT FILE="temp.dat"
FIELDS="bugnumber,subject,description,reporter,assignedto,state, id"
DELIMITER="|$%">
</MvIMPORT>
<MvASSIGN NAME="" VALUE="{frename('temp.dat','buglist.dat')}">
</MvIF>
The first MvEXPORT would at a the new data to the top of the list. The
the MvIMPORT with the nested MvEXPORT would add the rest of the data to
the list of data. I've been looking through my PHP book and only see
how to use databases in it. I was wondering if there is a way to save
something like this without the use of a database. I plan on making a
few form mages that are going to save some data, but like 3 or 4 entries
each. Since my webspace limits the number of databases, i'd rather do
it without the use of that.
My second question is about including pages.
would
|<?PHP include 'menu.html'; ?>
include the file the same way a SSI include would?
Thanks.
-Joe
|
attached mail follows:
[snip]
Since my webspace limits the number of databases, i'd rather do
it without the use of that.
[/snip]
see file functions in the manual like fopen, fwrite, etc.
[snip]
My second question is about including pages.
would
|<?PHP include 'menu.html'; ?>
include the file the same way a SSI include would?
[/snip]
Like this
<?php
include("menu.html");
?>
attached mail follows:
Hello list..
I was needing a small hint on how to make a sort of status page...
What I have is a function that takes a few minutes to complete...
It send an snmp signal out then waits a bit and then gets the status via
snmp.
I would like to have some sort of graphic or page for the status, e.g.
Percent done, a flashing waiting or something.
How might I do this?
attached mail follows:
[snip]
I was needing a small hint on how to make a sort of status page...
What I have is a function that takes a few minutes to complete...
It send an snmp signal out then waits a bit and then gets the status via
snmp.
I would like to have some sort of graphic or page for the status, e.g.
Percent done, a flashing waiting or something.
How might I do this?
[/snip]
A quick thought would be to use flush() http://www.php.net/flush to send
output to the browser.
attached mail follows:
This was posted to Slashdot not too long ago, and seems applicable to
php-general given the frequent mentions of register_globals and usage of
the get and post arrays. It's a detailed explanation of many common ways
that software which is overly trusting of its input can be exploited, and
underscores the point that input from the open internet is particularly
risky.
http://www-106.ibm.com/developerworks/linux/library/l-sp3.html
A lot of the article deals specifically with writing applications in a
Unix environment, but the general take-home points for PHP programmers
boil down to:
- In a client/server system, the server should never trust the client.
- Ruthlessly check untrusted inputs.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
attached mail follows:
Hi,
I am not sure how to go about this. =( I think my problems are twofold.
problem 1. I have to connect to a progress database, for which there is
no built-in php
support. I have been looking at the unified ODBC functions, but progress
isn't
one of the supported dbs there either.
problem 2. the db is not specifically a web db. It is the clients'
production db that
is located on their facility and it is behind a firewall. I know I will
get a performance
hit with this setup, but I can live with this.
question 1: do I need a progress driver, or do the ODBC functions take
care of that?
question 2: is it possible for the db connection to get thru a firewall,
and then connect
to a db?
TIA,
Craig
attached mail follows:
Sorry!
Here's a better example to what I meant from the last posting when I said
something about color=red#RowNum3.
--snip--
//Example #1
<a href="http://www.yourserver.com/yourpage.htm#RowNum3"
target="doc">Jump</a>
//Example #2
<a href="http://www.yourserver.com/yourpage.htm?color=red&color1=blue"
target="doc">Jump</a>
//Example #3
<a href="http://www.yourserver.com/yourpage.htm?color=red#RowNum3"
target="doc">Jump</a>
--snip--
As in example #3, PHP seem to be able to distingush the difference when
there is a pound symbol, or "#" in it and know that '#RowNum3' is not part
of the post string to the variable, color. So we get this
--snip--
color --> red
--snip--
And not this...
--snip--
Color --> red#RowNum3
--snip--
Cheer,
Scott
"Scott Fletcher" <scott
abcoa.com> wrote in message
news:20031212144111.99196.qmail
pb1.pair.com...
> It does work now. Going the other way around does the trick. Surprisely,
> PHP doesn't treat it as if two seperate thing are combined into one post
> data, like color for example that would be displayed as 'redRowNum3'.
>
> Thanks,
> Scott
>
> "Scott Fletcher" <scott
abcoa.com> wrote in message
> news:20031212142544.74333.qmail
pb1.pair.com...
> > Whoop! I think I found the problem, let me fix it and see if that
work..
> >
> >
> > "Scott Fletcher" <scott
abcoa.com> wrote in message
> > news:20031212142415.69724.qmail
pb1.pair.com...
> > > That would have been nice but it doesn't seem to work. Alright, I
guess
> > > I'll redo the script to make it work differently...
> > >
> > > Thanks,
> > > Scott
> > > "Stuart" <lists
sharedserver.net> wrote in message
> > > news:3FD98A9A.4000209
sharedserver.net...
> > > > Scott Fletcher wrote:
> > > > > Sample script I have here is this...
> > > > >
> > > > > --snip--
> > > > > <a href="http://www.yourserver.com/yourpage.htm#RowNum3"
> > > > > target="doc">Jump</a>
> > > > >
> > > > > <iframe id="doc" name="doc"
> > > > > src="http://www.yourserver.com/yourpage.htm"></iframe>
> > > > > --snip--
> > > > >
> > > > > Where yourpage.htm have this "<a href='#' name='RowNum3'>blah
> > > blah</a>"....
> > > > >
> > > > > So, question here is how do I pass the post string to the Iframe,
> like
> > > > > "&color=red" in this example, this example doesn't work... The
> iframe
> > > is
> > > > > the target method....
> > > > >
> > > > > --snip--
> > > > > <a href=http://www.yourserver.com/yourpage.htm#RowNum3&color=red
> > > > > target="doc">Jump</a>
> > > > > --snip--
> > > >
> > > > The anchor goes after the query string, like so...
> > > >
> > > > <a href=http://www.yourserver.com/yourpage.htm?color=red#RowNum3
> > > > target="doc">Jump</a>
> > > >
> > > > --
> > > > Stuart
attached mail follows:
Hi!
I'm encountering an interesting situation. I can do with one file path
in a flag for the compiler without a problem, but with 2 file paths in one
flag. What is needed to combine those two paths into one flags?
--snip--
LDFLAGS='-L/usr/local/ssl/lib'
LDFLAGS="CUSTOMER_ODBC_LIBS='-L/usr/local/lib -lodbc' "
--snip--
Thanks,
FletchSOD
attached mail follows:
Some one is asking me to create a sub search on a search that has already
been done. For instance, the database has 50,000 records, a user does a
search for two keywords which yielded 1700 records. They want to now filter
that list with other keywords. The logic is that searching 1700 records has
got to be faster than searching 50,000 records.
The only way I know how to do this is to save the results of the pervious
search to hidden fields and allow the user to add more keywords, which in
essence isn't doing other than adding more keywords to the search doing the
same exact thing they did before with new keywords. Is this logic correct or
is there a way to save that queries results and search only that?
Thanks
attached mail follows:
Hi!
What is the function exactly for encoding the user's typed password in
PHP after the HTTP Authentication pop-up window by Apache was submitted? I
tried the base64_encode() but it is not the right function. The
authentication header here is ..
--snip--
header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
--snip--
Thanks,
FletchSOD
attached mail follows:
Hi.
Do you know any mysql management programme as phpmyadmin but not works on
the server. i want to install on my PC. then i connect my database on server
from my PC at home. Do you know it?
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
- application/x-gzip attachment: java.tar.gz
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]