InsertRow() public method

Inserts a row into a table in the connected database
public InsertRow ( string $tableName, array $valuesArray ) : integer
$tableName string The name of the table
$valuesArray array An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect)
return integer Returns last insert ID on success or FALSE on failure
Esempio n. 1
0
 public function addNew($data)
 {
     $db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH');
     $d = array('name' => MySQL::SQLValue(strtoupper(trim($data['u']))), 'password' => MySQL::SQLValue(MD5($data['p'])));
     $result = $db->InsertRow('users', $d);
     return $result;
 }
Esempio n. 2
0
 function insertPaymentMethod($data)
 {
     $db = new MySQL();
     $paymentMethod['cdmodalitapagamento'] = MySQL::SQLValue($data[0]);
     $paymentMethod['dsmodalitapagamento'] = MySQL::SQLValue($data[1]);
     if (!empty($data[2]) && strtolower($data[2]) == "true") {
         $paymentMethod['cdvisibilita'] = MySQL::SQLValue(1);
     } else {
         $paymentMethod['cdvisibilita'] = MySQL::SQLValue(2);
     }
     if (empty($data[3])) {
         $paymentMethod['dssconto'] = MySQL::SQLValue("0");
     } else {
         $paymentMethod['dssconto'] = MySQL::SQLValue($data[3]);
     }
     $db->InsertRow("ps_webshop_modpagamento", $paymentMethod);
 }
Esempio n. 3
0
 /**
  * @param $data
  * @return bool|int
  */
 public function membership_role_create($data)
 {
     $values = array();
     foreach ($data as $key => $value) {
         if ($key == 'name') {
             $values[$key] = MySQL::SQLValue($value);
         } else {
             $values[$key] = MySQL::SQLValue($value, MySQL::SQLVALUE_NUMBER);
         }
     }
     $table = $this->kga['server_prefix'] . "membershipRoles";
     $result = $this->conn->InsertRow($table, $values);
     if (!$result) {
         $this->logLastError('membership_role_create');
         return false;
     }
     return $this->conn->GetLastInsertID();
 }
Esempio n. 4
0
 /**
  * Metodo utilizzato per leggere le informazioni da ERP
  * e inserirle nella tabella vsecommerce_info
  */
 function readInfoEcommerce()
 {
     $content = $this->file_get_contents_utf8(FOLDER_UNZIP . FILE_INFO . ".txt");
     $array_field = explode("\n", $content);
     if ($this->checkInsertOrAppend(FILE_INFO) == 0) {
         $this->truncateTable("vsecommerce_info");
     }
     foreach ($array_field as $field_comb) {
         $data = explode("§", $field_comb);
         if (!$this->checkInfoExists(trim($data[0]))) {
             $values['field_name'] = MySQL::SQLValue(trim($data[0]));
             $values['value'] = MySQL::SQLValue(trim($data[1]));
             $db = new MySQL();
             $db->InsertRow("vsecommerce_info", $values);
         } else {
             $where['field_name'] = MySQL::SQLValue(trim($data[0]));
             $values['value'] = MySQL::SQLValue(trim($data[1]));
             $db = new MySQL();
             $db->UpdateRows("vsecommerce_info", $values, $where);
         }
     }
 }
