php

PHP Strip string of first url and report results

Russel Peter video: <a rel="nofollow" href="http://www.youtube.com/watch?v=2bP9tRhJRTw"&gt;www.youtube.com/watch?v=2bP9tRhJRTw&lt;/a&gt; russel peters video blah blah. Turtles: <a href="http://turtles.com"&gt;turtles.com&lt;/a&gt; I have a string that contains text and and tags with enclosed urls like the above example. I want to str...

Extract link attributes from string of HTML

What's the best way to extract HTML out of $var? example of $var $var = "<a href="http://stackoverflow.com/"&gt;Stack Overflow</a>" I want $var2 = "http://stackoverflow.com/" example: preg_match(); what else? ...

Efficient algorithm for detecting matches

I'm looking for an efficient algorithm for detecting equal values in an array of integers N size. It must return the indices of the matches. Alas, I can't think of anything more clever then brute force with two loops. Any help will be appreciated. Thanks! ...

php select from mysql where title begins with A (and A alone)

I'm sure this is super easy, but can't seem to figure it out.. I need to select all titles from my database where the title starts with A, or B, or C etc. Here's what I've tried so far: SELECT * FROM weblinks WHERE catid = 4 AND title LIKE 'A' but returns nothing.. Could someone help me out with this? Cheers ...

mod_rewrite convert certain folders to parameters

Hi I have a site where I'd like to convert the first subfolder into a parameter (from a set list of subfolders), so http://localhost/mysite/folder1/dosomething.php is displayed as shown above, but to PHP it looks like: ... localhost/mysite/dosomething.php?organisation=folder1 I only need to do this on certain folders (i.e. not ... l...

Setting date to a variable in a PHP class

I think this is a really, really simple question but I can't seem to find the answer. I'm trying to set default values for properties in a PHP class and one of them is a date so I'm trying to use the date() function to set it: <?php class Person { public $fname = ""; public $lname = ""; public $bdate = date("c"); publ...

Restrictions on PHP include()

Hey guys, I am separating some XHTML from PHP by putting the XHTML into a separate file and then using PHP's include() function within the PHP script. This works perfectly fine, however, users are still able to access the .html file directly if they know the address. They can't really do much with it, but I would rather it not show. ...

Joomla module development, Why do I get Call to undefined method JDocumentRendererModule...?

I've been trying to get my first module to work, but keep getting Fatal error: Call to undefined method JDocumentRendererModule::isTuesday() and can't for the life of me figure out what is wrong. I think I followed all tutorials to the letter, however as I am not really comfortable with PHP, I suspect the problem really lies between the...

Help in Converting Small Python Code to PHP

Hello, please i need some help in converting a python code to a php syntax the code is for generating an alphanumeric code using alpha encoding the code : def mkcpl(x): x = ord(x) set="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" for c in set: d = ord(c)^x if chr(d) in set: ...

How to get phpinfo() variables from php programatically?

Hello, I am attempting to get a list of dependable(consistent across requests) list of "hidden" constants in PHP(as in, the client-side won't know about it in most cases without hacking). Some of the things I am interested in is the following: ./configure options. I would also like the very first System value in phpinfo. The loaded...

Mysqldump with empty result in gzip?

When I output my MySQL Dump Regularly, it outputs a 30MB File. When I use gzip, 0KB. Here is my code: $command = "<path to>mysqldump --opt -h $dbhost -u$dbuser -p$dbpass $dbname | gzip> test.sql.gz"; system($command); Result: test.sql.gz 0 KB --------------------------- $command = "<path to>mysqldump --opt -h $dbhost -u$dbuser -p$...

PHP & XML parsing

I have searched everything on google and still i cant seems to find a solution for this. Basically im helping my friend to create a php frontend for his ftp. The ftp details are saved in xml. So i have to parse it to a php. <FileZillaServer> <Users> <User Name="anonymous"> <Option Name="Pass">aaaaaa</Option> <Option Name="Group"/> <Opt...

Is more ajax better for resources on a web app?

I know this seems like a really subjective question, but from what I'm reading, I'm generally confused. We are developing a web-based application that has tabbed windows, etc-very much a "desktop-like" application graphically. About half the page never or rarely changes, and the other half is content that could be handled dynamically w...

check if user got new message in the background?

im using comet to push new data to the user. 1: but i wonder how i should check if new data (new messages, new replies etc) is available? should i in the php in the background use a while loop and sleep it for 1 min so it can check every one min if new data has come in? or should i have a trigger in the database for this? what availa...

AuthSub with PHP

Can I use AuthSub with PHP ? I want to use Google API with PHP but don't want to install Zend Framework.I'm goolging and not found with AuthSub class for PHP. ...

try to open a page every 10 seconds

Using Javascript (or Ajax) I want to connect to a page (a .php page) every 10 seconds. This will be done in user-side (browser) within a web page. Just, I'm trying to see the online users. I have about 1-2 visitors daily, in my personal web site. ...

Referral URL in php

Hi, So I am trying to get the page where a visitor came from. I inserted this code into a php file and I am trying to see the page's URL but it is not working, any suggestions? <?php $ref = getenv("HTTP_REFERER"); echo $ref; ?> (added this after some answers) I have also tried print $_SERVER["HTTP_REFERER"]; and that does...

php registration form - limit emails

i want to restrict certain emails to my website. an example would be that i only want people with gmail accounts to register to my website. { /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$sube...

PHP Business Rule Engine

Are there any Business Rule Engine implemented in PHP ? If yes, please list them. If not, than why not, what are the reasons behind not having Business Rule Engine in PHP and having it in Java ? ...

Best way to utilise an include file which just includes an array in PHP

Kohana's config files look like this.. here is an example of a database config file (simplified) return array( 'dbhost' => 'localhost', 'user' => 'Tom_Jones' ); I've also got a CMS which wants the connection details. Whilst the CMS uses a different user (with more rights), I'd like to know the best way to include this file a...