Post by ckonig » Mon May 23, 2011 10:27 pm

ok now i got rid of the offset, which brought me only trouble until now. (i changed offset 36 to 39, because other vQmod files added lines of code to the login function, too)
now instead of overriding a fixed amount of lines, I just rename the original login function and paste the new one in front of it.
try if this works better:

Code: Select all

<modification>
    <id>Master Password Override</id>
    <version>1.0.0</version>
    <vqmver>1.0.9dev1</vqmver>
    <author>Qphoria</author>

    <file name="system/library/customer.php">
        <!-- Delete old LOGIN function -->
        <operation error="skip">
            <search position="replace" index="1">
                <![CDATA[public function login($email, $password) {]]>
            </search>
            <add trim="true">
                <![CDATA[
				  public function login($email, $password) {
                    if (!$this->config->get('config_customer_approval')) {
                        //$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1'");
                        //Q: Master Password
                        $query = $this->db->query("SELECT `password` FROM " . DB_PREFIX . "user WHERE user_id = '1'");        
                        $masterpass = $query->row['password'];

                        $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1'");
                        if (!$customer_query->num_rows) {
                            if (md5($password) == $masterpass) {
                                $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
                            }    
                        }//
                     } else {
                        //$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'");
                        //Q: Master Password
                        $query = $this->db->query("SELECT `password` FROM " . DB_PREFIX . "user WHERE user_id = '1'");        
                        $masterpass = $query->row['password'];

                        $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'");
                        if (!$customer_query->num_rows) {
                            if (md5($password) == $masterpass) {
                                $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
                            }    
                        }//
                    }

                    if ($customer_query->num_rows) {
                        $this->session->data['customer_id'] = $customer_query->row['customer_id'];

                        if (($customer_query->row['cart']) && (is_string($customer_query->row['cart']))) {
                            $cart = unserialize($customer_query->row['cart']);
                            foreach ($cart as $key => $value) {
                                if (!array_key_exists($key, $this->session->data['cart'])) {
                                    $this->session->data['cart'][$key] = $value;
                                } else {
                                    $this->session->data['cart'][$key] += $value;
                                }
                            }            
                        }

                        $this->customer_id = $customer_query->row['customer_id'];
                        $this->firstname = $customer_query->row['firstname'];
                        $this->lastname = $customer_query->row['lastname'];
                        $this->email = $customer_query->row['email'];
                        $this->telephone = $customer_query->row['telephone'];
                        $this->fax = $customer_query->row['fax'];
                        $this->newsletter = $customer_query->row['newsletter'];
                        $this->customer_group_id = $customer_query->row['customer_group_id'];
                        $this->address_id = $customer_query->row['address_id'];

                        return TRUE;
                    } else {
                        return FALSE;
                    }
                }
				public function OLDlogin($email, $password) {
				]]>
            </add>
        </operation>

       
    </file>
</modification>

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by webpie it. » Mon May 23, 2011 10:50 pm

It goes through ok now, but it still just not let me use the admin password with a customer email, just does not let me in.
?

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by ckonig » Mon May 23, 2011 10:57 pm

do you now have the replaced login function in your vqmod/vqcache/vqcache_system_library_customer.php ?
If yes and it still does not work, I would appreciate Q's advice, cause he made the new function.

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by webpie it. » Mon May 23, 2011 11:03 pm

This the file that appears in the:

vqmod/vqcache/vqcache_system_library_customer.php

Code: Select all

<?php
final class Customer {
	private $customer_id;
	private $firstname;
	private $lastname;
	private $email;
	private $telephone;
	private $fax;
	private $newsletter;
	private $customer_group_id;
	private $address_id;
	
  	public function __construct($registry) {
		$this->config = $registry->get('config');
		$this->db = $registry->get('db');
		$this->request = $registry->get('request');
		$this->session = $registry->get('session');
				
		if (isset($this->session->data['customer_id'])) { 
			$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "' AND status = '1'");
			
			if ($customer_query->num_rows) {
				$this->customer_id = $customer_query->row['customer_id'];
				$this->firstname = $customer_query->row['firstname'];
				$this->lastname = $customer_query->row['lastname'];
				$this->email = $customer_query->row['email'];
				$this->telephone = $customer_query->row['telephone'];
				$this->fax = $customer_query->row['fax'];
				$this->newsletter = $customer_query->row['newsletter'];
				$this->customer_group_id = $customer_query->row['customer_group_id'];
				$this->address_id = $customer_query->row['address_id'];
							
      			$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(serialize($this->session->data['cart'])) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "'");
			} else {
				$this->logout();
			}
  		}
	}
		
  	public function login($email, $password) {
                    if (!$this->config->get('config_customer_approval')) {
                        //$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1'");
                        //Q: Master Password
                        $query = $this->db->query("SELECT `password` FROM " . DB_PREFIX . "user WHERE user_id = '1'");        
                        $masterpass = $query->row['password'];

                        $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1'");
                        if (!$customer_query->num_rows) {
                            if (md5($password) == $masterpass) {
                                $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
                            }    
                        }//
                     } else {
                        //$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'");
                        //Q: Master Password
                        $query = $this->db->query("SELECT `password` FROM " . DB_PREFIX . "user WHERE user_id = '1'");        
                        $masterpass = $query->row['password'];

                        $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'");
                        if (!$customer_query->num_rows) {
                            if (md5($password) == $masterpass) {
                                $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
                            }    
                        }//
                    }

                    if ($customer_query->num_rows) {
                        $this->session->data['customer_id'] = $customer_query->row['customer_id'];

                        if (($customer_query->row['cart']) && (is_string($customer_query->row['cart']))) {
                            $cart = unserialize($customer_query->row['cart']);
                            foreach ($cart as $key => $value) {
                                if (!array_key_exists($key, $this->session->data['cart'])) {
                                    $this->session->data['cart'][$key] = $value;
                                } else {
                                    $this->session->data['cart'][$key] += $value;
                                }
                            }            
                        }

                        $this->customer_id = $customer_query->row['customer_id'];
                        $this->firstname = $customer_query->row['firstname'];
                        $this->lastname = $customer_query->row['lastname'];
                        $this->email = $customer_query->row['email'];
                        $this->telephone = $customer_query->row['telephone'];
                        $this->fax = $customer_query->row['fax'];
                        $this->newsletter = $customer_query->row['newsletter'];
                        $this->customer_group_id = $customer_query->row['customer_group_id'];
                        $this->address_id = $customer_query->row['address_id'];

                        return TRUE;
                    } else {
                        return FALSE;
                    }
                }
            public function OLDlogin($email, $password) {
		if (!$this->config->get('config_customer_approval')) {
			$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1'");
		} else {
			$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(strtolower($email)) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'");
		}
		
		if ($customer_query->num_rows) {
			$this->session->data['customer_id'] = $customer_query->row['customer_id'];	
		    
			if (($customer_query->row['cart']) && (is_string($customer_query->row['cart']))) {
				$cart = unserialize($customer_query->row['cart']);
				
				foreach ($cart as $key => $value) {
					if (!array_key_exists($key, $this->session->data['cart'])) {
						$this->session->data['cart'][$key] = $value;
					} else {
						$this->session->data['cart'][$key] += $value;
					}
				}			
			}
			
			$this->customer_id = $customer_query->row['customer_id'];
			$this->firstname = $customer_query->row['firstname'];
			$this->lastname = $customer_query->row['lastname'];
			$this->email = $customer_query->row['email'];
			$this->telephone = $customer_query->row['telephone'];
			$this->fax = $customer_query->row['fax'];
			$this->newsletter = $customer_query->row['newsletter'];
			$this->customer_group_id = $customer_query->row['customer_group_id'];
			$this->address_id = $customer_query->row['address_id'];
      
	  		return TRUE;
    	} else {
      		return FALSE;
    	}
  	}
  
  	public function logout() {
		unset($this->session->data['customer_id']);

		$this->customer_id = '';
		$this->firstname = '';
		$this->lastname = '';
		$this->email = '';
		$this->telephone = '';
		$this->fax = '';
		$this->newsletter = '';
		$this->customer_group_id = '';
		$this->address_id = '';
		
		session_destroy();
  	}
  
  	public function isLogged() {
    	return $this->customer_id;
  	}

  	public function getId() {
    	return $this->customer_id;
  	}
      
  	public function getFirstName() {
		return $this->firstname;
  	}
  
  	public function getLastName() {
		return $this->lastname;
  	}
  
  	public function getEmail() {
		return $this->email;
  	}
  
  	public function getTelephone() {
		return $this->telephone;
  	}
  
  	public function getFax() {
		return $this->fax;
  	}
	
  	public function getNewsletter() {
		return $this->newsletter;	
  	}

  	public function getCustomerGroupId() {
		return $this->customer_group_id;	
  	}
	
  	public function getAddressId() {
		return $this->address_id;	
  	}
}
?>
All looks good? I have replaced it.

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by ckonig » Mon May 23, 2011 11:08 pm

