Jump to content

ukscotth

Members
  • Posts

    195
  • Joined

  • Last visited

Posts posted by ukscotth

  1. Hi,

     

    I have the following code which gives a fading out effect when clicking on links. I need to be able to disable it for anchor links so it is disabled when using # as the link.

     

    Any ideas ? 

    /* 
    * Function to animate leaving a page
    */
    $.fn.leavePage = function() {   
        
      this.click(function(event){
    
        // Don't go to the next page yet.
        event.preventDefault();
        linkLocation = this.href;
        
        // Fade out this page first.
        $('body').fadeOut(400, function(){
          
          // Then go to the next page.
          window.location = linkLocation;
        });      
      }); 
    };
    
    

    Thanks,

    Scott.

  2. #!/bin/bash
    clear
    echo "Enter username :"
    read username
    cd /
    cd /home/$username/
    

    Hi,

     

    I'm new to batch scripting and i'm trying to insert a variable into a command but cant get it working, can someone please tell me how I do the following properly :

     

    Thanks in advance.

     

     

  3. Hi,

     

    Recently I have been getting emails warning me of a high system load ( up in the 20s ). I look at the processes and its always mysql thats using all the cpu. I have been fixing the problem by simply rebooting the server which obviously isnt the right thing to do.

     

    Can anyone please tell me how I can find out what site and user it is that is causing the high cpu load when it happens ?

     

    Many thanks,

     

    Scott.

     

     

  4. Hi,

     

    I'm trying to create a custom theme for Opencart but Im having troubles extracting the telephone number from the database to include it in my header. Opencart confuses me in the way that it uses controller files and I think each controller file links to individual tpl files so the telephone number variable can only be used on the contact page etc. It wont let me use it in the header file.

     

    Is there an easy way I can use the telephone variable in my header file ? I will paste the contact controller code below if anyone can help it would be most appreciated.

     

    Thanks,

     

    Scott.

     

    
    <?php 
    class ControllerInformationContact extends Controller {
    private $error = array(); 
        
      	public function index() {
    	$this->language->load('information/contact');
    
        	$this->document->setTitle($this->language->get('heading_title'));  
    
        	if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    		$mail = new Mail();
    		$mail->protocol = $this->config->get('config_mail_protocol');
    		$mail->parameter = $this->config->get('config_mail_parameter');
    		$mail->hostname = $this->config->get('config_smtp_host');
    		$mail->username = $this->config->get('config_smtp_username');
    		$mail->password = $this->config->get('config_smtp_password');
    		$mail->port = $this->config->get('config_smtp_port');
    		$mail->timeout = $this->config->get('config_smtp_timeout');				
    		$mail->setTo($this->config->get('config_email'));
      		$mail->setFrom($this->request->post['email']);
      		$mail->setSender($this->request->post['name']);
      		$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
      		$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
          		$mail->send();
    
      		$this->redirect($this->url->link('information/contact/success'));
        	}
    
          	$this->data['breadcrumbs'] = array();
    
          	$this->data['breadcrumbs'][] = array(
            	'text'      => $this->language->get('text_home'),
    		'href'      => $this->url->link('common/home'),        	
            	'separator' => false
          	);
    
          	$this->data['breadcrumbs'][] = array(
            	'text'      => $this->language->get('heading_title'),
    		'href'      => $this->url->link('information/contact'),
            	'separator' => $this->language->get('text_separator')
          	);	
    
        	$this->data['heading_title'] = $this->language->get('heading_title');
    
        	$this->data['text_location'] = $this->language->get('text_location');
    	$this->data['text_contact'] = $this->language->get('text_contact');
    	$this->data['text_address'] = $this->language->get('text_address');
        	$this->data['text_telephone'] = $this->language->get('text_telephone');
        	$this->data['text_fax'] = $this->language->get('text_fax');
    
        	$this->data['entry_name'] = $this->language->get('entry_name');
        	$this->data['entry_email'] = $this->language->get('entry_email');
        	$this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
    	$this->data['entry_captcha'] = $this->language->get('entry_captcha');
    
    	if (isset($this->error['name'])) {
        		$this->data['error_name'] = $this->error['name'];
    	} else {
    		$this->data['error_name'] = '';
    	}
    
    	if (isset($this->error['email'])) {
    		$this->data['error_email'] = $this->error['email'];
    	} else {
    		$this->data['error_email'] = '';
    	}		
    
    	if (isset($this->error['enquiry'])) {
    		$this->data['error_enquiry'] = $this->error['enquiry'];
    	} else {
    		$this->data['error_enquiry'] = '';
    	}		
    
    		if (isset($this->error['captcha'])) {
    		$this->data['error_captcha'] = $this->error['captcha'];
    	} else {
    		$this->data['error_captcha'] = '';
    	}	
    
        	$this->data['button_continue'] = $this->language->get('button_continue');
        
    	$this->data['action'] = $this->url->link('information/contact');
    	$this->data['store'] = $this->config->get('config_name');
        	$this->data['address'] = nl2br($this->config->get('config_address'));
        	$this->data['telephone'] = $this->config->get('config_telephone');
        	$this->data['fax'] = $this->config->get('config_fax');
        	
    	if (isset($this->request->post['name'])) {
    		$this->data['name'] = $this->request->post['name'];
    	} else {
    		$this->data['name'] = $this->customer->getFirstName();
    	}
    
    	if (isset($this->request->post['email'])) {
    		$this->data['email'] = $this->request->post['email'];
    	} else {
    		$this->data['email'] = $this->customer->getEmail();
    	}
    
    	if (isset($this->request->post['enquiry'])) {
    		$this->data['enquiry'] = $this->request->post['enquiry'];
    	} else {
    		$this->data['enquiry'] = '';
    	}
    
    	if (isset($this->request->post['captcha'])) {
    		$this->data['captcha'] = $this->request->post['captcha'];
    	} else {
    		$this->data['captcha'] = '';
    	}		
    
    	if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/contact.tpl')) {
    		$this->template = $this->config->get('config_template') . '/template/information/contact.tpl';
    	} else {
    		$this->template = 'default/template/information/contact.tpl';
    	}
    
    	$this->children = array(
    		'common/column_left',
    		'common/column_right',
    		'common/content_top',
    		'common/content_bottom',
    		'common/footer',
    		'common/header'
    	);
    
    		$this->response->setOutput($this->render());		
      	}
    
      	public function success() {
    	$this->language->load('information/contact');
    
    	$this->document->setTitle($this->language->get('heading_title')); 
    
          	$this->data['breadcrumbs'] = array();
    
          	$this->data['breadcrumbs'][] = array(
            	'text'      => $this->language->get('text_home'),
    		'href'      => $this->url->link('common/home'),
            	'separator' => false
          	);
    
          	$this->data['breadcrumbs'][] = array(
            	'text'      => $this->language->get('heading_title'),
    		'href'      => $this->url->link('information/contact'),
            	'separator' => $this->language->get('text_separator')
          	);	
    
        	$this->data['heading_title'] = $this->language->get('heading_title');
    
        	$this->data['text_message'] = $this->language->get('text_message');
    
        	$this->data['button_continue'] = $this->language->get('button_continue');
    
        	$this->data['continue'] = $this->url->link('common/home');
    
    	if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
    		$this->template = $this->config->get('config_template') . '/template/common/success.tpl';
    	} else {
    		$this->template = 'default/template/common/success.tpl';
    	}
    
    	$this->children = array(
    		'common/column_left',
    		'common/column_right',
    		'common/content_top',
    		'common/content_bottom',
    		'common/footer',
    		'common/header'
    	);
    
    		$this->response->setOutput($this->render()); 
    }
    
      	private function validate() {
        	if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 32)) {
          		$this->error['name'] = $this->language->get('error_name');
        	}
    
        	if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
          		$this->error['email'] = $this->language->get('error_email');
        	}
    
        	if ((utf8_strlen($this->request->post['enquiry']) < 10) || (utf8_strlen($this->request->post['enquiry']) > 3000)) {
          		$this->error['enquiry'] = $this->language->get('error_enquiry');
        	}
    
        	if (empty($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
          		$this->error['captcha'] = $this->language->get('error_captcha');
        	}
    
    	if (!$this->error) {
      		return true;
    	} else {
      		return false;
    	}  	  
      	}
    
    public function captcha() {
    	$this->load->library('captcha');
    
    	$captcha = new Captcha();
    
    	$this->session->data['captcha'] = $captcha->getCode();
    
    	$captcha->showImage();
    }	
    }
    ?>
    
    
    

  5. Hi All,

     

    I've been creating sites with custom CMS for a while now and I'm trying to figure out how to let clients create new pages from within the CMS and what the standard method is to do it. I guess it would use mod rewrite but I'm not sure.

     

    Any ideas ?

     

    Thanks,

     

    Scott.

     

     

     

  6. Hi,

     

    I have a server setup which has been working fine for a couple of years now and has hundreds of sites on it. I'm trying to setup a new site for a client and ive asked him to set the nameservers for his domain to my nameservers but hes telling me he cant and that its telling him the nameservers are not configured for his domain.

     

    Never had this problem before, any ideas ?

     

    Many thanks,

     

    Scott.

  7. Hi,

     

    I have a function that pulls a random line from a text file and I would like to change it so it pulls a random line from a text file that contains a certain date, heres the current function :

     

    
    function RandomLine($filename) { 
        $lines = file($filename) ; 
        return $lines[array_rand($lines)] ; 
    } 
    
    

     

    Any ideas on the best way to do this ?

     

    Many thanks.

     

     

  8. Hi all,

     

    I have the following :

     

    print_r($fqlResult);

     

    Which gives the following result :

     

    Array ( [0] => Array ( [src_big] => http://a5.sphotos.ak.fbcdn.net/hphotos-ak-ash4/299117_2121699756933_1079004376_2442101_3103384_n.jpg ) ) 

     

    I want to grab just the image url from it and store it in a seperate variable.

     

    Any ideas how I can do this plzzz ?

     

    Thanks in advance,

     

    Scott.

  9. Hi,

     

    Im creating a facebook app and I want to be able to grab the users full size profile picture and save it locally. Apparently you can do it with this code :

     

    <script>
    FB.api('/me/albums', function(response) {
            for (album in response.data) {
              if (response.data[album].name == "Profile Pictures") {
                FB.api(response.data[album].id + "/photos", function(response) {
                  image = response.data[0].images[0].source;
    		  
    
                });
              }
            }
          });
      </script>

     

    Sorry if this is a stupid question but how would I echo out the image path after funning that ? Im only used to working with php.

     

    Thanks,

     

    Scott.

  10. Hi,

     

    This is probably very easy for someone who knows how but I cant seem to get it working.

     

    Can someone please tell me how I can alter this query to select a 'WHERE gender = female' so instead of picking a random user it picks a random female user ?

     

    $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `users` ");
    $offset_row = mysql_fetch_object( $offset_result ); 
    $offset = $offset_row->offset;
    $user1b = mysql_query( " SELECT * FROM `users` LIMIT $offset, 1 " );
    $user1= mysql_fetch_array($user1b);
    

     

    Also, would it be easy to modify it so it picks a second random user that isnt the same as the first user ? so I end up with 2 random females ( $user1 and $user2 )

     

    Many thanks,

     

    Scott

×
×
  • 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.