Jump to content

Perad

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Posts posted by Perad

  1. Hi, could someone help me out. This is my .htaccess file.

     

    <IfModule mod_rewrite.c>
         RewriteEngine on
    
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
    
         RewriteRule ^(.*)$ index.php?s=$1 [L]
    </IfModule>
    

     

    I need an IIS version of this. I found this.

     

    <rewrite>
        <rules>
            <rule name="Main Rule" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php" />
            </rule>
        </rules>
    </rewrite>
    

     

    How do I modify this to pass the parameter like the .htaccess file is doing?

     

    Thanks.

  2. Hi,

     

    Is anyone here familiar with the Facebook API?

     

    My boss wants people to be able to share their store with their friends on Facebook from within the stores admin panel. He wants the following.

     

    1) Display all friends with a checkbox next to each name.

    2) Check the friends you want to inform about your store.

    3) Post a message on checked friends wall.

     

    It sounds simple.

     

    The problem is the friends selection screen. Some of my friends on Facebook have 1000 friends. Obviously listing all of them is inpractical. Ideally I need a search box to limit the friends that display and make it easy to find who you are looking for. Does something like this already exist? Does it have a name?

  3. Hi,

     

    I wrote the function below. It switches out one color for another. The pictures going in are css sprites with various colors and a white background.

     

    So.. sprite 1 might by blue and sprite 2 might be green.

     

    The function would be run twice to replace the blue + green with whatever colors were required.

     

    /**
     * Changes the color of a graphic.
     * $settings = array (
     *  'icon'
     *  'new_icon'
     *  'old_color' = array
     *  'new_color' = array
     * );
    */
    function updateIconColor($settings=array()) {
    	// Create Image
    	$image = imagecreatefrompng($settings['icon']);
    
    	// Convert True color image to a palatte
    	imagetruecolortopalette($image, false, 255);
    
    	// Restore Alpha
    	$white = imagecolorclosest($image, 255, 255, 255);
    	imagecolortransparent($image, $white);
    
    	// Find + Set color
    	$index = imagecolorclosest($image, $settings['old_color'][0],$settings['old_color'][1],$settings['old_color'][2]);
    	imagecolorset($image, $index, $settings['new_color'][0], $settings['new_color'][1], $settings['new_color'][2]);
    
    	// Restore Alpha
    	imageAlphaBlending($image, true);
    	imageSaveAlpha($image, true);
    
    	// Save
    	imagepng($image, $settings['new_icon']); // save image as gif
    	imagedestroy($image);
    }
    

     

    How could this be updated to allow some dithering (is that what it is called?) - the thing that smooths out an image to avoid pixelation around the edges?

     

    Minor question.

    1) Is there any reason why imagecolorexact doesn't work in this function. When I use imagecolorexact nothing happens and the picture remains the same.

  4. Hi,

     

    Honestly, I am trying to pick up regex using nettuts. (http://net.tutsplus.com/tutorials/php/regular-expressions-for-dummies-screencast-series/) However I still haven't got very far and something need's fixing today.

     

    I need a regex that does the following.

     

    $html = '...'; // Lots of HTML
    $regex = '{absolutely anything}color: #{6 digits - [0-9][a-f][A-F]};{absolutely anything}';

     

    I will then use this to force users to have a certain color on their HTML elements.

  5. I think this is a simple problem but I cannot work it out.

     

    When an ajax page is loaded into the #ajax div the links are now longer triggered.

     

    I think this is because the document is loaded and the function is run. When the new information comes into the page it isn't in the same scope as the click function. Is this correct? Is there a work around?

     

    function pageload(hash) {
    if(hash) {
    	$.ajax({
    		url: "index.php?p="+hash+"&logo=0",
    		cache: false,
    		success: function(html){
    		     $("#ajax").html(html);
    		}
    	});
    }
    }
    
    $(document).ready(function(){
    $.historyInit(pageload, "index.php");
    
    // set onlick event for buttons
    $("a").click(function(){alert('click');
    	if (strpos($(this).attr('href'), 'index.php') !== false) {
    		var hash = idToPath($(this).attr('href'));						
    		$.historyLoad(hash);
    		return false;
    	}
    });
    });
    

  6. I have the following bit of XML.

     

    <contactform>
    <label1 check="1" textarea="0">Name</label1>
    <label2 check="1" textarea="0">Address</label2>
    <label3 check="1" textarea="0">Email</label3>
    <label4 check="0" textarea="0">Phone</label4>
    <label5 check="0" textarea="0">Cell</label5>
    <label6 check="0" textarea="0">Comments</label6>
    </contactform>

     

    I need to get back the following.

     

    Label Name = Name

    Textarea = 0

    Field Name = label1

     

    The problem I have is getting the fieldname. How do I retrieve this?

     

    <?php foreach($contactform->children() as $label): ?>
    <label><?php echo $label; ?></label>
    <?php if ($label['textarea'] == 1): ?>
    	<textarea name=""></textarea>
    <?php else: ?>
    	<input type="text" name="" />
    <?php endif; ?>
    <?php endforeach; ?>

  7. Hello, could someone help me out here.

     

    I have a login button which takes the user to the login page. Now... this to me seems like a slow way of logging in. I would like users who have javascript enabled to click the login button. Instead of them being forwarded to the login page, I want the login form to magically pop up on top of the web page.

     

    I can do this, I can creative a div, add the html and probably with a bit of trying - get the user to login.

     

    However I have a question. For maintainability, I want to have create a separate HTML file, how would I insert this into my page using Javascript?

     

    Furthermore speed is crucial, is there a way to have this fragment load in the background on every page? I am not sure what would be best, i just don't want a second or two wait when the button is pressed.

     

    Basically - in short - how to I load this file fragment? What is the fastest way to do this?

  8. SELECT u.name, u.email, u.id, ug.group_id FROM users AS u INNER JOIN users_groups AS ug ON ug.user_id = u.id WHERE u.id = 10 

     

    users

    - id

    - name

    - email

    - password

     

    users_groups

    - user_id

    - group_id

     

    This should return 1 row with the following

    id, name, email, group_id

     

    Currently returns 0 rows. No idea why, there are no errors. The record exists in the user table and group table. Can anyone see anything wrong with the query?

  9. Thanks, that sounds like it would work. So am I right in thinking that I would do something like this...

     

    class instance {
    
    }

     

    Then something like this.

     

    class controller {
      public function __construct($instance) {
        $this->i = $instance;
      }
    }

     

    class c extends controller {
      public function __construct() {
        $this->i->db = $this->load->library('db');
        $this->i->auth = $this->load->library('db');
        $this->i->session = $this->load->library('db');
      }
    }

     

    This actually wouldn't require much modification to adapt what I have at the moment. Have I interpreted this correctly?

  10. Hi,

     

    I am trying to write a small MVC framework. I am having a little trouble setting something up. I want to have a single instance for the entire application.

     

    For example.

     

    The instance would contain the following.

    $this->db

    $this->session

    $this->validation

     

    These should be accessible to all classes should they try to access them.

     

    I have heard about magic __get() __set() methods but don't quite understand how they work or if they would help. Does anyone know how I can achieve this?

     

    If __get() __set() methods can be used could someone briefly explain how.

     

    Thanks

  11. This is a bit odd to be honest.

     

    I have created a back up script which will rip out the clients database and files and save them to a tarball.

     

    This error is occurring in the restore script.

     

    function update_table($query) {
    	// Earlier function switched DB to ma - switch back - execute query
    	global $site;
    
    	$conn = new WebPage (null, db_connect ('mysql://'.$site['mysql']['user'].':'.$site['mysql']['pass'].'@'.$site['mysql']['host'].'/'.$site['mysql']['db'])); 	
    
    	mysql_query($query) or die(mysql_error());
    
    }

     

    This connects to the database. $query contains the sql. A sample of the sql is below.

     

    DROP TABLE IF EXISTS `billinginfo`;CREATE TABLE `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active` int(1) unsigned NOT NULL DEFAULT '0',`sort` double unsigned NOT NULL DEFAULT '0',`stamp` int(10) unsigned NOT NULL DEFAULT '0',`name` varchar(250) NOT NULL,`name_parsed` varchar(250) NOT NULL,`firstname` varchar(250) NOT NULL,`lastname` varchar(250) NOT NULL,`address` varchar(250) NOT NULL,`city` varchar(250) NOT NULL,`state` varchar(250) NOT NULL,`zip` varchar(250) NOT NULL,`phone` varchar(250) NOT NULL,`cc_number` varchar(250) NOT NULL,`cc_expiry` varchar(250) NOT NULL,`promo_code` varchar(250) NOT NULL,`cc_type` varchar(250) NOT NULL,primary key(id));

     

    SQL Error

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active' at line 1

     

    PLease Note: The following queries executed in the script separately work just fine.

    DROP TABLE IF EXISTS `billinginfo`;

    CREATE TABLE `billinginfo` (`id` int(5) unsigned NOT NULL AUTO_INCREMENT,`active` int(1) unsigned NOT NULL DEFAULT '0',`sort` double unsigned NOT NULL DEFAULT '0',`stamp` int(10) unsigned NOT NULL DEFAULT '0',`name` varchar(250) NOT NULL,`name_parsed` varchar(250) NOT NULL,`firstname` varchar(250) NOT NULL,`lastname` varchar(250) NOT NULL,`address` varchar(250) NOT NULL,`city` varchar(250) NOT NULL,`state` varchar(250) NOT NULL,`zip` varchar(250) NOT NULL,`phone` varchar(250) NOT NULL,`cc_number` varchar(250) NOT NULL,`cc_expiry` varchar(250) NOT NULL,`promo_code` varchar(250) NOT NULL,`cc_type` varchar(250) NOT NULL,primary key(id));

     

    Combined the world falls apart. Any ideas?

  12. Hi!

     

    Was wondering, how do I dynamically load a function? For example...

     

    /class/function/var1/var2

     

    The easy bit is by exploding the string.

     

    0 is the class

    1 is the function

     

    but if the number of variables is anything between 1 and 10 how do I dynamically put them into the function?

  13. Hi,

     

    I have a string which looks like this.

     

    <p style=\"text-align: left;\"><b><i><u>Left</u></i></b><br></p>

    <p style=\"text-align: center;\"><b><i><u>Middle</u></i></b></p>

    <p style=\"text-align: right;\"><b><i><u>Right</u></i></b></p>

     

    What I need to do is create a associative array from the above string. Something like this.

     

    array ('p' => array ('style' => array ('text-align' => 'center', 'property2' => 'value2')), 'content' => '<b><i><u>Left</u></i></b><br>');

     

    I then put it back together again in a different format.

     

    Any ideas how I would go about doing this? The only tag that will appear is a <p> tag.

     

     

  14. I have a custom validation library that I am making. I have hit a stumbling block. I need custom validation options. Unfortunately I cannot get the scope to work.

     

    Check it out.

    // User Class

    $this->v->class = 'User';

    $this->v->set_rule('username', 'required|maxlength.30|minlength.4|callback.valid_credentials');

     

    // Validation Class
    private function callback($function) {
    global $this->class;
    
    $this->class->$function();
    }

     

    To explain.

     

    The user class extends the base class. The base class basically does

    global $validation; $this->v = $validation

     

    When the validation is run it explodes the rules into "function.value". So above The callback function will be executed with the function name.

     

    What I need to do is put the user class into the same scope as the validation class. Then execute the function. I tried the code above. I got the following error.

    Fatal error: Cannot re-assign $this in C:\xampp\htdocs\clientApp\system\classes\validation.class.php on line 59

     

    I hope this makes sense. Do you have any ideas?

  15. When I was picking up PHP I went from procedural programming, fairly quickly into OOP, then after writing a bunch of custom libraries and applications I discovered CodeIgniter. I pretty much completely skipped PEAR all together. I have recently been tasked to work on an application that relies a lot of PEAR libraries. How relevant is PEAR today? Its been around for ages and is still being developed. Does anyone here still use it frequently? Does PEAR have a bright future or is it past its 'hay day'?

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.