php

How to decrypt IRC Bot's blowfish encrypted messages.

I am making an IRC bot in php to read content of a channel. Bot is done fine.But the messages are encrypted With blowfish encryption. i have the key and all, i tried PHP's code below but didn;t worked. echo mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$input,MCRYPT_MODE_ECB); For more help the encryption is done via drftpd site bot. I can fin...

Creating a Variable of Present Date Minus a Past Timestamp

Hello, In the code below, "created" is a field in a MySQL table. This field is of the type "timestamp" and the default is set to "CURRENT_TIMESTAMP" of whenever a given row is created. In the query below, I would like to create a new variable that equals the present date minus the timestamp of "created", rounded off to units of days...

How would I set a checkbox to activate a link in a wordpress blog?

I want to be able to let people download stuff from the blog, like code for people to use. But I want to make sure people read the "License/Copyright" stuff before hand. It would say something like, "Check to agree to terms and conditions" and when they click it the download link is activated. Bonus: records their IP address from wher...

MySQLi Wrapper -- will this slow down performance?

I found the following code on php.net. I'm trying to write a wrapper for the MySQLi library to make things incredibly simple. If this is going to slow down performance, I'll skip it and find another way, if this works, then I'll do that. I have a single query function, if someone passes in more than one variable, I assume the function h...

Security when writing a PHP webservice?

I am writing a web service in PHP for the first time and had ran into some security problems. 1) I am planning to hash passwords using md5() before I write them to the database (or to authenticate the user) but I realize that to do that, I would have to transmit the password in plaintext to the server and hash it there. Because of thi...

Inconsistent Session data from IE - cached sessions???

I'm trying to prevent some basic click-fraud on my site, and am building links based on session time data. Everything works in FF, but in IE the information I'm storing in the session is somehow being changed. When I load up the main page, I set my session variables like this session_start(); $_SESSION['time']=time(); I'm out putt...

[php] how to read only 5 last line of the txt file

hello i have a file named "file.txt" it updates by adding lines to it. I am reading it by this code: $fp = fopen("file.txt", "r"); $data = ""; while(!feof($fp)) { $data .= fgets($fp, 4096); } echo $data; and a huge number of lines appears. I just want to echo the last 5 lines of the file how can i do that ? thanks in advanced ...

where to store information like gender and year of birth?

i have users and i need them to specify a gender (male, female) and year of birth (1930, 1931...1999, 2000). i wonder where i should store these values: in the database? in php file? if i store them in the database i have to manually create all entries first. but a good thing is that the user table will have constraints so the gende...

how to get something to display only once in a while loop

I've got a mysql query running and it checks to see if an iterator is equal to 1, then display this div title... if ($this->dliterator == 1) {echo "<div class='clientsection' id='downloads'>Downloads</div><br/>";}; The problem is, is that the dl iterator may not necessarily start at 1. (it is directly related to a downloadid from the d...

Need help with transferring data between MySQL db's using PHP

In one of the sites I manage, the client has decided to take on ACH/Bank Account administration where it was previously outsourced. As a result, the information submitted in our online form which used to simply store in a single database for processing now must sit in 'limbo' until the funds used for payment have been verified. My origin...

How can I limit the number of registrants to an event?

I've set up a basic html/php submission form where people can register for our event, but need a way to replace the submission form webpage with one that reads something like "We have reached our registration limit" when we reach a certain number of submitted forms. Our database is MySQL (if that makes a difference) I've looked around on...

login code with session

if login in one session...how to block to login from another session by same userid & password...? ...

MySQLi -- OO or Procedural?

I know OO is the "way to go" but I'm thinking procedural might be easier to use in the wrapper I'm making. Any difference in performance between MySQLi Object Oriented vs Procedural? ...

Learning OOP in PHP, trying to refactor my code. Can't connect to database anymore.

Thought I understood how classes work, then I tried this code: class user { var $dbcon; var $dbinfo; var $con; var $error; function dbConnect() { $this->dbinfo['server'] = "localhost"; $this->dbinfo['database'] = "foolish_faith"; $this->dbinfo['user'] = "user"; $this->dbinfo['password'] = "password...

Show a different template after two days in php with date()

I have this code to capture a date and time: date('F j, Y, g:i a T') and save is as $datetime: and I have this code to include a template: function template_contents($file, $model) { if (!is_file($file)) { throw new Exception("Template not found"); } ob_start(); include $file; $contents2 = ob_get_conten...

Help with PHP and associative arrays

Hello. I have to do a simple calculator in php based on user's input and choice from select field, something like this: <?php $a = $_GET['a']; $b = $_GET['b']; $array = array( "option1" => 0.1, "option2" => 0.15, "option3" => 0.3, "option4" => 3, "option5" ...

Scheduling with gearman vs. cron?

Hi everybody, I have noticed a lot of people discussing Gearman and it's scheduling features making it enable to distribute work onto other servers. However, I have not yet seen a comparison to native cronjobs. What are the differences between cron and Gearman? ...

Gearman: Run both client and worker on same machine?

Hi everybody, I just manage to install gearman on my local Ubuntu test environment. I wonder if I could in any way run both the worker and the client at the same computer, while in development stage? Thanks a lot! ...

Storing Sessions in a DB in PHP - keep getting mysql error

Hi guys, I want to store all my sessions in a DB and have read up on this and implemented the following class: <?php /** * This class handles users sessions and stores the session in the DB rather than in a file. This way stops any * shared host security problems that could potentially happen. */ class sessionHandler { /** ...

How to create PHP method linking?

I've seen other objects that do this: $obj->method1()->method2(); How do I do that? Is each function just modifying the pointer of an object or returning a pointer? I don't know the proper term for this style -- if anyone could help me with that, it would be great. ...