function content_create_revision($id)
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('content_create_revision');
    $id = hook_filter('content_create_revision', $id);
    $tableName = DB_PREFIX . "content";
    $whereArray = array('id' => MySQL::SQLValue($id));
    $hmdb->SelectRows($tableName, $whereArray);
    if ($hmdb->HasRecords()) {
        $row = $hmdb->Row();
        $content_key = $row->key;
        $values["name"] = MySQL::SQLValue($row->name);
        $values["slug"] = MySQL::SQLValue($row->slug);
        $values["key"] = MySQL::SQLValue($row->key);
        $values["status"] = MySQL::SQLValue('revision');
        $values["parent"] = MySQL::SQLValue($row->id);
        $insert_revision_id = $hmdb->InsertRow($tableName, $values);
        unset($values);
        /** lưu field của bản revision content vào database */
        $tableName = DB_PREFIX . "field";
        $whereArray = array('object_id' => MySQL::SQLValue($id), 'object_type' => MySQL::SQLValue('content'));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            $count = $hmdb->RowCount();
            $i = 1;
            while ($row = $hmdb->Row()) {
                $values[$i]["name"] = MySQL::SQLValue($row->name);
                $values[$i]["val"] = MySQL::SQLValue($row->val);
                $values[$i]["object_id"] = MySQL::SQLValue($insert_revision_id);
                $values[$i]["object_type"] = MySQL::SQLValue('content');
                $i++;
            }
            foreach ($values as $value) {
                $hmdb->InsertRow($tableName, $value);
            }
        }
        /** lưu relationship của bản revision content vào database */
        $tableName = DB_PREFIX . "relationship";
        $whereArray = array('object_id' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            $count = $hmdb->RowCount();
            $i = 1;
            while ($row = $hmdb->Row()) {
                $values[$i]["relationship"] = MySQL::SQLValue($row->relationship);
                $values[$i]["target_id"] = MySQL::SQLValue($row->target_id);
                $values[$i]["object_id"] = MySQL::SQLValue($insert_revision_id);
                $i++;
            }
            foreach ($values as $value) {
                $hmdb->InsertRow($tableName, $value);
            }
        }
        return $insert_revision_id;
    } else {
        return FALSE;
    }
}
function taxonomy_ajax_add($key, $id_update = NULL)
{
    global $hmtaxonomy;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('taxonomy_ajax_add');
    $tax = $hmtaxonomy->hmtaxonomy;
    if (isset($tax[$key])) {
        $this_tax = $tax[$key];
        foreach ($_POST as $post_key => $post_val) {
            $primary = $this_tax['taxonomy_field']['primary_name_field']['name'];
            /** input này được dùng làm khóa tên chính */
            if ($post_key == $primary) {
                $tax_name = $post_val;
                $parent = hm_post('parent');
                if (!is_numeric($parent)) {
                    $parent = 0;
                }
                if ($parent == $id_update) {
                    $parent = 0;
                }
                if (isset($_POST['slug_of_' . $post_key])) {
                    if (is_numeric($id_update)) {
                        $tax_slug = $_POST['slug_of_' . $post_key];
                    } else {
                        $tax_slug = add_request_uri_custom($_POST['slug_of_' . $post_key]);
                    }
                } else {
                    switch ($_POST['accented_of_' . $post_key]) {
                        case 'true':
                            if (is_numeric($id_update)) {
                                $tax_slug = sanitize_title_with_accented($post_val);
                            } else {
                                $tax_slug = add_request_uri_with_accented($post_val);
                            }
                            break;
                        case 'false':
                            if (is_numeric($id_update)) {
                                $tax_slug = sanitize_title($post_val);
                            } else {
                                $tax_slug = add_request_uri($post_val);
                            }
                            break;
                        default:
                            if (is_numeric($id_update)) {
                                $tax_slug = sanitize_title($post_val);
                            } else {
                                $tax_slug = add_request_uri($post_val);
                            }
                    }
                }
                /** lưu taxonomy vào data base */
                $tableName = DB_PREFIX . 'taxonomy';
                $values["name"] = MySQL::SQLValue($tax_name);
                $values["slug"] = MySQL::SQLValue($tax_slug);
                $values["key"] = MySQL::SQLValue($key);
                $values["parent"] = MySQL::SQLValue($parent);
                $values["status"] = MySQL::SQLValue('public');
                if (is_numeric($id_update)) {
                    unset($values["status"]);
                    $whereArray = array('id' => $id_update);
                    $hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
                    $insert_id = $id_update;
                    up_date_request_uri_object($tax_slug, $insert_id, 'taxonomy', 'has_object');
                } else {
                    $insert_id = $hmdb->InsertRow($tableName, $values);
                    up_date_request_uri_object($tax_slug, $insert_id, 'taxonomy', 'null_object');
                }
                $latest_array = array('id' => $insert_id, 'name' => $tax_name, 'slug' => $tax_slug, 'key' => $key, 'parent' => $parent);
                unset($values);
            }
        }
        foreach ($_POST as $post_key => $post_val) {
            /** lưu taxonomy field vào data */
            if (is_numeric($insert_id)) {
                $tableName = DB_PREFIX . 'field';
                $values["name"] = MySQL::SQLValue($post_key);
                $values["val"] = MySQL::SQLValue($post_val);
                $values["object_id"] = MySQL::SQLValue($insert_id, MySQL::SQLVALUE_NUMBER);
                $values["object_type"] = MySQL::SQLValue('taxonomy');
                if (is_numeric($id_update)) {
                    $whereArray = array('object_id' => MySQL::SQLValue($id_update, MySQL::SQLVALUE_NUMBER), 'object_type' => MySQL::SQLValue('taxonomy'), 'name' => MySQL::SQLValue($post_key));
                    $hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
                } else {
                    $hmdb->InsertRow($tableName, $values);
                }
                unset($values);
            }
        }
        /** show table */
        $status = hm_get('status', 'public');
        $perpage = hm_get('perpage', '30');
        $return_array = taxonomy_show_data($key, $status, $perpage, false);
        $return_array['latest'] = $latest_array;
        return json_encode($return_array, true);
    }
}
Esempio n. 7
0
 function insertTipoEffettoScadenza($data)
 {
     $db = new MySQL();
     $tipoEff['id_tpe'] = MySQL::SQLValue($data[0]);
     $tipoEff['ds_tpe'] = MySQL::SQLValue($data[1]);
     $db->InsertRow("vs_tsa_tipoeff", $tipoEff);
 }
Esempio n. 8
0
 public function add($data)
 {
     $db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH');
     $result = $db->InsertRow('log', $data);
     return $result;
 }
