1. get username from .htaccess login?

    Date: 05/08/06     Keywords: no keywords

    Is it possible to retrieve the username when a user logs in to an app through an .htaccess login page?

    I have a directory protected by .htaccess and .htpasswd, and would like to be able to capture the username when someone logs in. I want to print it like, "Hello, Sharon!" in the app itself.

    Any ideas on how to do this?

    Source: http://community.livejournal.com/php/448615.html

  2. More image stuff

    Date: 05/06/06     Keywords: php

    I have more questions about image resizing & stuff in PHP, following this post.

    1. How can I tell the script only to resize to 500px in width if it's bigger in width than 500px? Means it should NOT increase smaller pictures in size.

    2. How can I make a "crop" from an image? I'd like all the thumbnails to be 100x75 pixels, but they should neither be distorted, stretched or squashed, nor should they be more in height than 75px. Is that possible?

    Thanks :)

    Source: http://community.livejournal.com/php/448260.html

  3. moving host woes

    Date: 05/06/06     Keywords: php, html

    Hi, moving a friend's site from one site to another proved to be a bit of a problem. I was at first getting Internal Server Errors, when I checked the logs I was getting premature end of script headers.
    After changing permissions I managed to avoid this error, but get another error.
    My problem is now this:

    Fatal error: Call to a member function on a non-object in /home/public_html/index.php on line 126

    when i check line 126
    this is what's there: $default_num_rows = $get_default->numRows();

    this doesn't look like something that would be affected by a move of hosts as nothing appears to be defined to any specific directory that isn't already there? can anyone help me?

    Source: http://community.livejournal.com/php/448029.html

  4. Dysfunctional Functions

    Date: 05/05/06     Keywords: php

    Okay... I need some help with functions here. I've read the documentation on php.net, and just when I think I understand functions, I get thrown a curve ball. Here's the situation.


    Lets say I have the following function:

    function DoStuff($var1){

    if($var1 == "z"){
         $x = 1
         return $x
    }else{
         $x = 2
         return $x;
    }

    }




    Now, lets say I call this function:

    $passedVar = "z";
    DoStuff($passedVar);
    echo $x;

    In theory, I should get an echo of "1" ($x)

    But, I do not. $x seems null. Now, as far I know, the variable of $x should be getting passed back to the file that called the function. Am I wrong in my thinking?

    Source: http://community.livejournal.com/php/447773.html

  5. Question on queries and links

    Date: 05/05/06     Keywords: php, database, sql

    Hey guys! I'm working on a project for my company, and running into a big of a block. Let's just say I'm a newbie at PHP, but intermediate on SQL.

    The project I'm working on is to create a PHP/SQL system that we can enter outage ticket information into, and then query the database of tickets. I've got the query working, however with all the data that's being put in, it spreads the table way out over to the right and makes me have to scroll to see the rest of the info. Which is a pain.

    What I'd like to do is have it query the information, and in the ticket# field have it hyperlink the # so that people can click the # and it'll query the database for all the information related to that ticket.

    Any thoughts on how to accomplish this easily?

    Thanks,
    Chris

    Source: http://community.livejournal.com/php/447603.html

  6. Weird emails generated from php contact form

    Date: 05/04/06     Keywords: php, browser, security, web, google

    I'm pretty new to php, and this may be the dumbest question ever asked, but it's freaking me out.

    I have a contact form on a website in php and it works perfectly fine. Once in a while, however, I will get 5-6 emails at once, all sent from the form, with weird email addresses (i.e. with the domain name of my site) that fill in all fields with the email address and the message is some sort of garbled version of a story by Hans Christian Andersen -- (I only know this because I googled the lines).



    I have the form automatically send me an email that fills in field so that I get an email like the following if someone has an issue with the website:


    Someone has a website issue.

    A user, $name, has an issue on the page $url

    The issue is: $message

    They are using $browser as a web browser and when asked if they would like a follow-up they said $followup.
    Their email address is $email




    But I will sometimes get emails like the following:


    Someone has a website issue.

    A user, blood7007@mydomain.com, has an issue on the page et
    Content-Type: multipart/alternative; boundary=c4ac4da924461ca45d3cbd03ebe2afb9
    MIME-Version: 1.0
    Subject: a brother
    bcc: bajfla2@aol.com

    This is a multi-part message in MIME format.

    --c4ac4da924461ca45d3cbd03ebe2afb9
    Content-Type: text/plain; charset=\"us-ascii\"
    MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit

    what a struggle his soul had passed through. he disputation continued. ilhelm was in one of his eloquent moods. he doctor regarded the etters of the andering host as one of the most perfect books in
    --c4ac4da924461ca45d3cbd03ebe2afb9--

    .


    The issue is: blood7007@mydomain.com.

    They are using as a web browser and when asked if they would like a follow-up they said blood7007@mydomain.com.
    Their email address is blood7007@mydomain.com.



    All of the emails are also blank carbon copying to the same address, the aol one as listed above.


    So, I'm wondering if anyone can tell me how and why these are sent, if it's a security issue, etc... and what I should have in place to prevent it, if it's possible.

    Source: http://community.livejournal.com/php/446812.html

  7. Using the IP address to pre-populate a form

    Date: 05/02/06     Keywords: no keywords

    I see some sites ads list my location (city, state, and Country) using my IP address. I would like to access this information and pre-populate the form.

    Has anyone here ever done this?

    Source: http://community.livejournal.com/php/446465.html

  8. Cookies

    Date: 05/02/06     Keywords: php, java, spam

    Hi,
    I dont really know cookies very much (In Javascript, reading a cookie was mind boggling so I never really learned them).

    I was looking at setcookie() and cookies at PHP.net for a means to read the expiration time of the cookie. I am using cookies to keep people from spamming my site but would like to tell them when they can come back.

    $HTTP_COOKIE_VARS and $_COOKIE doesnt seem to list the expiration time of the cookie. How can I access the expiration time of the cookie?

    Source: http://community.livejournal.com/php/446432.html

  9. Image upload with resizing and additional thumbnail creation

    Date: 05/02/06     Keywords: php

    Hi guys, since I'm a PHP novice I need some help with this script. I have a perfectly working script for uploading an image with resizing, *BUT* I need a script that takes the same image from the form a second time and creates a thumbnail from that. So the image would be uploaded twice - once as thumbnail and once as the original (resized). How exactly can that be done?

    Thank you so much in advance :=)


    This is the current script;

    if ($uploadfile != "") {

    $uploadedfile = $_FILES['uploadfile']['tmp_name'];


    $src = imagecreatefromjpeg($uploadedfile);


    list($width,$height)=getimagesize($uploadedfile);


    $newwidth = 500;

    $newheight = ($height/$width)*500;
    $tmp = imagecreatetruecolor($newwidth,$newheight);


    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);


    $filename = "/www/dir/". $_FILES['uploadfile']['name'];
    imagejpeg($tmp,$filename,100);

    imagedestroy($src);
    imagedestroy($tmp);


    // for the db
    $foto = "dir/". $_FILES['uploadfile']['name'];
    }

    Source: http://community.livejournal.com/php/446151.html

  10. Mail Server Configuration

    Date: 04/28/06     Keywords: software

    After spending a few months with a WAMP connection on my home machine, I've finally realized that I never set up the mail server. I have no experience with this sort of thing, so I was wondering if there was a way I could set one up without spending any money, compiling software, or downloading a new OS?

    (cross-posted to a few different groups)

    Source: http://community.livejournal.com/php/445655.html

  11. Config file encryption

    Date: 04/28/06     Keywords: database

    I'm looking for a way to encrypt the fields of a configuration file. Most importantly, I'd like to be able to encrypt the username and password stored in the file used to connect to the database. The structure of the file and the field name can be left unencrypted, so I only need a way to encrypt and decrypt a string. The encryption has to remain unbreakable even if someone has read the source code of the program that generated it. Is there a way to do this?

    Thanks!

    Source: http://community.livejournal.com/php/445396.html

  12. php's include function question

    Date: 04/28/06     Keywords: php, browser, html, web, apache

    I currently have a paid webhost, which runs *nix, I have a web proxy script running on there and rather than calling the script directly, I use the
    include('cgi-bin/proxy.pl');
    ?>
    function to load it in an index.php file on my webserver.

    Now I also have a local webserver, running Win2k3, Apache 2.0.55, the latest PHP, and Perl. (I'm not sure if its a misconfiguration on my part, or if theres something I'm doing wrong...) I setup everything, Installed the same proxy script (and when accessed directly, it runs exactly as it should,) But when I use the include('cgi-bin/proxy.pl'); function, It just returns the entire cgi script in plaintext exactly like this:
    #!/usr/bin/perl --## CGIProxy 2.0.1## nph-proxy.cgi-- CGIProxy 2.0.1: a proxy in the form of a CGI script.# Retrieves the resource at any HTTP or FTP URL, updating embedded URLs# in HTML resources to point back through this script. By default, no# user info is sent to the server. Options include text-only proxying# to save bandwidth, cookie filtering, ad filtering, script removal,# user-defined encoding of the target URL, and more. Requires Perl 5.## Copyright (C) 1996, 1998-2002 by James Marshall, james@jmarshall.com# All rights reserved.## For the latest, see http://www.jmarshall.com/tools/cgiproxy/### IMPORTANT NO

    I've also tried using the full URL in the include path include('http://mysiteurl/cgi-bin/proxy.pl'); But that causes it to timeout, and gives the following errors:

    Warning: include(http://mysiteurl/cgi-bin/proxy.pl) [function.include]:failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:\WebServer\htdocs2\public\index.php on line 5

    Warning: include() [function.include]: Failed opening 'http://mysiteurl/cgi-bin/proxy.pl' for inclusion (include_path='.') in D:\WebServer\htdocs2\public\index.php on line 5


    This also happens when I try to "include" any other file by the complete url... I'd like to figure out what's causing this, and why it can't read it from the complete url (all files I've tested, can be accessed fine via a web browser by the full URL, so I don't know why Apache / PHP is having a hard time with it.)

    I'm not quite sure where the problem is, But the first way of calling it include('cgi-bin/proxy.pl'); Obviously works, it just doesn't execute the cgi script before displaying it (which my paid webhost apparently does) How does one accomplish this?

    I'm by far no expert with PHP, I can piece together scripts and things, and do basic setting up, but this has really baffled me. :(


    ---Edit---
    Here are some actual domains so you can see what I really mean:

    My Webserver (Win2k3, Apache, PHP, Perl):
    The actual CGI Script (This runs fine):
    http://proxytest.dyndns.org/cgi-bin/nph-proxy.pl
    The PHP file using the include function to load the cgi script (Displays the actual CGI file in plaintext):
    http://proxytest.dyndns.org/proxy.php

    My Paid Host (Pre-configured, running on *nix):
    The actual CGI Script (This runs fine):
    http://www.wolfstudios3d.ca/cgi-bin/nph-proxy.pl
    The PHP file using the include function to load the cgi script (Displays the processed CGI File, exactly as if accessed directly):
    http://www.wolfstudios3d.ca/proxy.php

    Source: http://community.livejournal.com/php/445071.html

  13. PHP Links/Link Exchange Scripts

    Date: 04/26/06     Keywords: mysql, sql

    Can anyone recommend a good one? Especially if you have experience with it, anything you can share would be helpful. I've been poring through the huge variety of them on sites like Hot Scripts, but I'm thinking I need to hear from people who may have used them.

    I'd be tempted to just write my own, but I'm looking for something pre-made. Commercial is fine, if your recommendation is of that nature.

    EDIT: It has to be able to use a MySQL backend.

    Source: http://community.livejournal.com/php/444759.html

  14. Refresh

    Date: 04/26/06     Keywords: no keywords

    My pages don’t seem to refresh in FireFox or IE (I’ve adjusted IE’s settings to “Every Visit to the Page”).

    The refresh button works.

    Is there a way to force a refresh upon load?

    Source: http://community.livejournal.com/php/444576.html

  15. something wrong w/ this code?

    Date: 04/25/06     Keywords: database, sql

    I have a function/wrapper for basic SQL functionality, that looks like so:

    function NRE_Insert( $strSQL )
    {
    $db = mssql_connect( $db_host, $db_user, $db_pass ) or die ( "couldnt connect to server" );
    mssql_select_db( $db_name, $db ) or die ("couldnt connect to database." );

    $sql_result = mssql_query( $strSQL ) or die ("couldnt execute query" );
    }

    I'm calling it like so:

    $strSQL = "Insert Into AMGvenues(venueName, venueLink) Values('$venueName', '$venueLink')";

    NRE_Insert( $strSQL );

    Everything looks fine to me, but I'm constantly getting the "couldn't execute query" message. As far as I can tell, I do have the correct DB permissions (this is MS SQL Server, btw).

    does anything look blatantly wrong to you guys? It's 1am, and I'm just not seeing the problem clearly anymore.

    thanks.

    Source: http://community.livejournal.com/php/444381.html

  16. Might be a beginner question...

    Date: 04/25/06     Keywords: php, mysql, sql

    Solved:see bottom of post for more info.

    I have a .sql file that has 3 commands in it.
    2 "Create Tables table' followed by a "Insert Into table"

    Each command is terminated with a ;

    If I copy the text directly into MySQL. no problems.

    I'm trying to get a php file to run the information in the page.

    Below the cut is what I tried, what happened, and what I realized:

    I tried:

    echo "Creating tables and data for $sql_file_name...";
    $str = file_get_contents($filePath . $sql_file_name);
    if (mysql_query($str)) {
    	echo " Done.
    \n"; } else { echo mysql_errno() . ": Error on query for sqlfile $sql_file_name: " . mysql_error() . "
    \n"; die; }
    The runtime came back with
    1064: Error on querry for sqlfile address.sql:
    You have an error in your SQL syntax;
    check the manual that corresponds to your MySQL server version for
    the right syntax to use near ';
    CREATE TABLE `Address_Type`
    ( `AddType_UID` int(50) NOT NULL auto_increment' at line 15
    My guess is that since PHP queries are submitted without a semi-colon that this tripped up the system. So my question:

    Is there a php command: Run_sql_in_file($filepath) ... or
    Is there a way to split my .sql string that I'm getting from file_get_contents() into an array split by the semicolon character?

    If not obvious I am quite new to PHP and pretty much self teaching as I go.

    Thanks!

    SOLVED:

    I found the explode() command. '[info]'zimzat posted at about the same time.

    I'm on the way out, but will post the final function I generated later if people are interested.

    Source: http://community.livejournal.com/php/444038.html

  17. Security?

    Date: 04/24/06     Keywords: php, mysql, html, sql, security, web, spam

    Hi everyone,

    I'm looking for some advice on some simple security measures. I deal with a political web site that wouldn't necessarily be sticking its neck out for malicious attacks but has received some spam attention on its forms already, and I worry as we store more data in a MySQL db (is it wrong to store a mailing list there?) that an injection could get in and send out sensitive information or potentially attack our larger parent organization that provides us with server space.

    Basically I have the same kind of simple form doing the same thing in a few instances of the web site. The form has about 20 fields, most type text some textarea, and a few of type file (for resumes, applications, etc). I don't currently copy any of the files to the server because I don't have access to, so I email them (via PHP) to myself or whoever the coordinator is. I don't currently have anything in place except for strip slashes and/or remove html in some cases, but I know that these measly little concoctions don't do anything to protect me from a sophisticated (or hell, even newbie) attack.

    What kinds of things should I be doing? I should probably be processing strings to make sure that they don't have any sql in them or make it so that the user is blocked from having access to damaging things, but I don't know what signifiers to look for or even what functions to use. Anyone have any basic suggestions or advice, or a link to a source that might help me beef up my data police? Thanks in advance!

    Source: http://community.livejournal.com/php/443711.html

  18. creating variable

    Date: 04/24/06     Keywords: php

    Stupid question I’m sure…but I just can’t see the solution.

    I have the follow lines...that create a variable ($uploadfile) that I use later to load a file onto the site.

    $uploaddir = '../../../mem_hoa/';
    $uploadfile = $uploaddir . $filename;

    It works great!

    BUT…I want to allow for user selectable variable to determine directory location.

    The following DOESN’T work…and I don’t know why

    $uploaddir = '../../../$memselection/';
    $uploadfile = $uploaddir . $filename;

    Help?

    (NOTE: I have verified the variable ($memselection) is working correctly, and is actually used for some table insert and manipulation on the same php page.)

    Source: http://community.livejournal.com/php/443480.html

  19. include with variables

    Date: 04/24/06     Keywords: php

    hey guys, noobie question;

    how can I include a file with a variable, like file.php?id=one or something? OF course it doesn't work with somethin like include ('file.php?id=one'); , but are there some other ways in PHP of doing that?

    Source: http://community.livejournal.com/php/443201.html

  20. Is there a better way of doing this?

    Date: 04/24/06     Keywords: no keywords

    if ($id=="11" || $id=="1" || $id=="2")
    {
    // do something
    }

    This is fine for one or two OR clauses, but when I have say 10 the code looks pretty ugly. Is there a better, cleaner way of coding this?

    Thanks!

    Source: http://community.livejournal.com/php/443084.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home