Exemplo n.º 1
0
 public function controller($action)
 {
     switch ($action) {
         case 'login':
             $login = new LoginLogout();
             $login->logIn();
             break;
         case 'do-login':
             $login = new LoginLogout();
             $login->doLogin();
             break;
         case 'logout':
             $login = new LoginLogout();
             $login->logOut();
             break;
         case 'list':
             $records = new Records();
             $records->getRecords();
             break;
         case 'view-record':
             $records = new Records();
             $records->getOneRecord(intval($_GET['id']));
             break;
         case 'add-record':
             $records = new Records();
             $records->addRecord();
             break;
         case 'delete-record':
             $records = new Records();
             $records->delRecord(intval($_GET['id']));
             break;
         case 'add-comment':
             $comment = new Comments();
             $comment->addComment();
             break;
         case 'delete-comment':
             $comment = new Comments();
             $comment->delComment(intval($_GET['id']));
             break;
         case 'about':
             require ROOT . '/views/about.php';
             break;
         default:
             die("No action");
     }
 }
Exemplo n.º 2
0
 protected function _postCommentEntry($rawBody, $item)
 {
     // Get the Atom Adapter
     $entry = AtomDocumentAdapterFactory::getInstance()->adapt($rawBody);
     /* @var $entry AtomEntryAdapter */
     // Check whether the entry is an atom entry or not
     if ($entry->getDocumentType() == Atomns::ENTRY_ELEMENT) {
         $atomProcessor = new AtomProcessor();
         // Read the Entry
         $data = $atomProcessor->readCommentEntry($entry);
         if ($data['timestamp'] == '') {
             $data['timestamp'] = time();
         }
         $data['source_id'] = $item->getSource();
         $data['item_id'] = $item->getID();
         // Add new comment
         $comments = new Comments();
         $comments->setUser($this->_application->user);
         $data['id'] = $comments->addComment($data['source_id'], $data['item_id'], $data['comment'], $data['name'], $data['email'], $data['website'], $data['timestamp'], 0);
         return new Comment($data);
     } else {
         $this->_buildResponse(Api_BaseController::HTTP_FAILED, 'Invalid Data!!! Atom Entry Document is required!!');
         return false;
     }
 }
Exemplo n.º 3
0
 public function addAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_helper->json->sendJson(true);
     }
     $form = $this->getForm();
     if (!$form->isValid($_POST)) {
         return $this->_helper->json->sendJson($form->getErrorArray());
     }
     // Get the values and proceed
     $values = $form->getValues();
     $source_id = $values['source'];
     $item_id = $values['item'];
     $name = $values['name'];
     $email = $values['email'];
     $website = $values['website'];
     $comment = $values['comment'];
     $options = $values['options'];
     $timestamp = time();
     $notify = @in_array('notify', $options) ? 1 : 0;
     // Get the source and the user owning it
     $data = new Data();
     $sources = new Sources();
     $users = new Users();
     // Does the source exist ?
     if (!($source = $sources->getSource($source_id))) {
         return $this->_helper->json->sendJson(true);
     }
     // Does the item exists?
     if (!($item = $data->getItem($source_id, $item_id))) {
         return $this->_helper->json->sendJson(true);
     }
     // Does the user exist ?
     if (!($user = $users->getUser($source['user_id']))) {
         return $this->_helper->json->sendJson(true);
     }
     // Validate the website URL
     $matches = array();
     if (!preg_match_all("/^http/", $website, $matches)) {
         $website = "http://{$website}";
     }
     // Add the comment to the database
     $comments = new Comments();
     $comments->addComment($source_id, $item_id, $comment, $name, $email, $website, $timestamp, $notify);
     // Send an email alert to owner
     $on_comment = $this->_properties->getProperty('on_comment');
     $owner = $this->_application->user && $this->_application->user->email == $email ? true : false;
     if ($on_comment && !$owner) {
         $slug = $item->getSlug();
         Stuffpress_Emails::sendCommentEmail($user->email, $user->username, $name, $email, $comment, $slug);
     }
     // Send email alerts to everyone else (skip owner and current submiter)
     $subscribers = $comments->getSubscriptions($source_id, $item_id);
     foreach ($subscribers as $subscriber) {
         if ($subscriber['email'] == $user->email || $subscriber['email'] == $email) {
             continue;
         }
         Stuffpress_Emails::sendCommentNotifyEmail($subscriber['email'], $subscriber['name'], $name, $comment, $source_id, $item_id);
     }
     // Ok send the result
     return $this->_helper->json->sendJson(false);
 }
Exemplo n.º 4
0
/**
 * Post a new comment.
 *
 * @global Smarty $smarty
 * @param integer $kll_id
 * @param string $author
 * @param string $comment
 * @param string $password
 * @return xajaxResponse
 */
function postComments($kll_id, $author, $comment, $password = '')
{
    if (config::get('comments')) {
        $kll_id = intval($kll_id);
        $comments = new Comments($kll_id);
        global $smarty;
        $config = new Config();
        $page = new Page("Comments");
        $comments = new Comments($kll_id);
        $pw = false;
        if (!config::get('comments_pw') || $page->isAdmin()) {
            $pw = true;
        }
        if ($pw || crypt($password, config::get("comment_password")) == config::get("comment_password")) {
            if ($comment == '') {
                return getComments($kll_id, 'Error: The silent type, hey? Good for you, bad for a comment.');
            } else {
                if (!$author) {
                    $author = 'Anonymous';
                }
                $comments->addComment($author, $comment);
                return getComments($kll_id);
            }
        } else {
            // Password is wrong
            return getComments($kll_id, 'Error: Wrong Password');
        }
    } else {
        return false;
    }
}
Exemplo n.º 5
0
<?php