/** Load template user box */
function ajax_add_user($args = array())
{
    global $hmuser;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('ajax_add_user');
    if (isset($args['id_update'])) {
        $id_update = $args['id_update'];
    } else {
        $id_update = NULL;
    }
    $user_login = hm_post('user_login');
    $password = hm_post('password');
    $password2 = hm_post('password2');
    $nicename = hm_post('nicename');
    $user_email = hm_post('user_email');
    $userrole = hm_post('userrole');
    $user_group = hm_post('user_group', 0);
    $salt = rand(100000, 999999);
    $user_activation_key = '0';
    if ($password != $password2) {
        return json_encode(array('status' => 'error', 'mes' => _('Hai mật khẩu nhập vào không khớp')));
        hm_exit();
    }
    $tableName = DB_PREFIX . "users";
    /** check trùng user login */
    if (!is_numeric($id_update)) {
        $whereArray = array('user_login' => MySQL::SQLValue($user_login));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            return json_encode(array('status' => 'error', 'mes' => _('Tài khoản này đã tồn tại')));
            hm_exit();
        }
    }
    $password_encode = hm_encode_str(md5($password . $salt));
    /** Thêm tài khoản */
    $values["user_login"] = MySQL::SQLValue($user_login);
    $values["user_nicename"] = MySQL::SQLValue($nicename);
    $values["user_email"] = MySQL::SQLValue($user_email);
    $values["user_activation_key"] = MySQL::SQLValue($user_activation_key);
    $values["user_role"] = MySQL::SQLValue($userrole);
    $values["user_group"] = MySQL::SQLValue($user_group);
    if (is_numeric($id_update)) {
        if ($password != '') {
            $values["user_pass"] = MySQL::SQLValue($password_encode);
            $values["salt"] = MySQL::SQLValue($salt);
        }
        $whereArray = array('id' => $id_update);
        $hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
        $insert_id = $id_update;
    } else {
        $values["user_pass"] = MySQL::SQLValue($password_encode);
        $values["salt"] = MySQL::SQLValue($salt);
        $insert_id = $hmdb->InsertRow($tableName, $values);
    }
    /** Lưu user field */
    foreach ($_POST as $post_key => $post_val) {
        if (is_numeric($insert_id)) {
            if (is_array($post_val)) {
                $post_val = json_encode($post_val);
            }
            $tableName = DB_PREFIX . 'field';
            if ($post_key != 'password' and $post_key != 'password2') {
                $values["name"] = MySQL::SQLValue($post_key);
                $values["val"] = MySQL::SQLValue($post_val);
                $values["object_id"] = MySQL::SQLValue($insert_id, MySQL::SQLVALUE_NUMBER);
                $values["object_type"] = MySQL::SQLValue('user');
                if (is_numeric($id_update)) {
                    $whereArray = array('object_id' => MySQL::SQLValue($id_update, MySQL::SQLVALUE_NUMBER), 'object_type' => MySQL::SQLValue('user'), 'name' => MySQL::SQLValue($post_key));
                    $hmdb->AutoInsertUpdate($tableName, $values, $whereArray);
                } else {
                    $hmdb->InsertRow($tableName, $values);
                }
            }
            unset($values);
        }
    }
    if (is_numeric($id_update)) {
        return json_encode(array('status' => 'updated', 'mes' => _('Đã sửa thông tin tài khoản : ' . $user_login)));
    } else {
        return json_encode(array('status' => 'success', 'mes' => _('Đã thêm tài khoản : ' . $user_login)));
    }
}
Esempio n. 10
0
 /**
  * Metodo utilizzato per valorizzare le etichette delle categorie in base alle lingue dell'ecommerce e i tracciati passati da ERP
  * 
  * @param type $arrCat Array contenente i dati della categoria ricevuti dal tracciato ERP
  * @param type $id_category Id della categoria inserita in Prestashop
  * @param type $lang Array delle lingue ricevuto dal tracciato ERP (Se empty vengono utilizzati i valori del tracciato di default)
  */
 function insertCategoryLang($arrCat, $id_category, $lang)
 {
     foreach ($this->ecommerce_lang_by_erp as $erp_lang => $ps_id_lang) {
         $values = NULL;
         $values['id_category'] = MySQL::SQLValue($id_category);
         $values['id_shop'] = MySQL::SQLValue(1);
         $values['id_lang'] = MySQL::SQLValue($ps_id_lang);
         if (!empty($lang[$erp_lang])) {
             $values['name'] = MySQL::SQLValue(str_replace("’", "'", $lang[$erp_lang]));
         } else {
             // recupero il valore di default della lingua che deve essere usato
             if (!empty($lang[$this->ecommerce_lang_by_erp[$this->default_language_ecommerce]])) {
                 $values['name'] = MySQL::SQLValue(str_replace("’", "'", $lang[$this->ecommerce_lang_by_erp[$this->default_language_ecommerce]]));
             } else {
                 if (isset($arrCat[2]) and !empty($arrCat[2])) {
                     $values['name'] = MySQL::SQLValue(html_entity_decode(str_replace("’", "'", str_replace("à", "à", str_replace(" ", " ", str_replace("Ã", "à", htmlentities(str_replace("à", "à", $arrCat[2]))))))));
                 } else {
                     $values['name'] = MySQL::SQLValue("-Categoria Senza Nome-");
                 }
             }
         }
         if (isset($arrCat[12]) and !empty($arrCat[12])) {
             $values['description'] = MySQL::SQLValue(mb_convert_encoding($arrCat[12], "HTML-ENTITIES", "UTF-8"));
         } else {
             if (isset($arrCat[2]) and !empty($arrCat[2])) {
                 $values['description'] = MySQL::SQLValue($arrCat[2]);
             } else {
                 $values['description'] = MySQL::SQLValue("-Categoria Senza Descrizione-");
             }
         }
         $values['link_rewrite'] = MySQL::SQLValue($this->slugify($arrCat[2]));
         $values['meta_title'] = MySQL::SQLValue(html_entity_decode(str_replace(" ", " ", str_replace("Ã", "à", htmlentities($arrCat[2])))));
         $values['meta_keywords'] = MySQL::SQLValue(" ");
         $values['meta_description'] = MySQL::SQLValue(" ");
         $db = new MySQL();
         $db->InsertRow("ps_category_lang", $values);
     }
 }
