Exemplo n.º 1
0
 /**
  * get 'update' query
  *
  * @param string $table_name affected table
  * @param ArrayObject $data
  * @param string $condition target row 
  *
  * @return string  
  *
  */
 public static function get_update_query($table_name = '', array $data = NULL, $condition = '') {
     foreach ($data as $key => $value) {
         $data[$key] = set_type($value);
     }
     $fields = implode('=?,', array_keys($data));
     $fields.= '=?';
     $temp[] = explode('?', $fields);
     $ct = 0;
     $upd = "";
     foreach ($data as $key => $value)
         $upd.=$temp[0][$ct++] . $value;
     return "UPDATE $table_name SET $upd WHERE $condition";
 }
Exemplo n.º 2
0
function get_info() {
	reset_product_array();
	get_fields();
	cleanup();
	set_skus();
	set_vendor_code();
	set_sku_str();
	set_brand();
	set_name();
	set_type();
	set_price();
	set_features();
	set_description();
	set_keywords();
	set_main_image();
	output_product_str();
}
Exemplo n.º 3
0
         }
         if ($_REQUEST['type'] == 'SRV') {
             if (!preg_match('/\\..+$/', $_REQUEST['address'])) {
                 $srvaddress = $_REQUEST['address'] . "." . $domain;
             } else {
                 $srvaddress = $_REQUEST['address'];
             }
             $params[':srvaddress'] = $srvaddress;
             $params[':distance'] = $_REQUEST['distance'];
             $params[':weight'] = $_REQUEST['weight'];
             $params[':port'] = $_REQUEST['port'];
             $q = "insert into records\n            (domain_id,host,type,val,distance,weight,port,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            :srvaddress,\n            :distance,\n            :weight,\n            :port,\n            '" . $_REQUEST['ttl'] . "')";
         }
         if ($_REQUEST['type'] == 'SPF') {
             $params[':address'] = $_REQUEST['address'];
             $q = "insert into records\n            (domain_id,host,type,val,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            :address,\n            '" . $_REQUEST['ttl'] . "')";
         }
         $stmt = $pdo->prepare($q);
         $stmt->execute($params) or die(print_r($stmt->errorInfo()));
         set_msg("Record added successfully!");
         header("Location: {$base_url}&mode=records&domain=" . urlencode($domain));
         exit;
     }
 } else {
     if ($_REQUEST['record_mode'] == 'delete') {
         // Get record info
         $q = "select * from records where record_id='" . $_REQUEST['record_id'] . "' limit 1";
         $stmt = $pdo->query($q) or die(print_r($pdo->errorInfo()));
         $row = $stmt->fetch();
         $smarty->assign('type', get_type($row['type']));
         $smarty->assign('host', $row['host']);
Exemplo n.º 4
0
 /**
  * insert new data
  * 
  * @param string $table table name
  * @param string $data new data
  * @return none
  * 
  */
 public function insertRecords($table, $data) {
     $fields = "";
     $values = "";
     foreach ($data as $f => $v):
         $fields .= "`$f`,";
         $values .= set_type($v);
     endforeach;
     $fields = substr($fields, 0, -1);
     $values = substr($values, 0, -1);
     $insert = "INSERT INTO $table ({$fields}) VALUES({$values})";
     $this->executeQuery($insert);
     return true;
 }
Exemplo n.º 5
0
 public function search($field, $term) {
     list($tblname, $fields, $id, $is_auto) = ORMHelper::analize($this);
     $term = set_type($term);
     $query = "SELECT * FROM $tblname WHERE $field = $term";
     return data_model()->cacheQuery($query);
 }
Exemplo n.º 6
0
function verify_record($name, $type, $address, $distance, $weight, $port, $ttl)
{
    // convert type to single character format
    $type = set_type($type);
    // Make sure name was given for non A and MX records
    if ($type != 'A' && $type != 'M' && $name == "") {
        return "no Hostname supplied";
    }
    // verify A record
    if ($type == 'A') {
        if (validate_ip($address) == FALSE) {
            return "\"{$address}\" is not a valid A record address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid A record name";
        }
    }
    if ($type == '=') {
        if (validate_ip($address) == FALSE) {
            return "\"{$address}\" is not a valid A+PTR record address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid A+PTR record name";
        }
    }
    // verify AAAA record
    if ($type == '3') {
        if (validate_ipv6($address) == FALSE) {
            return "\"{$address}\" is not a valid AAAA record address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid AAAA record name";
        }
    }
    // verify AAAA+PTR record
    if ($type == '6') {
        if (validate_ipv6($address) == FALSE) {
            return "\"{$address}\" is not a valid AAAA+PTR record address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid AAAA+PTR record name";
        }
    }
    // verify NS record
    if ($type == 'N') {
        if (validate_ip($address) != FALSE) {
            return "\"{$address}\" should not be an IP address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid NS record name";
        }
    }
    // verify MX record
    if ($type == 'M') {
        if (validate_ip($name)) {
            return "MX records can not be an IP address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid MX record name";
        }
        if (!preg_match('/^([0-9])+$/i', $distance)) {
            return "\"{$distance}\" is not a valid MX distance";
        }
    }
    // verify PTR
    if ($type == 'P') {
        if (!preg_match('/^.*\\.in-addr.arpa\\.*$/i', $name) && !preg_match('/^.*\\.ip6.arpa\\.*$/i', $name)) {
            return "PTR \"{$name}\" does not end in .in-addr.arpa or ip6.arpa.";
        }
    }
    // verify CNAME record
    if ($type == 'C') {
        if (validate_ip($address)) {
            return "CNAME records can not point to an IP address";
        }
        if (check_domain_name_format($name) == FALSE) {
            return "\"{$name}\" is not a valid CNAME record name";
        }
        if (validate_domain_name($address) == FALSE) {
            return "\"{$address}\" is not a valid CNAME record address";
        }
    }
    // verify SRV record
    if ($type == 'V') {
        if (!preg_match('/^_.*\\._.*$/i', $name)) {
            return "SRV \"{$name}\" should be in the format _service._protocol";
        }
        if ($distance > 65535 || !preg_match('/^([0-9])+$/i', $distance)) {
            return "SRV distance must be a numeric value between 0 and 65535";
        }
        if ($weight > 65535 || !preg_match('/^([0-9])+$/i', $weight)) {
            return "SRV weight must be a numeric value between 0 and 65535";
        }
        if ($port > 65535 || !preg_match('/^([0-9])+$/i', $port)) {
            return "SRV port must be a numeric value between 0 and 65535";
        }
    }
    // make sure a TTL was given
    if ($ttl == "") {
        return "no TTL given";
    }
    return 'OK';
}
Exemplo n.º 7
0
                             } else {
                                 if ($_REQUEST['type'] == 'SRV') {
                                     if (!preg_match('/\\..+$/', $_REQUEST['address'])) {
                                         $srvaddress = $_REQUEST['address'] . ".DOMAIN";
                                     } else {
                                         $srvaddress = $_REQUEST['address'];
                                     }
                                     $params[':srvaddress'] = $srvaddress;
                                     $params[':distance'] = $_REQUEST['distance'];
                                     $params[':weight'] = $_REQUEST['weight'];
                                     $params[':port'] = $_REQUEST['port'];
                                     $q = "insert into default_records\n                (group_owner_id,host,type,val,distance,weight,port,ttl,default_type) values (\n                '" . $user_info['cid'] . "',\n                '{$name}',\n                '" . set_type($_REQUEST['type']) . "',\n                :srvaddress,\n                :distance,\n                :weight,\n                :port,\n                '" . $_REQUEST['ttl'] . "',\n                '{$default_type}')";
                                 } else {
                                     if ($_REQUEST['type'] == 'SPF') {
                                         $params[':address'] = $_REQUEST['address'];
                                         $q = "insert into default_records\n            (group_owner_id,host,type,val,ttl,default_type) values(\n            '" . $user_info['cid'] . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            :address,\n            '" . $_REQUEST['ttl'] . "',\n            '{$default_type}')";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $stmt = $pdo->prepare($q);
         $stmt->execute($params) or die(print_r($stmt->errorInfo()));
         set_msg("Record added successfully!");
         header("Location: {$base_url}&mode=default_records");
         exit;
     }
 } else {
Exemplo n.º 8
0
                 if ($_REQUEST['type'] == 'NS') {
                     $q = "insert into default_records\n            (group_owner_id,host,type,val,ttl,default_type) values(\n            '" . $user_info['cid'] . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "',\n            '{$default_type}')";
                 } else {
                     if ($_REQUEST['type'] == 'CNAME') {
                         $q = "insert into default_records\n            (group_owner_id,host,type,val,ttl,default_type) values(\n            '" . $user_info['cid'] . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "',\n            '{$default_type}')";
                     } else {
                         if ($_REQUEST['type'] == 'TXT') {
                             $q = "insert into default_records\n            (group_owner_id,host,type,val,ttl,default_type) values(\n            '" . $user_info['cid'] . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "',\n            '{$default_type}')";
                         } else {
                             if ($_REQUEST['type'] == 'SRV') {
                                 if (!ereg("\\..+\$", $_REQUEST['address'])) {
                                     $srvaddress = $_REQUEST['address'] . ".DOMAIN";
                                 } else {
                                     $srvaddress = $_REQUEST['address'];
                                 }
                                 $q = "insert into default_records\n        (group_owner_id,host,type,val,distance,weight,port,ttl,default_type) values (\n        '" . $user_info['cid'] . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($srvaddress) . "',\n            '" . mysql_escape_string($_REQUEST['distance']) . "',\n        '" . mysql_escape_string($_REQUEST['weight']) . "',\n        '" . mysql_escape_string($_REQUEST['port']) . "',\n            '" . $_REQUEST['ttl'] . "',\n            '{$default_type}')";
                             }
                         }
                     }
                 }
             }
         }
         mysql_query($q) or die(mysql_error());
         set_msg("Record added successfully!");
         header("Location: {$base_url}&mode=default_records");
         exit;
     }
 } else {
     if ($_REQUEST['record_mode'] == 'delete') {
         // Get record info
         $q = "select * from default_records where record_id='" . $_REQUEST['record_id'] . "' limit 1";
Exemplo n.º 9
0
         if ($_REQUEST['type'] == 'PTR') {
             $q = "insert into records\n            (domain_id,host,type,val,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "')";
         }
         if ($_REQUEST['type'] == 'TXT') {
             $q = "insert into records\n            (domain_id,host,type,val,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "')";
         }
         if ($_REQUEST['type'] == 'CNAME') {
             $q = "insert into records\n            (domain_id,host,type,val,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($_REQUEST['address']) . "',\n            '" . $_REQUEST['ttl'] . "')";
         }
         if ($_REQUEST['type'] == 'SRV') {
             if (!ereg("\\..+\$", $_REQUEST['address'])) {
                 $srvaddress = $_REQUEST['address'] . "." . $domain;
             } else {
                 $srvaddress = $_REQUEST['address'];
             }
             $q = "insert into records\n            (domain_id,host,type,val,distance,weight,port,ttl) values(\n            '" . get_dom_id($domain) . "',\n            '{$name}',\n            '" . set_type($_REQUEST['type']) . "',\n            '" . mysql_escape_string($srvaddress) . "',\n            '" . mysql_escape_string($_REQUEST['distance']) . "',\n            '" . mysql_escape_string($_REQUEST['weight']) . "',\n            '" . mysql_escape_string($_REQUEST['port']) . "',\n            '" . $_REQUEST['ttl'] . "')";
         }
         mysql_query($q) or die(mysql_error());
         set_msg("Record added successfully!");
         header("Location: {$base_url}&mode=records&domain=" . urlencode($domain));
         exit;
     }
 } else {
     if ($_REQUEST['record_mode'] == 'delete') {
         // Get record info
         $q = "select * from records where record_id='" . $_REQUEST['record_id'] . "' limit 1";
         $result = mysql_query($q) or die(mysql_error());
         $row = mysql_fetch_array($result);
         $smarty->assign('type', get_type($row['type']));
         $smarty->assign('host', $row['host']);
         $smarty->assign('cancel_url', "{$base_url}&mode=records&domain=" . urlencode($domain) . "&record_mode=delete_cancelled");