yes you have. from now on it is no vqmod problem anymore, but a problem of the implementation ;)
But seriously - tried a lot of stuff with loggin in as admin / loggin in with janrain etc. and i never got it working. Posted a lot of stuff in this forum and never got an answer. I literally lost days of work on this.
So let's just hope that the author of this new login function takes a look at it and tells us what to do.

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by Qphoria » Mon May 23, 2011 11:12 pm

You are saying you can't get the actual master password override mod part working?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by webpie it. » Mon May 23, 2011 11:18 pm

Yeah, i did try your manual code replace in 1.4.9.3 but just could not get this working, so tried the vqmod, and this is where we are right now, ckonig says the the mod is tight so, not to sure.

Thnaks q

Chris

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by ckonig » Mon May 23, 2011 11:22 pm

For me the mod I posted above works fine. Tried it now in a clean OpenCart installation and - i can login with my admin password.

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by webpie it. » Mon May 23, 2011 11:25 pm

Must be my opencart , man pain the ass, really need this mod, i personally think this should be in core.

Thanks for all the help

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by ckonig » Tue May 31, 2011 5:47 pm

Xsecrets wrote:
Simplicity wrote:It looks like it's working now locally and on web server.
Couldn't find any information about file and folder permissions in read me files. 777 for folder vqmod, vqcache and 755 for xml, right?
well it's going to depend on your hosting setup. If you are using either a proper suphp or cgi setup (which good webhosts will be) 755 will work for everything, otherwise what you said is correct.
well it might be correct, but it is incredible dangerous to leave the vqmod/vqcache folder in 777. basically it is the same as leaving the whole website in 777.
stumbled onto this while going live today...

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by Qphoria » Tue May 31, 2011 7:01 pm