// This checks for errors and if there is one, terminates the script
// while showing the last MySQL error.
// $db->Kill() is the same as die($db->Error()) or exit($db->Error());
if ($db->Error()) {
    $db->Kill();
}
// You could also throw an exception on errors using:
// $db->ThrowExceptions = true;
// =========================================================================
// Example to insert a new row into a table and display it
// =========================================================================
// $arrayVariable["column name"] = formatted SQL value
$values["Color"] = MySQL::SQLValue("Violet");
$values["Age"] = MySQL::SQLValue(777, MySQL::SQLVALUE_NUMBER);
// Execute the insert
$result = $db->InsertRow("Test", $values);
// If we have an error
if (!$result) {
    // Show the error and kill the script
    $db->Kill();
} else {
    // No error, show the new record's ID
    echo "The new record's ID is: " . $db->GetLastInsertID() . "\n<br />\n";
    // Show the record using the values array to generate the WHERE clause
    // We will use the SelectRows() method to query the database
    $db->SelectRows("Test", $values);
    // Show the results in an HTML table
    echo $db->GetHTML();
}
// =========================================================================
// Example to delete a row (or rows) in a table matching a filter
Esempio n. 12
0
//prodcode
//descr
//model
//category
//url
//price
//trade
//stocklevel
//updated
//onorder
//webready
//supplier
//brand
$sql = "SELECT * from import_hkstock";
$gethk = $db->QueryArray($sql);
$new_id = $db->InsertRow("webstock", $insert);
if (!$new_id) {
    //print_r ($insert);
    die('Unable to write record to DB.');
}
unset($insert);
echo '</table>';
//echo('<input type="submit" name="submit" value="submit" />');
echo '</form>';
echo '<br><h4>Finished, you may close this page, </h4></body>';
// If there were no errors...
// Commit the transaction and save these records to the database
if ($db->TransactionEnd()) {
    $db->Kill();
    $db->Release();
    print "<br><h1>Succesful database write!</h1><br>";
/** Ajax upload */
function add_media()
{
    if (isset($_SERVER["CONTENT_LENGTH"])) {
        if ($_SERVER["CONTENT_LENGTH"] > (int) ini_get('post_max_size') * 1024 * 1024) {
            return json_encode(array('status' => 'error', 'content' => _('Dung lượng tệp tin gửi lên vượt quá giới hạn cho phép của máy chủ')));
            hm_exit();
        }
    }
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    @($media_group = hm_post('media_group'));
    if (!is_numeric($media_group)) {
        $media_group = 0;
    }
    $tableName = DB_PREFIX . 'media_groups';
    $whereArray = array('id' => MySQL::SQLValue($media_group));
    $hmdb->SelectRows($tableName, $whereArray);
    $count = $hmdb->RowCount();
    if ($count != '0') {
        $row = $hmdb->Row();
        $folder = $row->folder;
        $folder_part = get_media_group_part($media_group);
        $dir = BASEPATH . HM_CONTENT_DIR . '/uploads/' . $folder_part;
        if (!file_exists($dir)) {
            mkdir($dir);
            chmod($dir, 0777);
        }
        $dir_dest = BASEPATH . HM_CONTENT_DIR . '/uploads/' . $folder_part;
    } else {
        $folder = "/";
        $media_group = 0;
        $dir_dest = BASEPATH . HM_CONTENT_DIR . '/uploads';
    }
    $dir_pics = $dir_dest;
    $files = array();
    foreach ($_FILES['file'] as $k => $l) {
        foreach ($l as $i => $v) {
            if (!array_key_exists($i, $files)) {
                $files[$i] = array();
            }
            $files[$i][$k] = $v;
        }
    }
    $status = 'success';
    foreach ($files as $file) {
        $handle = new Upload($file, LANG);
        if ($handle->uploaded) {
            $handle->Process($dir_dest);
            if ($handle->processed) {
                /** tạo .htaccess */
                $fp = fopen($dir_dest . '/.htaccess', 'w');
                $content_htaccess = 'RemoveHandler .php .phtml .php3' . "\n" . 'RemoveType .php .phtml .php3';
                fwrite($fp, $content_htaccess);
                fclose($fp);
                /** upload thành công, lưu database thông số file */
                $file_is_image = 'false';
                $file_info = array();
                $file_info['file_src_name'] = $handle->file_src_name;
                $file_info['file_src_name_body'] = $handle->file_src_name_body;
                $file_info['file_src_name_ext'] = $handle->file_src_name_ext;
                $file_info['file_src_mime'] = $handle->file_src_mime;
                $file_info['file_src_size'] = $handle->file_src_size;
                $file_info['file_dst_name'] = $handle->file_dst_name;
                $file_info['file_dst_name_body'] = $handle->file_dst_name_body;
                $file_info['file_dst_name_ext'] = $handle->file_dst_name_ext;
                $file_info['file_is_image'] = $handle->file_is_image;
                $file_name = $file_info['file_src_name'];
                if ($file_info['file_is_image'] == TRUE) {
                    $file_is_image = 'true';
                    $file_info['image_src_x'] = $handle->image_src_x;
                    $file_info['image_src_y'] = $handle->image_src_y;
                    $file_info['image_src_bits'] = $handle->image_src_bits;
                    $file_info['image_src_pixels'] = $handle->image_src_pixels;
                    $file_info['image_src_type'] = $handle->image_src_type;
                    $file_info['image_dst_x'] = $handle->image_dst_x;
                    $file_info['image_dst_y'] = $handle->image_dst_y;
                    $file_info['image_dst_type'] = $handle->image_dst_type;
                    $handle->image_resize = true;
                    $handle->image_ratio_crop = true;
                    $handle->image_y = 512;
                    $handle->image_x = 512;
                    $handle->Process($dir_dest);
                    $file_info['thumbnail'] = $handle->file_dst_name;
                }
                $file_info = json_encode($file_info);
                $tableName = DB_PREFIX . 'media';
                $values["media_group_id"] = MySQL::SQLValue($media_group, MySQL::SQLVALUE_NUMBER);
                $values["file_info"] = MySQL::SQLValue($file_info);
                $values["file_name"] = MySQL::SQLValue($file_name);
                $values["file_folder"] = MySQL::SQLValue($folder);
                $values["file_is_image"] = MySQL::SQLValue($file_is_image);
                $insert_id = $hmdb->InsertRow($tableName, $values);
                unset($values);
                $status = 'success';
                $content[] = $insert_id;
            } else {
                $status = 'error';
                $content[] = $file_name . ' : ' . $handle->error;
            }
        } else {
            $status = 'error';
            $content[] = $file_name . ' : ' . $handle->error;
        }
    }
    if (is_array($content)) {
        $content = implode(", ", $content);
    }
    return json_encode(array('status' => $status, 'content' => $content, 'media_group' => $media_group));
}
Esempio n. 14
0
 function insertOrderDocumentsPdf()
 {
     /* Init directories e files */
     if (!is_dir(FOLDER_PDF)) {
         mkdir(FOLDER_PDF, 0777);
     }
     if (!is_dir(FOLDER_TMP_PDF)) {
         //$this -> fileLog("#15. Creazione directory temporanea per i PDF: " . $this -> folderTmpPdf);
         mkdir(FOLDER_TMP_PDF, 0777);
     }
     $files = glob(FOLDER_TMP_PDF . "*");
     // get all file names
     foreach ($files as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
     $zip = new \ZipArchive();
     $res = $zip->open(FOLDER_IMPORT_ROOT . "oi_b2b_allegati.zip");
     if ($res === TRUE) {
         $zip->extractTo(FOLDER_TMP_PDF);
         $zip->close();
     } else {
     }
     /* Fine Init directories e files */
     $filesPdf = glob(FOLDER_TMP_PDF . "*");
     $db = new MySQL();
     // get all file names
     foreach ($filesPdf as $filePdf) {
         $fullPath = $filePdf;
         $basename = basename($filePdf);
         $filename = $basename;
         $extension = "";
         $document_id = -1;
         $document_file_name = "";
         if (strpos($basename, '.') !== false) {
             $indexPoint = strrpos($basename, ".");
             $filename = substr($basename, 0, strlen($basename) - (strlen($basename) - $indexPoint));
             if ($indexPoint + 1 < strlen($basename)) {
                 $extension = substr($basename, $indexPoint + 1);
             }
         }
         if (strtolower($extension) == "pdf" && strpos($filename, '_') !== false) {
             $indexUnderscore = strpos($filename, "_");
             $document_id_string = substr($filename, 0, strlen($filename) - (strlen($filename) - $indexUnderscore));
             $document_file_name = "order" . $document_id_string . "t" . time();
             if ($indexUnderscore + 1 < strlen($filename)) {
                 $document_file_name = substr($filename, $indexUnderscore + 1);
             }
             $document_id = intval($document_id_string);
         }
         if ($document_id > 0) {
             $basenameDestination = $document_id . "_" . $document_file_name . ".pdf";
             $fullPathDestination = FOLDER_PDF . $basenameDestination;
             $fullPathSource = $fullPath;
             copy($fullPathSource, $fullPathDestination);
             $orderDocumentPdf['id_doc'] = MySQL::SQLValue($document_id);
             $orderDocumentPdf['filename'] = MySQL::SQLValue($basenameDestination);
             $orderDocumentPdf['uri'] = MySQL::SQLValue("/img/p/pdf/" . $basenameDestination);
             $db->InsertRow("vs_orderdocuments_attachments", $orderDocumentPdf);
         }
     }
 }
Esempio n. 15
0
 function insertRelatedProduct($data)
 {
     /*
     Idassociazione	int			si	Codice univoco dell'associazione
     Cdprodotto		char(50)	no	Codice del prodotto
     Cdaccessorio	char(50)	no	Codice del prodotto da associare al primo
     Dsaccessorio	char(1000)	no	Descrizione breve del prodotto associato
     flagAccessorio 	bool		Manca: se � = 1 e' un prodotto accessorio, altrimenti prod correlato.
     */
     /* DEVO CONTROLLARE CHE IL RECORD NON SIA APPARTENENTE ALAL GESTIONE DELLe TAGLIE */
     # faccio lo split in base al delimitatore per la gestione delle taglie
     $array_combination = explode(DELIMITATORE_TAGLIE, $data[1]);
     if (count($array_combination) > 1) {
         $data[1] = $array_combination[0];
     }
     $array_combination2 = explode(DELIMITATORE_TAGLIE, $data[2]);
     if (count($array_combination2) > 1) {
         $data[2] = $array_combination2[0];
     }
     /* Parte prodotti accessori */
     $prod1 = $this->getIdProductFromCode($data[1]);
     $prod2 = $this->getIdProductFromCode($data[2]);
     $db = new MySQL();
     //FIXME:
     if (isset($data[4]) and !empty($data[4]) and $data[4] != 1) {
         // e' un prodotto sostitutivo
         $crossProduct['id_product_1'] = MySQL::SQLValue($prod1);
         $crossProduct['id_product_2'] = MySQL::SQLValue($prod2);
         $crossProduct['description'] = MySQL::SQLValue($data[3]);
         $db->InsertRow("ps_visioncrossselling", $crossProduct);
     } else {
         // e' un prodotto accessorio
         $accessoryProduct['id_product_1'] = MySQL::SQLValue($prod1);
         $accessoryProduct['id_product_2'] = MySQL::SQLValue($prod2);
         $db->InsertRow("ps_accessory", $accessoryProduct);
     }
 }
Esempio n. 16
0
    //2 comparamos si existio otro registro similar en el tiempo
    $sql = "SELECT NOW() as fecha";
    if ($database->Query($sql)) {
        //  if ($database->Query("select * from kiiconnect_mensajes where creado > date_sub('2015-09-23 11:16:30', interval 1 minute) ;")) {
        $data = $database->RecordsArray();
        $fechaServidor = $data[0]['fecha'];
        $datetime1 = new DateTime($fechaCreado);
        $datetime2 = new DateTime($fechaServidor);
        $diferencia = $datetime1->diff($datetime2);
        if ($diferencia->y == 0 && $diferencia->m == 0 && $diferencia->d == 0 && $diferencia->h == 0 && $diferencia->i == 0 && $diferencia->s == 0) {
            // registro en el mismo minuto se omite
        } else {
            // registro se inserta
            $update["body"] = MySQL::SQLValue($body);
            $update["header"] = MySQL::SQLValue($header);
            $update["p"] = MySQL::SQLValue($p);
            $update["l"] = MySQL::SQLValue($l);
            $update["richpage"] = MySQL::SQLValue($richpage);
            $update["tag"] = MySQL::SQLValue($tag);
            $update["tagsetings"] = MySQL::SQLValue($tag);
            $update["latitud"] = MySQL::SQLValue($fechaCreado);
            $update["longuitud"] = MySQL::SQLValue($fechaServidor);
            $database->InsertRow("kiiconnect_mensajes", $update);
        }
    } else {
        echo "<p>Query Failed</p>";
    }
} else {
    echo "<p>Query Failed</p>";
}
echo '{"status":"OK"}';
Esempio n. 17
0
 function insertAnagrafica($anagrafica, $arrDest)
 {
     $db = new MySQL();
     $id_address = 0;
     $id_country = empty($anagrafica[10]) ? $this->getIdCountry("IT") : $this->getIdCountry($anagrafica[10]);
     $values['id_country'] = MySQL::SQLValue($id_country);
     $db = new MySQL();
     $id_state = $this->getIdState($id_country, $anagrafica[9]);
     $values['id_state'] = MySQL::SQLValue($id_state);
     /*     * ********************************************************************************* */
     /* 	MODIFICA GESTIONE INDIRIZZI FATTURAZIONE - SPEDIZIONE (1/2)
         /*********************************************************************************** */
     if (empty($anagrafica[0]) || $anagrafica[0] == null || strlen($anagrafica[0]) < 1) {
         $this->fileLog("#8 ERROR: codice ANAGRAFICA non trovato");
         return;
     }
     $values["vs_code"] = MySQL::SQLValue($anagrafica[0]);
     if (strlen($anagrafica[0]) <= 6) {
         $id_address = $this->checkIfAnagraficaFatturazioneEsiste($anagrafica[0]);
         // indirizzo di fatturazione!
         $values["alias"] = MySQL::SQLValue("fatturazione");
         if (isset($anagrafica[2]) and !empty($anagrafica[2])) {
             $db = new MySQL();
             $id_cust = $this->getIdUserFromCode($anagrafica[2]);
             $values['id_customer'] = MySQL::SQLValue($id_cust);
         } else {
             $db = new MySQL();
             $id_cust = $this->getIdUserFromCode($anagrafica[0]);
             $values['id_customer'] = MySQL::SQLValue($id_cust);
         }
     } else {
         // indirizzo di spedizione!
         $values["alias"] = MySQL::SQLValue("spedizione " . substr($anagrafica[0], 6));
         $anagrafica[0] = substr($anagrafica[0], 0, 6);
         if (isset($anagrafica[2]) and !empty($anagrafica[2])) {
             $db = new MySQL();
             $id_cust = $this->getIdUserFromCode($anagrafica[2]);
             $values['id_customer'] = MySQL::SQLValue($id_cust);
         } else {
             $db = new MySQL();
             $id_cust = $this->getIdUserFromCode($anagrafica[0]);
             $values['id_customer'] = MySQL::SQLValue($id_cust);
         }
     }
     /*     * ********************************************************************************* */
     /* 	FINE MODIFICA GESTIONE INDIRIZZI FATTURAZIONE - SPEDIZIONE (1/1)
         /*********************************************************************************** */
     $values['id_manufacturer'] = MySQL::SQLValue(0);
     $values['id_supplier'] = MySQL::SQLValue(0);
     $values['id_warehouse'] = MySQL::SQLValue(0);
     /*     * ********************************************************************************* */
     /* 	MODIFICA GESTIONE INDIRIZZI FATTURAZIONE - SPEDIZIONE (2/2)
         /*********************************************************************************** */
     //$values['alias'] = MySQL::SQLValue("address " . $this -> getCountAddress($id_cust));
     /*     * ********************************************************************************* */
     /* 	FINE MODIFICA GESTIONE INDIRIZZI FATTURAZIONE - SPEDIZIONE (2/2)
         /*********************************************************************************** */
     $values['company'] = MySQL::SQLValue($anagrafica[3]);
     $values['lastname'] = MySQL::SQLValue($anagrafica[4] . " ");
     $values['firstname'] = MySQL::SQLValue($anagrafica[5] . " ");
     $values['address1'] = MySQL::SQLValue($anagrafica[6]);
     $values['postcode'] = MySQL::SQLValue($anagrafica[8]);
     $values['city'] = MySQL::SQLValue($anagrafica[7]);
     $values['phone'] = MySQL::SQLValue($anagrafica[11]);
     $values['phone_mobile'] = MySQL::SQLValue($anagrafica[13]);
     $values['vat_number'] = MySQL::SQLValue($anagrafica[16]);
     $values['dni'] = MySQL::SQLValue($anagrafica[17]);
     $now = date("Y-m-d H:i:s");
     $values['date_add'] = MySQL::SQLValue($now);
     $values['date_upd'] = MySQL::SQLValue($now);
     /*     * ****************************************************************************************
      * 	Gestione Anagrafiche bloccate (1/1)
      * **************************************************************************************** */
     $values_customer = null;
     if ($anagrafica[44] != null && strlen($anagrafica[44]) > 0) {
         $values_customer['dsblocco'] = MySQL::SQLValue($anagrafica[44]);
     } else {
         $values_customer['dsblocco'] = MySQL::SQLValue(NULL);
     }
     /*     * ****************************************************************************************
      *  Fine Gestione Anagrafiche bloccate (1/1)
      * **************************************************************************************** */
     if ($anagrafica[52] != null && strlen($anagrafica[52]) > 0) {
         $values_customer['cdpag_pre'] = MySQL::SQLValue($anagrafica[52]);
     } else {
         $values_customer['cdpag_pre'] = MySQL::SQLValue(NULL);
     }
     /*     * ****************************************************************************************
      * 	Gestione Spese di spedizione (1/1)
      * **************************************************************************************** */
     if (!empty($anagrafica[46]) && strlen($anagrafica[46] > 0)) {
         $values_customer["vs_fgspesesped"] = MySQL::SQLValue($anagrafica[46]);
     } else {
         $values_customer["vs_fgspesesped"] = MySQL::SQLValue($anagrafica[46]);
     }
     if (!empty($anagrafica[47])) {
         $values_customer["vs_nrsogliaspesesped"] = MySQL::SQLValue($anagrafica[47], "float");
     } else {
         $values_customer["vs_nrsogliaspesesped"] = MySQL::SQLValue(0, "float");
     }
     if (!empty($anagrafica[48])) {
         $values_customer["vs_nrcostofissospesesped"] = MySQL::SQLValue($anagrafica[48], "float");
     } else {
         $values_customer["vs_nrcostofissospesesped"] = MySQL::SQLValue(0, "float");
     }
     if (!empty($anagrafica[49])) {
         $values_customer["vs_nrcostopercspesesped"] = MySQL::SQLValue($anagrafica[49], "float");
     } else {
         $values_customer["vs_nrcostopercspesesped"] = MySQL::SQLValue(0, "float");
     }
     /*     * ****************************************************************************************
      * 	Fine Gestione Spese di spedizione (1/1)
      * **************************************************************************************** */
     /*     * ****************************************************************************************
      * 	Modalit� Pagamento (2/4)
      * **************************************************************************************** */
     if ($anagrafica[52] != null && strlen($anagrafica[52]) > 0) {
         $values_customer['cdpag_pre'] = MySQL::SQLValue($anagrafica[52]);
     } else {
         $values_customer['cdpag_pre'] = MySQL::SQLValue(NULL);
     }
     /*     * ****************************************************************************************
      * 	Fine Modalit� Pagamento (2/4)
      * **************************************************************************************** */
     /*     * ****************************************************************************************
      *  campo cat_ute (per area download) (1/1)
      * **************************************************************************************** */
     // CDcatCliente char(50)  no  Codice categoria del cliente  posizione 40 (partendo da 0)
     if (!is_null($anagrafica[40])) {
         $values_customer['vs_cat_ute'] = MySQL::SQLValue($anagrafica[40]);
     }
     /*     * ****************************************************************************************
      *  fine campo cat_ute (per area download) (1/1)
      * **************************************************************************************** */
     $where_blocco['id_customer'] = MySQL::SQLValue($id_cust);
     $db = new MySQL();
     $db->UpdateRows("ps_customer", $values_customer, $where_blocco);
     $db2 = new MySQL();
     if ($id_address == 0) {
         $db2->InsertRow("ps_address", $values);
     } else {
         $where["id_address"] = MySQL::SQLValue($id_address);
         $db2->UpdateRows("ps_address", $values, $where);
     }
     $this->refreshCustomer($id_cust, $anagrafica[5], $anagrafica[4], $anagrafica[3], $anagrafica[42], $anagrafica[43]);
 }
Esempio n. 18
0
 function insertLayeredCategory($category, $idValueCarat)
 {
     $db = new MySQL();
     foreach ($idValueCarat as $idCarat => $arrIdCart) {
         $attributeLayeredCategory['id_shop'] = MySQL::SQLValue(1);
         $attributeLayeredCategory['id_category'] = MySQL::SQLValue($category);
         $attributeLayeredCategory['id_value'] = MySQL::SQLValue($idCarat);
         $attributeLayeredCategory['type'] = MySQL::SQLValue("id_feature");
         $attributeLayeredCategory['position'] = MySQL::SQLValue($idCarat);
         $attributeLayeredCategory['filter_type'] = MySQL::SQLValue(0);
         $attributeLayeredCategory['filter_show_limit'] = MySQL::SQLValue(0);
         $db->InsertRow("ps_layered_category", $attributeLayeredCategory);
     }
 }
Esempio n. 19
0
             //$row[2] = $modelstring;
             //print'Modeldata='.$insert['model'].'<br>';
             //var_dump($newsuppliers);
             //print 'newmodel='.$newmodel.'<br>';
             if ($cli == "1") {
                 echo "Updating:" . $row[0] . "-" . $insert['stocklevel'] . "-" . $insert['updated'] . "-" . $insert['price'] . "-" . $insert['trade'] . "\r\n";
                 //command line output only
                 // commandline is true, and webready is true, build array of data to update
                 $row[2] = $modelstring;
                 $hkdata[] = "INSERT INTO import_webstock (prodcode,descr,model,category,url,updated,onorder,stocklevel,price,trade,wholesale,supplier,brand) VALUES ('{$row['0']}','{$row['1']}','{$row['2']}','{$row['3']}','{$row['123']}','{$row['20']}','{$row['7']}','{$stockcount}','{$row['30']}','{$row['32']}','{$row['5']}','{$row['122']}','{$row['112']}')";
                 $counter++;
             }
             // close cli is true
             if ($cli == "0") {
                 //print_r($insert); print '<br/>';
                 $new_id = $db->InsertRow("import_tempstock", $insert);
                 if (!$new_id) {
                     die('Unable to write record to DB:' . $db->Error . print_r($insert));
                 }
                 unset($insert);
             }
         }
     }
     //close if able to get dbf info loop
 }
 // close for $i loop
 $db->Query('DROP TABLE import_hkstock');
 $db->Query('CREATE TABLE import_hkstock LIKE import_tempstock');
 if (!$db->Query('INSERT INTO import_hkstock (prodcode,descr,model,category,url,price,trade,wholesale,onorder,stocklevel,updated,webready,supplier,brand) SELECT prodcode,descr,model,category,url,price,trade,wholesale,onorder,stocklevel,updated,webready,supplier,brand FROM import_tempstock ORDER BY import_tempstock.prodcode')) {
     die('problem duplicating db.');
 }
