php

PHP using array_replace with multidimensional array

I am trying to build a game board 8x8 for a small game of battleship with game pieces in place (kind of like checkers) so i could move the pieces with MySQL the players can move freely in the board to go against each others battleships. the pieces will be place in predetermined spaces while other space will be empty and be handle by mys...

i want to check ip address to corresponding hostname and hostname ip ranges

I need to make it with PHP, maybe with some pear package or php internal functions. How i can do that ? I know i need gethostbyname() for hostname checking, but i need also ip range of this provider. example: ip: 5.7.8.9 host: usa provider ip range 5.7.8.0-5.7.9.0 Is it possible with php? ...

Redirect/.htaccess to change old PHP parameter URLs to SEO friendly CakePHP URLs?

I'm about to update my site to use CakePHP instead of an old homegrown framework. I need to write the HTAccess file to redirect the old PHP parameter URLs to the new CakePHP SEO friendly urls, but I can't get it to work. My htacess file (the one in app/webroot) looks like this at the moment: RewriteEngine On RewriteRule ^index.php?a...

Move title attribute value to class attribute value in the HTML code

We have variable $menu with HTML inside (there is no loop, it comes from a function). On echo it gives the code like this: <ul id="menu"> <li id="some-id" class="many classes"><a title="one" href="#">text</a></li> <li id="some-id" class="many classes"><a href="#">text</a></li> <li id="some-id" class="many classes"><a title=...

Generate md5 or sha1 hash across windows & linux system in php

I m trying to generate a signature using md5 or sha1 hash on a linux system. This signature will be tested across a windows system to ensure it authenticates. What i find is both hash generated using same parameters are different. Please help how i can generate a common hash on both system for authentication. ...

Effective ip->location query

Hello all, I have two tables: one is ip_group_city from ipinfodb.com containing ip_start numbers for determining location of IPs, and other is "visits" with information about web site visitor containing column 'ip'. I need to select top 10 region_code (from ip_group_city) by checking region_code for each IP from "visits" table. Right ...

PHP max() with an array of strings?

Hi all I have an array of tags taken from a MySQL database. Obviously, these tags are strings and are stored in an array, with one element in the array storing each tag. TO build my tag cloud, I want to be able to count the occurrences of each tag to find the most common tag. For example, if I have the table below... tag1 tag1 hi bye...

PHP: Check if variable exist but also if has a value equal to something

PHP Question: Hi there, this is just something I was wondering today, what I'm doing: I have (or not) a variable $_GET['myvar'] coming from my querystring and I want to check if this variable exists and also if the value corresponds to something inside my if statment: What I'm doing and think is not the best way to do: if(isset($_GET...

JavaScript bookmarklet in IE7

Hi, I am trying to get my JavaScript working in IE7 which works smoothly in all other browsers. document.write('<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?act...

clickatell Provider

Hello, Am using Clickatell provider to send SMS through my PHP application. It works fine except it cause "Error delivering message" with Mobinil numbers. Is there any reason for that? Thanks in Advance ...

What does this code do?

function mystery($y, $m, $d) { $a = 0; $b = 0; $c = 0; if($m < 3) { $a = $m + 10; $b = ($y-1) % 100; $c = ($y-1) / 100; } else { $a = $m - 2; $b = $y % 100; $c = $y / 100; } $w = (700 + (((26*$a)-2)/10)+$d+$b+$b/4+$c/4-(2*$c))%7; echo $w; } One of my tutorial questions asks what the functio...

each user their own subdomain

Possible Duplicate: How to let PHP to create subdomain automatically for each user? How do i set up so that each member on my community site get their own username? i run WAMP i understand i have to set wildcard subdomain in vhost.conf something, and then $_server['http_host'] to find out which member profile to display? Is...

persistent connection

I'm writing php web-app using unholy alliance of php+oracle+iis :) every time script being executed I create a new connection to db - and it takes time: class ORACLE_layer { public function __construct($usr, $pwd, $db) { $this->conn = oci_connect ("...") } function __destruct() { oci_close($this->conn); ...

Name comparison algorithm

To check if a name is inside an anti-terrorism list. In addition of the given name, also search for similar names (possible aliases). Example: given name => Bin Laden alert! given name => Ben Larden mhm.. suspicious name, matchs at xx% with Bin Laden How can I do this? using PHP names are 100% correct, since they are from offic...

How can I improve on this. (Breadcrumbs class)

Hi, I have recently created a breadcrumbs class that fits in with our in-house CMS and it works as I intend but I have a nagging feeling it could have been done better. I was thinking of doing an array_pop close to the end of the construct but I decided to go with an IF statement instead, what do you guys think? (Oh also $_REQUEST['sec...

Access specific menu from url in admin area

Is that possible to load an admin page in a browser with settings for some specific menu in WordPress 3? Something like :http://mysite/wp-admin/nav-menus.php?action=edit&amp;menu=mymenu. ...

PHP sessions; How should I solve this big security problem?

I am fairly new to sessions. I have a classifieds website, and users may chose to "EDIT" their classifieds. All they have to enter is a password which they chose when creating the classified. In the "edit.php" page, if the password is correct, the classified details show up. There is a picture upload tool, which reloads the page but u...

Best Library for Real-Time Javascript Game with PHP Backend

Hi! I'm currently in the planning stages for a real-time multiplayer game that would be built using Javscript at the frontend and PHP on the backend and I'm just wondering if anyone here knows of any good libraries for such a game? Thanks, DLiKS ...

php session management

Hello All, I am developing a system in php which has different types of users like admin, A, B, C. I need to allow log in just one user from the type at a time. Means 1) if there is already an admin user is logged in, no other admin user can log in. 2) And the logged in credentials cannot be used on other pc at the same time (just li...

How to create MySQl tables forA PHP Game for movement?

I am trying to build PHP based battleship the php code below displays a board but now im trying to ad values to the individual squares of the board so I can use those values with mysql to move the pieces in place around the board so the players can go after each others battleship: the game does not involve session it is strictly 2 playe...