require_once "../config/Autoload.php";
require_once "../libs/datafilter.php";
if (isset($_POST['text_c'])) {
    $_POST = trimAll($_POST);
    $_POST = htmlAll($_POST);
    $comments = Comments::addComment($_POST['message_id'], $_POST['date_c'], $_POST['text_c'], $_POST['user_comment_id']);
    if ($comments == true) {
        echo 'Added successfully';
    } else {
        echo 'Please try again';
    }
}
if (isset($_POST['text_edit_c'])) {
    $_POST = trimAll($_POST);
    $_POST = htmlAll($_POST);
    $edit_comment = Comments::editComment($_POST['comment_edit_id'], $_POST['message_c_edit_id'], $_POST['text_edit_c']);
    if ($edit_comment == true) {
        echo 'Added successfully';
    } else {
        echo 'Please try again';
    }
}
Exemplo n.º 6
0
 /**
  * Start constructing the page.
  *
  * Prepare all the shared variables such as dates and check alliance ID.
  */
 function start()
 {
     $this->kll_id = (int) edkURI::getArg('kll_id');
     $this->kll_external_id = 0;
     if (!$this->kll_id) {
         $this->kll_external_id = (int) edkURI::getArg('kll_ext_id');
         if (!$this->kll_external_id) {
             // internal and external ids easily overlap so we can't guess which
             $this->kll_id = (int) edkURI::getArg('id', 1);
         }
     }
     $this->nolimit = edkURI::getArg('nolimit', 2);
     $this->menuOptions = array();
     $this->page = new Page('Kill details');
     if (!$this->kll_id && !$this->kll_external_id) {
         $html = "No kill id specified.";
         $this->page->setContent($html);
         $this->page->generate($html);
         exit;
     }
     if ($this->kll_id) {
         $this->kill = Cacheable::factory('Kill', $this->kll_id);
     } else {
         $this->kill = new Kill($this->kll_external_id, true);
         $this->kll_id = $this->kill->getID();
     }
     if (!$this->kill->exists()) {
         $html = "That kill doesn't exist.";
         $this->page->setContent($html);
         $this->page->generate($html);
         exit;
     }
     if ($this->kll_external_id) {
         $this->page->addHeader("<link rel='canonical' href='" . edkURI::build(array('kll_ext_id', $this->kll_external_id, true)) . "' />");
     } else {
         $this->page->addHeader("<link rel='canonical' href='" . edkURI::build(array('kll_id', $this->kll_id, true)) . "' />");
     }
     $this->finalblow = false;
     $this->commenthtml = '';
     // Check for posted comments.
     // If a comment is being posted then we won't exit this block.
     if (isset($_POST['comment']) && config::get('comments')) {
         $comments = new Comments($this->kll_id);
         $pw = false;
         if (!config::get('comments_pw') || $this->page->isAdmin()) {
             $pw = true;
         }
         if ($pw || crypt($_POST['password'], config::get("comment_password")) == config::get("comment_password")) {
             if ($_POST['comment'] == '') {
                 $this->commenthtml = 'Error: The silent type, hey? Good for' . ' you, bad for a comment.';
             } else {
                 $comment = $_POST['comment'];
                 $name = $_POST['name'];
                 if ($name == null) {
                     $name = 'Anonymous';
                 }
                 $comments->addComment($name, $comment);
                 //Redirect to avoid refresh reposting comments.
                 header('Location: ' . $_SERVER['REQUEST_URI'], TRUE, 303);
                 die;
             }
         } else {
             // Password is wrong
             $this->commenthtml = 'Error: Wrong Password';
         }
     }
     global $smarty;
     if (!file_exists('img/panel/' . config::get('fp_theme') . '.png')) {
         config::set('fp_theme', 'tyrannis');
     }
     $smarty->assign('panel_colour', config::get('fp_theme'));
     $smarty->assign('showiskd', config::get('kd_showiskd'));
     $smarty->assign('formURL', edkURI::build(edkURI::parseURI()));
     // Check admin update options.
     if ($this->page->isAdmin()) {
         $smarty->assign('admin', true);
         $this->updatePrices();
     }
     $this->involvedSetup();
     $this->fittingSetup();
 }
