php

PHP: Unique visits/hits to specific items using cookies/ip...

Hi, I use a simple MySQL table to count day hits for specific pages/items in a website. Using 'id' column for page/item ids, 'date' for the day of the visits/hits, and 'hits' column for the number of hits. Everytime someone visit the page the value of hits for that specific date is updated to +1. But, the value is updated one more time...

PHP access external $var from within a class function

In PHP, how do you use an external $var for use within a function in a class? For example, say $some_external_var sets to true and you have something like class myclass { bla .... bla .... function myfunction() { if (isset($some_external_var)) do something ... } } $some_external_var =true; $obj = new myclass(); $obj->myfu...

wrapping my php/mysql app in modx

I wrote a small app that relies heavily on a series of php pages in which mysql data is displayed and formatted, given the user's credentials. Rather than rolling a whole user management system from scratch, im debating putting these files into modx pages and utilizing its usermanagement features to secure and restrict those pages and t...

How to deal with streaming data in PHP?

There is a family of methods (birddog, shadow, and follow)in the Twitter API that opens a (mostly) permanent connection and allows you to follow many users. I've run the sample connection code with cURL in bash, and it works nicely: when a user I specify writes a tweet, I get a stream of XML in my console. My question is: how can I acce...

Find out which class called a method in another class.

Is there a way in PHP to find out what object called what method in another object. Exmaple: class Foo { public function __construct() { $bar = new Bar(); $bar->test(); } } class Bar { public function test() { } } $foo = new Foo(); Would there be a way for me to find out that the test method was called from the f...

Stumped in the middle of a PHP loop

Here's what I've got so far- $awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error()); $awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error()); $awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section_id = 3') or die(mysql_error()); $awards_s...

what controls the time a request is processed on an apache2.2/php5 web service

I'm testing a web service that is running on Apache 2.2 and PHP 5. Using curl to send requests I see that the time spent is always 2 minutes. I'm only getting partial returns from the service and I think something is configured to stop after 2 minutes. A search of httpd.config and php.ini for the string 120 turned up nothing. What co...

Automating a Job at Work: Importing Powerpoint Bullet Text into an Excel Sheet

I have been asked to automate a particular task at work today which takes up a lot of our time! The following is what needs to be done and I would appreciate any help on how I can do this (Implementation Advice) within the realms of my knowledge, if possible. Problem I have a PowerPoint document (.ppt). I would like to extract text fro...

php security and scalablity

hi is there is any book on php site security and on scalability ...

Session timing out on ASP.NET app after visiting PHP app on same server

I'm working with a client's proprietary ASP.NET app, to which we added a PHP wiki to a subdirectory on the same server. The PHP app authenticates against the cookies that the .NET app uses. This all works fine. When you login to the .NET app and then visit the PHP app (Dokuwiki), and then visit any page on the .NET app, it reports that...

Registration script tips

Register.php if (isset($_POST['submit'])) { $username = mysql_real_escape_string(trim($_POST['username'])); $email = mysql_real_escape_string(trim($_POST['email'])); $passwd = mysql_real_escape_string(trim($_POST['passwd'])); if (empty($username)) { die ('You need to enter a username.'); }...... else insert } ?> Is it...

Send email with attachments in PHP?

How can I send emails with attachments with a PHP script? ...

Get class name from extended class

Is it possible to get the name of the top level class from an extended class, without setting it from the top level class. See example below, I would like to get 'Foo' from Base. I know I could set a variable from Foo, but hoping to skip the extra step. Thanks. class Base { function __construct() { echo '<p>get_class: '.get_class(...

Even more lost than before - stumped with a PHP loop

Okay, so I followed the advice on this question: http://stackoverflow.com/questions/1214176/stumped-in-the-middle-of-a-php-loop But now, I'm having even more problems than before. Here's what I have so far: $sql = "SELECT section_name, category_name, result_level, url, winner FROM 2009_RKR_bestof INNER JOIN categories ON 2009_RKR_best...

PHP Static functions don't work when directory changes?

I have a class that looks like this: utils/Result.php <?php class Result { public static function ok() { echo "OK"; } } If I create the following script ./sandbox.php <?php require_once("utils/Result.php"); print_r(Result::ok()); And run it with php sandbox.php it works fine. But if I do the following: cd tes...

Break a CSS file into an array with PHP

I wanted to break a css file into an array with PHP. Ex: #selector{ display:block; width:100px; } #selector a{ float:left; text-decoration:none; } Into a php array... array(2) { ["#selector"] => array(2) { [0] => array(1) { ["display"] => string(5) "block" } [1] => array(1) { ["width"] => string(5) "100px" ...

Set php include_path from nginx

Apache lets you set php.ini values for virtual hosts with the php_value directive. Does nginx have something similar? Is there another way to set the include_path on a per-site basis? ...

Hide video and mp3 files

I am coding a site that has video and audio files, I need people to be able watch/listen to the files if they are logged in php/mysql login but I don't want people who haven't register to be able to download the files, I need to be able to block direct access to the file and only let them access by the user with accounts. ...

php session with flash

url: page.php?sid=session_id(); php code: if ($_REQUEST['sid']) session_id($_REQUEST['sid']); session_start(); Question: im trying to access php session with passing the id, so it continues to login and returns data of the user. session id is successfully transfered, but session getting reset each time, emptying the old session an...

A few question about PHP memcache

1) I understand I can call this $memcache_obj = memcache_connect('memcache_host', 11211); in the header files of my site with no impact on pages that don't use memcache but what about this $memcache->connect('127.0.0.1', 11211); Should this be called on a page to page basis? 2) what if the server does not have enough memory to w...