Esempio n. 20
0
 function insertSpecificPriceFromRule($specific_prezzi_speciali, $id_product, $id_customer, $from, $to)
 {
     $values = null;
     $values['id_specific_price_rule'] = MySQL::SQLValue(0);
     $values['id_cart'] = MySQL::SQLValue(0);
     $values['id_product'] = MySQL::SQLValue($id_product);
     $values['id_shop'] = MySQL::SQLValue(0);
     $values['id_shop_group'] = MySQL::SQLValue(0);
     $values['id_currency'] = MySQL::SQLValue(0);
     $values['id_country'] = MySQL::SQLValue(0);
     $values['id_group'] = MySQL::SQLValue(0);
     $values['id_customer'] = MySQL::SQLValue($id_customer);
     $values['price'] = MySQL::SQLValue($specific_prezzi_speciali->price);
     if ($specific_prezzi_speciali->from_quantity == 0) {
         $specific_prezzi_speciali->from_quantity = 1;
     }
     $values['from_quantity'] = MySQL::SQLValue($specific_prezzi_speciali->from_quantity);
     $values['reduction'] = MySQL::SQLValue($specific_prezzi_speciali->reduction);
     $values['reduction_type'] = MySQL::SQLValue($specific_prezzi_speciali->reduction_type);
     $values['from'] = MySQL::SQLValue($from);
     $values['to'] = MySQL::SQLValue($to);
     $values['type'] = MySQL::SQLValue($specific_prezzi_speciali->type);
     $values['stringSconto'] = MySQL::SQLValue($specific_prezzi_speciali->stringSconto);
     $db = new MySQL();
     $last_id = $db->InsertRow("ps_specific_price", $values);
     $this->_GLOBAL_COUNTER++;
     return $last_id;
 }
