php

How to make sure about the ip of the visitor?

I have a blog aggregation website the stories are ordered by the number of visits I think I am facing a spam of visits because some blogs' stories receive a lot of visits in the same second with efferent ip address my website does not allow visits from the same ip; however, my visitors somehow changing their ips. is their any soluti...

Unsigned int to signed in php

I got a problem with ip2long in PHP5. It appears, that in 32bit OS ip2long returns signed int, and in 64bit OS unsigned int is returned. My application is working on 10 servers, and some are 32bit and some are 64bit, so I need all them to work same way. In PHP documentation there is a trick to make that result always unsigned, but since ...

Good Way to Secure File Uploads in PHP

Writing a small app that (among other things) lets users upload a file (like an image, a .doc or a text file) as part of their posting/submission. Our current prototype just dumps the file into /{app_root}/files/, but of course, anyone can get to that even if they are not logged in or using the system. The goal is to only grant access ...

Prettifying a conversion from m(metres) to feet(') and inches ('')

I'm creating table for defining an individual's BMI. The chart (as yet) doesn't take input (because I want to make the thing work stand-alone, first), but it does show (on parallel axes) the height in both metres and feet/inches. In order to do this I'm defining the metres' start point and range and then converting the defined metres va...

With simplexml_load_file I would like to differeniate between time out and and 404 errors

I am currently using: $page = simplexml_load_file('http://www.example.com/page.html'); In my code I would like to retry if the page time outs, but if the page is not found ( 404 ) I would like to add it to a list of not found pages. If I could differentiate between the two types of errors I can do the rest. Any help would be apprec...

is it worth it to compile a C program and run it instead of PHP page?

it seems that most of the time, the speed gained is not worth it -- is it so? otherwise many people will do it for their most popular page. Is there real benefit of using a C program. I can think of a case where it is not important: when the network bottleneck on the server is quite bigger than the CPU bottleneck, then how fast the pr...

Accessing codeigniter models in other models

It used to be that within a CodeIgniter model you couldn't access another model. E.g $this->load->model('bar'); $this->bar->something(); Would be invalid within the code of a model. Is this still valid or have they changed it? ...

PHP FTP directory listing error

array(1) { [0]=> string(8) "outgoing" } bool(false) array(1) { [0]=> string(8) "outgoing" } bool(false) Is currently being produced by $connect = ftp_connect('example.com'); $result = ftp_login($connect, 'username', 'password'); echo '<pre>'; var_dump(ftp_nlist($connect, '')); var_dump(ftp_nlist($connect, '/outgoing/')...

mod_php vs mod_python

Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php ...

Eastern Arabic Numerals in Wordpress

Any ideas how to configure Wordpress to get the date and page numbers in Eastern Arabic Numerals? These are 0660 up till 0669 in UTF-8. I am talking about getting those numbers ٠١٢٣٤٥٦٧٨٩ replace those 0123456789. I am using Wordpress 2.7. ...

What is the name of your system with PHP_OS constant

I use PHP_OS constant and I want to know what it can return on differents OS. I found this : On Linux -> Linux On FreeDSB -> FreeBSD On Windows NT -> WINNT On Mac Os X -> Darwin Can anyone tell me what they get with them configurations ? On Solaris, Windows XP... ...

PHP: Sort data from nested sets

We're currently building a website with a categorized MySQL table containing various competences, and we noticed that the nested set model would be optimized for this. Although, we've got a pretty serious problem - the nested set model doesn't allow any sorting, and we really need that possibility. I'd like the output data to be array(id...

PHP 5.2 Virtual-like static methods

Hello all, Here is my situation: I have a PHP base class that looks something like this: class Table { static $table_name = "table"; public function selectAllSQL(){ return "SELECT * FROM " . self::$table_name; } } And a subclass that is like this: class MyTable extends Table { static $table_name = "my_table"; } Unfort...

poedit workaround for dynamic gettext

I have started using gettext for translating text and messages i send to user. I am using poedit as an editor, but i am struggling with dynamic messages. For example i have things like the login where i have a variable that tells the type of error. $this->translate('page-error-' . $error); When i auto update from poedit this gets rea...

Warning: Division by zero in....

Hi. Ive been programming a search form with three fields, and the one thatt is giving me troubles is the one that use "LIKE" clause in sql. Here is the code: <form method="post" action="<?php $_SERVER['PHP_SELF']?>"> <p> <label for="nome">Nome Empresa:</label> <input type="text" name...

Why use a web framework (like rails) over php?

This isn't a question about what framework to use. I've learned both Rails and Django, and I write all of my webapps in PHP. My question is why bother with the frameworks? It's always taken me longer to use a framework than to reuse old MySQL code and build "models" with phpMyAdmin. I also like writing everything myself, because I know w...

Is the PHP Architect's Zend Certification Book needed to pass the Exam?

I want to get the Zend cert under my belt and am thinking about buying this book: Zend Book Is this the best book to get in preparation for it. I have heard mixed reviews and some opinions that the book has a lot of errors in it, which is pretty bad if you're trying to learn from it. UPDATE: Just found this site: Zend Site Has anybody...

Badge system and storing conditions as variables?

I'm trying to write a piece of code that checks a users stats, be that their points, rank or num_friends and in turn awards them a badge similar to that used in SO. The system is set so when a task (vote up, comment, etc.) is completed by a user, their user_id is recorded and queued to be evaluated at 5 min intervals by a cron job. Is ...

$_SESSION Problem.

I have recently changed my editor to save int UTF-8. This started poping out afterwards and don't know what it means. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/sudancar/public_html/index.php:1) in /home/sudancar/public_html/index.php on line 1 ...

PHP extensions won't load on Apache startup

I've added php as a module for Apache 2.2.11: LoadModule php5_module "c:/php/php5apache2_2.dll" And also added AddType application/x-httpd-php .php And in PHP.ini, my extension dir is set to: extension_dir = "C:\php\ext" And yes, the directories are correct and all files do exist. But when I start apache, I get these errors: ...