php

Amfphp 500 internal server error (sessions)

So to sketch out our situation We have a html page(domain: hyves.nl) with an iframe in that iframe we load a php file (domain : atik.nl) in that php file we start a session and we embed our swf file (domain : atik.nl ) in our swf file we access a special page "calls.php" (domain: atik.nl) where we can get some special data. (that's ...

using cakephp values inside JQuery

Hi, I m new to CakePhp and JQuery. I am getting an error in using the cakephp code inside my JQuery. My code <script type="text/javascript"> $(document).ready(function(){ var attributeid;var fieldname; $("#"+<?=$r['Attribute']['id'];?>).change(function () { fieldname=<?=$r['Attribute']['label'];?>; ...

Keyword search using PHP MySql?

Hi there, I have title (varchar), description (text), keywords (varchar) fields in my mysql table. I kept keywords field as I thought I would be searching in this field only. But I now require to search among all three fields. so for keywords "word1 word2 word3", my query becomes SELECT * FROM myTable WHERE ( name LIKE '%word1%' OR d...

How to get selected category id after 1st page in pagination?

//$id=$_REQUEST['category']; //$catid=mysql_escape_string($id); $catid = isset($_GET['category']) ? (int)$_GET['category'] : 0; $recordsPerPage =4; 0 // //default startup page $pageNum = 1; if(isset($_GET['p'])) { $pageNum = $_GET['p']; settype($pageNum, 'integer'); } $offset = ($pageNum - 1) * $recordsPerPage; //set the number...

changing data in the $_SESSION variable

Hi . Currently I have a class in the constructor stores variables in $_SESSION. I was told not to store the user_id in $_SESSION, because then a user could change the ID to a one of his liking, and then access the website freely from any account. Instead, I've stored a session_id and created a table that has links a session_id to a us...

calling method of object of object with call_user_func

Hi all, consider this simple scenario: $this->method($arg1, $arg2); Solution: call_user_func_array(array($this,'method'), array($arg1, $arg2)); consider this scenario: $this->object->method($arg1, $arg2); Should this solution work? call_user_func_array(array($this->object,'method'), array($arg1, $arg2)); Or should this work?...

How can I pass variables from JavaScript to PHP?

I am using jQuery to calculate prices. Here is a small snippet of my JavaScript: // Prices: radio var curLam = "gloss"; $("input[name=lamination]").click(function(){ var gloss = 5; var matt = 6; if ($(this).val() == 'gloss' && curLam != 'gloss'){ $('#prices span').text(parseInt($('#prices span').text()) + gloss - matt); curLam = ...

regex to turn URLs into links without messing with existing links in the text

Hi there I am trying to convert URLs in a piece of text into hyperlinks - using regular expressions. I have managed to achieve this but the problem is when there are already existing links in the text so bla bla blah www.google.com bla blah <a href="www.google.com">www.google.com</a> should result in bla bla blah <a href="http://www...

recommendation for a php validation framework

Hi I'm validating allot of fields now in PHP, and I have to preform basic (string length ect.) and more complex (strip <> tags, for example) Can anyone recommend a class that does this, or maybe a framework, or maybe some functions that do these things? ...

How to use CBC encryption mode in PHP

Hi, I'm trying to encrypt a string, 50-150 characters long, with AES in a mode other than ECB (due to security issues). I wrote an encryption class and am able to encrypt/decrypt perfectly in ECB mode, however when I switch to CBC, CTR or OFB mode, I fail to get the original plaintext back. Source: define('DEFAULT_ENCRYPTION_KEY', 'as...

How do I subtract using SQL in MYSQL between two date time values and retrieve the result in minutes or second?

I want to subtract between two date time values using SQL in MySQL such that I get the interval in minutes or seconds. Any ideas? I want to run a SQL query that retrieves uses from a database who have logged in like 10 minutes from the time. ...

Setting the Max length in a <TD>

I have a column where some users are not entering spaces (i.e.: .........................................) and it is stretching my TD column. Is there a way to force line breaks in html with a simple option? If not, I think I am going to have to break the line up myself, which would not be optimal, as I would have to determine the best...

URIs vs Hidden Forms

I'm working in the Codeigniter framework, and want to send requests to my controller/model that have several variables involved. Is there a difference between passing those variables via a hidden form (i.e. using "post") as opposed to passing them through URIs (e.g. 'travel/$month/$day/')? What about security concerns? e.g. URIs: http:...

How can I access a RESTful API in PHP that is password projected (I know the password)

So for example here is a URL: https://rexms.net:32005/rexwapi/common/timeframes -- if I go to that URL in my browser enter the correct username/password it will spit out XML at me. The problem is I need to access this through PHP so I obviously don't get a prompt to enter username/password. Current code is: $timeframes_xml = simplexml...

CakePHP - Related models in a relationship table, displaying in a drop down?

Given the following table structures: Registered Participant model: <?php class RegisteredParticipant extends AppModel { var $name = "RegisteredParticipant"; var $primaryKey = "id"; var $belongsTo = array( 'EventLocation' => array('className' => 'EventLocation'), 'RegistrationStatus' => array('className' => 'RegistrationStatus'), ...

lots of files tactics have directory traversal security problem?

If I choose lots of files tactics, then I become to have directory traversal security problem? I need to write login system, and lots of file tactics means make lots of id files and use scandir. so the directory would have aaa.txt (contents is aaa_pass) bbb.txt (contents is bbb_pass) ccc.txt (contents is ccc_pass) and when some...

How can one check to see if a remote file exists using PHP?

The best I could find, an if fclose fopen type thing, makes the page load really slowly. Basically what I'm trying to do is the following: I have a list of websites, and I want to display their favicons next to them. However, if a site doesn't have one, I'd like to replace it with another image rather than display a broken image. Any ...

check if user is logged in

Hi, I have some basic code that I place at the header of every page to make sure that the user is logged in. I was hoping someone could take a look at it and give me some suggestions: if ($_SESSION['logged_in'] == 1) { $handle = dbconnect::init; $result = $handle->select()->from('session_id') ...

What is the preferred way of notating methods in comments?

Hey! Sometimes one has to refer to another method when commenting. Here some example in PHP: class A { /** * @see B::bar */ public function foo() { B::bar(); } } class B { public static function bar() { // ... } } So what if there would be a non-static method bar in class B? What...

How useful is PHP CodeSniffer? Code Standards Enforcement in General?

I'm dabbling with the idea of setting up PHP CodeSniffer on our continuous integration server in an effort to improve the quality of our code-base. After reading the documentation I'm very excited about the idea of normalizing and enforcing our coding standards. However, I'm left wondering about the actual improvement to our product. I'm...