示例#1
0
function write_worksheet($in, $file, $options = array())
{
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (isset($options["write"])) {
        if ($ext != "" && $options["write"] != $ext) {
            fputs(STDERR, "Warning: Ignored the extension to adopt {$options["write"]}.\n");
        }
        $ext = $options["write"];
    }
    switch (strtolower($ext)) {
        case "raw":
            $out = fopen($file, "w");
            while (($line = fgets($in)) !== false) {
                fputs($out, $line);
            }
            fclose($out);
            break;
        case "csv":
            $options["delimiter"] = ",";
            write_csv($in, $file, $options);
            break;
        case "tsv":
            $options["delimiter"] = "\t";
            write_csv($in, $file, $options);
            break;
        case "xlsx":
            write_excel($in, $file, $options);
            break;
        case "json":
            write_json($in, $file, $options);
            break;
        case "yml":
        case "yaml":
            write_yaml($in, $file, $options);
            break;
        case "xml":
            write_xml($in, $file, $options);
            break;
        case "htm":
        case "html":
            // a write only converter
            write_html($in, $file, $options);
            break;
        case "tex":
            // a write only converter
            write_tex($in, $file, $options);
            break;
        case "sql":
            // a write only converter
            write_sql($in, $file, $options);
            break;
        default:
            fputs(STDERR, "Error[{$ext}]: No writer is available.\n");
            break;
    }
    return;
}
示例#2
0
    echo "</header>";
    die;
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "<header class='padding-large' >";
        echo "<h4>The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded. Your data sent successfully!</h4>";
        echo "<a href='http://career.bisabelajar.com' class='margin-small padding-small yellow-bg btn btn-primary btn-xl'> Kembali </a> ";
        echo "</header>";
        // die();
    } else {
        echo "<header class='padding-large' >";
        echo "<h4>Sorry, there was an error uploading your file.</h4>";
        echo "<a href='http://career.bisabelajar.com' class='margin-small padding-small yellow-bg btn btn-primary btn-xl'> Kembali </a> ";
        echo "</header>";
        die;
    }
}
// Check if image file is a actual image or fake image
$data[] = array($posisi, $nama, $email, $nohp, $alamat, $porto);
write_csv('candidate.csv', $data);
//header("Location: http://career.bisabelajar.com/index.php");
//echo "<script type='text/javascript'>alert('data terkirim dengan sukses!')</script>";
?>

<?php 
include 'layout/foot.php';
?>

