Example #1
0
$con = mysqli_connect("localhost", "k2459657_nruser", "@harianNasional", "k2459657_newsroom");
if (isset($_GET['idBerita'])) {
    $idBerita = $_GET['idBerita'];
} else {
    die("Error. No idBerita Selected! ");
}
$query = "SELECT tblhalaman.Halaman as Hal, tblberita.judulBerita AS Judul " . "FROM tblberita " . "LEFT JOIN tblhalaman ON tblberita.halaman = tblhalaman.idHalaman " . "WHERE idBerita='{$idBerita}'";
$sql = mysqli_query($con, $query);
$record = mysqli_fetch_array($sql);
// HTML fragment we want to parse:
$periode = date('Y-m');
//periode tahun bulan
$tglBerita = date('d', time() + 86400);
//tanggal besok
$dailyNaskah = 'naskah/' . $periode . '/' . $tglBerita . '/';
$filehtml = fileHtmlName($record['Hal'], $record['Judul']);
$filepath = $dailyNaskah . $filehtml;
$html = file_get_contents($filepath . ".html");
// New Word Document:
$phpword_object = new PHPWord();
$section = $phpword_object->createSection();
// HTML Dom object:
$html_dom = new simple_html_dom();
$html_dom->load('<html><body>' . $html . '</body></html>');
// Create the dom array of elements which we are going to work on:
$html_dom_array = $html_dom->find('html', 0)->children();
// We need this for setting base_root and base_path in the initial_state array
// (below). We are using a function here (derived from Drupal) to create these
// paths automatically - you may want to do something different in your
// implementation. This function is in the included file
// documentation/support_functions.inc.
Example #2
0
$query = "SELECT tblhalaman.Halaman as Hal, tblrubrik.namaRubrik AS Rubrik, " . "tblberita.judulBerita AS Judul, tblberita.kota AS Kota, " . "tblberita.isiBerita AS Naskah, tbluser.uname As Penulis, " . "tblberita.penulisBerita AS idPenulis " . "FROM tblberita " . "LEFT JOIN tblhalaman ON tblberita.halaman = tblhalaman.idHalaman " . "LEFT JOIN tblrubrik ON tblberita.rubrikBerita = tblrubrik.idRubrik " . "LEFT JOIN tbluser ON tblberita.penulisBerita = tbluser.iduser " . "WHERE idBerita='{$idBerita}'";
$sql = mysqli_query($con, $query);
$record = mysqli_fetch_array($sql);
$idpenulis = $record['idPenulis'];
$query1 = "SELECT firstName, midleName, lastName FROM tbluser WHERE iduser='******'";
$sql1 = mysqli_query($con, $query1);
$record1 = mysqli_fetch_array($sql1);
$fname = $record1['firstName'];
$mname = $record1['midleName'];
$lname = $record1['lastName'];
$namaLengkap = $fname . " " . $mname . " " . $lname;
$string = $record['Naskah'];
$string1 = html_entity_decode($string);
//html content
$content = "<H2>" . $record['Judul'] . "</H2>" . "<br/><br/><b>" . $record['Kota'] . " (HN)</b>" . $string1 . "" . $namaLengkap;
$periode = date('Y-m');
//periode tahun bulan
$tglBerita = date('d', time() + 86400);
//tanggal besok
// create folder if not exist
if (!file_exists('naskah')) {
    mkdir('naskah', 0777, true);
}
$dailyNaskah = 'naskah/' . $periode . '/' . $tglBerita;
if (!file_exists($dailyNaskah)) {
    mkdir($dailyNaskah, 0777, true);
}
$fp = fopen($dailyNaskah . "/" . fileHtmlName($record['Hal'], $record['Judul']) . ".html", "wb");
fwrite($fp, $content);
fclose($fp);
header("location:index.php");
Example #3
0
$con = mysqli_connect("localhost", "root", "", "newsroom");
if (isset($_GET['idBerita'])) {
    $idBerita = $_GET['idBerita'];
} else {
    die("Error. No idBerita Selected! ");
}
$query = "SELECT tblHalaman.Halaman as Hal,   \n\t\t\t\ttblberita.judulBerita AS Judul\n\t\t\t\tFROM tblberita \n\t\t\t\tLEFT JOIN tblhalaman ON tblberita.halaman = tblhalaman.idHalaman \n\t\t\t\tWHERE idBerita='{$idBerita}'";
$sql = mysqli_query($con, $query);
$record = mysqli_fetch_array($sql);
// HTML fragment we want to parse:
$periode = date('Y-m');
//periode tahun bulan
$tglBerita = date('d', time() + 86400);
//tanggal besok
$dailyNaskah = 'naskah/' . $periode . '/' . $tglBerita . '/';
$filehtml = $dailyNaskah . fileHtmlName($record['Hal'], $record['Judul']);
$html = file_get_contents($filehtml . ".html");
// New Word Document:
$phpword_object = new PHPWord();
$section = $phpword_object->createSection();
// HTML Dom object:
$html_dom = new simple_html_dom();
$html_dom->load('<html><body>' . $html . '</body></html>');
// Create the dom array of elements which we are going to work on:
$html_dom_array = $html_dom->find('html', 0)->children();
// We need this for setting base_root and base_path in the initial_state array
// (below). We are using a function here (derived from Drupal) to create these
// paths automatically - you may want to do something different in your
// implementation. This function is in the included file
// documentation/support_functions.inc.
$paths = htmltodocx_paths();