How can CodeIgniter and Wordpress be integrated such that the look and feel/template of
the Wordpress blog is carried over to the CodeIgniter-created pages?
Kick me if I'm being silly but some some reason I'm having a heck of time building a dynamic array in magento.
Example:
$data = array();
$data[0] = 'test';
$data[1] = 'what';
I keep getting an ERROR:
Notice: Undefined offset: 0
Any ideas?
Do I need to handle these arrays differently since they are in a class?
Hello Everyone,
Right now i got an array which has some sort of information and i need to create a table from it. e.g.
Student{
[Address]{
[StreetAddress] =>"Some Street"
[StreetName] => "Some Name"
}
[Marks1] => 100
[Marks2] => 50
}
Now I want to create database table like which contain the fields name as :
Student_Address_StreetAddress
Student_Address_StreetName
Student_Marks1
Student_Marks2
It should be recursive so from any depth of array it can create the string in my format.
I have a site which has been running for some time now that uses a great deal of user input to build the site. Naturally there are dozens of forms on the site. When building the site, I often used hidden form fields to pass data back to the server so that I know which record to update.
an example might be:
<input type="hidden" name="id" value="132" />
<input type="text" name="total_price" value="15.02" />
When the form is submitted, these values get passed to the server and I update the records based on the data passed (i.e. the price of record 132 would get changed to 15.02).
I recently found out that you can change the attributes and values via something as simple as firebug. So...I open firebug and change the id value to "155" and the price value to "0.00" and then submit the form. Viola! I view product number 155 on the site and it now says that it's $0.00. This concerns me.
How can I know which record to update without either a query string (easily modified) or a hidden input element passing the id to the server?
And if there's no better way (I've seen literally thousands of websites that pass the data this way), then how would I make it so that if a user changes these values, the data on the server side is not executed (or something similar to solve the issue)?
I've thought about encrypting the id and then decrypting it on the other side, but that still doesn't protect me from someone changing it and just happening to get something that matches another id in the database.
I've also thought about cookies, but I've heard that those can be manipulated as well.
Any ideas? This seems like a HUGE security risk to me.
Currently I have this:
function parse_string($string, $variables){
extract($variables);
return eval('return "'. addcslashes($string, '"') .'";');
}
So I can input this string:
'Hi {$name}, my name is {$own_name}'
Together with this array:
array('name' => 'John', 'own_name' => 'Tom')
And get this back:
'Hi John, my name is Tom'
I've never liked this eval() approach but it works and it's fast (faster than regex at least).
Question: Is there a more elegant way to do this (faster than using regex) in PHP5?
hi
does anyone know any sort of app that lets users visit a page on their mobile phone, enter information and have it update the website
i believe the term is "mobile-blogging" but there isn't all that much on google
or, is there any good resources for coding pages specifically for a mobile phone? I could probably design a script to insert blog posts on a site but not sure how it would work with a mobile.
thanks for any pointers
Using simplexml_load_string() how do I get "ForgotPassword" from the following XML?
<?xml version="1.0" encoding="utf-8"?>
<ForgotPassword>
<version>1.0</version>
<authentication>
<login>username</login>
<apikey>login</apikey>
</authentication>
<parameters>
<emailAddress>[email protected]</emailAddress>
</parameters>
</ForgotPassword>
I have an edit form, The form is made through symfony2 Form types. I checked the documentation but couldn't find any option for adding CSS to the form. The form display the data correctly and everything is fine what I want to do is to add styling to each field.
My Edit Type is
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('id', 'hidden')
->add('patent_name', 'text', array('label' => 'Patent Name'))
->add('description', 'textarea', array('label' => 'Description', 'required' => false))
->add('appln_auth','text', array('label' => 'Application Authorization'))
;
}
Anyone has any idea ho I can add css ?
Thanks
Hi all, I've been stomping at this all day :(
I want to display a status feed of both twitter and facebook on my website. For twitter, this is not a problem, as my account is public, I can easily get the feed.
Facebook however, is a whole different story! I can't seem to find an easy way to just get my last status updates and display it on my website.
The code I currently have, needs authentication of the visitor, and I don't want that!
This is my current code:
$facebook = new Facebook($api_key, $secret);
$stream = $facebook->api_client->fql_query("SELECT message,source,time FROM status WHERE uid = $user_id LIMIT 6");
I've seen several possible solutions, including the RSS feed, but as Facebook keeps changing the way their site works, none of the previous methods I've seen (including those from as late as januari) currently work!
Is there anybody who can provide me with a currently working solution to this (simple?) problem?
I've a table which has 3 columns: id, a_id and b_id.
Suppose rows are like this:
1, a1, b1
2, a1, b2
3, a1, b3
4, a2, b4
5, a2, b5
6, a2, b6
I want to convert it to
1, a1, b1
2, a1, b1
3, a1, b1
4, a2, b4
5, a2, b4
6, a2, b4
So I want to make all the b_id corresponding to a_id same, and equal to the one which is found first. How can I do this? For simplicity, I've removed other columns from table. So please ignore row duplication here.
I want to display the video using click to play button which pops up a window. As seen here. Currently I am using iframe to display the video. How to do that using html, css?
Currently this is the code to display the video
<div class="player">
<iframe src="http://player.vimeo.com/video/<?= $vimeo;?>?title=0&byline=0&portrait=0&color=abcc16&autoplay=0" width="250" height="250" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>
</div>
Can this code help to sanitize malicious code in user submit form?
function rex($string) {
$patterns = array();
$patterns[0] = '/=/i';
$patterns[1] = '/javascript:/i';
$replacements = array();
$replacements[0] = '';
$replacements[1] = '';
return preg_replace($patterns, $replacements, $string);
I have included htmlentities() to prevent XSS on client side, is all the code shown is safe enough to prevent attack?
I have a form on a website I'm working (you can see it here) on that allows my users to give feedback. It's an jQuery/Ajax popup form:
$('.contact_us').click(function(){
var boxy_content;
boxy_content += "<div style=\"width:300px; height:300px \"><form id=\"feedbacked\">";
boxy_content += "<p>Subject<br /><input type=\"text\" name=\"subject\" id=\"subject\" size=\"33\" /></p><p>Your E-Mail Address:<br /><input type=\"text\" name=\"your_email\" size=\"33\" /></p><p>Comment:<br /><textarea name=\"comment\" id=\"comment\" cols=\"33\" rows=\"5\"></textarea></p><br /><input type=\"submit\" name=\"submit\" value=\"Send >>\" />";
boxy_content += "</form></div>";
// Other code here...
Is there anyway I can save what the user has entered (in case they see our error message when they try to submit)?
I am using xampp on localhost and when I use _SERVER["REMOTE_ADDR"] it returns ::1 (also does this in phpinfo()). Why does it do this? I want it to return a normal ip address like 127.0.0.1. My operating system is windows vista.
I've read like 10 or so "tutorials", and they all involve the same thing:
Pull a count of the data set
Pull the relevant data set (LIMIT, OFFSET)
IE:
SELECT COUNT(*)
FROM table
WHERE something = ?
SELECT *
FROM table
WHERE something =?
LIMIT ? offset ?`
Two very similar queries, no? There has to be a better way to do this, my dataset is 600,000+ rows and already sluggish (results are determined by over 30 where clauses, and vary from user to user, but are properly indexed of course).
Put simply: it causes a massive memory leak within an hour if I work on a Symfony project, and I don't use any of the features that it provides. I've looked through all of the menus and can't seem to see an option to disable support for it.
Has anyone attempted or managed to remove this module from the IDE? I quite like NetBeans, but on the rare occasions when I need to work with a Symfony project it's causing me quite a headache.
Is it considered better practice and/or more efficient to create a 'reset' function for a particular object that clears/defaults all the necessary member variables to allow for further operations, or to simply construct a new object from outside?
I've seen both methods employed a lot, but I can't decide which one is better. Of course, for classes that represent database connections, you'd have to use a reset method rather than constructing a new one resulting in needless connecting/disconnecting, but I'm talking more in terms of abstraction classes.
Can anyone give me some real-world examples of when to use each method? In my particular case I'm thinking mostly in terms of ORM or the Model in MVC. For example, if I would want to retrieve a bunch of database objects for display and modify them in one operation.
I'm using an HTML table for a calendar and I want to fill the cells with various events from my database. Usually they will land on weekends but some will run for long weekend, bank holidays or even the odd week day.
How can I get my tables columns to expand and shrink accordingly. I'd like to avoid the use of javascript if possible.
If this can't be done I'm going to need a tutorial to help me get my head around how to make div's positioning behave.
cheers
Hi, I have a problem with resizing images.
What happens is that if you upload a file larger than the stated parameters, the image is cropped, then saved at 100% quality.
So if I upload a large jpeg which is 272Kb. The image is cropped by 100 odd pixels. The file size then goes up to 1.2Mb.
We are saving images at a 100% quality. I assume that this is what is causing the problem. The image is exported from Photoshop at 30% quality which reduces the file size. Resaving the image at 100% quality creates the same image but I assume with a lot of redundant file data.
Has anyone encountered this before? Does anyone have a solution?
This is what we are using.
$source_im = imagecreatefromjpeg ($file);
$dest_im = imagecreatetruecolor ($newsize_x, $newsize_y);
imagecopyresampled (
$dest_im, $source_im,
0, 0,
$offset_x, $offset_y,
$newsize_x, $newsize_y,
$sourceWidth, $sourceHeight
);
imagedestroy ($source_im);
if ($greyscale) {
$dest_im = $this->imageconvertgreyscale ($dest_im);
}
imagejpeg($dest_im, $save_to_file, $quality);
break;
What i know:- We can use Ajax to change database from javascript. So whenever we press the 'X' button on title bar it calls "onbeforeunload" event. And by this event we can change the database.
But in my case, i want to change the status of user only when user click on 'X' button. Not in case of changing the page. As because changing the page is unloading the page. and closing the page is also unloading the page(As much i know).
Is there any way to differentiate between closing the page and moving from one page to other page?
I want to use it for changing the status of user(i.e. login/logout), whenever he presses cross button.
I don't want to set status "logout" when user changes the page.
I want to set status "logout" when user 'X' the button.
Plese help me.
I am writing a wordpress theme, and have run into a fairly basic problem. By default, when you inset an image into the post, it displays that image at the size you specify, on both the homepage and the single post.
I would like to have different sized images, displaying a thumbnail on the homepage, and a full sized image when you click through to the post. I am using wordpress 2.9's new thumbnail feature, which has created great thumbnails for the homepage. But now, I am stuck with a nice thumbnail next to a large photo (on the index/home page). On the single page, it is displaying correctly with just the large picture.
Basically, I need to know how to tell wordpress to only display the large post image on the single page, not on the index.
Also: I have used the timthumb script, but I think the answer is far more basic then needing plugins or scripts
Thanks!
Basically what I'm trying to do is compare the ID's of rows against 15 results in MySQL, eliminating all but 1 (using NOT IN) and then pull that result.
Now normally this would be fine by itself, however the order of the 15 rows I'm doing the SQL query for are constantly changing based on a ranking, so there is a possibility that between the time the ranking updates, and the ajax request (which I submit the ID's for NOT IN) more than just one ID has changed, which would of course bring back more than one row which I do not want.
So in short, is there a way in which I can query 15 rows, but only return one? Without having to run two separate queries. Any help is appreciated, thank you.
EXAMPLE:
Say I have 7 items in my database, and I'm displaying 5 on the page to the user.
These are what are being displayed to the user:
Apple
Orange
Kiwi
Banana
Grape
But in the database I also have
Peach
Blackberry
Now what I want to do is if the user deletes an item from their list, it will add another item (based on a ranking they have)
Now the issue is, in order to know what they have on their list at the moment I send the remaining items to the database (say they deleted Kiwi, I would send Apple, Orange, Banana, and Grape)
So now I select the highest ranked 5 items from are remaining six items, make sure they are not the ones already displayed on the page, and then add the new one to list (either Peach or Blackberry)
All good and well, except that if both peach and blackberry now outrank grape, then I will be returning two results instead of just one. Because it would've searched...
Apple
Orange
Banana
Peach
Blackberry
and excluded...
Apple
Orange
Banana
Grape
Which leaves us with both Peach and Blackberry, instead of just Peach or Blackberry
I have a model 'listing' with a field 'created' which is in a datetime format.
I need to list in a view all listings that were created over 2 weeks ago.
An extra thing if possible is to somehow mark them as expired.
This is in cakePhp 1.27