|
-
One of the projects I am working on has gone to Beta
Date: 12/16/05
Keywords: no keywords
T-Tag allows you send, or schedule, messages to the telephone. T-tag converts your text message to spoken-text. Sign up to be a beta-user and schedule holiday greetings. Send greetings to those who don't have internet access. Send a T-Tag to your office reminding them of the Christmas party or remind your friends of your party. Try it today!
http://www.t-tag.com
Source: http://www.livejournal.com/community/php/380313.html
-
Help "locking down" a form
Date: 12/16/05
Keywords: php, html, web, hosting, spam
Thanks to the responses on the captcha code. I think I know what I can do with it, but as someone pointed out, there will be accessibility problems, which is an issue because the site I'm working on is a gov't site.
My hosting company says the script to handle the contact form is vulnerable and that I should lock it down. They recommended the captcha method or a "guest" login requirement via .htaccess. I'll look into that, but in the meantime, they mentioned that my handler was "badly coded and allows more than one email address to be added to it." Since I've learned PHP by the seat of my pants, I'm not surprised, but I also don't know what to do to clean it up and make it better. Any help?
The HTML Form
< form action="contactmail.php" method="post" name="contact"> < table width="411" border="0" cellspacing="2" cellpadding="4"> < tr> < td align="right" valign="middle" width="143"> < p>Your Name:< /p> < /td> < td align="left" valign="middle" width="254">< input type="text" name="yourname" size="36" tabindex="1">< /td> < /tr> < tr> < td align="right" valign="middle" width="143"> < p>Your Email:< /p> < /td> < td align="left" valign="middle" width="254">< input type="text" name="youremail" size="36" tabindex="2">< /td> < /tr> < tr> < td align="right" valign="middle" width="143"> < p>Your Organization:< /p> < /td> < td align="left" valign="middle" width="254">< input type="text" name="yourorganization" size="36" tabindex="3">< /td> < /tr> < tr> < td align="right" valign="top" width="143"> < p>Comment or Question:< /p> < /td> < td align="left" valign="middle" width="254">< textarea name="comment" rows="17" cols="33" tabindex="4">< /textarea>< /td> < /tr> < tr> < td align="right" valign="middle" width="143"> |
< td align="left" valign="middle" width="254">< input type="submit" name="submitEmail" value="Send Email">< /td>
< /tr>
< tr>
< td align="right" valign="middle" width="143">
< td align="left" valign="middle" width="254">
< /tr>
< /table>
< /form>
The PHP script
if (!empty($HTTP_POST_VARS))
{
//Check for spammers first
if (eregi("MIME-Version: ",$_POST['youremail'].$_POST['yourname'].
$_POST['yourorganization'].$_POST['comment'])){die('Get out, spammer.');}
$now = date( "D dS M h:m:s" ); // Set these variables according to your details
$toAddress = "***@****.***" ;
$redirect = "contactconfirm.php";
$subject = "Contact Message from BII Website" ;
// Form information.
$formEmail = trim($HTTP_POST_VARS[ 'youremail' ]);
$emailparts=explode("@",$formEmail);
if ($emailparts[1]=="*****.***"){ //Another spammer stop.
die('You seem to be trying to use this form to spam. Stop it.');
}
$formName = trim($HTTP_POST_VARS[ 'yourname' ]);
$formOrg = trim($HTTP_POST_VARS[ 'yourorganization' ]);
$formMessage = trim($HTTP_POST_VARS[ 'comment' ]); // Email message
$message = "Name: " .$formName. "\n" ;
$message .= "Email: " .$formEmail. "\n" ;
$message .="IP Address: ".$REMOTE_ADDR. "\n";
$message .= "Organization:" .$formOrg. "\n" ;
$message .= "Comments:\n" ;
$message .= $formMessage. "\n" ;
$headers="From: \"".$formName."\" <".$formEmail.">\n";
$bMailSent = mail($toAddress, $subject, $message, $headers);
if (!$bMailSent){ echo "Unable to send email"; }
else { header("Location: $redirect"); }
}
?>
Source: http://www.livejournal.com/community/php/380005.html
gettext()
Date: 12/15/05
Keywords: php, html, linux, apache
I just can not get gettext() to work! I feel like every article I've read on the subject offers a different way to implement this in a script, but none of them seem to be working for me. If anyone can offer any help, it would be greatly appreciated.
Server environment(s):
- Local
- Server
- Windows XP Prof SP2
- Apache 1.3.34
- PHP 5.0.5 (with the gettext extension enabled)
- File system
-
BASEDIR: c:\localhost\site\
internals\lang\ --language file directory
internals\lang\en\
internals\lang\en\LC_MESSAGES\messages.mo
internals\lang\en\LC_MESSAGES\messages.po
internals\lang\es\
internals\lang\en\LC_MESSAGES\messages.mo
internals\lang\es\LC_MESSAGES\messages.po
public_html\gettext.php --gettext test file
- Remote
- Server
- Linux (not sure of the distro)
- Apache 1.3.33
- PHP 4.3.11 --with-gettext
- File system
-
BASEDIR: /home/username/
(same as above)
------------------------
public_html\gettext.php
------------------------
putenv ("LANG=es");
setlocale(LC_ALL, "");
bindtextdomain ("messages", "c:\localhost\site\internals\lang");
textdomain ("messages");
print(gettext ("Hello!"));
?>
------------------------
shell commands
------------------------
xgettext -a --omit-header gettext.php
msgfmt -o messages.mo messages.po
------------------------
internals\lang\en\LC_ MESSAGES\messages.po
------------------------
#: gettext.php:27
msgid "Hello!"
msgstr "!olleH"
------------------------
internals\lang\es\LC_ MESSAGES\messages.po
------------------------
#: gettext.php:27
msgid "Hello!"
msgstr "Hola!"
EDIT: I've miraculously and inexplicably gotten the script to work on my local box, but it still won't work on the Linux server. I think it might have something to do with the "putenv("LANG=es"). Is there a different variable that needs to be set? Ideas?
Source: http://www.livejournal.com/community/php/379698.html
Multi-lingual "captcha" scripts?
Date: 12/15/05
Keywords: no keywords
I am looking to add one of those image-verification captcha things to a form I have. I've done a bit of poking around and found a script that will do this, but I'm not sure what to do about the fact that one of the forms will be in English and the other in Russian, meaning the image needs to be in a different language depending on the language of the form, so that users without access to the other language's alphabet can still submit. Any thoughts on how I can do this? (I'm guessing just specifying a different font isn't going to be enough.) Or are there other scripts out there that will do it for me? TIA!
Source: http://www.livejournal.com/community/php/379543.html
Why isn't this working?
Date: 12/14/05
Keywords: php, database
Just a small problem, but I'm going desperate here because I don't know what wrong. I'm pretty much a noob, you should know...
this script is for generating the sitetitle; if there's one set in the file it should take the one for the file (that part works), and if it's display.php, it should pull it from a database. The database one is not working, doesn't show anything....
Here's my code:
if (isset($sitetitle)) { echo " :: $sitetitle"; }
elseif ($_SERVER['PHP_SELF'] == "/www/htdocs/w005ab22/www/test/display.php"){
include('inc/connect.php');
$sql = "SELECT * FROM blog WHERE id='$id'";
$result = mysql_query($sql) or
print ("Can't select entries from table blog.
" . $sql . "
" . mysql_error());
while ($row = mysql_fetch_array($result))
{
$title = $row["title"];
$category = $row["category"];
echo " :: $title :: ($category)";
}
}
else echo "";
?>
Thanks in advance :)
Source: http://www.livejournal.com/community/php/379164.html
Query Help
Date: 12/13/05
Keywords: mysql, sql
I am not very experienced at writing queries that pull from several tables...
Can anyone tell me why $maillist
has 639 results when it should have only 8 (where assgo.aprivi='m'
) ?
code
$maillist = array();
$Link = mysql_connect ($Host, $User, $Password);
$Query = "SELECT fb_user.emailAddress, fb_user.ustatus, passgo.aprivi, member_services.salesAlert
FROM fb_user, passgo, member_services
WHERE fb_user.ustatus='active' AND passgo.aprivi='m' AND member_services.salesAlert='y'
";
$Result = mysql_db_query ($DBName, $Query, $Link);
if (!$Result) {
print("$Query
\n");
echo 'MySQL Error: ' . mysql_error();
exit;
}
while($Row = mysql_fetch_array ($Result)) {
$email = $Row['emailAddress'];
$type = $Row['aprivi'];
$send = $Row['salesAlert'];
$maillist[] = array($email, $type, $send);
}
mysql_close ($Link);
Solution:
$Query = "SELECT
u.userID,
u.emailAddress,
ui.cats,
p.aprivi,
ms.salesAlert
FROM fb_user AS u
INNER JOIN passgo AS p ON u.userID = p.goID
INNER JOIN member_services AS ms ON u.userID = ms.serviceID
LEFT JOIN fb_user_interest AS ui ON u.userID = ui.userID
WHERE u.ustatus='active'
AND p.aprivi='m'
AND ms.salesAlert='y'";
Source: http://www.livejournal.com/community/php/378930.html
Best Practice for a dynamic site
Date: 12/12/05
Keywords: php
I've recently started developing page's in a more "dynamic" way. So instead of having 1 page that for each page of content I would have 1 index page that simply reference's other pages and then variable's to control the content.
Example
First off I have a $_POST variable called $p, this basically control's which page you want to access. I then pipe this though an If...Then loop
eg
pagchg.php
<.?.php
if ($p == 1) {
include ('includes/mainpage.php');
} elseif ($p == 2) {
include ('includes/page2.php');
}
?.>
In each "selected" page I just have the main content eg
<.?.php
print "
Test
";
?.>
And then the menu would be something like
<.a href='?p=1'>Test1
<.a href='?p=2'>Test2
The main index.php page would just reference page's like
<.?.php
include_once('includes/header.php');
include_once('includes/pagechg.php');
include_once('includes/footer.php');
?.>
What I want to know is, is this a safe method of creating a dynamic site. I do use htaccess so the user would see somesite.com/somepage instead of somesite.com/?p=1. If this isn't safe what is a safer method?
Thanks again for any replies
Source: http://www.livejournal.com/community/php/378469.html
regular expressions
Date: 12/11/05
Keywords: no keywords
EDIT: nevermind, it seems to be functioning as is.
i'm receiving a data feed that comes through kind of like this:
HTTP OK here is your data legal disclaimer blah blah blah column1,column2,column3,column4
something,some stuff,some data,hellosomething,some stuff,some data,hellosomething,some stuff,some data,hello
a giant stream of plain text. what i'd like to do is get the data into an array, so that i might have something like this:
$data[0] == "something,some stuff,some data,hello"
$data[1] == "something,some stuff,some data,hello"
$data[2] == "something,some stuff,some data,hello"
which would allow me to work with each line.
preg_match_all("|(.*)|U",$data_fetch,$data);
this looks like it's taking all of the data lines and putting everything into one array element. what would be the proper expression to parse out each data line individually?
Source: http://www.livejournal.com/community/php/377888.html
Menus
Date: 12/10/05
Keywords: php, css, html, java
Hi guys,
I'm looking at various menu systems for a site I'm working on. I want to avoid DHTML and javascript if possible, sticking to a purely CSS model. So I saw this article (http://htmlfixit.com/?p=808) online, and I liked the end result, but after a second look I've determined it's not what I'm after.
(http://htmlfixit.com/?p=808 is currenly offline, but the CSS menu they talk about is here: http://www.stormtrumpets.com -- compare with http://www.stormtrumpets.com/trumpets01.html to see how they implement the menu)
The menu on this page, while purely CSS, appears to be coded individually for each page -- that's find for a site with a limited number of pages, but not practical in terms of scalability.
What I'm looking for is a way to set one menu across all the pages on my site, and allow the users to expand the menu with a mouse-click (hover is a second acceptible (if not preferred) choice). I don't want to have to create the menu for each page that ends up being on the site.
I'm happy to use PHP to achieve this, since the site is all PHP-based to begin with.
x-posted to _css and php
Source: http://www.livejournal.com/community/php/377523.html
I'm at a loss
Date: 12/10/05
Keywords: php, mysql, sql, apache
This may be because my brain is fried after a format and reinstallation of everything but I can't seem to see the resolution to this problem.
I'm getting this: Fatal error: Call to undefined function mysql_connect() in...
I'm running PHP 5.1.1 as an Apache 2.0 module using MySQL5 on WinXP. I've been over php.ini several times and everything appears in order, and all the .dll's exist in their correct place, but it continues to insist it does not know the function.
Help is appreciated.
Source: http://www.livejournal.com/community/php/377171.html
Dropdown madness
Date: 12/09/05
Keywords: database
Hi all I have a project that requires me to be able to do the following.
Display a dropdown of US states, when state is selected the corresponding countys will appear in another dropdown.
Like this page: http://www.personalinjurylawyer.com/
If anyone can help me with the following I would be most appreciative.
1) Where can I buy the code that would make that happen?
or
2) Where can I buy the database so I can create the code on my own?
Thanks in advance.
cross posted.
Source: http://www.livejournal.com/community/php/376952.html
Configuration
Date: 12/09/05
Keywords: cms, php, programming
First time poster to the community...
This may sound like an easy question, but I don't know the answer. I'm writing a custom CMS for my site, and would really like to know how to make a config system (ie. loading/saving properties, like an INI file). I have got programming experience but I'm relatively new to PHP, so I'm a bit lost.
Source: http://www.livejournal.com/community/php/376598.html
Anyone else use GD out there?
Date: 12/08/05
Keywords: no keywords
Here's what I'm thinking about doing, but I don't want to do it if it's going to run into a lot of slow response time for the client.
Let's say I want to create a dynamic map of a virtual town. I have a .jpg of the map (map.jpg) and I have a .jpg of a house (house.jpg). With GD, I know I can overlay that house to the right pixel coordinates on map.jpg. But let's say that I need to draw 10 house.jpg's on to map.jpg. Now let's add on top of that decent traffic where this is going on quite regularly.
Am I heading for disaster using the GD extension in this way? Am I better off considering Flash?
Right now, I'm at a quandry. To Flash or not to Flash with this part of my development. Obviously, doing it via flash would put all of the load on the client. But upon every click, it may require a new flash page. .swf files can sometimes take time to load.
So, I guess the question is who out there has experience with GD? Is it fast and effective considering a server with moderate traffic?
Source: http://www.livejournal.com/community/php/376363.html
PHP Forms
Date: 12/08/05
Keywords: php, html, database, web
Hi, I am sure this is really simple but I am beat and I hope someone can point me in the right direction.
I have a php program that takes data from a form and puts it into a database. This information can then be edited with a web form as well. The data is displayed in a news page for the web site's visitors. Ok all that is easy. The part I am having a hard time with is the correct way to handle the text. I suppose essentially its like LJ but on a much smaller scale with no comments. A daily news system.
I can use nl2br() to convert the new lines, but then in the editing window I dont want the user to see it when they are editing. The know nothing about HTML.
Can you point me to a resource that will explain the correct procedure for handling this? Or just tell me which functions to use.
Much thanks.
Source: http://www.livejournal.com/community/php/375861.html
PHP Email
Date: 12/07/05
Keywords: php, mysql, sql, linux, google, apache
Hello everyone
I've got a little bit of a problem, @ work I run PHP on apache which then runs on Win2k Server. For email I have just edited the php.ini and changed
SMTP =
smtp_port = 25
to point at our exchange server. Now here's the hard part @ home I run a linux server, well 2, 1 is my mailserver and various other stuff the other is my dev box, apache/mysql/php. How/what do I need to change to get my dev box to send mail to my mailserver ? I've had a look on google but drawn a blank.
My dev box is called pm-sr02, mailserver called pm-sr01.
Thanks for any answers
Source: http://www.livejournal.com/community/php/375707.html
When you think you know more than the code...
Date: 12/07/05
Keywords: php, mysql, sql
Some may find this amusing :)
First, a little preface for those that keep up with this journal. I was running on RedHat 9.0, way outdated. And when I tried to update PHP, it was a mess. So I decided that it was time to just upgrade the entire OS. Went to Fedora 4... even worse nightmare. Then I found Ubuntu... redemption.
After getting everything setup and modified: The core, PHP, http, postfix, MySQL, SSH, FTP (yeah, thank God for Ubuntu!), everything finally returned to normal Monday morning around 3:00 AM.
The whole reason for updating was due to a bug I read about a long time ago in v 4.2.2. The bug was with the sort() function. I just remembered reading about it in my O'Reilly PHP Cookbook. Most of my sorting has always been done via MySQL. So I've never had a use for sort() until this one line of code. So I'm thinking after coding and it not working "ah, this is that bug".
So I went back to that line. After all this headache, I just immediately had to know if it worked now:
$options = ksort($this->allowable_commands());
I almost got sick to my stomach. The right answer?
$options = $this->allowable_commands();
ksort($options);
So only NOW do I go back to try to find what the bug actually was that PHP Cookbook talked about (page 98):
The sort() function doesn't preserve the key/value association between elements. Instead, entries are reindexed starting at 0 and going upward. (The one exception to this rule is a one-element array; its lone element doesn't have its index reset to 0. This is fixed as of PHP 4.2.3)
My usage wasn't even CLOSE to this bug! I thought sort() returned the re-sorted array.
That's what I get for overthinking. Go ahead, you can laugh at me. I did.
Source: http://www.livejournal.com/community/php/375336.html
Nifty bit of code I thought I'd share...
Date: 12/07/05
Keywords: php, css
Ever had a one page (out of an entire site) that had specific CSS no other page should share?
If you're like me, and use a common header.inc.php and footer.inc.php, including the CSS inside a