</body>
</html>
    $result = pod_query("SELECT name AS Name, email AS Email, address AS Address, city AS City, state AS State, zipcode AS Zipcode, phone AS Phone, DATE_FORMAT(event_date,'%Y/%m/%d') AS EventDate, interests AS Interests, interest_weddings AS InterestedInWeddings, interest_social AS InterestedInSocial, interest_corporate AS InterestedInCorporate, interest_mitzvahs AS InterestedInMitzvahs, interest_parties AS InterestedInParties, notes AS Notes, inquire_date AS DateOfInquiry FROM wp_pod_tbl_user_profiles WHERE event_date = '0000-00-00 00:00:00' OR event_date >= NOW() ORDER BY id");
    $out = fopen('php://output', 'w');
    // get our field information
    $i = 0;
    $aFields = array();
    while ($i < mysql_num_fields($result)) {
        $meta = mysql_fetch_field($result, $i);
        $aFields[] = $meta->name;
        $i++;
    }
    // write our fields to the CSV file
    write_csv($out, $aFields);
    // write our rows to the CSV file
    while ($row = mysql_fetch_assoc($result)) {
        $field_data = array_values($row);
        write_csv($out, $field_data);
    }
    fclose($out);
    exit;
}
$cmd = iif($cmd == '', 'bydate', $cmd);
$nav = '<p>Sort by: ';
if ($cmd == 'bydate') {
    $sortby = 't.event_date';
    $nav .= 'Event Date | ';
} else {
    $nav .= '<a href="' . $const['PAGE_LEADS'] . '/bydate">Event Date</a> | ';
}
if ($cmd == 'byinquiry') {
    $sortby = 't.inquire_date DESC';
    $nav .= 'Inquiry Date | ';
        $store[$config['_mandatory']] = "__ERROR__ ";
        ++$missing;
    }
}
if ($missing || isset($_cancel)) {
    write_errors($config['_html_return'], $store);
    // show confirm page
} elseif (!empty($config['_html_confirm'])) {
    parse_html($config['_html_confirm'], $store);
    // perform all actions
} else {
    if ($config['_mail_to']) {
        write_mail();
    }
    if ($config['_save_csv']) {
        write_csv($config['_csv_directory'] . '/' . $config['_save_csv'] . '.csv');
    }
    if ($config['_save_database']) {
        write_database($config['_save_database']);
    }
    if ($config['_mail_confirm']) {
        write_receipt();
    }
    if (empty($config['_html_thanks'])) {
        parse_html($config['_html_return'], $store);
    } else {
        parse_html($config['_html_thanks'], $store);
    }
}
exit;
// === C O D E ==========================================================
示例#5
0
            }
        }
        fclose($handle);
        return $ads;
    }
    function write_csv($array)
    {
        $handle = fopen('ads.csv', 'w');
        fputcsv($handle, $array);
        fclose($handle);
    }
    $createdAt = date('D, d M Y');
    $ads = read_csv();
    $new_ad = [$_POST['title'], $_POST['body'], $_POST['contact_name'], $_POST['contact_email'], $createdAt];
    $ads[] = $new_ad;
    write_csv($ads);
    header('location:ad_home.php');
    exit;
}
?>
<div class="container">
	<form role="form" method="POST">
		<div class="form-group">
			<label for="category">Category</label>
			<select name="category" class="form-control">
				<option value="Automotive">Automotive</option>
				<option value="Jobs">Jobs</option>
				<option value="Housing">Housing/Rental Properties</option>
				<option value="Dating">Dating</option>
				<option value="Deals">Deals</option>
			</select>
}
$data = substr($x, $pos, $pos2 - $pos);
$list = [];
$rows = explode("\n", $data);
for ($i = 0; $i < count($rows); $i++) {
    if (!$rows[$i] || $rows[$i] == '|-' || $rows[$i] == '|') {
        continue;
    }
    $country = cleanText($rows[$i++]);
    $country = mapCountry($country);
    $codes = extractLinks($rows[$i++]);
    $timezone = $rows[$i++];
    foreach ($codes as $c) {
        $code = getRightSideOfMediawikiTag($c);
        $code = str_replace(' ', '', $code);
        $code = str_replace('+', '', $code);
        $codes2 = explode(',', $code);
        foreach ($codes2 as $code2) {
            if (!is_numeric($code2)) {
                echo "Skipping " . $code2 . "\n";
                continue;
            }
            $o = new \MartinLindhe\Data\CallingCodes\CallingCode();
            $o->country = $country;
            $o->code = $code2;
            $list[] = $o;
        }
    }
}
write_csv(__DIR__ . '/../data/calling_codes.csv', $list);
write_json(__DIR__ . '/../data/calling_codes.json', $list);
    }
    $o->name = trim($name);
    // HACK
    $cols[4] = str_replace('[[Caribbean Netherlands]] (BQ - Bonaire, Sint Eustatius and Saba)', 'Caribbean Netherlands', $cols[4]);
    $countries = [];
    foreach (explode(', ', $cols[4]) as $c) {
        $c = \MartinLindhe\MediawikiClient\Client::stripMediawikiLinks($c);
        $c = trim(getRightSideOfMediawikiTag($c));
        if (!$c) {
            continue;
        }
        $code = countryCodeFromName($c, $allCountries);
        if (!$code) {
            err("WARNING: didn't find country code to " . $c);
        } else {
            $countries[] = $code;
        }
    }
    $o->countries = $countries;
    $list[] = $o;
}
if (!isAlpha3InList('BTC', $list)) {
    $o = new MartinLindhe\Data\Currencies\Currency();
    $o->alpha3 = 'BTC';
    $o->name = 'Bitcoin';
    $o->number = '000';
    $o->decimals = 2;
    $list[] = $o;
}
write_csv(__DIR__ . '/../data/currencies.csv', $list);
write_json(__DIR__ . '/../data/currencies.json', $list);
        $name = $rows[$i];
        $i++;
        $rows[$i] = cleanText($rows[$i]);
        $cols = explode('||', $rows[$i]);
    }
    $o = new \MartinLindhe\Data\Countries\Country();
    $o->alpha2 = getRightSideOfMediawikiTag($cols[0]);
    $o->alpha3 = getRightSideOfMediawikiTag($cols[1]);
    $o->number = getRightSideOfMediawikiTag($cols[2]);
    $name = cleanText($name);
    $name = getRightSideOfMediawikiTag(\MartinLindhe\MediawikiClient\Client::stripMediawikiLinks($name));
    $pos = mb_strpos($name, '/');
    if ($pos !== false) {
        $name = mb_substr($name, 0, $pos);
    }
    $pos = mb_strpos($name, '|');
    if ($pos !== false) {
        $name = mb_substr($name, $pos + 1);
    }
    $o->name = trim(translateName($name));
    $list[] = $o;
}
// aug 2015: Kosovo has a temporary "XK" code since 2010
$o = new \MartinLindhe\Data\Countries\Country();
$o->alpha2 = 'XK';
$o->alpha3 = 'XKO';
$o->number = '';
$o->name = 'Kosovo';
$list[] = $o;
write_csv(__DIR__ . '/../data/countries.csv', $list);
write_json(__DIR__ . '/../data/countries.json', $list);
require_once 'initialize.php';
/* 
Initialize Global array

Reason for the use of Array:
Processing speed is a lot faster than modifiing CSV data constantly. 
*/
$GLOBALS['z'] = array();
// Product Category Loop
for ($i = 0; $i < sizeOf($product_categories); $i++) {
    // Pass array value into Query Function
    $response = product_categories_items($product_categories[$i]['queryValue']);
    process_json($response, $product_categories[$i]);
}
write_csv();
function product_categories_items($customQuery)
{
    /*
    
    Removed connection information - Private
    */
    $curl = curl_init($API_Call);
    curl_setopt($curl, CURLOPT_FAILONERROR, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $cresult = curl_exec($curl);
    if (curl_error($curl)) {
        // if error occurs: