Exemplo n.º 1
0
function read_worksheet($out, $file, $options = array())
{
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (isset($options["read"]) && $options["read"] != $ext) {
        fputs(STDERR, "Warning: The file extension was ignored to adopt {$options["read"]}.\n");
        $ext = $options["read"];
    }
    switch (strtolower($ext)) {
        case "raw":
            $in = fopen($file, "r");
            while (($line = fgets($in)) !== false) {
                fputs($out, $line);
            }
            fclose($in);
            break;
        case "csv":
            $options["delimiter"] = ",";
            read_csv($out, $file, $options);
            break;
        case "tsv":
            $options["delimiter"] = "\t";
            read_csv($out, $file, $options);
            break;
        case "xlsx":
            read_excel($out, $file, $options);
            break;
        case "json":
            read_json($out, $file, $options);
            break;
        case "yml":
        case "yaml":
            read_yaml($out, $file, $options);
            break;
        case "xml":
            read_xml($out, $file, $options);
            break;
        default:
            print "Error[{$ext}]: No reader is available.\n";
            break;
    }
    return;
}
Exemplo n.º 2
0
<!-- <!DOCTYPE html> -->
<html lang="en">
<?php 
include 'layout/head.php';
?>
<body class="no-padding" id="home">
<?php 
include 'core/init.inc.php';
// header('Content-Type: text/plain');
// print_r(read_csv('tes.csv'));
$data = read_csv('candidate.csv');
$posisi = $_POST["posisi"];
$nama = $_POST["nama"];
$email = $_POST["email"];
$nohp = $_POST["nohp"];
$alamat = $_POST["alamat"];
$porto = $_POST["portofolio"];
//$fileToUpload = $_POST["fileToUpload"];
// if(empty($posisi) || empty($nama) || empty($email) || empty($nohp) || empty($alamat) || empty($fileToUpload))
// {
// 	echo "<script type='text/javascript'>alert('data belum terisi semua!')</script>";
// 	die();
// }
//echo $nama;
$target_dir = "candidates/";
$target_file = $target_dir . $nama . '_' . basename($_FILES["fileToUpload"]["name"]);
$fileType = pathinfo($target_file, PATHINFO_EXTENSION);
if (isset($_POST["submit"])) {
    //$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    //if($check !== false) {
    //echo "File is an image - " . $check["mime"] . ".";
Exemplo n.º 3
0
include 'header.php';
function read_csv()
{
    $ads = [];
    $handle = fopen('ads.csv', 'r');
    while (!feof($handle)) {
        $row = fgetcsv($handle);
        if (is_array($row)) {
            $ads[] = $row;
        }
    }
    fclose($handle);
    return $ads;
}
$ads = read_csv();
$ads_id = $_GET['id'];
$ad = $ads[$ads_id];
?>
<div class="container">
	<div class="col-md-9">
		<h2><?php 
echo htmlspecialchars($ad[1]);
?>
</h1>
		<p>Posted at: <?php 
echo htmlspecialchars($ad[5]);
?>
</p>
		<p><?php 
echo htmlspecialchars($ad[2]);
Exemplo n.º 4
0
<?php

include_once '../../frame.php';
$table_name = 'fb_company';
$list = new table_class(fb_company);
$fields = $list->fields;
$upload = new upload_file_class();
$upload->save_dir = "/upload/xls/";
$xls = $upload->handle('xls');
$file = ROOT_DIR . 'upload/xls/' . $xls;
$lines = read_csv($file);
unlink($file);
unset($lines[0]);
$success = 0;
$fail = 0;
$fail_info = array();
$sql_array = array();
$db = get_db();
if ($_POST['stock_code'] != '') {
    $code = $_POST['stock_code'] - 1;
} else {
    $code = 'no';
}
unset($_POST['stock_code']);
function conver_place($code)
{
    switch ($code) {
        case '上海':
            return 'SS';
            break;
        case '深圳':
Exemplo n.º 5
0
        return $people;
    } else {
        return FALSE;
    }
}
function get_people($filter)
{
    global $people;
    foreach ($people[$filter] as $p) {
        $str = "<div class=\"adressblock clearfix\">\n";
        $str .= "    <h3>" . get($p['title'], '') . " {$p['first']} {$p['last']}</h3>\n";
        #mind the space before first
        $str .= "    <img class=\"floatimg\" src=\"" . gett("people/", $p['foto'], "anon.jpg") . "\">\n";
        $str .= "    <p>";
        $str .= $p['func'] ? "({$p['func']})<br>" : "";
        $str .= $p['hp'] ? "<a href='{$p['hp']}'>Homepage</a> " : "";
        if ($p['hp'] and $p['mail']) {
            $str .= " | ";
        }
        /* encrypt email adresses, let js decrypt them */
        $encr_adr = encrypt($p['mail'], 21);
        $str .= $p['mail'] ? "<a class='iimeil' href='mailto:someone@inter.net?body=Please enable javascript to decrypt email adresses. Alternativly you can try http://www.phonebook.uzh.ch/.' data-iimeil='{$encr_adr}' title='email address'>eMail</a><br>" : "";
        $str .= $p['buro'] ? "Office: {$p['buro']}<br>" : "";
        $str .= $p['tel'] ? "<a href='tel:" . preg_replace('/\\s+/', '', $p['tel']) . "'>Phone: {$p['tel']}</a><br>" : "";
        $str .= "</p>\n";
        $str .= "</div>\n";
        echo $str;
    }
}
$people = read_csv();
#print_r($people);
Exemplo n.º 6
0
                    }
                }
                $template_class_uri = $csvRow[$spalte];
                $template_class_uri = str_replace("/page/", "/resource/", $template_class_uri);
                $query = 'SELECT uri FROM template_uri where uri="' . $template_class_uri . '" and template_id=' . $template_id;
                $result = mysqlQuery($query);
                if (mysql_num_rows($result) == 0) {
                    $query = "INSERT INTO template_uri (template_id, uri) VALUES ('" . $template_id . "', '" . $template_class_uri . "')";
                    mysqlQuery($query);
                }
            }
            $spalte++;
        }
    }
}
$csv_c = read_csv($hierarchy_csv);
foreach ($csv_c as $row) {
    $i = 0;
    while ($row[$i] != "" || $row[$i + 1] != "" || $row[$i + 2] != "") {
        if ($row[$i] != "") {
            $class = str_replace(" ", "", $row[$i]);
            $classLabel = $row[$i];
            if (!in_array($class, $overall_classes)) {
                $strSQL = "INSERT INTO class (name, label) VALUES ('" . $class . "', '" . $classLabel . "')";
                if (!mysql_query($strSQL)) {
                    // echo "[INFO] " . mysql_error() . "\n";
                    $result_cid = mysql_query('SELECT id FROM class where name="' . $class . '"');
                    if (mysql_num_rows($result_cid) > 0) {
                        while ($row_c = mysql_fetch_row($result_cid)) {
                            $class_id = $row_c[0];
                            $overall_classes[] = $class;
}
// reads a csv file and returns an two-dimensional array of lines/fields
function select_csv($file, $delimiter, $field, $query)
{
    $data_array = file($file);
    for ($i = 0; $i < count($data_array); $i++) {
        $parts_array[$i] = explode($delimiter, $data_array[$i]);
        if (trim(strtolower($parts_array[$i][$field])) == trim(strtolower($query))) {
            $result_array[] = $parts_array[$i];
        }
    }
    return $result_array;
}
// ------------------- demonstration below --------------------
// this willl display all records in the csv file
$data = read_csv('/home/papajohn/public_html/phpparser/dummy.txt', '|');
for ($i = 0; $i < count($data); $i++) {
    for ($u = 0; $u < count($data[$i]); $u++) {
        echo $data[$i][$u] . ' ';
        if ($data[$i][$u] == end($data[$i])) {
            echo '<br>';
        }
    }
}
echo '<p>';
// this willl display all records where the value
// of the selected field matches the query
$data = select_csv('/home/papajohn/public_html/phpparser/dummy.txt', '|', '1', '1069167712');
for ($i = 0; $i < count($data); $i++) {
    for ($u = 0; $u < count($data[$i]); $u++) {
        echo $data[$i][$u] . ' ';
Exemplo n.º 8
0
$csv_rules_properties = "rules_properties.csv";
require_once "../extraction/databaseconfig.php";
require_once "mapping_db_util.php";
$language = "en";
mysql_connect($host, $user, $password) or die("Database connection could not be established.");
mysql_select_db("dbpedia_extraction_" . $language) or die("Database 'dbpedia_extraction_{$language}' not found.");
dropAndCreateRulesTables();
$classes = array();
$result = mysql_query('SELECT id, name FROM class');
if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_row($result)) {
        $classes[$row[1]] = $row[0];
    }
}
$csv_rules_class_content[] = read_csv($csv_rules_class);
$csv_rules_properties_content[] = read_csv($csv_rules_properties);
// uri -> class
foreach ($csv_rules_class_content[0] as $csvRow) {
    $class = null;
    $template_uri = null;
    $csvRow[0] = trim($csvRow[0]);
    $csvRow[1] = trim($csvRow[1]);
    if ($csvRow[1] != "Set Class" && $csvRow[0] != "") {
        if (strpos($csvRow[0], "http://dbpedia.org/resource/Template:") === false) {
            echo "[DIE] Template URI of incorrect format: {$csvRow['0']}";
            die;
        } else {
            $template_uri = $csvRow[0];
        }
        if (!in_array(str_replace(" ", "", $csvRow[1]), array_keys($classes))) {
            echo "[DIE] Class does not exist: {$csvRow['1']}";
Exemplo n.º 9
0
Arquivo: b.php Projeto: andygoo/cms
    $str = "<?php \nreturn " . var_export($data, true) . ";\n";
    file_put_contents($file, $str);
}
function read_csv($file)
{
    $ret = array();
    $fp = fopen($file, "r");
    while (!feof($fp)) {
        $line = trim(fgets($fp));
        $ret[] = explode(',', $line);
    }
    fclose($fp);
    return $ret;
}
$file = 'b.csv';
$data = read_csv($file);
$ret = array();
foreach ($data as $item) {
    $a = strtolower($item[0]);
    $a = str_replace(' ', '', $a);
    $l = mb_strlen($a);
    for ($i = 1; $i <= $l; $i++) {
        $sa = mb_substr($a, 0, $i);
        if (!isset($ret[$sa])) {
            $ret[$sa] = array();
        }
        $ret[$sa][] = $item[0];
    }
    $a = strtolower($item[1]);
    $a = str_replace(' ', '', $a);
    $l = mb_strlen($a);
Exemplo n.º 10
0
////////////////////////////////////////////////////////////////////////////////
//ЯДРО - КЛИЕНТ
////////////////////////////////////////////////////////////////////////////////
//Основа GET
$command_link = 'login='******'&password='******'&searchnumber=' . $search_number . '&procent=' . $procent . '&price_all=' . $price_all;
//Формируем запрос GET
if ($client_price_only) {
    //только прайс клиента
    $command_link .= '&client_price_only=1';
}
//Соединение с сервером данных
$file = 'http://' . $host . '/partner/price.php?code_page=' . $code_page . '&' . $command_link;
function read_csv($file)
{
    //Определение массива
    $arr = array();
    $f = @fopen($file, "rt") or die("Нет связи с файлом!");
    //Чтение результата
    for ($i = 0; $data = fgetcsv($f, 1000, ";"); $i++) {
        //читаем столбцы
        for ($c = 0; $c < count($data); $c++) {
            //записываем в двумерный массив
            $arr[$i][$c] = $data[$c];
        }
    }
    fclose($f);
    return $arr;
}
$result_massiv = read_csv('http://' . $host . '/partner/price.php?code_page=' . $code_page . '&' . $command_link);
$result = json_encode($result_massiv);
echo $result;