public function prueba() { $conex = dbase_open('C:\\mficha.DBF', 0); //return dbase_get_header_info($conex); $total_registros = dbase_numrecords($conex); for ($i = 1; $i <= $total_registros; $i++) { echo dbase_get_record($conex, $i)[0] . '<br>'; } }
function ProcessDBF($AName) { $vResult = 0; $vHandle = dbase_open($AName, 0); if ($vHandle === FALSE) { throw new Exception('Невозможно открыть файл базы данных'); } try { $vFieldList = GetFieldList($vHandle); $vSurgeryIDIdx = FindFieldIdx($vFieldList, 'MYSURGERYID', false); $vCaseIDIdx = FindFieldIdx($vFieldList, 'MYCASEID'); $vDateIdx = FindFieldIdx($vFieldList, 'DATEIN'); $vSendIdx = FindFieldIdx($vFieldList, 'SEND'); $vErrorIdx = FindFieldIdx($vFieldList, 'ERROR'); $vCnt = dbase_numrecords($vHandle); for ($i = 1; $i <= $vCnt; $i++) { $vRecord = dbase_get_record($vHandle, $i); ProcessDBFRecord(trim(@$vRecord[$vSurgeryIDIdx]), trim(@$vRecord[$vCaseIDIdx]), DBF2Date(trim(@$vRecord[$vDateIdx])), trim(@$vRecord[$vSendIdx]), iconv('CP866', 'UTF-8', trim(@$vRecord[$vErrorIdx]))); $vResult++; } } catch (Exception $e) { dbase_close($vHandle); throw $e; } dbase_close($vHandle); return $vResult; }
public function postDailySales() { $dbf_file = $this->extracted_path . DS . 'CSH_AUDT.DBF'; if (file_exists($dbf_file)) { $db = dbase_open($dbf_file, 0); $header = dbase_get_header_info($db); $record_numbers = dbase_numrecords($db); $last_ds = $this->ds->lastRecord(); $update = 0; for ($i = 1; $i <= $record_numbers; $i++) { $row = dbase_get_record_with_names($db, $i); $vfpdate = vfpdate_to_carbon(trim($row['TRANDATE'])); if (is_null($last_ds)) { $attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']]; if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) { } $update++; } else { if ($last_ds->date->lte($vfpdate)) { $attrs = ['date' => $vfpdate->format('Y-m-d'), 'branchid' => session('user.branchid'), 'managerid' => session('user.id'), 'sales' => $row['CSH_SALE'] + $row['CHG_SALE'], 'tips' => $row['TIP'], 'custcount' => $row['CUST_CNT'], 'empcount' => $row['CREW_KIT'] + $row['CREW_DIN']]; if ($this->ds->firstOrNew($attrs, ['date', 'branchid'])) { } $update++; } } } dbase_close($db); return count($update > 0) ? true : false; } return false; }
public function __construct($options) { $this->_dBase = dbase_open($options['file'], 0); if ($this->_dBase === false) { throw new Zend_Exception('Ошибка открытия файла импорта'); } }
/** * Export data * @return boolean */ function export() { $def = array(array('o_id', 'N', 10, 0), array('o_uid', 'N', 10, 0), array('o_date', 'D'), array('o_state', 'N', 1, 0), array('o_ip', 'C', 32), array('o_lastname', 'C', 155), array('o_firstnam', 'C', 155), array('o_adress', 'C', 155), array('o_zip', 'C', 30), array('o_town', 'C', 155), array('o_country', 'C', 3), array('o_telephon', 'C', 30), array('o_email', 'C', 155), array('o_articles', 'N', 10, 0), array('o_total', 'N', 10, 2), array('o_shipping', 'N', 10, 2), array('o_bill', 'L'), array('o_password', 'C', 155), array('o_text', 'C', 155), array('o_cancel', 'C', 155), array('c_id', 'N', 10, 0), array('c_prod_id', 'N', 10, 0), array('c_qte', 'N', 10, 0), array('c_price', 'N', 10, 2), array('c_o_id', 'N', 10, 0), array('c_shipping', 'N', 10, 2), array('c_pass', 'C', 155)); /* * Correspondances * cmd_id o_id * cmd_uid o_uid * cmd_date o_date * cmd_state o_state * cmd_ip o_ip * cmd_lastname o_lastname * cmd_firstname o_firstnam * cmd_adress o_adress * cmd_zip o_zip * cmd_town o_town * cmd_country o_country * cmd_telephone o_telephon * cmd_email o_email * cmd_articles_count o_articles * cmd_total o_total * cmd_shipping o_shipping * cmd_bill o_bill * cmd_password o_password * cmd_text o_text * cmd_cancel o_cancel * caddy_id c_id * caddy_product_id c_prod_id * caddy_qte c_qte * caddy_price c_price * caddy_cmd_id c_o_id * caddy_shipping c_shipping * caddy_pass c_pass */ if (!dbase_create($this->folder . DIRECTORY_SEPARATOR . $this->filename, $def)) { $this->success = false; return false; } $dbf = dbase_open($this->folder . DIRECTORY_SEPARATOR . $this->filename, 2); if ($dbf === false) { $this->success = false; return false; } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('cmd_id', 0, '<>')); $criteria->add(new Criteria('cmd_state', $this->orderType, '=')); $criteria->setSort('cmd_date'); $criteria->setOrder('DESC'); $orders = $this->handlers->h_myshop_commands->getObjects($criteria); foreach ($orders as $order) { $carts = array(); $carts = $this->handlers->h_myshop_caddy->getObjects(new Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '=')); foreach ($carts as $cart) { dbase_add_record($dbf, array($order->getVar('cmd_id'), $order->getVar('cmd_uid'), date('Ymd', strtotime($order->getVar('cmd_date'))), $order->getVar('cmd_state'), $order->getVar('cmd_ip'), $order->getVar('cmd_lastname'), $order->getVar('cmd_firstname'), $order->getVar('cmd_adress'), $order->getVar('cmd_zip'), $order->getVar('cmd_town'), $order->getVar('cmd_country'), $order->getVar('cmd_telephone'), $order->getVar('cmd_email'), $order->getVar('cmd_articles_count'), $order->getVar('cmd_total'), $order->getVar('cmd_shipping'), $order->getVar('cmd_bill'), $order->getVar('cmd_password'), $order->getVar('cmd_text'), $order->getVar('cmd_cancel'), $cart->getVar('caddy_id'), $cart->getVar('caddy_product_id'), $cart->getVar('caddy_qte'), $cart->getVar('caddy_price'), $cart->getVar('caddy_cmd_id'), $cart->getVar('caddy_shipping'), $cart->getVar('caddy_pass'))); } } dbase_close($dbf); $this->success = true; return true; }
public function conectar() { $this->conexao = dbase_open($this->caminho, $this->modo); if ($this->conexao == false) { return false; } return $this->conexao; }
/** * Обновляет справочник банков, используя указанный файл или файл из папки data. * * Необходимо расширение dbase. Установить расширение dbase можно так: sudo pecl install dbase * * @param null $file * @return int */ public function actionIndex($file = null) { if (!extension_loaded('dbase')) { $this->stdout("Для работы скрипта обновления необходимо установить расширение dbase\n", Console::FG_RED); return 1; } if ($file === null) { $file = Yii::getAlias(dirname(__FILE__) . '/../data/bnkseek.dbf'); } else { $file = Yii::getAlias($file); } if (!file_exists($file)) { $this->stdout("Файл {$file} не найден!\n", Console::FG_RED); return 1; } if ($this->confirm("Обновить справочник банков России, используя файл {$file}?")) { $this->stdout('Выполняю обновление...' . "\n"); $db = dbase_open($file, 0); if (!$db) { $this->stdout("Не удалось открыть файл как базу данный dbase!\n", Console::FG_RED); return 1; } $current_db_records_count = Bank::find()->count(); $data_records_count = dbase_numrecords($db); $data_updated = false; $this->stdout("Количество банков в текущем справочнике - {$current_db_records_count}.\n"); $this->stdout("Количество банков в файле - {$data_records_count}.\n"); for ($i = 1; $i <= $data_records_count; $i++) { $rec = dbase_get_record_with_names($db, $i); /** @var Bank $model */ $model = Yii::createObject(['class' => Bank::className(), 'bik' => $rec["NEWNUM"], 'okpo' => $rec["OKPO"], 'full_name' => iconv('CP866', 'utf-8', $rec["NAMEP"]), 'short_name' => iconv('CP866', 'utf-8', $rec["NAMEN"]), 'ks' => $rec["KSNP"], 'city' => iconv('CP866', 'utf-8', $rec["NNP"]), 'zip' => (int) $rec["IND"], 'address' => iconv('CP866', 'utf-8', $rec["ADR"]), 'tel' => iconv('CP866', 'utf-8', $rec["TELEF"])]); foreach ($model->getAttributes() as $key => $value) { $model->{$key} = trim($value); } /** @var Bank $exist */ $exist = Bank::findOne($model->bik); if (!$exist) { $this->stdout("Добавлен новый банк: {$model->bik} {$model->short_name}\n"); $data_updated = true; $model->save(false); } else { if ($exist->getAttributes() != $model->getAttributes()) { $exist->setAttributes($model->getAttributes()); $this->stdout("Обновлены данные банка: {$exist->bik} {$exist->short_name}\n"); $data_updated = true; $exist->save(false); } } } dbase_close($db); if ($data_updated) { $this->stdout('Справочник банков успешно обновлен!' . "\n", Console::FG_GREEN); } else { $this->stdout('В справочник банков не было внесено изменений.' . "\n", Console::FG_GREEN); } } return 0; }
protected function _load($file) { if ($this->_fp) { return $this->_fp; } $this->_fp = dbase_open($file, 0); $this->_setHeader(); $this->_setSize(); }
function DBFOpen($flag = 2) { $this->DBFCon = dbase_open($this->DBFFile, $flag); if (!$this->DBFCon) { die("Gagal Membuka File DBF"); } else { return $this->DBFCon; } }
function __construct($url_dbf) { $this->url = $url_dbf; // Abrir un el archivo dbase $this->dbf = dbase_open($this->url, 0) or die("¡Error! No se pudo abrir el archivo de base de datos dbase '{$this->url}'."); // Inicializo valores $this->info_columna = dbase_get_header_info($this->dbf); $this->set_campos(); $this->set_nombre_tabla(); $this->set_campos_array(); }
public function actionImportDbf($filename, $region = false) { $db = @dbase_open($filename, 0); if (!$db) { $this->stderr("Не удалось открыть DBF файл: '{$filename}'\n"); return 1; } $classMap = ['/^.*DADDROBJ\\.DBF$/' => FiasDaddrobj::className(), '/^.*ADDROBJ\\.DBF$/' => FiasAddrobj::className(), '/^.*LANDMARK\\.DBF$/' => FiasLandmark::className(), '/^.*DHOUSE\\.DBF$/' => FiasDhouse::className(), '/^.*HOUSE\\d\\d\\.DBF$/' => FiasHouse::className(), '/^.*DHOUSINT\\.DBF$/' => FiasDhousint::className(), '/^.*HOUSEINT\\.DBF$/' => FiasHouseint::className(), '/^.*DLANDMRK\\.DBF$/' => FiasDlandmrk::className(), '/^.*DNORDOC\\.DBF$/' => FiasDnordoc::className(), '/^.*NORDOC\\d\\d\\.DBF$/' => FiasNordoc::className(), '/^.*ESTSTAT\\.DBF$/' => FiasDhousint::className(), '/^.*ACTSTAT\\.DBF$/' => FiasActstat::className(), '/^.*CENTERST\\.DBF$/' => FiasCenterst::className(), '/^.*ESTSTAT\\.DBF$/' => FiasEststat::className(), '/^.*HSTSTAT\\.DBF$/' => FiasHststat::className(), '/^.*OPERSTAT\\.DBF$/' => FiasOperstat::className(), '/^.*INTVSTAT\\.DBF$/' => FiasIntvstat::className(), '/^.*STRSTAT\\.DBF$/' => FiasStrstat::className(), '/^.*CURENTST\\.DBF$/' => FiasCurentst::className(), '/^.*SOCRBASE\\.DBF$/' => FiasSocrbase::className()]; $modelClass = false; foreach ($classMap as $pattern => $className) { if (preg_match($pattern, $filename)) { $modelClass = $className; break; } } if ($modelClass === false) { $this->stderr("Не поддерживаемый DBF файл: '{$filename}'\n"); return 1; } $rowsCount = dbase_numrecords($db); $this->stdout("Записей в DBF файле '{$filename}' : {$rowsCount}\n"); $j = 0; for ($i = 1; $i <= $rowsCount; $i++) { $row = dbase_get_record_with_names($db, $i); if ($modelClass == FiasAddrobj::className() && $this->region && intval($row['REGIONCODE']) != intval($this->region)) { continue; } if ($j == 0) { $transaction = Yii::$app->db->beginTransaction(); } $model = new $modelClass(); foreach ($row as $key => $value) { if ($key == 'deleted') { continue; } $key = strtolower($key); $model->{$key} = trim(mb_convert_encoding($value, 'UTF-8', 'CP866')); } $model->save(); $j++; if ($j == 1000) { $transaction->commit(); $j = 0; $this->stdout("Обработано {$i} из {$rowsCount} записей\n"); } } if ($j != 0) { $transaction->commit(); } return 0; }
public static function open($filename, $mode = self::MODE_READ) { if (!file_exists($filename)) { throw new RuntimeException(sprintf('Filename %s not found', $filename)); } if (!function_exists('dbase_open')) { throw new RuntimeException(sprintf('Extension dBase not support with your PHP interpreter')); } $dbaseId = @dbase_open($filename, $mode); if (false === $dbaseId) { throw new RuntimeException(sprintf('Failed to open database file %s', $filename)); } return new self($dbaseId); }
function volcarDBF($db = "ctw10005") { $results = array(); $mFile = $db . date("Ymd") . ".txt"; //Abrir el Archivo para Escribir $TFile = fopen(PATH_TMP . $mFile, "a"); $pathdbase = CTW_PATH . vLITERAL_SEPARATOR . $db . ".dbf"; //$db = dbase_open($ipdbase . $dirdbase . $nombredb . $db, 0); $rs = dbase_open($pathdbase, 0); //echo $pathdbase; $results[SYS_MSG] .= "Abrir {$pathdbase} <br />"; $num_rows = dbase_numrecords($rs); //$o_num_rows = dbase_numrecords ($rs); if ($num_rows > 100000) { //$num_rows = 100000; //Eliminar la Consulta a 50000 } $results[SYS_MSG] .= "Numero de Filas {$num_rows} <br />"; if (isset($rs)) { $results[SYS_MSG] .= "Cerrando " . dbase_get_header_info($rs) . " <br />"; for ($i = 1; $i <= $num_rows; $i++) { //$field = dbase_get_record_with_names($rs, $i); $field = dbase_get_record($rs, $i); $lim = sizeof($field); $strW = ""; for ($a = 0; $a < $lim; $a++) { if ($a == 0) { $strW .= trim($field[$a]); } else { $strW .= STD_LITERAL_DIVISOR . trim($field[$a]); } } $strW .= "\n"; @fwrite($TFile, $strW); //if (dbase_delete_record ($rs, $i)) { // print "Registro $i Marcado para Eliminar de un total de $o_num_rows; se Busco $field[$key]. <br >"; //break; # Exit the loop //} } } else { //dbase_get_header_info($rs); } //dbase_pack($rs); //$results[SYS_MSG] .= " <br />"; dbase_close($rs); $results[SYS_MSG] .= "Cerrando {$pathdbase} <br />"; fclose($TFile); $results[SYS_MSG] .= "Cerrando {$mFile} <br />"; return $results; }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('<info>Started at ' . date('H:i:s') . '</info>'); $em = $this->em = $this->getEntityManager('default'); $this->truncate(); $db_path = __DIR__ . '/../Resources/KLADR/STREET.DBF'; $db = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'."); $record_numbers = dbase_numrecords($db); $batchSize = $input->getOption('batch'); for ($i = 1; $i <= $record_numbers; $i++) { $row = dbase_get_record_with_names($db, $i); $street = new KladrStreet(); $street->setTitle(trim(iconv('cp866', 'utf8', $row['NAME']))); $code = trim($row['CODE']); if(substr($code, -2) != '00') continue; $code = substr($code, 0, -2); $street->setId($code); $street->setParentCode(intval(str_pad(substr($code, 0, -4), 11, '0', STR_PAD_RIGHT))); $street->setZip(trim($row['INDEX'])); $street->setOcatd(trim($row['OCATD'])); $street->setSocr(trim(iconv('cp866', 'utf8', $row['SOCR']))); $em->persist($street); if (($i % $batchSize) == 0) { $em->flush(); $em->clear(); $output->writeln('<info>Inserted '. $i. ' records</info>'); } } $em->flush(); $output->writeln('<info>Inserted '. $i. ' records</info>'); $output->writeln('<info>Success</info>'); $output->writeln('<info>Deleting dead links</info>'); $this->deleteNotLinkedElements(); $output->writeln('<info>Assigning parents</info>'); $this->updateParents(); $output->writeln('<info>Success</info>'); }
function connect($dsninfo, $persistent = false) { if (!DB::assertExtension('dbase')) { return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); } $this->dsn = $dsninfo; ob_start(); $conn = dbase_open($dsninfo['database'], 0); $error = ob_get_contents(); ob_end_clean(); if (!$conn) { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, strip_tags($error)); } $this->connection = $conn; return DB_OK; }
function import_dbf($db, $table, $dbf_file) { global $conn; if (!($dbf = dbase_open($dbf_file, 0))) { die("Could not open {$dbf_file} for import."); } $num_rec = dbase_numrecords($dbf); $num_fields = dbase_numfields($dbf); $fields = array(); for ($i = 1; $i <= $num_rec; $i++) { $row = @dbase_get_record_with_names($dbf, $i); $q = "insert into {$db}.{$table} values ("; foreach ($row as $key => $val) { if ($key == 'deleted') { continue; } $q .= "'" . addslashes(trim($val)) . "',"; // Code modified to trim out whitespaces } if (isset($extra_col_val)) { $q .= "'{$extra_col_val}',"; } $q = substr($q, 0, -1); $q .= ')'; //if the query failed - go ahead and print a bunch of debug info if (!($result = mysql_query($q, $conn))) { print mysql_error() . " SQL: {$q}\n\n"; print substr_count($q, ',') + 1 . " Fields total.\n\n"; $problem_q = explode(',', $q); $q1 = "desc {$db}.{$table}"; $result1 = mysql_query($q1, $conn); $columns = array(); $i = 1; while ($row1 = mysql_fetch_assoc($result1)) { $columns[$i] = $row1['Field']; $i++; } $i = 1; foreach ($problem_q as $pq) { print "{$i} column: {$columns[$i]} data: {$pq}\n\n"; $i++; } die; } } }
function subedbff($file = 'TRABAJAD.DBF') { //nota:hay que modificar el upload_max_file_size=100M del php.ini //nota:cambiar el tamanano de pres.nacinal a 15 caracteres //nota:cambiar tamano de carg.descrip a tamano de 100 set_time_limit(3600); $this->load->dbforge(); $this->load->dbutil(); $filea = explode('.', $file); $name = $filea[0]; $ext = $filea[1]; $uploadsdir = getcwd() . '/uploads/'; $filedir = $uploadsdir . $file; $tabla = strtoupper($ext . $name); if (extension_loaded('dbase')) { $db = dbase_open($filedir, 0); $this->dbforge->drop_table($tabla); if ($db) { $cols = dbase_numfields($db); $rows = dbase_numrecords($db); $row = dbase_get_record_with_names($db, 10); foreach ($row as $key => $value) { $fields[trim($key)] = array('type' => 'TEXT'); } //print_r($fields); //exit(); $this->dbforge->add_field($fields); $this->dbforge->create_table($tabla); $insert = array(); for ($i = 0; $i <= $rows; $i++) { $r = dbase_get_record_with_names($db, $i); foreach ($row as $key => $value) { $a = utf8_encode(trim($r[trim($key)])); $insert[trim($key)] = $a; } $this->db->insert($tabla, $insert); } echo $i; dbase_close($db); } else { echo "No pudo abrir el archivo"; } } else { echo 'Debe cargar las librerias dbase para poder usar este modulo'; } }
public function load_dbf($filename, $mode = 0) { if (!file_exists($filename)) { return cy_dt(CYE_ERROR, 'Not a valid DBF file!'); } $tail = substr($filename, -4); if (strcasecmp($tail, '.dbf') != 0) { return cy_dt(CYE_ERROR, 'Not a valid DBF file!'); } try { $this->_handler = dbase_open($filename, $mode); } catch (Exception $e) { echo $e->getMessage(); return cy_dt(CYE_ERROR, 'open DBF file failed!'); } $this->field_num = dbase_numfields($this->_handler); $this->rec_num = dbase_numrecords($this->_handler); $this->field_names = dbase_get_header_info($this->_handler); return cy_dt(0); }
function connect($dsninfo, $persistent = false) { if (!DB::assertExtension('dbase')) { return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); } $this->dsn = $dsninfo; $ini = ini_get('track_errors'); if ($ini) { $conn = @dbase_open($dsninfo['database'], 0); } else { ini_set('track_errors', 1); $conn = @dbase_open($dsninfo['database'], 0); ini_set('track_errors', $ini); } if (!$conn) { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, strip_tags($php_errormsg)); } $this->connection = $conn; return DB_OK; }
public function __construct($file_name, $dsn, $user, $passwd) { if (false === ($this->_link = dbase_open($file_name, 0))) { throw new Exception('Не удалось открыть файл ' . $file_name); } $options = array(Db_Pdo::ATTR_ERRMODE => Db_Pdo::ERRMODE_EXCEPTION); $this->_db = Db_Pdo::create($dsn, $user, $passwd, $options); $this->_db->exec('SET NAMES utf8'); $sql = ' INSERT INTO regions (code, name) VALUES (:code, :name) '; $this->_insert_region = $this->_db->prepare($sql); $sql = ' INSERT INTO localities (region_id, code, name, type) VALUES (:region_id, :code, :name, :type) '; $this->_insert_locality = $this->_db->prepare($sql); }
public function __construct($file, $rw = 0, $use_trim = true) { if ($rw == 'read') { $rw = 0; } else { if ($rw == 'write') { $rw = 2; } } if ($rw !== 0 && $rw !== 2) { throw new Exception('Invalid read/write bit, must be 0 for read, or 2 for read/write'); } $this->file = $file; $this->db = dbase_open($file, $rw); if ($this->db) { $this->numrecords = $this->numrecords(); } else { throw new Exception("Could not open database file {$file}"); } $this->rw = $rw; $this->use_trim = $use_trim; }
public function __construct($shp_file, $dbf_file = '') { if ($dbf_file == '') { $dbf_file = substr($shp_file, 0, -3) . 'dbf'; } if (!(is_readable($shp_file) && is_file($shp_file))) { $this->Error('FILE_SHP'); } if (!(is_readable($dbf_file) && is_file($dbf_file))) { $this->Error('FILE_DBF'); } $this->shp = fopen($shp_file, 'rb'); if (!$this->shp) { $this->Error('FILE_SHP_READ'); } $this->dbf = dbase_open($dbf_file, 0); if ($this->dbf === false) { $this->Error('FILE_DBF_READ'); } $this->file_size = filesize($shp_file); $this->LoadHeader(); }
function mspti() { $this->layout = 'ajax'; $this->autoRender = FALSE; // database "definition" $def = array(array("KDYYSMSPTI", "C", 7), array("KDPTIMSPTI", "C", 6), array("NMPTIMSPTI", "C", 50), array("ALMT1MSPTI", "C", 30), array("ALMT2MSPTI", "C", 30), array("KOTAAMSPTI", "C", 20), array("KDPOSMSPTI", "C", 5), array("TELPOMSPTI", "C", 20), array("FAKSIMSPTI", "C", 20), array("TGPTIMSPTI", "D"), array("NOMSKMSPTI", "C", 30), array("EMAILMSPTI", "C", 40), array("HPAGEMSPTI", "C", 40), array("TGAWLMSPTI", "D")); $epsbed_file = EPSBED_DIR . 'MSPTI.dbf'; if (!dbase_create($epsbed_file, $def)) { echo "Error, can't create the database\n"; exit; } else { $db = dbase_open($epsbed_file, 2); if ($db) { $this->loadModel('Configuration'); $yys = $this->Configuration->getPTI(); $yys['YYS_KODE'] = ''; dbase_add_record($db, array($yys['YYS_KODE'], $yys['PTI_KODE'], $yys['PTI_NAMA'], $yys['PTI_ALAMAT_1'], $yys['PTI_ALAMAT_2'], $yys['PTI_KOTA'], $yys['PTI_KODE_POS'], $yys['PTI_TELEPON'], $yys['PTI_FAX'], str_replace('-', '/', $yys['PTI_TANGGAL_SK']), $yys['PTI_NOMOR_SK'], $yys['PTI_EMAIL'], $yys['PTI_WEBSITE'], str_replace('-', '/', $yys['PTI_TANGGAL_BERDIRI']))); echo "<a href='files/epsbed/MSPTI.dbf'>Download file MSPTI.dbf</a>"; dbase_close($db); } } }
/** * Connect to the database and create it if it doesn't exist * * Don't call this method directly. Use DB::connect() instead. * * PEAR DB's dbase driver supports the following extra DSN options: * + mode An integer specifying the read/write mode to use * (0 = read only, 1 = write only, 2 = read/write). * Available since PEAR DB 1.7.0. * + fields An array of arrays that PHP's dbase_create() function needs * to create a new database. This information is used if the * dBase file specified in the "database" segment of the DSN * does not exist. For more info, see the PHP manual's * {@link http://php.net/dbase_create dbase_create()} page. * Available since PEAR DB 1.7.0. * * Example of how to connect and establish a new dBase file if necessary: * <code> * require_once 'DB.php'; * * $dsn = array( * 'phptype' => 'dbase', * 'database' => '/path/and/name/of/dbase/file', * 'mode' => 2, * 'fields' => array( * array('a', 'N', 5, 0), * array('b', 'C', 40), * array('c', 'C', 255), * array('d', 'C', 20), * ), * ); * $options = array( * 'debug' => 2, * 'portability' => DB_PORTABILITY_ALL, * ); * * $db = DB::connect($dsn, $options); * if (PEAR::isError($db)) { * die($db->getMessage()); * } * </code> * * @param array $dsn the data source name * @param bool $persistent should the connection be persistent? * * @return int DB_OK on success. A DB_Error object on failure. */ function connect($dsn, $persistent = false) { if (!PEAR::loadExtension('dbase')) { return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); } $this->dsn = $dsn; if ($dsn['dbsyntax']) { $this->dbsyntax = $dsn['dbsyntax']; } /* * Turn track_errors on for entire script since $php_errormsg * is the only way to find errors from the dbase extension. */ @ini_set('track_errors', 1); $php_errormsg = ''; if (!file_exists($dsn['database'])) { $this->dsn['mode'] = 2; if (empty($dsn['fields']) || !is_array($dsn['fields'])) { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, 'the dbase file does not exist and ' . 'it could not be created because ' . 'the "fields" element of the DSN ' . 'is not properly set'); } $this->connection = @dbase_create($dsn['database'], $dsn['fields']); if (!$this->connection) { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, 'the dbase file does not exist and ' . 'the attempt to create it failed: ' . $php_errormsg); } } else { if (!isset($this->dsn['mode'])) { $this->dsn['mode'] = 0; } $this->connection = @dbase_open($dsn['database'], $this->dsn['mode']); if (!$this->connection) { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg); } } return DB_OK; }
function createDBF($fullpath_filename, $field_structure, $data, $file_mode = '0') { # Constants for dbf field types /* L = BOOLEAN C = CHAR D = DATE N = NUMBER */ # Constants for dbf file mode /* '0' = 'READ_ONLY'; '1' = 'WRITE_ONLY'; '2' = 'READ_WRITE'; */ # Path to dbf file $db_file = $fullpath_filename; if (is_dir($db_file)) { unlink($db_file); } # create dbf file using the $create = dbase_create($db_file, $field_structure); # open dbf file for reading and writing $id = @dbase_open($db_file, $file_mode) or die("Could not open dbf file <i>{$db_file}</i>."); if (is_array($data)) { foreach ($data as $dt) { dbase_add_record($id, $dt) or die("Could not add record {$dt['0']} to dbf file <i>{$db_file}</i>."); } } # close the dbf file dbase_close($id); }
$KDIB = $vdata['KDIB']; if ($THANG == $ta) { $sql = "INSERT INTO d_akun VALUES ('" . $THANG . "', '" . $KDJENDOK . "', '" . $KDSATKER . "', '" . $KDDEPT . "', '" . $KDUNIT . "', '" . $KDPROGRAM . "', '" . $KDGIAT . "', '" . $KDOUTPUT . "', '" . $KDLOKASI . "', '" . $KDKABKOTA . "', '" . $KDDEKON . "', '" . $KDSOUTPUT . "', '" . $KDKMPNEN . "', '" . $KDSKMPNEN . "', '" . $KDAKUN . "', '" . $KDKPPN . "', '" . $KDBEBAN . "', '" . $KDJNSBAN . "', '" . $KDCTARIK . "', '" . $REGISTER . "', '" . $CARAHITUNG . "', '" . $PROSENPHLN . "', '" . $PROSENRKP . "', '" . $PROSENRMP . "', '" . $KPPNRKP . "', '" . $KPPNRMP . "', '" . $KPPNPHLN . "', '" . $REGDAM . "', '" . $KDLUNCURAN . "', '" . $KDIB . "')"; #echo $sql."<br>"; mysql_query($sql); } $i++; } } } if ($_FILES['pok']['name'] != "") { mysql_query("DELETE FROM d_item WHERE THANG = '" . $ta . "'"); $filename = $_FILES['pok']['name']; $filedir = "dipa_files/" . $filename; move_uploaded_file($_FILES["pok"]["tmp_name"], $filedir); $data = dbase_open($filedir, 0); if ($data) { $ndata = dbase_numrecords($data); $i = 0; #THANG KDJENDOK KDSATKER KDDEPT KDUNIT KDPROGRAM KDGIAT KDOUTPUT KDLOKASI KDKABKOTA 10 KDDEKON KDSOUTPUT KDKMPNEN KDSKMPNEN KDAKUN KDKPPN KDBEBAN KDJNSBAN KDCTARIK REGISTER 20 CARAHITUNG HEADER1 HEADER2 KDHEADER NOITEM NMITEM VOL1 SAT1 VOL2 SAT2 30 VOL3 SAT3 VOL4 SAT4 VOLKEG SATKEG HARGASAT JUMLAH PAGUPHLN PAGURMP 40 PAGURKP KDBLOKIR BLOKIRPHLN BLOKIRRMP BLOKIRRKP RPHBLOKIR KDCOPY KDABT KDSBU VOLSBK 50 VOLRKAKL BLNKONTRAK NOKONTRAK TGKONTRAK NILKONTRAK JANUARI PEBRUARI MARET APRIL MEI 60 JUNI JULI AGUSTUS SEPTEMBER OKTOBER NOPEMBER DESEMBER JMLTUNDA KDLUNCURAN JMLABT 70 NOREV KDUBAH KURS INDEXKPJM KDIB while ($i <= $ndata) { $vdata = dbase_get_record_with_names($data, $i); $THANG = $vdata['THANG']; $KDJENDOK = $vdata['KDJENDOK']; $KDSATKER = $vdata['KDSATKER']; $KDDEPT = $vdata['KDDEPT']; $KDUNIT = $vdata['KDUNIT']; $KDPROGRAM = $vdata['KDPROGRAM']; $KDGIAT = $vdata['KDGIAT']; $KDOUTPUT = $vdata['KDOUTPUT']; $KDLOKASI = $vdata['KDLOKASI'];
function file0() { include_once "dwo.lib.php"; //HdrExcl(HOME_FOLDER . DS . "tmp/cobacsv.csv"); echo "<body bgcolor=#EEFFFF>"; $dat = $_SESSION['AD' . $_SESSION['ADPOS']]; $arr = explode('~', $dat); $mhsw = GetFields('mhsw', 'MhswID', $arr[0], "Nama, NamaBank, NomerRekening, ProdiID"); $khs = GetFields('khs', 'KHSID', $arr[1], "TahunID, Biaya, Potongan, Bayar, Tarik, TotalSKS"); //$krs = GetaField('krs left outer join jadwal j on krs.JadwalID = j.JadwalID', "j.JenisJadwalID = 'R' and KHSID", $khs['KHSID'], 'count(krs.KRSID)'); $krs = GetaField('krstemp k left outer join jadwal j on k.JadwalID=j.JadwalID', "k.TahunID='{$khs['TahunID']}' and k.MhswID='{$arr['0']}' and j.JenisJadwalID", 'R', "count(*)"); $balance = $khs['Biaya'] - $khs['Bayar'] - $khs['Potongan'] + $khs['Tarik']; $bpm = GetFields('bayarmhsw', "TahunID='{$khs['TahunID']}' and Autodebet=1 and MhswID", $arr[0], '*'); $bpmid = $bpm['BayarMhswID']; //echo "<h1>» $khs[TahunID] ($arr[1]) - $bpmid</h1>"; echo "Processing: #" . $_SESSION['ADPOS'] . " : <b>" . $arr[0] . ' (' . $arr[1] . ")</b><hr>"; // baca header $nmf = HOME_FOLDER . DS . "tmp/{$_SESSION['_Login']}.autodebet.hdr.csv"; $f = fopen($nmf, 'r'); $_hdr = fread($f, filesize($nmf)); fclose($f); // ekstrak header $_arrhdr = explode(chr(13) . chr(10), $_hdr); $hdr = $_arrhdr[0]; $arrhdr = explode(';', $hdr); $detail = GetDetailBPM($arr[0], $arr[1], $khs['TahunID'], $arrhdr); //$jumlahPrak = GetaField() $det = implode(';', $detail); $fak = substr($mhsw['ProdiID'], 0, 1); $jur = substr($mhsw['ProdiID'], 1, 1); $bpmnostrip = str_replace('-', '', $bpmid); //$nmf = HOME_FOLDER . DS . "tmp/$_SESSION[_Login].autodebet.csv"; //$f = fopen($nmf, 'a'); $isi = array($khs['TahunID'], $fak, $jur, $arr[0], $mhsw['Nama'], $balance, '', $detail[1], $detail[2], $detail[3], $detail[4], $detail[5], $detail[6], $detail[7], '0', $bpmnostrip, $khs['TotalSKS'], $krs); $namadbfisi = "autodebet/autodebet-{$_SESSION['tahun']}-{$_SESSION['prodi']}.dbf"; $conn = dbase_open($namadbfisi, 2); dbase_add_record($conn, $isi); // hihihi... if ($_SESSION['ADPOS'] < $_SESSION['MaxData'] - 1) { echo "<script type='text/javascript'>window.onload=setTimeout('window.location.reload()', 2);</script>"; } else { echo "<hr><p>Proses pembuatan file <b>Berhasil</b>. Silakan download file di:\r\n <input type=button name='Download' value='Download File' onClick=\"location='downloaddbf.php?fn={$namadbfisi}'\">\r\n </p>"; } $_SESSION['ADPOS']++; }
function _openDBFFile($toWrite = false) { $checkFunction = $toWrite ? "is_writable" : "is_readable"; if ($toWrite && !file_exists(str_replace('.*', '.dbf', $this->FileName))) { if (!@dbase_create(str_replace('.*', '.dbf', $this->FileName), $this->DBFHeader)) { return $this->setError(sprintf("It wasn't possible to create the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); } } if ($checkFunction(str_replace('.*', '.dbf', $this->FileName))) { $this->DBFFile = dbase_open(str_replace('.*', '.dbf', $this->FileName), $toWrite ? 2 : 0); if (!$this->DBFFile) { return $this->setError(sprintf("It wasn't possible to open the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); } } else { return $this->setError(sprintf("It wasn't possible to find the DBase file '%s'", str_replace('.*', '.dbf', $this->FileName))); } return TRUE; }
update terakhir tgl. 04-02-2009 Ana update terakhir tgl. .............. -abrarhedar- ------------------------------------------------------ */ session_start(); include "../lib/sambung.php"; include "../lib/sipl.php"; CheckAuthentication(); $kdunit = $_SESSION[kdunit]; $sktunit = strtolower(sktunitkerja($kdunit, $ta)); $ta = $_SESSION[ta]; $filedata = '../DataDipa/' . $sktunit . '/d_item.dbf'; if (file_exists($filedata)) { echo 'file ' . $filedata . ' ada'; $data = dbase_open($filedata, 2); dbase_pack($data); $jml = dbase_numrecords($data); $vdataawal = dbase_get_record_with_names($data, 1); $tahun = $vdataawal["THANG"]; $kodesatker = $vdataawal["KDSATKER"]; //dbase_pack($data); $kdsatkerunit = kdsatker($kdunit); echo 'tahun anggaran ' . $tahun . ' satker data ' . $kodesatker; echo 'kode unit ' . $kdunit . ' satker unit ' . $kdsatkerunit; if ($_REQUEST['ok']) { mysql_query("delete from d_item where ThAng='{$ta}' and kdsatker='{$kdsatkerunit}' "); $i = 0; $no == 0; while ($i <= $jml) { $vdata = dbase_get_record_with_names($data, $i);
round($daily_fee), round($monthly_fee), round($monthly_premium), round($monthly_insure_include), round($pay), round($worker_insure_include), round($employer_insure_value), round($unemployment_insure_value), '27', NULL, NULL ); $file = "DSKKAR00.DBF" ; $db_path = "../../../HRProcess/".$file ; $dbi = dbase_open($db_path,2); dbase_add_record($dbi, $record2); dbase_close($dbi); if (file_exists("../../../HRProcess/"."DSKKAR".$res[0]['cost_center_id'].".DBF")) { unlink("../../../HRProcess/"."DSKKAR".$res[0]['cost_center_id'].".DBF"); } //.............rename a file ............................ $directory ="../../../HRProcess/" ; foreach (glob($directory."*.DBF") as $filename) { $file = realpath($filename); rename($file, str_replace("DSKKAR00","DSKKAR".$res[0]['cost_center_id'],$file)); }