Jump to content

Destramic

Members
  • Posts

    969
  • Joined

  • Last visited

Posts posted by Destramic

  1. hey guys i had some really good help off jacques1 a while back about encrypting/decrypting rows in my database via php...now as i've gone further down the line in my project i have stumbled across a problem i didnt forsee.

     

    i'm using nodejs which connects to my database for one of my pages...but the data is encryted...i need to also encrypt and decrypt the database rows server side via javascript :-\

     

    this is how it's done via php:

    <?php
    
    const ENCRYPTION_ALGORITHM = 'AES-128-CBC';
    
    class AES
    {
        private $_master_key;
        
        public function __construct()
        {
            $this->_master_key = "5e2a0626516f3108e55e25e4bb6a62835c2f5d2b2b8d194c9acca63ef8beff6bfb947233bd83cfda9021e5a80bc183bcd835180c9955b733fd1a6d9d";
        }
        
        public function generate_master_key($length = 60)
        {
            if (!is_numeric($length))
            {
                return null;
            }
            
            $max_attempts = 10;
            $attempts     = 0;
              
            do
            {
                $bytes = openssl_random_pseudo_bytes($length, $cryptographically_strong);
                
                $attempts++;
            }
            
            while (!$cryptographically_strong && $attempts < $max_attempts);
    
            if (!$cryptographically_strong)
            {
                return false;
            }
            
            $hex = bin2hex($bytes);
            
            return $hex;
        }
        
        public function encrypt($value, $master_key)
        {
            $init_vector = openssl_random_pseudo_bytes(openssl_cipher_iv_length(ENCRYPTION_ALGORITHM));
            $ciphertext  = openssl_encrypt($value, ENCRYPTION_ALGORITHM, $master_key, false, $init_vector);
        
            return array(
                'init_vector' => $init_vector,
                'ciphertext'  => $ciphertext
            );
        }
        
        public function decrypt($ciphertext, $init_vector, $master_key)
        {
            $plaintext = openssl_decrypt($ciphertext, ENCRYPTION_ALGORITHM, $master_key, false, $init_vector);
        
            return $plaintext;
        }
        
        public function encrypt_array($array)
        {
            $encrypted_array = array();
            $master_key      = $this->_master_key;
            
            foreach ($array as $key => $data)
            {
                foreach ($data as $column => $value)
                {
                    $encryption         = $this->encrypt($value, $master_key);
                    $init_vector_column = $column . '_init_vector';
                    
                    $encrypted_array[$key][$column]             = $encryption['ciphertext'];
                    $encrypted_array[$key][$init_vector_column] = $encryption['init_vector'];
                }
            }
            
            return $encrypted_array;
        }
        
        public function decrypt_array($array)
        {
            $decrypted_array = array();
            $master_key      = $this->_master_key;
            
            foreach ($array as $key => $data)
            {
                foreach ($data as $column => $value)
                {
                    $init_vector = $column . '_init_vector';
            
                    if (array_key_exists($init_vector, $data))
                    {
                        $init_vector = $data[$init_vector];
            
                        $decrypted_value                = $this->decrypt($value, $init_vector, $master_key);
                        $decrypted_array[$key][$column] = $decrypted_value;
                    }
                }
            }
            
            return $decrypted_array;
        }
    }
    
    $aes = new AES;
    
    $data = array(
             array('name' => 'destramic', 
                   'age' => '28'),
             array('name' => 'alan',
                   'age' => '99')    
    );
    
    $encryption = $aes->encrypt_array($data);
    print_r($encryption);
    $decryption = $aes->decrypt_array($encryption);
    print_r($decryption);
    

    can anyone please point me in the right direction on how i can achieve this please? (if even possible)

     

    thank you!

     

  2. You are right about joining twice to the attribute table, but you would use INNER JOINS if both attributes must match. Not sure you need the MATCH..AGAINST - if an attribute is "clock type" then the chances are it's a clock.

     

     

    If you only join once, as benanamen suggests, then you are back to finding someone who is both male and female at the same time, to quote the earlier example.

     

    yeah join the attributes table twice filtering out the items that way seems the only way possible...thanks for the inner join advice.

     

    thank you for all your posts in this painful thread guys haha :happy-04:

  3. SELECT DISTINCT(i.item_id),
           i.title
    FROM items i
    LEFT JOIN item_attributes ia ON ia.item_id = i.item_id
    LEFT JOIN item_attributes ia2 ON ia2.item_id = i.item_id
    WHERE ia.attribute = 'Clock Type' AND ia.value = 'Wall Clock'
    AND ia2.attribute = 'Condition' AND ia2.value = 'New'
    AND MATCH (i.title, i.description) AGAINST ('clock' IN BOOLEAN MODE)
    
    

    how about this?

  4. For the best feedback, detail out about the site and the functionality desired and how it should work. Based on your posts, it appears to be some sort of auction application.

     

    yeah my plan is to design a auction application...i apologizes cause after re-assessing my thinking and design (thanks to you guys, sorry!)...what i was trying to do wasn't what i really needed.

     

    what i was trying to achieve is when a user adds an item, the user will add item attributes (specifics) for that item...ie. manufacturer, color, etc...

     

     

    so...i made a table called item_attributes which contains all attributes of the item specified by the selling user.

    item_attributes
    
    --------------------------
    
    item_attribute_id
    
    item_id
    
    attribute
    
    value
    
    -----------------------
    

    and with a simple query like so i was able to get the items i want by the attributes i want...

    SELECT i.title
    FROM items i
    RIGHT JOIN (SELECT item_id FROM item_attributes WHERE attribute IN ('Clock Type') AND value IN ('Wall Clock')) ai ON ai.item_id = i.item_id
    RIGHT JOIN (SELECT item_id FROM item_attributes WHERE attribute IN ('Condition') AND value IN ('New')) ai2 ON ai2.item_id = ai.item_id
    

    IN not really needed as i could just use WHERE :stoopid:

     

    the specifications i be banging on about throughout this painful thread is so i can add attributes (specifications) to certain categories, sub categories etc..

     

    so when the user comes to the add item page the specifications will appear depending on categories selected....when they submit item and attributes it all gets added to the database

     

     

    what i've done here seems logical? :)

     

    thank you for your time and patience :suicide:

  5. Just like building a house or a building, you need to have a solid foundation before you hammer the first nail. The place to start right now is getting your database correct and then building upon that otherwise you are just going to have problems down the road

     

    i understand that like i said i stripped tables before dumping...i still believe there is a away for me to do this...i come across the IN() function which seems to be what i need

     

    i used it in my query like so:

    SELECT DISTINCT(i.item_id),
           i.title
    FROM items i
    RIGHT JOIN category_specifics cs ON cs.category_id = i.category_id
    RIGHT JOIN sub_category_specifics scs ON scs.sub_category_id = i.sub_category_id
    
    RIGHT JOIN (SELECT s2.specific_id
           FROM specifics s2
           LEFT JOIN category_specifics cs2 ON cs2.specific_id = s2.specific_id
           LEFT JOIN sub_category_specifics scs2 ON scs2.specific_id = s2.specific_id
    ) s ON s.specific_id = cs.specific_id
        OR s.specific_id = scs.specific_id
        
    RIGHT JOIN specific_values sv ON sv.specific_id = s.specific_id
    RIGHT JOIN item_specific_values isv ON  isv.specific_value_id = sv.specific_value_id
    
    WHERE MATCH (i.title) AGAINST ('clock' IN BOOLEAN MODE)
    AND isv.item_id = i.item_id
    AND (sv.value IN ('Alarm Clock', 'New') AND sv.specific_id IN (15, 19))
    GROUP BY isv.specific_value_id
    

    clock 1

    AND (sv.value IN ('Alarm Clock', 'New') AND sv.specific_id IN (15, 19))

    clock 2

    AND (sv.value IN ('Wall Clock', 'Used') AND sv.specific_id IN (15, 19))

    when searching for specifics match clock 3 - clock 3 and clock 1 show

    AND (sv.value IN ('Cuckoo Clock', 'New') AND sv.specific_id IN (15, 19))
    

    doesn't return clock 4 as it should

    AND (sv.value IN ('Alarm Clock', 'Used') AND sv.specific_id IN (15, 19))
    

    doesn't return clock 5 as it should

    AND (sv.value IN ('Wall Clock', 'Used') AND sv.specific_id IN (15, 19))
    

    please tell me i'm on to something here?

  6.  

    I am going to give a minute for others to chime in, but this DB Schema is just no good.

     

    Off hand, a category is a category is a category, just that some have parent categories and others dont. You also have some timestamp issues.

     

    1.  `sub_category_id` INT(11) NOT NULL,
    2.   `sub_sub_category_id` INT(11) DEFAULT NULL,
    3.   `sub_sub_sub_category_id` INT(11) DEFAULT NULL,
     
    Really? Sub sub sub?
     
    enum('Town/City','County','Country','Continent','MENA Region','Worldwide') 
    Enum???
     
    You only have one table that has any foreign keys. Not sure if you stripped them out or not.
     
    This is just really bad. But dont worry, it will get straightened out on this forum.
     
    * I think it would be helpful for you to google shopping cart DB schemas in the images tab.

     

     

    yeah i know the database schema isnt good but the one you have is stripped bare just to get the query can data that i want...no forgien keys, index etc....even stripped data as cats, sub cats have thousands of entries.

     

     

    All items have the same category and subcategory in that dump. What results are you expecting from the data you provided?

     

    as show here it displays what specific values are given to an item and the specific id's

     

    http://s30.postimg.org/v1y8370m9/Untitled_2.gif

     

    for instance i'd like to create a query where i can select any items where the      sv.value = 'Alarm Clock' AND s.specific_id = 15    as well as the    sv.value = 'New' AND s.specific_id = 19

     

    retrieving clock 1 or any of them that match the specific values and id's

     

     

    hope you can help and understand what it is im trying to do

  7. ok well i've stripper everything back to basics...here is the database dumb (no foreign keys ect etc) : http://pastebin.com/J3chVrQu

     

    this is how i designed my table relationship:

     

    relationship.gif

    lines on picture doesn't point to column that they relate to but you can gather from column name....each category has different specifics that specific having values linked to the item via the item_specific_values

     

    hope this a lot clearer for you guys now

     

     

     

    sql so far as we know:

    SELECT i.title
    FROM items i
    LEFT JOIN category_specifics cs ON cs.category_id = i.category_id
    LEFT JOIN sub_category_specifics scs ON scs.sub_category_id = i.sub_category_id
    
    INNER JOIN (SELECT s2.specific_id FROM specifics s2 
                        LEFT JOIN category_specifics cs2 ON cs2.specific_id = s2.specific_id 
    					LEFT JOIN sub_category_specifics scs2 ON scs2.specific_id = s2.specific_id 
    ) s ON s.specific_id = cs.specific_id
        OR s.specific_id = scs.specific_id
        
    LEFT JOIN specific_values sv ON sv.specific_id = s.specific_id
    RIGHT JOIN item_specific_values isv ON isv.item_id = i.item_id
    WHERE MATCH (i.title, i.description) AGAINST ('clock' IN BOOLEAN MODE)
    AND isv.specific_value_id = sv.specific_value_id
    AND cs.category_id = 1
    AND scs.sub_category_id = 4
    
    AND (
           (sv.value = 'Alarm Clock' AND s.specific_id = 15)
            OR (sv.value = 'New' AND s.specific_id = 19)
    )
    
    GROUP BY i.item_id
    

    what im trying to achieve is to retrieve an item by adding multiple conditions to the specific value and specific id

     

    please ask if you need any more information....thank for your help much appreciated

  8. No, there are no records that match that condition. It is impossible for a record to have a sv.value = 'Alarm Clock' AND sv.value='New'. If you dispute this, please provide a sample record with values that you think would match the condition. You need an OR operator on those last two pairs of condition.

     

    You are thinking like a human - not a machine. Let me provide an example:

     

    Let's take an example of a health insurance premium. Women live longer than men on average. So, an insurance rate might jump to a new lever at different ages for women than men. Let's say the highest rate starts for men at age 70, but for women that same rate doesn't kick in until age 74. As a human you might state that the highest rates apply to men that are 70 and above and to women that are 74 and above. So, you might be thinking that the condition for those people to be (gender='male' and age>=70) and (gender='female' and age>=74). but, that is incorrect, because no one person can be male and female (Bruce Jenner aside). The correct condition would be:

    (gender='male' and age>=70) OR (gender='female' and age>=74)

     

    So, either the person must be male and at least age 70 or the person must be female and at least 74.

     

    haha....ok i understand :)

     

    well the results i have returned from the or statement isn't what i was after as its returning sv.values on alarm clock and new....and i want to select sv.values with both conditions only....if i can explain what is it i'm trying to do with this picture please...

     

     

    Untitled_1.gif

     

    clock 1 has a sv.value of alarm clock and new, with s.specific_id 15 and 19

     

    how am i able to get this item with those exact conditions? to only return clock 1...is it possible?...is the way I've created my relationship structure or table incorrect?

     

    sorry to be a pain but i'm struggling to do what it is im trying to do

     

    thank you for your patience

  9. yeah thats the problem there are records there which match my conditions but just aren't showing

     

    here i used group_concat with the conditions to what values im dealing with:

     

    Untitled_2.gif

     

    so i know i have specific_id's of 15 and 19 and values of alarm clock and new...

     

    doesn't make sense to me why when i use my query nothing shows

     

    what am i missing here? =/

    SELECT i.title
    FROM items i
    LEFT JOIN category_specifics cs ON cs.category_id = i.category_id
    LEFT JOIN sub_category_specifics scs ON scs.sub_category_id = i.sub_category_id
    LEFT JOIN sub_sub_category_specifics sscs ON sscs.sub_sub_category_id = i.sub_sub_category_id
    LEFT JOIN sub_sub_sub_category_specifics ssscs ON ssscs.sub_sub_sub_category_id = i.sub_sub_sub_category_id
    
    INNER JOIN (SELECT s2.specific_id FROM specifics s2 
                        LEFT JOIN category_specifics cs2 ON cs2.specific_id = s2.specific_id 
    					LEFT JOIN sub_category_specifics scs2 ON scs2.specific_id = s2.specific_id 
                        LEFT JOIN sub_sub_category_specifics sscs2 ON sscs2.specific_id = s2.specific_id 
    	                LEFT JOIN sub_sub_sub_category_specifics ssscs2 ON ssscs2.specific_id = s2.specific_id 
    ) s ON s.specific_id = cs.specific_id
        OR s.specific_id = scs.specific_id
        OR s.specific_id = sscs.specific_id 
        OR s.specific_id = ssscs.specific_id
        
    LEFT JOIN specific_values sv ON sv.specific_id = s.specific_id
    RIGHT JOIN item_specific_values isv ON isv.item_id = i.item_id
    WHERE MATCH (i.title, i.description) AGAINST ('clock' IN BOOLEAN MODE)
    AND isv.specific_value_id = sv.specific_value_id
    
    AND (
           (sv.value = 'Alarm Clock' AND s.specific_id = 15)
            AND (sv.value = 'New' AND s.specific_id = 19)
    )
    
    GROUP BY i.item_id
    
  10. this query and table structure is quite complicated...for me anyways...

     

    i've made changes as you've said:

    SELECT i.title
    FROM items i
    
    LEFT JOIN category_specifics cs ON cs.category_id = i.category_id
    LEFT JOIN sub_category_specifics scs ON scs.sub_category_id = i.sub_category_id
    LEFT JOIN sub_sub_category_specifics sscs ON sscs.sub_sub_category_id = i.sub_sub_category_id
    LEFT JOIN sub_sub_sub_category_specifics ssscs ON ssscs.sub_sub_sub_category_id = i.sub_sub_sub_category_id
    
    INNER JOIN (SELECT s2.specific_id FROM specifics s2 
                        LEFT JOIN category_specifics cs2 ON cs2.specific_id = s2.specific_id 
    					LEFT JOIN sub_category_specifics scs2 ON scs2.specific_id = s2.specific_id 
                        LEFT JOIN sub_sub_category_specifics sscs2 ON sscs2.specific_id = s2.specific_id 
    	                LEFT JOIN sub_sub_sub_category_specifics ssscs2 ON ssscs2.specific_id = s2.specific_id 
    ) s ON s.specific_id = cs.specific_id
        OR s.specific_id = scs.specific_id
        OR s.specific_id = sscs.specific_id 
        OR s.specific_id = ssscs.specific_id
        
    LEFT JOIN specific_values sv ON sv.specific_id = s.specific_id
    RIGHT JOIN item_specific_values isv ON isv.item_id = i.item_id
    WHERE MATCH (i.title, i.description) AGAINST ('clock' IN BOOLEAN MODE)
    AND isv.specific_value_id = sv.specific_value_id
    
    AND (
           (sv.value = 'Alarm Clock' AND s.specific_id = '15')
       AND (sv.value = 'Used' AND s.specific_id = '19')
    )
    
    GROUP BY i.item_id
    

    i need

    AND (
           (sv.value = 'Alarm Clock' AND s.specific_id = '15')
       AND (sv.value = 'Used' AND s.specific_id = '19')
    )
    

    not OR as i want to match items with both specific value and id.

     

    query returns no results with both sv.value's and s.specific_id's but returns singularly.

     

    i've checked my data inserted into tables which looks fine =/

  11. hey guys I'm trying to join tables together but i want to be able to have multiple conditions for the same column.

     

    ie:

    WHERE sv.value = 'Alarm Clock'
    AND s.specific_id = '15'
    
    AND sv.value = 'New'
    AND s.specific_id = '19'
    

    now i know this is complicated as you can't see my table structure and table data but here is the query i'm trying to execute which returns 0 results when having multiple conditions from same column...

    SELECT i.title
    FROM items i
    LEFT JOIN category_specifics cs ON cs.category_id = i.category_id
    LEFT JOIN sub_category_specifics scs ON scs.sub_category_id = i.sub_category_id
    LEFT JOIN sub_sub_category_specifics sscs ON sscs.sub_sub_category_id = i.sub_sub_category_id
    LEFT JOIN sub_sub_sub_category_specifics ssscs ON ssscs.sub_sub_sub_category_id = i.sub_sub_sub_category_id
    
    INNER JOIN (SELECT s2.specific_id FROM specifics s2
                        LEFT JOIN category_specifics cs2 ON cs2.specific_id = s2.specific_id
                        LEFT JOIN sub_category_specifics scs2 ON scs2.specific_id = s2.specific_id
                        LEFT JOIN sub_sub_category_specifics sscs2 ON sscs2.specific_id = s2.specific_id
                        LEFT JOIN sub_sub_sub_category_specifics ssscs2 ON ssscs2.specific_id = s2.specific_id
    ) AS `s`
    
    LEFT JOIN specific_values sv ON sv.specific_id = s.specific_id
    LEFT JOIN item_specific_values isv ON isv.item_id = i.item_id
    WHERE MATCH (i.title, i.description) AGAINST ('clock' IN BOOLEAN MODE)
    AND isv.specific_value_id = sv.specific_value_id
    
    AND sv.value = 'Alarm Clock'
    AND s.specific_id = '15'
    
    AND sv.value = 'New'
    AND s.specific_id = '19'
    
    GROUP BY i.item_id
    

    if i take away


    AND sv.value = 'Alarm Clock'
    AND s.specific_id = '15'
    
    -------OR ---------
    
    AND sv.value = 'New'
    AND s.specific_id = '19'

    then it'll works

     

     

    i'll be happy to post table structures and data if needed...hopefully you can see what i'm trying to do and tell me if it's possible or not and what it is i need to be doing.

     

    any help would be appreciated and like i said i can provide data if need.

     

    thank you

  12. hey guys im trying to set to columns as a full text index but im receiving an error:

     

     

    Error Code: 1283. Column 'description' cannot be part of FULLTEXT index

     

    this is where the fault lies but i dunno why im getting the error...im using innodb engine for the table on mariadb 10

    FULLTEXT `items_FULLTEXT` (`description`, `title`),
    

    this is the sql i'm executing which is failing....i know innodb now support fulltext so where am i going wrong here please?

    
    CREATE TABLE `items` (
      `item_id` int(11) NOT NULL AUTO_INCREMENT,
      `user_id` int(11) NOT NULL,
      `category_id` int(11) NOT NULL,
      `sub_category_id` int(11) NOT NULL,
      `sub_sub_category_id` int(11) DEFAULT NULL,
      `sub_sub_sub_category_id` int(11) DEFAULT NULL,
      `user_address_id` int(11) DEFAULT NULL,
      `condition_id` int(11) DEFAULT NULL,
      `title` varchar(90) NOT NULL,
      `description` text NOT NULL,
      `auction` int(11) NOT NULL,
      `buy_now` tinyint(1) NOT NULL DEFAULT '0',
      `starting_price` decimal(15,2) NOT NULL,
      `listing_duration` enum('1','3','7','10','30') NOT NULL,
      `buy_now_price` decimal(15,2) NOT NULL,
      `quantity` int(11) NOT NULL DEFAULT '1',
      `offers_accepted` tinyint(1) NOT NULL DEFAULT '0',
      `start_timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
      `dispatch_time` enum('Same Day','1 Working Day','2 Working Days','3 Working Days') NOT NULL,
      `returns` int(1) NOT NULL DEFAULT '0',
      `return_policy` text,
      `free_delivery` int(1) DEFAULT '0',
      `free_delivery_condition` enum('Town/City','County','Country','Continent','MENA Region','Worldwide') DEFAULT NULL,
      `collection` int(1) DEFAULT '0',
      `collection_only` int(1) DEFAULT '0',
      `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
      `personal_delivery` int(1) DEFAULT '0',
      `personal_delivery_distance` int(10) DEFAULT '0',
      `persnal_delivery_price` decimal(12,2) DEFAULT '0.01',
      `draft` int(1) NOT NULL DEFAULT '0',
      PRIMARY KEY (`item_id`),
      FULLTEXT `items_FULLTEXT` (`description`, `title`),
      UNIQUE KEY `items_item_id_UNIQUE` (`item_id`),
      KEY `items_user_id_INDEX` (`user_id`),
      KEY `items_category_id_INDEX` (`category_id`),
      KEY `items_sub_category_id_INDEX` (`sub_category_id`),
      KEY `items_user_address_id_INDEX` (`user_address_id`),
      KEY `items_condition_id_INDEX` (`condition_id`),
      CONSTRAINT `items_category_id_FOREIGN_KEY` FOREIGN KEY (`category_id`) REFERENCES `categories` (`category_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
      CONSTRAINT `items_condition_id_FOREIGN_KEY` FOREIGN KEY (`condition_id`) REFERENCES `conditions` (`condition_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
      CONSTRAINT `items_sub_category_id_FOREIGN_KEY` FOREIGN KEY (`sub_category_id`) REFERENCES `sub_categories` (`sub_category_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
      CONSTRAINT `items_user_address_id_FOREIGN_KEY` FOREIGN KEY (`user_address_id`) REFERENCES `user_addresses` (`user_address_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
      CONSTRAINT `items_user_id_FOREIGN_KEY` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
    ) ENGINE=InnoDB AUTO_INCREMENT=1243 DEFAULT CHARSET=utf16;
    

    thank you

  13. ok i turned off my windows firewall completely but im still getting no joy...if you could please help...

     

     

    here is the rule i did for my firewall

     

    firewall.gif

     

     

    opened port 8080 on my router

     

     

    router.gif

     

    followed by my nginx config containing 192.168.1.80

    error_log logs/error.log;
    
    events {
    	worker_connections 1024;
    }
    
    http {
    	keepalive_timeout  	300;
    	proxy_read_timeout 	300;
    	proxy_connect_timeout 	300;
    	fastcgi_read_timeout 	300;
    
    	server {
    		listen 		8080;
    		server_name 	192.168.1.80;
    		client_max_body_size 	500M;
    
    		index index.html index.htm index.php;
    		root 	c:/nginx/html;
    
    		location / {
    			autoindex on;
    		}
    		
    		location = /favicon.ico {
      			log_not_found off;
    		}
    
    		location ~ .php$ {
    			fastcgi_pass 	     127.0.0.1:9000;
     			include 	     fastcgi.conf;
    			fastcgi_index 	     index.php;
    			fastcgi_read_timeout 300; 
    		}
    	}
    }
    
    

    hope you can tell me where i've gone wrong?

     

    thank you

  14. ok notes taken thank you.

     

    nginx config:

    listen 		8080;
    server_name 	192.168.1.80;
    

    i've made port 8080 as a new inbound rule on my firewall for nginx.exe and port 80 on my router forwarding to port 8080 :)

     

    now when i get someone to try connecting to my (ip):80 it doesn't connect...any ideas on this please requinix? i'm sure i've done everything right

     

     

    thank you

  15. I'm not sure what you need to do this for, but I'm going to give a plug to https://ngrok.com

     

    brilliant that worked like a charm....also very east to use and it broadcasted thanks gizmola

    ngork http 8080
    

    requinix i'd like to know how to do it via my router also....here is what i've done.

     

    nginx operates on port 8080 locally...i've added a port forwarding on my router (port 80) for port 8080 (nginx) as seen in image above...

    i just added a rule in firewall for port 80 to be public, but i noticed there is a few other things that operate on port 80 in my firewall....so should i make it unique?

     

    here is my nginx conf...do i need to alter this too?

    worker_processes  1;
    error_log logs/error.log;
    
    events {
    	worker_connections 1024;
    }
    
    http {
    	keepalive_timeout  	300;
    	proxy_read_timeout 	300;
    	proxy_connect_timeout 	300;
    	fastcgi_read_timeout 	300;
    
    	server {
    		listen 		8080;
    		server_name 	127.0.0.1;
    		client_max_body_size 	500M;
    
    		index index.html index.htm index.php;
    		root 	c:/nginx/html;
    
    		location / {
    			autoindex on;
    		}
    		
    		location = /favicon.ico {
      			log_not_found off;
    		}
    
    		location ~ .php$ {
    			fastcgi_pass 	     127.0.0.1:9000;
     			include 	     fastcgi.conf;
    			fastcgi_index 	     index.php;
    			fastcgi_read_timeout 300; 
    		}
    	}
    }
    
    

    thank you for your help guys

  16. hey guys,

     

    i'm trying to set up router so my local host can be visible to users...I've altered options in my router port forwarding but i'm unable to get it to work.

     

    i'm currently using nginx on my local host using port 8080 so i'm able to connect via: http://127.0.0.1:8080/

     

    here are the options i've changed in my router: (port 21 for FTP 80 for nginx server)

     

    Untitled_2.gif

     

    after there alterations i've tried to connect with my ip followed by the port (ip:80) and also http://192.168.1.1:80 but its not working.

     

    can anyone please give me advise on how i can get this working?

     

    thank you

  17. hey guys i've made a upload script for my site but i'm getting a server internal error 500 when selecting 3+ files at once, but works fine when uploading singular files.

     

    when the user browses and selects a image to upload it's send to my send_image() function which will send the image file, where its added to the server via php in my uploaded script...each file has its own request.

     

    here is the function

    	function send_image(method, selector, filename, file, cover){
    		  var data    = new FormData(),
    		      xhr     = XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"),
    		      message = 'Uploading ' + filename;
    		 
    		  if (method !== 'upload'){
    			  file = JSON.stringify(file);
    		  }
    		  
    		  if (method === 'crop'){
    			 message = 'Editing ' + filename;
    		  }
    		  else if (method === 'restore'){
    			  message = 'Retoring ' + filename;
    		  }
    		  else if (method === 'remove'){
    			  message = 'Removing ' + filename;
    		  }
    		  else if (method === 'change_cover_image' ||
    				  method === 'set_cover_image'){
    			  message = 'Changing cover image';
    		  }
    		  
    		 loader.display(message);
    		  
    		 if (method === 'upload'){
    			 data.append('cover', cover);
    		 }
    		 
    		  data.append('method', method);
    		  data.append('file', file);
    		  xhr.open('POST', 'http://bisi.bid/ajax/image', true);
    		  
    		  xhr.upload.onprogress = function(e) {
    		    if (e.lengthComputable) {
    		    	var percentage = Math.round((e.loaded * 100) / e.total);
    
    		    	progress.display(message, percentage);
    		    	
    		    	if (percentage === 100){
    		    		loader.stop(message);
    		    	}
    		    }
    		  }
    		  
    		  xhr.onerror = function () { 
    			  upload_status('Image failed to upload.'); 
    		  };
    		  
    		  xhr.onreadystatechange = function(){ 
    			  if (xhr.readyState == 4) {  
    			      if (xhr.status == 200) {
    				      if (method.match(/^(upload|crop|restore)$/)){
    				    	  var src = this.responseText;
    					      selector.attr('src', src + '?time=' + new Date());
    					      selector.data('uploaded', true);
    					      $('#images-uploaded').text($("li[id^='image-'] img").length);
    				      }
    			      } else { 
    			    	  upload_status('Image failed to upload.');
    			      } 
    			  } 
    			  
    			  console.log(xhr.responseText);
    			  console.log(xhr.readyState);
    			  console.log(xhr.status);
    			  console.log(xhr.statusText);
    		  }; 
    
    		  xhr.send(data);
    		  
    		  return xhr;
    	 }
    

    i believe the error i'm getting is because of the server configuration i'm getting these errors so i made changes to my server config files

     

     

    nginx.config

     

    keepalive_timeout  125;proxy_read_timeout 125;proxy_connect_timeout 125;fastcgi_read_timeout 125;

     

    php.ini

    upload_max_filesize = 40M
    post_max_size       = 40M
    

    after i made changes i tried to upload 5 images at once but the server comes back with internal error 500.

     

    images I'm uploading altogether are about 8mb.

     

    has someone come across this before?...any help on this matter would be appropriated...if you require further details/code please let me know.

     

     

    thank you

     

     

  18. Look again!

     

     

    before: ID: 14     Cover:1
    after:  ID: 14     Cover:0
    
    Both the image and cover are changed.

     

    If your objective is to switch which is the main image, just change cover and not the image name (or vice versa)

     

     

    what a plonker i am...i took away setting the cover and it worked as i wanted it to :suicide:

    UPDATE item_images im1, 
           item_images im2 
    SET im1.path = im2.path,  
        im2.path = im1.path 
    WHERE im1.item_id = im2.item_id
    AND im1.path = :cover_image_path
    AND im2.path = :image_path
    AND im1.item_id = :item_id
    

    sorry for being a fool! haha...thank you for your help barand

  19. yeah cover column dosn't move....here is results upon select before sql.

     

     

    image_id       item_id         path                                  cover

    ---------------------------------------------------------------------------

    13                   58                1447700481.jpg                 1

    14                   58                1447700522.jpg                 0

    ---------------------------------------------------------------------------

     

    after sql execution

     

    image_id       item_id         path                                  cover

    ---------------------------------------------------------------------------

    13                   58               1447700522.jpg                 0

    14                   58               1447700481.jpg                 1

    ---------------------------------------------------------------------------

     

    here is the table i'm using

    CREATE TABLE `item_images` (
    	`image_id` INT(11) NOT NULL AUTO_INCREMENT,
    	`item_id` INT(11) NOT NULL,
    	`path` VARCHAR(130) NOT NULL,
    	`cover` INT(1) NOT NULL DEFAULT '0',
    	PRIMARY KEY (`image_id`),
    	UNIQUE INDEX `item_images_image_id_UNIQUE` (`image_id`),
    	INDEX `item_images_item_id_INDEX` (`item_id`),
    	CONSTRAINT `item_images_item_id_FOREIGN_KEY` FOREIGN KEY (`item_id`) REFERENCES `items` (`item_id`) ON UPDATE NO ACTION ON DELETE NO ACTION
    )
    COLLATE='utf8_general_ci'
    ENGINE=InnoDB;
    

    somethings not right although it seems it should be...be good to know what's up here.

     

    thank you

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