php

mysql counting results between two datetime

Hey All, Really hope this can be done but I have come across a problem I need to resolve. I have an Inventory booking system for items. Each item gets booked in and out by hours. So some may go in and out within a few hours while others may be days. So in my column I have 2 datetime fields out | in. But I may have multiple items so in...

PHP: Using APC as general cache, XCache as opcache, possible?

I'm really intreagued by the general cache aspects of APC and want to use it in my code (this I know how to do, this is not the problem). However, I'm using XCache as opcache now and want to continue to do so since I have it tweaked "just right" for my particular needs. The reason I want to use APC cache as general cache is that I'm no...

PHP: STR replace by link

Hello, i have this PHP chatbox. If i would type a link in the chatbox, it would not display it as a link. How can i use STR replace to do this? It should respond to stuff like 'http' 'http://' '.com' '.nl' 'www' 'www.' .... My other STR replace lines look like these: $bericht = str_replace ("STRING1","STRINGREPLACEMENT1",$bericht);...

framework questions. How can I reuse the same template?

I'm hoping I can get a definite answer on this. I will try and explain this as best I can. I have a main template file that contains everything I want. In a small area within this template, I want to echo the view that is associated with the link that the user clicks on. This is not a problem so far however, when I have to use a loop da...

some help with this php regular expression

I have this HTML that I am reading from wordpress into a regular PHP file. This is not valid HTML but wordpress is supposed to strip the [caption] out take the img tag, and put it into a div with the caption as a <p> tag. But I want to do this in PHP, with no wordpress. [caption id="" align="alignnone" width="190" caption="my caption"]h...

Escaping with this PHP function is unsafe?

Hi, If I escape data with addcslashes($input,chr(0x00) . chr(0x0d) . chr(0x0a) . chr(0x1a) . chr(0x5c) . chr(0x27) . chr(0x22)); would that be enough to stop SQLi? I have all required characters there, so, as long as the $input is UTF-8, there should be no problems with that itself. Of course invalid use of the method or something si...

Add Word document to another Word document with PHP

How can I add a Word document to another Word document with PHP (fwrite)? $filename = "./1.doc"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $filename2 = "./2.doc"; $handle2 = fopen($filename2, "r"); $contents2 = fread($handle2, filesize($filename2)); $contents3 =$contents2.$contents; $fp = fop...

PHP Trace Redirect

I have a database of over 10,000 URL's, however every single one of them redirects to another URL. How can I request a URL and find out it's final destination in a path of (possibly) multiple redirects? ...

Passing by Reference in PHP 5.x

Hi, iam studying for the Zend PHP5 Cerfitication, everything looks good but i cant find real world exampled for passing or returning variables my reference. It would be very nice, if someone has an example when to use this? Thanks in advance. ...

Sanitize $_GET parameters to avoid XSS and other attacks

I have a website in php that does include() to embed the content into a template. The page to load is given in a get parameter, I add ".php" to the end of the parameter and include that page. I need to do some security check to avoid XSS or other stuff (not mysql injection since we do not have a database). What I've come up with is the f...

JavaScript: To the other page

I made this PHP chatbox which supports some JavaScript code. I have these 'images' which if you click them make special codes inside the textfield. e.g: <head> <script language="javascript"> function addCode(code) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); } </head> <bo...

Why would rand() return a negative value when min and max values are positive?

Hi, I have a simple piece of PHP code which requires a random number to be created. However, even though the input is always positive, it sometimes returns a negative output. Here's my debug code: $debt = rand($this->gdp * 0.02, $this->gdp * 0.17); echo "<p>GDP: ".$this->gdp." rand(".$this->gdp * 0.02." , ".$this->gdp * 0.17.") = <st...

facebook connect problem

how can i get firstname and last name of facebook user while using f-connect? i can login using api. but i couldnt get firstname and lastname of logged in user. ...

PHP: Send Email via cronjob and set amount of email send per mins

Hi guy i have a program which use to send group emails, i set a cornjob per mins for this program, and set execute per 2nd/min, and check if the now time is match to my defined schedule time in db. if true the program will run and send email, else nth... the problem is i want to dynamic set the amount of email sending per mins by use...

Use PHP to create a DOC file on a Unix Box based on an HTML webform selection

Hello, I have an HTML file which contains a webform with multiple questions which have a YES / NO responses. If the question has a YES answer, I would like a predefined ( per question ) section of text to be written to a DOC file on the server, but only AFTER the submit button has been pressed ( this way, if the user changes their mind...

What are the best ways of protecting my source code?

What is the best way of protecting my source code from being distributed without permission. I've thought of perhaps moving my source to another server. Also toyed with the idea of obfuscating my code, but this might make it a pain to alter at a later date. Has anyone any better ideas? ...

button for annual report

in my system i need to get the annual report. how can i get the annual report only once a year. i have a button that generates the report but it should only be once a year. so it shouldn't be a button because that means the report can be gotten more than once a year. any suggestions? i'm using php by the way. ...

Session time out in PHP

HI, i have code for session time out but i dont know whats the issue its not working someone pls look at this and help me. Here is the code: $inactive = 10; // check to see if $_SESSION['timeout'] is set if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive) { ...

problems with encoding (php)

Hello! My site have a utf-8 encoding (Drupal). I use include function to integrate my page with 3rd party service. But this gives a bad result - bad encoding for include part of page. i try this, but this don't give any result: iconv("ASCII","utf-8",include("http://new.velo-travel.ru/themes/themex/spectrum_view.php?$QUERY_STRING")) ...

Wordpress how can I know if the pagination is active?

Has Wordpress a function or something like that?I need a way to check if there are any page links(Older Entries | Newer Entries)to be displayed or not. Best Regards, ...