Exemplo n.º 7
0
 public function showProduct()
 {
     $msg = "";
     if (filter_has_var(INPUT_GET, 'id')) {
         $idprod = $_GET['id'];
     }
     $product = new Product();
     $resultatProduct = $product->findProduct($idprod);
     include_once "controllers/comments.php";
     $comm = new Comments();
     if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
         $id_membre = $_SESSION['user']['id_membre'];
         $id_salle = $resultatProduct['id_salle'];
         $comm->addComment($id_membre, $id_salle);
     }
     $resultatRoom = $product->access_ModelRoom_FindOne($resultatProduct['id_salle']);
     $resultatPromo = $product->access_ModelPromotion_FindOne($resultatProduct['id_promo']);
     $dateArrivee = $product->changeDatetoFrenchFormat($resultatProduct['date_arrivee']);
     $dateDepart = $product->changeDatetoFrenchFormat($resultatProduct['date_depart']);
     $msg .= '<div class="row rowColor">';
     $msg .= '<div class="col-sm-10 rowColor2">';
     $msg .= '<div class="blocImage">';
     $msg .= '<img class="img-responsive" src="' . $resultatRoom['photo'] . '" width= 600/>';
     $msg .= '</div>';
     $msg .= '<div class="infos ">';
     $msg .= '<p class="detailTitre">' . $resultatRoom['titre'] . '</p>';
     $msg .= '<p class="detailCat">Catégorie: ' . $resultatRoom['categorie'] . '</p>';
     $msg .= '<p class="detailCat">Max: ' . $resultatRoom['capacite'] . ' personnes</p>';
     $msg .= '<p class="detailAdresse">' . $resultatRoom['adresse'] . '</p>';
     $msg .= '<p class="detailAdresse">' . $resultatRoom['cp'] . ' ' . $resultatRoom['ville'] . '</p>';
     $msg .= '<p class="detailDate">Date d\'arrivée: ' . $dateArrivee . '</p>';
     $msg .= '<p class="detailDate">Date de départ: ' . $dateDepart . '</p>';
     $msg .= '<p class="detailPrix">' . $resultatProduct['prix'] . ' €</p>';
     // SI LE CODE PROMO EXISTE
     if (isset($resultatPromo['code_promo']) && $resultatPromo['code_promo'] != '') {
         $msg .= '<p class="detailPromo">*Code promo: ' . $resultatPromo['code_promo'] . ' pour bénéficier d\'une réduction de ' . $resultatPromo['reduction'] . ' €</p>';
     }
     $msg .= '<div class="clearfix"></div>';
     $msg .= '</div>';
     $msg .= '</div>';
     $msg .= '<div class="col-sm-2 optionsButton">';
     if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
         $msg .= '<a class="btn btn-success" href="index.php?controller=orders&action=addToCart&id=' . $resultatProduct['id_produit'] . '" title="Ajouter">Ajouter au panier</a>';
     } else {
         $msg .= '<a class="btn btn-success btnDetail" href="index.php?controller=members&action=connect" title="Se connecter">Se connecter</a>';
         $msg .= "<br/>";
         $msg .= '<a class="btn btn-success btnDetail" href="index.php?controller=members&action=add_member" title="Inscription">Inscription</a>';
     }
     $msg .= '</div>';
     $msg .= '</div>';
     // COMMENTAIRES
     $msg .= '<div class="row row2">';
     $msg .= '<div class="col-sm-4 detailAvis">';
     // AFFICHAGE DES AVIS SUR LA SALLE
     $comments = $product->access_ModelComment_roomComments($resultatProduct['id_salle']);
     if (isset($comments) && !empty($comments)) {
         $msg .= '<p class="avisTitre">Avis sur cette salle: </p>';
         foreach ($comments as $comm) {
             $member = $product->access_ModelMember_retrieveMember($comm['id_membre']);
             $msg .= '<div class="commentaire">';
             $msg .= '<p class="avisMembre">Par ' . $member['prenom'] . ' ' . $member['nom'] . ' le ' . $comm['date'] . '</p>';
             $msg .= '<p class="avisTexte">' . $comm['commentaire'] . '</p>';
             $msg .= '<p class="avisNote">Note: ' . $comm['note'] . '/10  </p>';
             $msg .= '</div>';
         }
     } else {
         $msg .= '<p>Cette salle n\'a aucun commentaires pour le moment.</p>';
     }
     $msg .= '</div>';
     $msg .= '<div class="col-sm-8">';
     $msg .= '<div class="row rowDesc">';
     $msg .= '<p>' . $resultatRoom['description'] . '</p>';
     $msg .= '</div>';
     $msg .= '<div class="row rowMap">';
     $msg .= '<input type="hidden" id="address" value="' . $resultatRoom['adresse'] . ' ' . $resultatRoom['cp'] . ' ' . $resultatRoom['ville'] . '"/>';
     $msg .= '<div id="map-canvas" class="pull-right"></div>';
     $msg .= '</div>';
     $msg .= '</div>';
     $msg .= '</div>';
     $msg .= '<div class="row rowAvisForm">';
     // Vérification si l'utilisateur connecté a déjà posté un avis sur cette salle
     if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
         $verif = $product->checkMemberComments($_SESSION['user']['id_membre'], $resultatProduct['id_salle']);
     }
     if (empty($verif) || $verif == NULL) {
         //Affichage du formulaire pour entrer un commentaire
         if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
             $msg .= '<form method="post" class="form-horizontal">';
             $msg .= '<div class="form-group">';
             $msg .= '<label class="label-control col-sm-4" for="comment">Ajouter un commentaire</label>';
             $msg .= '<div class="col-sm-8">';
             $msg .= '<textarea name="comment" id="comment">Votre commentaire...</textarea>';
             $msg .= '</div>';
             $msg .= '</div>';
             $msg .= '<div class="form-group">';
             $msg .= '<label class="label-control col-sm-4" for="note">Note/10</label>';
             $msg .= '<div class="col-sm-8">';
             $msg .= '<select class="form-control" name="note" id="note">';
             $msg .= '<option value="0">0</option>';
             $msg .= '<option value="1">1</option>';
             $msg .= '<option value="2">2</option>';
             $msg .= '<option value="3">3</option>';
             $msg .= '<option value="4">4</option>';
             $msg .= '<option value="5" selected>5</option>';
             $msg .= '<option value="6">6</option>';
             $msg .= '<option value="7">7</option>';
             $msg .= '<option value="8">8</option>';
             $msg .= '<option value="9">9</option>';
             $msg .= '<option value="10">10</option>';
             $msg .= '</select><br/>';
             $msg .= '</div>';
             $msg .= '</div>';
             $msg .= '<div class="form-group">';
             $msg .= '<div class="col-sm-12">';
             $msg .= '<input class="btn btn-success pull-right" type="submit" name="enregistrer" value="Enregistrer">';
             $msg .= '</div>';
             $msg .= '</div>';
             $msg .= '</form>';
         } else {
             $msg .= 'Vous devez vous connecter pour pouvoir poster un commentaire';
         }
     } else {
         $msg .= '<div class="panel panel-default">';
         $msg .= '<div class="panel-body">';
         $msg .= 'Merci pour votre commentaire.';
         $msg .= '</div>';
         $msg .= '</div>';
     }
     $msg .= '</div>';
     // AUTRES SUGGESTIONS
     // Récupérer localisation de la salle et date du produit
     //        var_dump($resultatRoom['ville']);
     //        var_dump($resultatProduct['date_arrivee']);
     // Recupérer les produits dont la ville est identique et la date d'arrivée >= à celle du produit déjà choisi
     $rooms = $product->access_ModelRoom_findByCity($resultatRoom['ville']);
     $suggest = $product->findSuggestions($resultatProduct['date_arrivee']);
     //        var_dump($rooms);
     //        var_dump($suggest);
     $msg .= '<div class="row">';
     $msg .= '<div id="suggestTitle">';
     $msg .= '<h3>Autres suggestions</h3>';
     $msg .= '</div>';
     $msg .= '<div class="owl-carousel">';
     foreach ($suggest as $suggestion) {
         foreach ($rooms as $room) {
             if ($suggestion['id_salle'] == $room['id_salle'] && $suggestion['id_produit'] != $resultatProduct['id_produit']) {
                 $date = new DateTime($suggestion['date_arrivee']);
                 $suggestion['date_arrivee'] = $date->format('d-m-Y');
                 $date = new DateTime($suggestion['date_depart']);
                 $suggestion['date_depart'] = $date->format('d-m-Y');
                 $msg .= '<div>';
                 $msg .= '<a href="index.php?controller=products&action=showProduct&id=' . $suggestion['id_produit'] . '"><img src="' . $room['photo'] . '" width=360 /></a><br/>';
                 $msg .= $room['titre'] . '<br/>';
                 $msg .= $suggestion['prix'] . '€ Pour ' . $room['capacite'] . ' personnes<br/>';
                 $msg .= 'Du ' . $suggestion['date_arrivee'] . ' au ' . $suggestion['date_depart'] . '<br/>';
                 $msg .= $room['ville'] . '<br/>';
                 $msg .= '</div>';
             }
         }
     }
     $msg .= '</div>';
     $msg .= '</div>';
     include "views/products/showProduct.php";
 }
