Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

003 localhost94 branch #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Website Resmi PHP Indonesia Community
8. Untuk proses development baca dokomentasi di sini : http://docs.popojicms.org

9. Untuk cara kerja github baca di sini : https://github.com/phpindonesia/phpindonesia.or.id-profile/blob/master/git-workflow.md

---

Beberapa content masih dalam tahap development dan pengumpulan data
Expand All @@ -38,5 +39,6 @@ Beberapa content masih dalam tahap development dan pengumpulan data

**Changelog** :

* 10 Juli 2015 : Menambahkan upload facebook group event via po-component/po-event/ #1
* 9 Juli 2015 : Menambahkan git-workflow.md dan update README.md
* 8 Juli 2015 : Core awal untuk menjadi role model.
40 changes: 39 additions & 1 deletion po-adminboard/po-component/po-event/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,46 @@
</ul>
<?php
switch($_GET[act]){
default:
default:
?>
<div class="block full">
<div class="block-title"><h2>Add New</h2></div>
<form id="form-validation" class="form-bordered" method="post" action="<?=$aksi;?>" autocomplete="off" enctype="multipart/form-data">
<fieldset>
<input type="hidden" name="mod" value="event">
<input type="hidden" name="act" value="uploadgroupevent">
<div class="form-group">
<label>Event File <span class="text-danger">*</span></label>
<input class="form-control" type="file" id="eventfile" name="eventfile" required>
<small>File Format : .txt</small>
<br>
<small>Example : <a href="<?php echo $site['con'].'/event/phpindonesia-event-2014.txt'; ?>">phpindonesia-event-2014.txt</a></small>
</div>
<div class="form-group">
<label>Color <span class="text-danger">*</span></label>
<div class="row">
<div class="col-md-6">
<select class="select-chosen-no-search" name="color" style="width:280px;">
<option value="#1BBAE1">default</option>
<option value="#888">night</option>
<option value="#AF64CC">amethyst</option>
<option value="#46B7BF">modern</option>
<option value="#E67E22">autumn</option>
<option value="#1EC1B8">flatie</option>
<option value="#27AE60">spring</option>
<option value="#F31455">fancy</option>
<option value="#E74C3C">fire</option>
</select>
</div>
</div>
</div>
<div class="form-group form-actions">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> Submit</button>
<!-- <button type="reset" class="btn btn-sm btn-danger pull-right" onclick="self.history.back()"><i class="fa fa-times"></i> Cancel</button> -->
</div>
</fieldset>
</form>
</div>
<div class="block block-alt-noborder full">
<div class="row">
<div class="col-md-12">
Expand Down
118 changes: 118 additions & 0 deletions po-adminboard/po-component/po-event/proses.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,123 @@
$table->updateBy('id_event', $id, $data);
header('location:../../admin.php?mod='.$mod);
}
elseif ($mod=='event' AND $act=='uploadgroupevent'){
$filename = $_FILES['eventfile']['tmp_name'];
$color = $val->validasi($_POST['color'],'xss');
/*
* Upload facebook group event
*/
for ($i=1; $i <= 12; $i++) {
/*
* Get event month
* Locale : EN
*/
$monthlong[$i] = date("F", mktime(0, 0, 0, $i+1, 0, 0, 0));
$monthshort[$i] = date("M", mktime(0, 0, 0, $i+1, 0, 0, 0));
}
$monthreverselong = array_flip($monthlong);
$monthreverseshort = array_flip($monthshort);
$handle = fopen($filename, "r");
$result = fread($handle, filesize($filename));
fclose($handle);
$stripdash = explode('-----------------------------------------------', $result);
$x = 0;
foreach ($stripdash as $key => $value) {
// Strip dash between event
$x++;
$stripline = explode("\n", $value);
$y = 0;
$z = 0;
foreach ($stripline as $key2 => $value2) {
// Strip line between entry event
$y++;
$value2 = trim($value2);
if(!empty($value2)){
$z++;
if($z == 1){
// Title always in the first line
$resultdata[$x]['title'] = $value2;
$resultdata[$x]['seotitle'] = str_replace('[', '', $value2);
$resultdata[$x]['seotitle'] = str_replace(']', '', $resultdata[$x]['seotitle']);
$resultdata[$x]['seotitle'] = str_replace(' - ', ' ', $resultdata[$x]['seotitle']);
$resultdata[$x]['seotitle'] = str_replace(' ', '-', $resultdata[$x]['seotitle']);
$resultdata[$x]['seotitle'] = strtolower($resultdata[$x]['seotitle']);
$resultdata[$x]['seotitle'] = stripslashes(htmlspecialchars($resultdata[$x]['seotitle'],ENT_QUOTES));
} elseif ($z == 2){
/*
* Second line always be date and time, but may be differ through the date may be all day or time-between or date-between
*/
$stripdate = explode(' to ', $value2); // Strip date-between date format
if(count($stripdate) > 1){
/*
* date-between format
* Example : Jun 14, 2014 at 09:00 to Jun 15, 2014 at 17:00
*/
$stripdatetime[0] = explode(' at ', $stripdate[0]);
$stripdatetime[1] = explode(' at ', $stripdate[1]);

$stripday[0] = explode(' ', $stripdatetime[0][0]);
$stripday[1] = explode(' ', $stripdatetime[1][0]);

$resultdata[$x]['starttime'] = $stripdatetime[0][1];
$resultdata[$x]['endtime'] = $stripdatetime[1][1];

$resultdata[$x]['startdate'] = $stripday[0][2].'-'.$monthreverseshort[$stripday[0][0]].'-'.(int)$stripday[0][1];
$resultdata[$x]['enddate'] = $stripday[1][2].'-'.$monthreverseshort[$stripday[1][0]].'-'.(int)$stripday[1][1];

$resultdata[$x]['start'] = $resultdata[$x]['startdate'].' '.$resultdata[$x]['starttime'];
$resultdata[$x]['end'] = $resultdata[$x]['enddate'].' '.$resultdata[$x]['endtime'];
$resultdata[$x]['allday'] = 'false';
}else{
/*
* One-day format
* Example : Wednesday, July 16, 2014 at 15:00
*/
$stripdatetime = explode(' at ', $value2);
$stripday = explode(' ', $stripdatetime[0]);

$realtime = explode(' - ', $stripdatetime[1]);
$resultdata[$x]['date'] = $stripday[3].'-'.$monthreverselong[$stripday[1]].'-'.(int)$stripday[2];
if(empty($realtime[0])){
$resultdata[$x]['allday'] = 'true';
$resultdata[$x]['start'] = $resultdata[$x]['date'].' 00:00';
$resultdata[$x]['end'] = $resultdata[$x]['date'].' 00:00';
}else{
$resultdata[$x]['allday'] = 'false';
$resultdata[$x]['starttime'] = $realtime[0];
$resultdata[$x]['endtime'] = (!empty($realtime[1])) ? $realtime[1] : $realtime[0];
$resultdata[$x]['start'] = $resultdata[$x]['date'].' '.$resultdata[$x]['starttime'];
$resultdata[$x]['end'] = $resultdata[$x]['date'].' '.$resultdata[$x]['endtime'];
}
}
$resultdata[$x]['time'] = $value2;
}
$data = trim($value);
$data = stripslashes($data);
$eutf = htmlspecialchars($data,ENT_QUOTES);

$resultdata[$x]['content'] = $eutf; //Overall content
}
}
}
// echo '<pre>';print_r($resultdata);echo '</pre>';exit();
$copyfile = $dir['con'].'event/success/';
if(!is_readable($copyfile.$_FILES['eventfile']['name'])){
$table = new PoTable('event');
foreach ($resultdata as $key => $value) {
$table->save(array(
'title' => $value['title'],
'start' => $value['start'],
'end' => $value['end'],
'allday' => $value['allday'],
'content' => $value['content'],
'seotitle' => $value['seotitle'],
'color' => $color
));
}
}
move_uploaded_file($_FILES['eventfile']['tmp_name'], $copyfile.$_FILES['eventfile']['name']);
header('location:../../admin.php?mod='.$mod);
}
}
?>
Loading