php

java equivalent to php's hmac-SHA1

I'm looking for a java equivalent to this php call: hash_hmac('sha1', "test", "secret") I tried this, using java.crypto.Mac, but the two do not agree: String mykey = "secret"; String test = "test"; try { Mac mac = Mac.getInstance("HmacSHA1"); SecretKeySpec secret = new SecretKeySpec(mykey.getBytes(),"HmacSHA1"); mac.init(...

Limit second and third sql if no insert

I got on my php script $result1 = mysql_query("insert ignore into...this.... $result2 = mysql_query("insert into...that.... $result3 = mysql_query("insert ignore...again those all are different queries. when first query tries to insert, and if it has duplicate record, it does not enter this. well I dont want to run second and third ...

PHP inserting ellipsis in the middle(!) of a string?

I am working on a PHP forum software (FluxBB) and a user encountered a rather interesting error, that - so it seems - PHP is inserting an ellipsis in the middle of a string. Due to a similar error I found on the net I feel forced to say that this code is situated in a function and that $db is a global variable. Here's the (simplified) ...

Is it possible to curry method calls in PHP?

I have a SoapClient instance generated for a WSDL file. All except one of the method invocations require the username and the password to be passed id. Is there any way of currying the method calls so that I can omit the username and password? ...

php the point for __get() and __set() magic

PHP 5 introduces the magic method __get() and __set(). From my understanding it is a shortcut for having to write each member's getter and setter; <?php class Person { private $firstname; private $lastname; function __set($var, $name) { $this->$var = $name; } function __get($var) { return $this->$...

file path problems with Zend Framework and fread()

Hi, I have a quick and hopefully simple question that I hope someone can help me with. I have a application that I am working on and I allow users to upload files. All files are loaded in to a directory with in the application folder of the project layout /application --/myuploadedfiles /library /public However when I need to rea...

Downloading files with PHP - Only downloading one at a time!

Hi there, I have a PHP file that serves up a file, but the problem is that no matter what browser is being used, if you click on 2 links that go to 2 separate files, the second download doesn't start until the first one is complete! Any ideas? Download Code header('Content-Type: application/octet-stream'); header('Content-Description:...

Represent numbers as shorten like SO does (13500 => 13.5k)?

Ok I write my own JS code for this bug I'm sure there's something more comprehensive out there I can use. My Google mojo isn't working though - any help finding open source code that'll help me represent numbers like how SO does for high numbers (102500 => 102.5K, 18601 => 18.6K, etc)? JS or PHP would be awesome, otherwise I can transla...

CodeIgniter - Is my custom session data being stripped by Facebook?

I'm wondering if there's a way to dump all of the values of $this->session->userdata() so I can troubleshoot? I'm working within Facebook, and have a login page, and once that's successful I want to pass around the UID of the current user, and I thought this would work well. I currently have the uid set as follows: require_once '...

Is there a way to turn off auto-conversion of objects to strings in php 5.2?

I'm using a compiler that has a slightly older version of PHP than my dev machine (5.1.3 vs. 5.2.6 IIRC). That version doesn't do the auto-conversion, which can result in some sneaky bugs in the compiled version. I'd rather not downgrade my dev box, but if I can somehow turn that off, that might be helpful in finding those earlier. ...

php/timeout/connection to server reset?

I have a php script that needs to run for quite some time. What the script does: connects to mysql initiates anywhere from 100 to 100,000 cURL requests each cURL request returns compact-decoded data of 1 to 2000 real estate listings - i use preg-match-all to get all the data and do one mysql insert per listing. each query never exceed...

How do you display a JavaScript alert from PHP?

I don't code in PHP, but I have this form which I pulled off the web and its working great: What I would like to do is somehow add some code in here that can fire up a JS script, simple alert box, saying "Thank you form is submitted". After the form was received by this mailer.php file. <?php if(isset($_POST['submit'])) { $to = "myEma...

ASP vs PHP compiliation

I am starting a major project and will be hiring developers soon. Right now im trying to decide between ASP.net and PHP and leaning strongly towards asp as most of the desktop apps will be written in C# About 50% of this project will be coded into a web system. My question is about how i could secure the code. Does php or asp offer any ...

Best way to Learn PHP

What are some of the best PHP tutorials/sites/resources/books or blogs which I can refer to learn PHP ? ...

cleaning $_POST variables

I'm trying to come up with a way to effectively easily clean all POST and GET variables with a single function. Here's the function itself: //clean the user's input function cleanInput($value, $link = '') { //if the variable is an array, recurse into it if(is_array($value)) { //for each element in the array... fore...

Security issues when cleaning arrays(in PHP)?

Could someone please explain why $_POST= array(); isn't an effective way of resetting your $_POST superglobal? I thought of this when reading this question. Being an array, I would imagine all elements of that array, be it $_POST or any other, would be reset when re-initializing it. ...

Overhead costs of opening a file handle in PHP?

I'm writing a logging tool which writes messages to a file, and I'm not sure of the best way to deal with the file pointer. I'm tossing up between these two methods: // Open, Write, Close; Open, Write, Close... function write($message) { $fh = fopen('file.log', 'a'); fwrite($fh, $message . "\n"); fclose($fh); } // OR ----- ...

How to import csv files selected by user to database

Hi I wonder how i can import csv files that selected by user to database using php. is there any practical way on this ? thanks ...

php mail() statments

Hello i am trying to get all the users infomation from the database and check the timestamp (fourteendays) and check it with the time now i got the time bit working but i can''t get it to send to all the when the time is > fourteendays $result1 = mysql_query("SELECT * FROM accounts") or die (mysql_error()); while ($row1 = mysql_fet...

Requests with Jquery

Currently I'm trying to add on to the auto-complete module for jquery that is out there. After i've auto-completed my text field, i tab to my next field (a drop down). When that drop down is focused, i want to check against my text field and populate the drop down with a specific list depending on what the text field has. Is this somet...