Esempio n. 21
0
    $db_host = MReq::tp('host');
    // server name
    $db_user = MReq::tp('compte');
    // user name
    $db_pass = MReq::tp('passwords');
    // password
    $db_dbname = MReq::tp('db');
    $db = new MySQL(true, $db_dbname, $db_host, $db_user, $db_pass);
    $values["nom"] = MySQL::SQLValue(MReq::tp('username'));
    $values["mail"] = MySQL::SQLValue(MReq::tp('email'));
    $values["pass"] = MySQL::SQLValue(md5(MReq::tp('password')));
    $values["servic"] = MySQL::SQLValue('1');
    $values["fnom"] = MySQL::SQLValue(MReq::tp('firstname'));
    $values["lnom"] = MySQL::SQLValue(MReq::tp('lastname'));
    $values["tel"] = MySQL::SQLValue(012222222);
    $values["active"] = MySQL::SQLValue(1);
    $values["defapp"] = MySQL::SQLValue(3);
    $values["agence"] = MySQL::SQLValue(2);
    $values["signature"] = MySQL::SQLValue("");
    // Execute the insert
    $result = $db->InsertRow("users_sys", $values);
    if (!$result) {
        $db->Kill($db->Error());
    }
    exit('5# dakchi daz mziane');
    //model::load('user','user');
    //adduser(MReq::tp('username'),MReq::tp('firstname'),MReq::tp('lastname'),MReq::tp('password'),MReq::tp('email'),' ',' ',' ',' ',' ');
    //
} else {
    view::load('install', 'install');
}