Jump to content

Orionsbelter

Members
  • Posts

    493
  • Joined

  • Last visited

Posts posted by Orionsbelter

  1. I'm trying to create an ajax call using jQuery jsonp. I'm fairly new jQuery and jsonp (trying out some examples to learn), however i'm very keen to learn how to build a javascript file to include into future project that will validate a license code. 

    I'm come up with the following code: 

     

    <script type="text/javascript" src="http://www.example.co.uk/javascript/jquery/jquery-1.7.1.min.js"></script>
    <script type="application/javascript">
    (function($) {
        var licensing = function() {
    		var domain = 'test.com';
    		var EID = 'EXT123';
    		var LC = '1234';
    		
            $.ajax({
                 type : "GET",
                 dataType : "jsonp",
                 jsonp:"callback",
                 contentType: "application/json",
                 jsonpCallback: "resp",
                 url : "//example.com/license/index.php?domain="+ domain +"&licenseCode="+ LC +"&EID="+ EID +"",
                 success: function(response) {
    		alert(response)
                 },
                 error: function() {
                    alert('An error occurred during validation. Please try again. If the issue persists, contact support.');
                 }
            });
        
        }
            
        licensing(null);
    })(jQuery)
    </script>
    
    

    However I'm struggling to find suitable examples for the next stage which would be the PHP file example.com/license/index.php which I would like to handle the parameters passed, check the database and create an array named response to hold all the information pulled from the database. 

    I'm fine with connecting to the database, building the array etc but I'm not too sure where to start in regards to accepting the call, I'm tried this simple code for now:

     

    <?php 
    
    $domain = $_GET['domain'];
    $licenseCode = $_GET['licenseCode'];
    $EID = $_GET['EID'];
    
    
    echo $domain . " " . $licenseCode . " " . $EID . " ";
    ?>
    

    But It's throwing the error as the AJAX has failed. 

    Does anyone have any good examples of what would need to include the in PHP file to handle the request? 

    Thanks. 

  2. Hi Guys, 

     

    I'm looking to create a module for a third party eCommerce system, that will allow the user to create rules or conditions for sending out emails to the customer. 

     

    For example, the user will be able to select from dropdowns to create a rule, similar to email filtering:

     

    Example 

     

    IF - Cart Value - Is Greater Than - 300

     

    AND - Product Category - Is Equal To - Phones 

     

    FYI - All the BOLD text represents multi-select dropdowns and ITALIC text represents input boxes

    I do not wish for someone to write this code for me, but would anyone know if anywhere I can learn this or does anyone of a open source script / system that I could look at. 

     

    Thank you. 

  3. If you don't want anybody to see your code, then don't publish it.

    This isn't always the possible though, imagine if you were a publisher of an extension on a open-source project such as Joomla, Opencart, Presta Shop etc.

     

    Then you would have to publish your code for people to pay,  download and install on their website; Then someone could do the same and make changes to your extension's code and make it look different and upload to the marketplace to compete against your own product in which it was originally your own. 

     

    And I am the guy who constanly keep telling everyone they SHOULD use other people's code (if available, well-tested, and adheres to some standard).

     

    I'm a big believer in this also, as long as it not going to be used against the original developer as mentioned above. 

     

    There has been some extremely interesting points made in the forum and I would like to thank everyone who has posted.  

  4. What about getting help in forums? Should you give credit and royalties?

    Exactly is someone provide you with some source code that they wrote to solve your problem, then I would consider this as a valid reason to credit that person somewhere in the program / software. 

     

     

    BTW, Leibniz invented binary, had one of the first mechanical computers using it.

     

    This is a whole other subject in it's self haha, Awhile back I was researching who actually invented the computer and there isn't a simple answer as you will already know.

     

    I always believed Konrad Zuse invented the computer by using Leibniz's binary with telephone relays, however I soon learnt that there was a history of computers long before that! 

     

    The lawyers who take these such cases on must be pretty well paid!

     

     

  5. I believe Apple patented the bounce at the end of a scroll, even though it was a basic falloff animation, but that's Apple for you, steal everyone else's tech then moan and claim for cash when they think they can, even though various games had used such events for years.

    http://www.theregister.co.uk/2013/11/21/samsung_cries_racism_then_asks_for_further_review_in_apple_patent_case/

     

     

    You find some tutorials online where people go to silly lengths to make their code look unique, but at the cost of speed.

     

    Another way (not really with PHP) is to obfuscate compiled code in specific tell tale ways.

     

     

    When I say I don't copy code... well, maybe through the use of tutorials a longtime before, which I've hacked apart and rebuilt numerous times and eventually writing into own classes. Also tutorials rarely have error checking and such so it is so far removed from the original that its not.

     

     

    The thing you want to try to patent is the end product concept and also the brand.

     

    All said,there are a few encryption algorithms that are copyrighted, e.g. RC4 encryption (ref: http://arstechnica.com/security/2012/11/patent-suits-target-google-intel-hundreds-more-for-encrypting-web-traffic/) but there are variations on it that are supposedly not covered simply because they have a different name, personally I'd have thought that the patent would have run out by now (or even just after it was published)! Anyway it appears its flawed, https://en.wikipedia.org/wiki/RC4

     

     

    Excellence reply, very informative!  I totally agree with comments regarding Apple, they seem to steal many people ideas even the ones protected; then they just pay them off in court with the big stack of cash they're sitting on. 

     

    I imagine algorithms are very hard to copy and pass off as your own work due to the nature of the mathematics; It would be like someone trying to say they came up with e =mc2 :tease-03: 

     

    Going to give them links a read now, thanks for replying 0x00! :)

     

     

  6. Thank you for reply. 

     

    To be blunt, is not much can do and is a waste of time unless you actually get a patent on said code. Even then is not easy to prove it.

    Most people are not willing to spend the thousands to do this.

     

    I imagine it is very hard to prove, luckily I haven't had this happen to me. Fingers crossed that I never do; Just something I have always wondered and never really been able to hard much information on it. Like you said it's hard to prove and even harder to states what's copied and what is clearly just code wrote similar. 

     

    You may also discover that someone before you holds patents on what you have.

    You mean you could spend months working on a project not copying anyone else's work and coming up with the ideas and design all by yourself only to discover you have wrote something similar to something someone has patented?   

  7. First let me start by saying I'm not looking to copy someone else's code but better understand where the line is drawn for people copying my own code. 

     

    All developers at some point will have used others code in there own work. If you see something that inspires you, you may decided to use that code in your design. In some degree this maybe classed as fair use depending on the quantity of code you copy. 

     

    Another developer may taken an entire php file, function, class, CSS sheet, HTML file and use this in there work / pass this off as there own work. This is blatant plagiarism. 

     

    However what is stopping a developer from taking an entire piece of code and editing every aspect of the file to make it his own? 

     

    For instance a designer my change the names of the styles and perhaps change the order of the properties and there values slightly; He may also move around parts of the html. In doing so causes the design to look different to your own but still the copying your work no the less. 

     

    Another instance maybe that a PHP developer uses your entire code / software package and change the names of the variables, classes and methods; He may also change the order in which the methods appear and even change some similar functions to use alternatives such as loops. Again this causes the program to do exactly what your intends to do, however the source code will now look different to your own. 

     

    How far can someone go back doing these actions? 

     

    Is this legal? 

     

    How best would you be able to prove it?

  8. Apologise, for some reason my text hasn't posted. 

     

     

    $tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
    $tracking_file                 =  fopen($tracking_file_location, "r") or die("Unable to open file!");
    $tracking_file_size        =  filesize($tracking_file_location);
    $tracking_file_text        =  fread($tracking_file,$tracking_file_size);
    fclose($tracking_file);
     
    
  9.  

    $tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
    $tracking_file                 =  fopen("$tracking_file_location", "r") or die("Unable to open file!");
    $tracking_file_size        =  filesize("$tracking_file_location");
    $tracking_file_text        =  fread($tracking_file,$tracking_file_size);
    fclose($tracking_file);
    
  10. I'm trying to create a part of a script where by the system will generate a sku code and loop through out to see if this exists in the database, if the sku does the script adds one too the code so 001 will turn to 002 then it will keep looping until it finds a SKU that isn't in the database. 

     

    However I can get the script to keep generating the new SKU codes but it will only test the first SKU code so the loop will keep going if it exists. 

     

     

    $number=001;
    if(isset($_POST['submit'])){
     
    $product = $_POST['product'];
    $brand = $_POST['brand'];
    $description = $_POST['description'];
    $contruct=strtoupper($product."-".$brand."-".$description);
    $number=sprintf("%03s",$number);
    $check_for=$contruct."-".$number;
     
    $query=$cc_db->query("SELECT `sku` FROM `product` WHERE `sku`='".$check_for."'");
    $fetch=$cc_db->fetch_object($query);
    $checking=$cc_db->num_rows($query);
    while($checking > 0){
    echo"$check_for is there : $checking rows : $fetch->sku<br>";
    $number=$number+1;
    $number=sprintf("%03s",$number);
    $check_for=$contruct."-".$number;
    }
    echo $checking;
    echo $check_for;
    }
    
  11. Hi, I am quite new to using php classes so it maybe something simple here, however I am trying to establish to connection to two different databases using one PHP class; The problem is that this will work for one but when I create a new connection they will both fail. 

     

     

    <?php
    putenv("TZ=Europe/London");
     
    // start database connection
    $funky_db = new Database('xxxx', 'xxxx', 'xxxx', 'xxxx');
     
    // start database connection
    $funky_cc = new Database('xxxx', 'xxxx', 'xxxx', 'xxxx');
     
    class Database {
     
        private $host;
        private $user;
        private $pass;
        private $name;
        private $link;
        private $error;
        private $errno;
        private $query;
     
        function __construct($host, $user, $pass, $name = "", $conn = 1) {
            $this -> host = $host;
            $this -> user = $user;
            $this -> pass = $pass;
            if (!empty($name)) $this -> name = $name;      
            if ($conn == 1) $this -> connect();
        }
     
        function __destruct() {
            @mysql_close($this->link);
        }
     
        public function connect() {
            if ($this -> link = mysql_connect($this -> host, $this -> user, $this -> pass, TRUE)) {
                if (!empty($this -> name)) {
                    if (!mysql_select_db($this -> name)) $this -> exception("Could not connect to the database!");
                }
            } else {
                $this -> exception("Could not create database connection!");
            }
        }
     
        public function close() {
            @mysql_close($this->link);
        }
     
        public function query($sql) {
            if ($this->query = @mysql_query($sql)) {
                return $this->query;
            } else {
                $this->exception("Could not query database!".$this->name);
                return false;
            }
        }
     
        public function num_rows($qid) {
            if (empty($qid)) {         
                $this->exception("Could not get number of rows because no query id was supplied!");
                return false;
            } else {
                return mysql_num_rows($qid);
            }
        }
     
        public function fetch_array($qid) {
            if (empty($qid)) {
                $this->exception("Could not fetch array because no query id was supplied!");
                return false;
            } else {
                $data = mysql_fetch_array($qid);
            }
            return $data;
        }
     
        public function fetch_array_assoc($qid) {
            if (empty($qid)) {
                $this->exception("Could not fetch array assoc because no query id was supplied!");
                return false;
            } else {
                $data = mysql_fetch_array($qid, MYSQL_ASSOC);
            }
            return $data;
        }
     
    public function fetch_object($qid) {
            if (empty($qid)) {
                $this->exception("Could not fetch object assoc because no query id was supplied!");
                return false;
            } else {
                $data = mysql_fetch_object($qid);
            }
            return $data;
        }
     
        public function fetch_all_array($sql, $assoc = true) {
            $data = array();
            if ($qid = $this->query($sql)) {
                if ($assoc) {
                    while ($row = $this->fetch_array_assoc($qid)) {
                        $data[] = $row;
                    }
                } else {
                    while ($row = $this->fetch_array($qid)) {
                        $data[] = $row;
                    }
                }
            } else {
                return false;
            }
            return $data;
        }
     
        public function last_id() {
            if ($id = mysql_insert_id()) {
                return $id;
            } else {
                return false;
            }
        }
     
        private function exception($message) {
            if ($this->link) {
                $this->error = mysql_error($this->link);
                $this->errno = mysql_errno($this->link);
            } else {
                $this->error = mysql_error();
                $this->errno = mysql_errno();
            }
            if (PHP_SAPI !== 'cli') {
            ?>
     
                <div class="alert-bad">
                    <div>
                        Database Error
                    </div>
                    <div>
                        Message: <?php echo $message; ?>
                    </div>
                    <?php if (strlen($this->error) > 0): ?>
                        <div>
                            <?php echo $this->error; ?>
                        </div>
                    <?php endif; ?>
                    <div>
                        Script: <?php echo @$_SERVER['REQUEST_URI']; ?>
                    </div>
                    <?php if (strlen(@$_SERVER['HTTP_REFERER']) > 0): ?>
                        <div>
                            <?php echo @$_SERVER['HTTP_REFERER']; ?>
                        </div>
                    <?php endif; ?>
                </div>
            <?php
            } else {
                        echo "MYSQL ERROR: " . ((isset($this->error) && !empty($this->error)) ? $this->error:'') . "\n";
            };
        }
     
    }
    ?>
    
  12. Hi there, 

     

    I'm currently using ajax to update the mysql database via onchange or onclick 

     

    using checkboxes such as below:

     

     

    <input type="checkbox" name="wac_non_bce" id="wac_non_bce" <?php if($cue_wac_non_bce=="1"){echo"checked='checked'";}?> onchange="changeData(this.value, 'wac_non_bce', '<?php echo"$add_prod_id";?>')" />
    

     

    The this.value only returns 'on' when checking and unchecking the box; 

     

    Which is for clear reasons not helpful at all 

     

    Has any one come across this issue before?

     

     

  13. I'm running a function and within the function is coding that helps populate a drop down with brand names for a product. 

     

    If the brand from the mysql database with is defined and working as $cue_brand matches the populated option it should be putting in the selected coding. However it is not, the options are populating correctly and the $cue_brand is correct so I can not see what the issue might be

    if($drop_type=="brand"){
    $type_query=mysql_query("SELECT * FROM `brands` ORDER BY `brand` ASC ");
    while($get_type=mysql_fetch_object($type_query)){
    if($cue_brand=="$get_type->brand"){$selected="selected='selected'";}else{$selected="";}
    echo '<option value="'.$get_type->brand.'" '.$selected.'>'.$get_type->brand.'</option>';
    }
    }
    
  14. Hi Guys, 

     

    I'm looking for an excellent image manager for my website, it will be for uploading large image files for products to be sold online, the image program would need to be easy to install and integrate with my system.

     

    Preferable written mainly in PHP, It would need to reduce the size of the image but keep the quality of the image still.

     

    Kind of the same as how image manage their image uploads, or Photobucket.

     

    It doesn't have to be FREE, I don't mind forking out for a quality programme. But will also use a FREE open source program if it does the job. 

     

    Has anyone got any ideas or links to where I could find the best options. 

     

    I have researched this myself and found basic scripts, this isn't what I'm looking for. 

     

    Cheers for reading guys. 

  15. I'm creating a CSV file using php and what to extract data from mysql however each record needs to be on a new line and the current coding isn't doing this. Any suggestions?

     

     

    <?php
    include "common/db_connect.php";
    $date = date("Y-m-d");
    $rand = rand(10000000000,999999999999999999);
    $query=mysql_query("SELECT * FROM `DPD` WHERE `date`='$date' AND `submitted`='0'");
    $content="";
     
      while($fetch_DPD=mysql_fetch_object($query)){
     
      $content .= "".$fetch_DPD->ref.",".$fetch_DPD->date.",".$fetch_DPD->name.",".$fetch_DPD->add1.",".$fetch_DPD->add3.",".$fetch_DPD->add4.",".$fetch_DPD->post_code.",".$fetch_DPD->country_code.",".$fetch_DPD->service.",".$fetch_DPD->no_of_parcels.",".$fetch_DPD->weight.", ".$fetch_DPD->tele.", ".$fetch_DPD->SMS.", ".$fetch_DPD->email.", ".$fetch_DPD->value.", ".$fetch_DPD->description."" . PHP_EOL;
     
         $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/admin/temp/".$rand.".csv","wb");
     fwrite($fp,$content);
      fclose($fp);
      }
     
    ?>
    
  16. Thank you for your response,  I have edited the code and getting an error for the foreach loop; 

     

    Where have I gone wrong? 

    <?php
    include "common/db_connect.php";
                $date = date("Y-m-d");
    if($_POST['submit']){ 
        foreach($_POST['id'] as $record_id => $nothing_useful){
    mysql_query("UPDATE `DPD` SET `weight` ='".$_POST['weight'][$record_id]."', `service`='".$_POST['service'][$record_id]."' WHERE `ref` ='".$record_id."'");
        } 
    echo"Submitted";
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Funky Chalk</title>
    <link rel="stylesheet" href="css/960.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="css/template.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="css/colour.css" type="text/css" media="screen" charset="utf-8" />
    </head>
    <body>
        <div id="container">
    <?php include("nav-bar.php"); ?>
     
     <div id="content" class="container_16 clearfix">
       <form id="form1" method="post" action="">
         <table width="90%" border="1">
           <tr>
             <td><div align="center"><strong> </strong></div></td>
             <td><strong>Order</strong></td>
             <td><strong>Service</strong></td>
             <td><strong>Weight</strong></td>
                </tr>
           <?php 
    $query=mysql_query("SELECT * FROM `delivery_information` WHERE `date`='$date'");
    while($fetch_DI=mysql_fetch_object($query)){
    $fetchDPD=mysql_fetch_object(mysql_query("SELECT * FROM `DPD` WHERE `ref`='$fetch_DI->customer_ref'"));
    echo'
    <tr>
    <td><input name="id['.$fetchDPD->ref.']" type="checkbox" id="checkbox" checked="checked" /></td>
    <td>
    ';
    $string=mysql_query("SELECT * FROM `delivery_items` WHERE `customer_ref`='$fetch_DI->customer_ref'");
    while($fetch_items=mysql_fetch_object($string)){
    echo"<span class='paraProducts'>".$fetch_items->item."</span><br>";
    }
    echo"<span class='paraDetails'><font color='#0099CC'>".$fetch_DI->contact_name."</font> Order ID: <font color='#0099CC'>".$fetch_DI->customer_ref."</font></span>";
    echo"</td>";
     
    echo'<td valign="top"><select name="service['.$fetchDPD->ref.']" id="select">';
    echo"<option value='12'"; if($fetchDPD->service=="12"){echo'selected="selected"';} echo">Next Day</option>";
    echo"<option value='11'"; if($fetchDPD->service=="11"){echo'selected="selected"';} echo">Two Day</option>";
    echo"<option value='59'"; if($fetchDPD->service=="59"){echo'selected="selected"';} echo">Hermes</option>";
    echo"<option value='19'"; if($fetchDPD->service=="19"){echo'selected="selected"';} echo">Classic</option>";
    echo"<option value='10'"; if($fetchDPD->service=="10"){echo'selected="selected"';} echo">Express Air</option>";
    echo"</select> to ".$fetch_DI->country_code." (".$fetch_DI->post_code.")</td>";
     
    echo'<td><input name="weight['.$fetchDPD->ref.']" type="text" id="textfield" size="2" /> 
    KG</td>
    </tr>';
     
     
    }
    ?>
           <tr>
             <td colspan="4"><div align="right">
               <input type="submit" name="submit" id="submit" value="Submit" />
               </div></td>
                </tr>
              </table>
         <p> </p>
         <p> </p>
       </form>
       <p> </p>
                  <p> </p>
            </div>
        </div>
    </body>
    </html>
    
  17. This page is too populate a table of orders that is going out for delivery it then needs to allow a user to select a service and add the weight.

     

    As there will be no idea how many rows will be present nor the names of the input how can I declare the inputs so I can successfully update the records with the selected service and weights.

  18. How would I submit the below info?

     

     

    <?php
    include "common/db_connect.php";
                $date = date("Y-m-d");
    if($_POST['button']){ 
     
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Funky Chalk</title>
    <link rel="stylesheet" href="css/960.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="css/template.css" type="text/css" media="screen" charset="utf-8" />
    <link rel="stylesheet" href="css/colour.css" type="text/css" media="screen" charset="utf-8" />
    </head>
    <body>
        <div id="container">
    <?php include("nav-bar.php"); ?>
     
     <div id="content" class="container_16 clearfix">
            <table width="90%" border="1">
                    <tr>
                      <td width="71%"><strong>Order</strong></td>
                      <td width="22%"><strong>Service</strong></td>
                      <td width="7%"><strong>Weight</strong></td>
                    </tr>
              <?php 
    $query=mysql_query("SELECT * FROM `delivery_information` WHERE `date`='$date'");
    while($fetch_DI=mysql_fetch_object($query)){
    $fetchDPD=mysql_fetch_object(mysql_query("SELECT * FROM `DPD` WHERE `ref`='$fetch_DI->customer_ref'"));
    echo"
    <tr>
    <td>
    ";
    $string=mysql_query("SELECT * FROM `delivery_items` WHERE `customer_ref`='$fetch_DI->customer_ref'");
    while($fetch_items=mysql_fetch_object($string)){
    echo"<span class='paraProducts'>".$fetch_items->item."</span><br>";
    }
    echo"<span class='paraDetails'><font color='#0099CC'>".$fetch_DI->contact_name."</font> Order ID: <font color='#0099CC'>".$fetch_DI->customer_ref."</font></span>";
    echo"</td>";
     
    echo"<td valign='top'><select name='service_".$fetchDPD->ref."' id='select'>";
    echo"<option value='12'"; if($fetchDPD->service=="12"){echo'selected="selected"';} echo">Next Day</option>";
    echo"<option value='11'"; if($fetchDPD->service=="11"){echo'selected="selected"';} echo">Two Day</option>";
    echo"<option value='59'"; if($fetchDPD->service=="59"){echo'selected="selected"';} echo">Hermes</option>";
    echo"<option value='19'"; if($fetchDPD->service=="19"){echo'selected="selected"';} echo">Classic</option>";
    echo"<option value='10'"; if($fetchDPD->service=="10"){echo'selected="selected"';} echo">Express Air</option>";
    echo"</select> to ".$fetch_DI->country_code." (".$fetch_DI->post_code.")</td>";
     
    echo'<td><input name="weight_'.$fetchDPD->ref.'" type="text" id="textfield" size="2" /> 
    KG</td>
    </tr>';
     
     
    }
    ?>
     
                    <tr>
                      <td colspan="3"><div align="right">
                        <input type="button" name="button" id="button" value="Submit" style="margin:3px;" />
                      </div></td>
                    </tr>
                  </table>
                  <p> </p>
                  <p> </p>
            </div>
        </div>
    </body>
    </html>
    
×
×
  • 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.