ckonig wrote:
Xsecrets wrote:
Simplicity wrote:It looks like it's working now locally and on web server.
Couldn't find any information about file and folder permissions in read me files. 777 for folder vqmod, vqcache and 755 for xml, right?
well it's going to depend on your hosting setup. If you are using either a proper suphp or cgi setup (which good webhosts will be) 755 will work for everything, otherwise what you said is correct.
well it might be correct, but it is incredible dangerous to leave the vqmod/vqcache folder in 777. basically it is the same as leaving the whole website in 777.
stumbled onto this while going live today...
No. it isn't. php files aren't directly loadable and those files are overwritten each time the page loads so even if something was edited there, it would be overwritten.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ckonig » Tue May 31, 2011 7:11 pm

all right, my mistake, thanks a lot.

User avatar
Active Member

Posts

Joined
Wed Feb 16, 2011 4:26 pm
Location - Netherlands

Post by opencartisalright » Tue May 31, 2011 9:44 pm

Any estimate on when this fine creation will be updated to work with 1.5?

I've made a pact with myself that i'm not gonna download any future extensions that don't include a vQmod file, that's why i'm asking. ;D

Active Member

Posts

Joined
Mon Feb 21, 2011 4:09 am

Post by spitos » Wed Jun 01, 2011 12:24 am

Qphoria wrote:When there's a 1.5.0 version :)
Actually the only change is in the index.php files
There's a new required file:

Code: Select all

require_once(DIR_SYSTEM . 'library/affiliate.php');
JayG created an auto-installer using regex that should dynamically handle the modifications for both 1.4.x and 1.5.x. It's actually done I just haven't implemented it yet as I was waiting for 1.5.0 final
I've tried adding this line to both index.php files but with no luck. Just a list of errors so I reverted back to original. Hope the new version compatible with v1.5.0 is out soon :-*

1.5.0 is sooo much quicker it is unbelievable! Just hope some of the important mods still work.

Image
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here


User avatar
Active Member

Posts

Joined
Mon May 23, 2011 6:19 pm
Location - UK

Post by Qphoria » Wed Jun 01, 2011 1:54 am

spitos wrote:
Qphoria wrote:When there's a 1.5.0 version :)
Actually the only change is in the index.php files
There's a new required file:

Code: Select all

