<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
<?php
if (isset($_POST['submit'])) {
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
echo "<h1>" . "File ". $_FILES['filename']['name'] ." uploaded successfully." . "</h1>";
}
$handle = fopen($_FILES['filename']['tmp_name'], "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($data[6]!="Email Address" and $data[6]!=""){
$sql="select * from test where email_address='$data[6]'";
$pageposts = $wpdb->get_row($sql);
if($pageposts->email_address){
$import="update test set home_address='$data[4]',city_state_zip_code='$data[5]',email_address='$data[6]' where email_address='$data[6]'";
}
else
{
$import="INSERT INTO `test` (`last_name`, `home_address`, `city_state_zip_code`, `email_address`) VALUES ('$data[1]','$data[2]', '$data[3]', '$data[4]')";
}
mysql_query($import);
}
}
fclose($handle);
}?>
<form enctype='multipart/form-data' action='' method='post'>
<input size='50' type='file' name='filename'><span>(upload only .csv File.)</span><br />
<input type='submit' name='submit' value='Import' class="add-new-h2"></form>
<?php } ?>
<h2><a href="<?php echo get_site_url();?>/save_forms.php" class="add-new-h2">Export</a></h2>
/// save_forms.php
<?php
global $wpdb;
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=form.csv');
header('Pragma: no-cache');
include_once("connection.php");
$arr = array();
$arr[count($arr)] = array(
,'First Name'
,'Last Name'
);
$sql = 'select * from family_application ';
$allpageposts = mysql_query($sql);
while($row = mysql_fetch_assoc($allpageposts))
{
$arr[count($arr)] = array(
,$row['first_and_last_name']
,$row['last_name']
);
}
$dir=str_replace("save_forms.php","csv/form.csv",$_SERVER['SCRIPT_FILENAME']);
$filename = $dir;
$fp = fopen($dir, 'w');
foreach ($arr as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
readfile($filename);
?>
Comments
Post a Comment