Exemplo n.º 8
0
        // If sent Javascript will do anything...
        echo "Error: Unauthorized.";
    }
}
if (is_writable($jsonDatabaseFile) && is_readable($jsonDatabaseFile)) {
    if (!($handle = fopen($jsonDatabaseFile, 'a+'))) {
        echo "Cannot open file ({$jsonDatabaseFile})";
        exit;
    }
    $comments = new Comments();
    $comments->allComments($jsonDatabaseFile);
    if ($_GET['action'] == "save" && $_POST['id'] == "E73BF175-F920-447D-993D-CE4169F17BCD") {
        $postedComment = new Comment();
        $postedComment->createComment($_POST['commentatorName'], $_POST['commentatorEmail'], $_POST['commentatorText'], $_POST['commentatorWebsite'], $_SERVER['REMOTE_ADDR']);
        if (!is_null($postedComment)) {
            $comments->addComment($postedComment);
            echo json_encode($postedComment);
        } else {
            echo "Error: Comment could not be saved.";
        }
    } else {
        if ($_GET['action'] == "save" && $_POST['id'] != "E73BF175-F920-447D-993D-CE4169F17BCD") {
            echo "Error: Unauthorized.";
        }
    }
    if ($_GET['action'] == "remove") {
        if ($_POST['adminUsername'] == $encryptedUsername && $_POST['adminPassword'] == $encryptedPassword) {
            $postid = $_GET['id'];
            if ($postid == "") {
                echo "Error: No ID sent or it is empty.";
            } else {
/**
 * Home page layout and importer
 */
function upload_csv_file()
{
    global $impCE, $impRen, $pluginActive, $custo_taxo;
    global $custom_array;
    global $wpdb;
    $mFieldsArr = '';
    if (!isset($_REQUEST['action']) || !$_REQUEST['action']) {
        ?>
			<script>
			window.location.href = "<?php 
        echo WP_PLUGIN_URL;
        ?>
/../../wp-admin/admin.php?page=upload_csv_file&action=post";
		</script>
			<?php 
    }
    $importdir = $impCE->getUploadDirectory();
    if (!$_REQUEST['action'] || isset($_POST['post_csv']) && $_POST['post_csv']) {
        echo "<input type = 'hidden' value ='dashboard' id='requestaction'>";
    } else {
        echo "<input type='hidden' value='" . $_REQUEST['action'] . "' id ='requestaction'>";
    }
    echo '<input type="hidden" value="' . WP_CONTENT_URL . '" id="contenturl">';
    /*
     * Get POST data
     */
    if (isset($_POST['delim']) && in_array($_POST['delim'], $impCE->delim_avail)) {
        $impCE->delim = $_POST['delim'];
    }
    if (isset($_POST['titleduplicatecheck']) && trim($_POST['titleduplicatecheck'] != "")) {
        $impCE->titleDupCheck = true;
    }
    if (isset($_POST['contentduplicatecheck']) && trim($_POST['contentduplicatecheck'] != "")) {
        $impCE->conDupCheck = true;
    }
    $custom_array = array();
    if (isset($_POST['Import'])) {
        ?>
			<input type="hidden" name="versionedname" id="versionedname" value=""/>
			<input type="hidden" name="fileversion" id="fileversion" value=""/>
			<?php 
        $data_rows = $impCE->csv_file_data($_FILES['csv_import']['tmp_name'], $impCE->delim);
        require_once "SmackImpCE.php";
        $impObj = new SmackImpCE();
        $impObj->move_file();
        ?>
			<div class="smack-wrap" id="smack-content">
			<?php 
        echo $impRen->renderMenu();
        if ($_REQUEST['action'] == 'users' || $_REQUEST['action'] == 'comments') {
            $impCE->defCols = $impRen->renderMapping($_REQUEST['action']);
        }
        if (count($impCE->headers) >= 1 && count($data_rows) >= 1) {
            ?>
				<form class="add:the-list: validate" name="secondform" id="secondform" method="post" onsubmit="return import_csv();"
				class="secondform">
				<div style="float: left; min-width: 45%">
				<div style="float: left; margin-top: 11px; margin-right: 5px;"><img
				src="<?php 
            echo WP_CONTENT_URL;
            ?>
/plugins/wp-ultimate-csv-importer/images/Importicon_24.png">
				</div>
				<div style="float:left;">
				<h3>Import Data Configuration</h3>
				</div>
				</br>
				<?php 
            $cnt = count($impCE->defCols) + 2;
            $cnt1 = count($impCE->headers);
            ?>
				<input type="hidden" id="h1" name="h1" value="<?php 
            echo $cnt;
            ?>
"/>
				<input type="hidden" id="h2" name="h2" value="<?php 
            echo $cnt1;
            ?>
"/>
				<input type="hidden" id="prevoptionindex" name="prevoptionindex" value=""/>
				<input type="hidden" id="prevoptionvalue" name="prevoptionvalue" value=""/>
				<?php 
            // second form starts here
            if ($_REQUEST['action'] == 'post' || $_REQUEST['action'] == 'custompost' || $_REQUEST['action'] == 'page' || $_REQUEST['action'] == 'users' || $_REQUEST['action'] == 'comments') {
                //set custom fields value
                $taxo = get_taxonomies();
                foreach ($taxo as $taxokey => $taxovalue) {
                    if ($taxokey != 'category' && $taxokey != 'link_category' && $taxokey != 'post_tag' && $taxokey != 'nav_menu' && $taxokey != 'post_format' && $taxokey != 'product_tag' && $taxokey != 'wpsc_product_category' && $taxokey != 'wpsc-variation') {
                        $custo_taxo .= $taxokey . ',';
                    }
                }
                $custo_taxo = substr($custo_taxo, 0, -1);
                ?>
						<input type='hidden' name='cust_taxo' id='cust_taxo' value='<?php 
                echo $custo_taxo;
                ?>
'/><br>
						<div id="posttypecss" style="margin-top: 30px;">
						<table>
						<tr>
						<td>
						<input name="_csv_importer_import_as_draft" type="hidden" value="publish"/>
						<?php 
                if ($_REQUEST['action'] == 'custompost') {
                    ?>
							<label> Select Post Type<span class="mandatory"> *</span> </label></td>
								<td>
								<select name='csv_importer_cat' id='csv_importer_cat'>
								<option>-- Select --</option>
								<?php 
                    foreach (get_post_types() as $key => $value) {
                        if ($value != 'featured_image' && $value != 'attachment' && $value != 'wpsc-product' && $value != 'wpsc-product-file' && $value != 'revision' && $value != 'nav_menu_item' && $value != 'post' && $value != 'page' && $value != 'wp-types-group' && $value != 'wp-types-user-group') {
                            ?>
											<option id="<?php 
                            echo $value;
                            ?>
"> <?php 
                            echo $value;
                            ?>
 </option>
											<?php 
                        }
                    }
                    ?>
								</select>
								<a href="#" class="tooltip">
								<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" />
								<span class="tooltipOne">
								<img class="callout" src="../wp-content/plugins/wp-ultimate-csv-importer/images/callout.gif" />
								<strong>Select a custom post type to import</strong>
								<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" style="margin-top: 6px;float:right;" />
								</span>
								</a>

								<?php 
                } else {
                    if ($_REQUEST['action'] == 'post' || $_REQUEST['action'] == 'page') {
                        ?>
									<input name='csv_importer_cat' type='hidden' id='csv_importer_cat'
										value=<?php 
                        echo $_REQUEST['action'];
                        ?>
>
										<?php 
                    }
                }
                ?>
										</td>
										</tr>
										<?php 
                $cnt1 = count($impCE->headers);
                if ($_REQUEST['action'] != 'users' && $_REQUEST['action'] != 'comments') {
                    ?>
										<tr>
										<td>

										<label>Import with post status<span class="mandatory"> *</span></label></td>
										<td><select
										name='importallwithps' id='importallwithps'
										onchange='importAllPostStatus(this.value, "<?php 
                    echo $cnt1;
                    ?>
")'>
										<option value='0'>Status as in CSV</option>
										<option value='1'>Publish</option>
										<option value='2'>Sticky</option>
										<option value='4'>Private</option>
										<option value='3'>Protected</option>
										<option value='5'>Draft</option>
										<option value='6'>Pending</option>
										</select>
										<a href="#" class="tooltip">
										<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" /> 									      <?php 
                    if ($_REQUEST['action'] == 'custompost') {
                        ?>
										<span class="tooltipTwo">
										<?php 
                    } else {
                        ?>
										<span class="tooltipFive">
										<?php 
                    }
                    ?>
										<img class="callout" src="../wp-content/plugins/wp-ultimate-csv-importer/images/callout.gif" />
										<strong>Select a status for the post imported, if not defined within your csv. E.g. Publish</strong>
										<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" style="margin-top: 6px;float:right;" />
										</span>
										</a>
										</td>
										</tr>
										<tr>
										<td>
										<label id='passwordlabel' style="display:none;">Password</label></td>
										<td>
										<input type='text' id='postsPassword' name='postsPassword' value='admin'
										style="display:none;">
										<span style="display: none; color: red; margin-left: 5px;" id='passwordhint'
										style="display:none;">Replace the default value</span>
										</td>
										</tr>
										</table>
										<?php 
                }
                ?>
										</div>
										<div style="width:50%;float:left;"><h3>Map Fields</h3></div><div style="width:50%;float:right;"><input type="button" name="remap" id="remap" value="Clear Mapping" onclick="clearmapping();" />
										<a href="#" class="tooltip">
										<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" />
										<span class="tooltipThree">
										<img class="callout" src="../wp-content/plugins/wp-ultimate-csv-importer/images/callout.gif" />
										<strong>Refresh to re-map fields</strong>
										<img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" style="margin-top: 6px;float:right;" />
										</span>
										</a></div></br></br></br>
										<div id='display_area'>
										<?php 
                $cnt = count($impCE->defCols) + 2;
                ?>
										<input type="hidden" id="h1" name="h1" value="<?php 
                echo $cnt;
                ?>
"/>
										<input type="hidden" id="h2" name="h2" value="<?php 
                echo $cnt1;
                ?>
"/>
										<?php 
                if (isset($_POST['titleduplicatecheck'])) {
                    ?>
											<input type="hidden" id="titleduplicatecheck"
												name="titleduplicatecheck"
												value="<?php 
                    echo $_POST['titleduplicatecheck'];
                    ?>
"/>
												<?php 
                }
                ?>
												<?php 
                if (isset($_POST['contentduplicatecheck'])) {
                    ?>
													<input type="hidden" id="contentduplicatecheck" name="contentduplicatecheck"
														value="<?php 
                    echo $_POST['contentduplicatecheck'];
                    ?>
"/>
														<?php 
                }
                ?>
														<input type="hidden" id="delim" name="delim" value="<?php 
                echo $_POST['delim'];
                ?>
"/> <input type="hidden" id="header_array" name="header_array" value="<?php 
                print_r($impCE->headers);
                ?>
"/>
														<table style="font-size: 12px;">
														<?php 
                $count = 0;
                if ($_REQUEST['action'] == 'page') {
                    unset($impCE->defCols['post_category']);
                    unset($impCE->defCols['post_tag']);
                }
                foreach ($impCE->headers as $key => $value) {
                    ?>
									<tr>
									<td><label><?php 
                    print $value;
                    ?>
</label></td>
									<td><select name="mapping<?php 
                    print $count;
                    ?>
"
									id="mapping<?php 
                    print $count;
                    ?>
" class='uiButton'
									onchange="addcustomfield(this.value,<?php 
                    echo $count;
                    ?>
);">
									<option id="select">-- Select --</option>
									<?php 
                    foreach ($impCE->defCols as $key1 => $value1) {
                        if ($key1 == 'post_name') {
                            $key1 = 'post_slug';
                        }
                        $strip_CF = strpos($key1, 'CF: ');
                        //Auto mapping
                        if ($strip_CF === 0) {
                            $custom_key = substr($key1, 4);
                        }
                        ?>
											<option value="<?php 
                        print $key1;
                        ?>
">
											<?php 
                        if ($key1 != 'post_name') {
                            print $key1;
                            $mappingFields_arr[$key1] = $key1;
                        } else {
                            print 'post_slug';
                            $mappingFields_arr['post_slug'] = 'post_slug';
                        }
                        ?>
											</option>
											<?php 
                    }
                    if ($_REQUEST['action'] != 'users' && $_REQUEST['action'] != 'comments') {
                        foreach (get_taxonomies() as $taxokey => $taxovalue) {
                            if ($taxokey != 'category' && $taxokey != 'link_category' && $taxokey != 'post_tag' && $taxokey != 'nav_menu' && $taxokey != 'post_format') {
                                ?>
											<option
											value="<?php 
                                print $taxokey;
                                ?>
"><?php 
                                print $taxovalue;
                                ?>
</option>
											<?php 
                                $mappingFields_arr[$taxovalue] = $taxovalue;
                            }
                        }
                        ?>
									<option value="add_custom<?php 
                        print $count;
                        ?>
">Add Custom Field
									</option>
								<?php 
                    }
                    ?>
									</select> <!-- added to solve issue id 1072-->
									<input class="customfieldtext" type="text"
									id="textbox<?php 
                    print $count;
                    ?>
"
									name="textbox<?php 
                    print $count;
                    ?>
" TITLE="Replace the default value" style="display: none;" value="<?php 
                    echo $value;
                    ?>
"/>
<span style="display: none;" id="customspan<?php 
                    echo $count;
                    ?>
">
<a href="#" class="tooltip">
    <img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" />
    <span class="tooltipFour">
        <img class="callout" src="../wp-content/plugins/wp-ultimate-csv-importer/images/callout.gif" />
        <strong>Give a name for your new custom field</strong>
        <img src="../wp-content/plugins/wp-ultimate-csv-importer/images/help.png" style="margin-top: 6px;float:right;" />
    </span>
</a> 
</span>
									<!--<span style="display: none; color: red; margin-left: 5px;"
									id="customspan<?php 
                    //echo $count
                    ?>
">Replace the default value</span>-->
									</td>
									</tr>
									<?php 
                    $count++;
                }
                foreach ($mappingFields_arr as $mkey => $mval) {
                    $mFieldsArr .= $mkey . ',';
                }
                $mFieldsArr = substr($mFieldsArr, 0, -1);
                ?>
								</table>
								<input type="hidden" id="mapping_fields_array" name="mapping_fields_array" value="<?php 
                print_r($mFieldsArr);
                ?>
"/>
								</div>
								<br/>
								<?php 
            } elseif ($_REQUEST['action'] == 'dashboard') {
                echo $impRen->renderDashboard();
            } elseif ($_REQUEST['action'] == 'help') {
            }
            //second form exits
            ?>
			<input type='hidden' name='filename' id='filename'
				value="<?php 
            echo $_FILES['csv_import']['name'];
            ?>
"/>
				<?php 
            $explodeCsv = explode('.csv', $_FILES['csv_import']['name']);
            $exactFIlename = $explodeCsv[0] . '-' . $_REQUEST['action'] . '.csv';
            ?>
				<input type='hidden' name='realfilename' id='realfilename'
				value="<?php 
            echo $_FILES['csv_import']['name'];
            ?>
"/>
				<input type="hidden" name="version" id="version" value=""/>
				<input type='hidden' name='selectedImporter' id='selectedImporter'
				value="<?php 
            echo $_REQUEST['action'];
            ?>
"/>
				<input type='hidden' name='delim' id='delim' value="<?php 
            echo $_POST['delim'];
            ?>
"/>
				<button type='submit' class="action" name='post_csv' id='post_csv' value='Import'>Import</button>

				</form>
				</div>
				<div style="min-width: 45%;float:right;margin-right:9px;">
				<div style="width:100%;">
				<div style="float:left;"><h3>CSV Mapping Headers Explained</h3></div>
				<div style="float:right;margin-top:15px;margin-right:25px;"><a
				href="http://www.smackcoders.com/blog/wordpress-ultimate-csv-importer-csv-sample-files-and-updates.html"
				target="_blank">Download Sample Files Here</a></div>
				</div>
				<a href="<?php 
            echo WP_CONTENT_URL;
            ?>
/plugins/wp-ultimate-csv-importer/images/HeadersExplained.jpeg"
				target="_blank" title="Headers Explained"><img
				src="<?php 
            echo WP_CONTENT_URL;
            ?>
/plugins/wp-ultimate-csv-importer/images/HeadersExplained.jpeg"
				width=600 style='border:1px solid;padding:2px;'/></a>
				</div>
				<?php 
        } else {
            ?>
				<div style="font-size: 16px; margin-left: 20px;"><?php 
            echo $impCE->t("CHOOSE_ANOTHER_DELIMITER");
            ?>
				</div>
				<br/>
				<div style="margin-left: 20px;">
				<form class="add:the-list: validate" method="post" action="">
				<input type="submit" class="button-primary" name="Import Again"
				value="Import Again"/>
				</form>
				</div>
				<div style="margin-left: 20px; margin-top: 30px;">
				<b><?php 
            echo $impCE->t("NOTE");
            ?>
 :-</b>

				<p>1. <?php 
            echo $impCE->t("NOTE_CONTENT_1");
            ?>
</p>

				<p>2. <?php 
            echo $impCE->t("NOTE_CONTENT_2");
            ?>
</p>
				</div>
				<?php 
        }
    } else {
        if (isset($_POST['post_csv']) && ($_REQUEST['action'] == 'post' || $_REQUEST['action'] == 'page' || $_REQUEST['action'] == 'custompost')) {
            //third form starts here
            $impCE->processDataInWP();
            echo $impRen->renderMenu();
            if ($impCE->insPostCount != 0 || $impCE->dupPostCount != 0) {
                ?>
			<div>
			<?php 
                echo $impRen->setDashboardAction();
                $messageString = $impCE->insPostCount . " records are successfully Imported.";
                if (isset($_POST['titleduplicatecheck']) && $_POST['titleduplicatecheck'] == 1 || isset($_POST['contentduplicatecheck']) && $_POST['contentduplicatecheck'] == 1) {
                    $messageString .= $impCE->dupPostCount . " duplicate records found.";
                }
                if ($impCE->noPostAuthCount != 0 && in_array('post_author', $_POST)) {
                    $messageString .= '<br>' . $impCE->noPostAuthCount . " posts with no valid UserID/Name are assigned admin as author.";
                }
                echo $impRen->showMessage('success', $messageString);
                ?>
				</div>
				<?php 
            } else {
                if ($impCE->insPostCount == 0 && $impCE->dupPostCount == 0) {
                    ?>
			<div>
			<?php 
                    echo $impRen->showMessage('error', "Check your CSV file and format.");
                    ?>
			</div>
	  <?php 
                }
            }
            $_REQUEST['action'] = 'dashboard';
            echo $impRen->renderDashboard();
        } else {
            if (isset($_POST['post_csv']) && $_REQUEST['action'] == 'users') {
                // Code for import users and their Datas.
                echo $impRen->setDashboardAction();
                require_once 'class.userroles.php';
                $impCE1 = new SmackImpCE();
                $userObj = new Users();
                $data_rows = $impCE1->csv_file_data($impCE1->getUploadDirectory() . "/" . $_POST['filename'], $_POST['delim']);
                $result = $userObj->addUsers($data_rows);
                echo $impRen->renderMenu();
                if ($userObj->insUserCount != 0) {
                    echo $impRen->showMessage('success', $userObj->insUserCount . " users has been imported");
                }
                if ($userObj->skipUserCount != 0) {
                    echo $impRen->showMessage('error', $userObj->skipUserCount . " users has been skipped");
                }
                $_SESSION['thirdformaction'] = 'dashboard';
                echo $impRen->renderDashboard();
            } else {
                if (isset($_POST['post_csv']) && $_REQUEST['action'] == 'comments') {
                    echo $impRen->setDashboardAction();
                    require_once 'class.comments.php';
                    $impCE1 = new SmackImpCE();
                    $commentObj = new Comments();
                    $data_rows = $impCE1->csv_file_data($impCE1->getUploadDirectory() . "/" . $_POST['filename'], $_POST['delim']);
                    $result = $commentObj->addComment($data_rows);
                    echo $impRen->renderMenu();
                    if ($commentObj->insComments != 0) {
                        echo $impRen->showMessage('success', $commentObj->insComments . " comments has been imported");
                    }
                    if ($commentObj->skippedComments != 0) {
                        echo $impRen->showMessage('error', $commentObj->skippedComments . " comments has been skipped");
                    }
                    echo $impRen->renderDashboard();
                } else {
                    ?>
			<!-- first form gets displayed from here -->
			<?php 
                    if (!$_REQUEST['action']) {
                        $_REQUEST['action'] = 'post';
                    } elseif ($_REQUEST['action'] == 'dashboard') {
                        echo $impRen->renderMenu();
                        echo $impRen->renderDashboard();
                    } elseif ($_REQUEST['action'] == 'settings') {
                        echo $impRen->renderMenu();
                        if ($pluginActive != null) {
                            echo $impRen->showMessage('error', $pluginActive);
                        }
                        echo $impRen->renderSettings();
                    } elseif ($_REQUEST['action'] == 'custompost') {
                        ?>
				<div class="wrap" id="smack-content">
				<?php 
                        echo $impRen->renderMenu();
                        $sett = new IMPSettings();
                        ?>
						<div class="smack-postform">
						<?php 
                        echo $impRen->renderPostPage();
                        ?>
						</div>
						<div class="module-desc">
						<?php 
                        print $impRen->renderDesc();
                        ?>
						</div>
						</div>
						<?php 
                    } else {
                        ?>
					<div class="wrap" id="smack-content">
					<?php 
                        echo $impRen->renderMenu();
                        ?>
					<div class="smack-postform">
					<?php 
                        echo $impRen->renderPostPage();
                        ?>
					</div>
					<div class="module-desc">
					<?php 
                        print $impRen->renderDesc();
                        ?>
					</div>
					</div>
					<!-- end wrap -->
					<?php 
                    }
                }
            }
        }
    }
}
Exemplo n.º 10
0
<?php 
require_once "commentsClass.php";
echo "<html><body bgcolor=#D8D8D8>";
// Replace periods with underscores (SQL doesn't allow periods in table names)
$comments = new Comments(strtr($_GET['id'], ".", "_"));
echo "<h2>Discussion for PROJECT {$comments->projectID}</h2>";
/* Onclick event of 'Add Comment' button. Blocks empty comments and replaces
   empty names with "Anonymous" */
if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $comment = $_POST['comment'];
    if ($name == "") {
        $name = "Anonymous";
    }
    if ($comment != "") {
        $comments->addComment($name, $comment);
    }
}
/* Fetch comments from table and display them all */
$stmt = $comments->DB->prepare("SELECT * FROM {$comments->projectID}");
$stmt->execute();
$stmt->bind_result($name, $comment);
while ($stmt->fetch()) {
    echo $name . " says: ";
    echo $comment;
    printf("<button onclick=prependName('%s');>Reply</button>", $name);
    echo "<hr style='width:20%;' align='left'/>";
}
?>

	<?php 
Exemplo n.º 11
0
function ajax_comment_reply()
{
    $parent = isset($_POST['id']) ? absint($_POST['id']) : 0;
    $content = isset($_POST['content']) ? $_POST['content'] : '';
    if (!($comment = Comment::find($parent))) {
        json_message('Parent comment not found.', false);
    }
    $page = $comment->page;
    $page_url = $comment->page_url;
    $page_title = $comment->page_title;
    Comments::setMailer(app('mailer'))->setDispatcher(app('events'));
    $comment = Comments::addComment(compact('content', 'parent', 'page', 'page_url', 'page_title'));
    if (is_array($comment)) {
        json_message(true);
    } else {
        json_message(is_object($comment) ? $comment->first() : trans('errors.dbsave'), false);
    }
}