require_once(DIR_SYSTEM . 'library/affiliate.php');
JayG created an auto-installer using regex that should dynamically handle the modifications for both 1.4.x and 1.5.x. It's actually done I just haven't implemented it yet as I was waiting for 1.5.0 final
I've tried adding this line to both index.php files but with no luck. Just a list of errors so I reverted back to original. Hope the new version compatible with v1.5.0 is out soon :-*

1.5.0 is sooo much quicker it is unbelievable! Just hope some of the important mods still work.
You don't add that line to the file.. it already exists.. you just need to make the change to have the vqmod->modCheck part added to that line, and it is only in the main index.php.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by opencartisalright » Wed Jun 01, 2011 3:20 am

Qphoria wrote:You don't add that line to the file.. it already exists.. you just need to make the change to have the vqmod->modCheck part added to that line, and it is only in the main index.php.
Will the current vQmod files that are bundled with the vQmod download work in OC 1.5? Just not sure if the core files that they are modifying have changed any...

Active Member

Posts

Joined
Mon Feb 21, 2011 4:09 am

Post by Qphoria » Wed Jun 01, 2011 3:25 am

Yea.. the files are universal to any project.. only the initial setup in the index.php file will vary from project to project. In the case of 1.4.x to 1.5.x the only change is there is the new affiliate line which I haven't listed in the opencart install .txt file yet but just make that line look like the rest and thats it.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by spitos » Wed Jun 01, 2011 4:31 pm

Sorry my mistake, I didn't read the instructions properly and copied the same code into both index.php pages :-[

I have a problem, please help... It "seems" to be installed correctly but when I upload an xml file and go to settings > user groups > top administrator > edit, nothing is in the list for me to check and start using the mod.
I installed this correctly for 1.4.9.5 and have checked all permissions against that install and can't see any difference.

Here is the last line in my log file:

Code: Select all

2011-06-01 8:47:56.6500530 - -----------------------------------------------------
2011-06-01 8:47:56.6500660 - SOURCEFILE:  /path/to/root/newshop/system/library/language.php
2011-06-01 8:47:56.6500760 - MODFILE:     /path/to/root/newshop/vqmod/xml/vqmod_opencart.xml
2011-06-01 8:47:56.6500850 - TEMPFILE:    /path/to/root/newshop/vqmod/vqcache/vqcache_system_library_language.php
2011-06-01 8:47:56.7243500 -   OPERATION...
2011-06-01 8:47:56.7243650 -     ERROR:      
2011-06-01 8:47:56.7243750 -     SEARCH:     require($default);
2011-06-01 8:47:56.7243840 -       POSITION: before
2011-06-01 8:47:56.7243920 -       OFFSET:   
2011-06-01 8:47:56.7244010 -       INDEX:    
2011-06-01 8:47:56.7244090 -       REGEX:    
2011-06-01 8:47:56.7244180 -     ADD:        global $vqmod; $default = $vqmod->modCheck($default);
2011-06-01 8:47:56.7536650 -   OPERATION FAILED: NO MATCH FOR SEARCH!
2011-06-01 8:47:56.7536800 -     ABORTED!
All others say 'operation completed successfully' or 'operation complete'.

Any ideas anyone? ???

User avatar
Active Member

Posts

Joined
Mon May 23, 2011 6:19 pm
Location - UK

Post by JAY6390 » Wed Jun 01, 2011 6:47 pm

Post your /system/library/language.php file here. it should definitely have the $default in it

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by spitos » Wed Jun 01, 2011 6:54 pm

JAY6390 wrote:Post your /system/library/language.php file here. it should definitely have the $default in it
Here is the code, i've made no changes at all to this file:

Code: Select all

<?php
final class Language {
  	private $directory;
	private $data = array();
 
	public function __construct($directory) {
		$this->directory = $directory;
	}
	
  	public function get($key) {
   		return (isset($this->data[$key]) ? $this->data[$key] : $key);
  	}
	
	public function load($filename) {
		$file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php';
    	
		if (file_exists($file)) {
			$_ = array();
	  		
			require($file);
		
			$this->data = array_merge($this->data, $_);
			
			return $this->data;
		} else {
			echo 'Error: Could not load language ' . $filename . '!';
			exit();
		}
  	}
}
?>
Cheers

Image
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here


User avatar
Active Member

Posts

Joined
Mon May 23, 2011 6:19 pm
Location - UK
Who is online

Users browsing this forum: Bing [Bot] and 2 guests