ÿØÿàJFIF``ÿþxØ Dre4m Was Here
Dre4m Shell
Server IP : 109.234.164.53  /  Your IP : 216.73.216.136
Web Server : Apache
System : Linux cervelle.o2switch.net 4.18.0-553.32.1.lve.el8.x86_64 #1 SMP Thu Dec 19 13:14:03 UTC 2024 x86_64
User : computer3 ( 1098)
PHP Version : 7.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/computer3/lachocolateriedevirginie.fr/cp-admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/computer3/lachocolateriedevirginie.fr/cp-admin/add_avis_g2.php
<?php
require_once('includes/header.php');
require_once('includes/menu.php');

function clean_avis_txt($txt)
{
    $txt = strip_tags($txt);
    $txt = html_entity_decode($txt, ENT_QUOTES, 'UTF-8');
    $txt = str_replace("\r", "\n", $txt);
    $txt = preg_replace("/\n+/", "\n", $txt);
    $txt = preg_replace("/[ \t]+/", " ", $txt);
    return trim($txt);
}

function avis_initial($nom)
{
    $nom = trim($nom);
    if ($nom == '') return '';

    $parts = preg_split('/\s+/', $nom);
    $ini = '';

    foreach ($parts as $p) {
        if ($p != '') {
            $ini .= strtoupper(substr($p, 0, 1));
        }
    }

    return $ini;
}

function avis_date_relative_to_sql($txt)
{
    $txt = strtolower(trim($txt));
    $ts = time();

    if (preg_match('/il y a ([0-9]+) jour/', $txt, $m)) {
        return date('Y-m-d', strtotime('-' . (int)$m[1] . ' days', $ts));
    }

    if (preg_match('/il y a ([0-9]+) semaine/', $txt, $m)) {
        return date('Y-m-d', strtotime('-' . ((int)$m[1] * 7) . ' days', $ts));
    }

    if (preg_match('/il y a ([0-9]+) mois/', $txt, $m)) {
        return date('Y-m-d', strtotime('-' . (int)$m[1] . ' months', $ts));
    }

    if (preg_match('/il y a ([0-9]+) an/', $txt, $m)) {
        return date('Y-m-d', strtotime('-' . (int)$m[1] . ' years', $ts));
    }

    if (strpos($txt, 'hier') !== false) {
        return date('Y-m-d', strtotime('-1 day', $ts));
    }

    return date('Y-m-d');
}

function parse_google_avis($raw)
{
    $raw = clean_avis_txt($raw);

    $lines = explode("\n", $raw);
    $clean = array();

    foreach ($lines as $l) {
        $l = trim($l);
        if ($l != '') {
            $clean[] = $l;
        }
    }

    $nom = '';
    $note = 5;
    $date_avis = date('Y-m-d');
    $texte = '';

    if (isset($clean[0])) {
        $nom = $clean[0];
    }

    $texte_start = 1;

    foreach ($clean as $k => $line) {

        if (preg_match('/(★{1,5})/u', $line, $m)) {
            $note = strlen($m[1]);
            $texte_start = $k + 1;
            continue;
        }

        if (preg_match('/([1-5])\s*(étoile|etoile|star)/i', $line, $m)) {
            $note = (int)$m[1];
            $texte_start = $k + 1;
            continue;
        }

        if (strpos(strtolower($line), 'il y a') !== false || strtolower($line) == 'hier') {
            $date_avis = avis_date_relative_to_sql($line);
            $texte_start = $k + 1;
            continue;
        }
    }

    $txt_parts = array();
    for ($i = $texte_start; $i < count($clean); $i++) {
        $l = trim($clean[$i]);

        if ($l == '') continue;
        if (stripos($l, 'local guide') !== false) continue;
        if (stripos($l, 'avis') !== false && strlen($l) < 20) continue;
        if (stripos($l, 'photo') !== false && strlen($l) < 20) continue;

        $txt_parts[] = $l;
    }

    $texte = implode("\n", $txt_parts);

    return array(
        'nom'       => $nom,
        'initial'   => avis_initial($nom),
        'note'      => $note,
        'source'    => 'Google',
        'date_avis' => $date_avis,
        'texte'     => $texte
    );
}

$blog = array(
    'nom'       => '',
    'initial'   => '',
    'note'      => 5,
    'source'    => 'Google',
    'date_avis' => date('Y-m-d'),
    'texte'     => ''
);

$raw_google = '';

if (isset($_POST['preview_google'])) {
    $raw_google = isset($_POST['raw_google']) ? $_POST['raw_google'] : '';
    $blog = parse_google_avis($raw_google);
}

if (isset($_POST['add'])) {

    $date_avis = isset($_POST['date_debut']) ? $_POST['date_debut'] : '';

    $sql = "INSERT INTO " . $GLOBALS['db_table']['avis_g'] . " 
            (initial, nom, note, texte, source, date_avis)
            VALUES 
            (:initial, :nom, :note, :texte, :source, :date_avis)";
    $qid = $bdd->prepare($sql);
    $qid->execute(array(
        'initial'   => isset($_POST['initial']) ? $_POST['initial'] : '',
        'nom'       => isset($_POST['nom']) ? $_POST['nom'] : '',
        'note'      => isset($_POST['note']) ? $_POST['note'] : '',
        'texte'     => isset($_POST['content']) ? $_POST['content'] : '',
        'source'    => isset($_POST['source']) ? $_POST['source'] : '',
        'date_avis' => $date_avis
    ));

    echo '<script>';
    echo 'window.location = "./avis_g.php"';
    echo '</script>';
}
?>

<style>
.rating {
  direction: rtl;
  unicode-bidi: bidi-override;
  display: inline-flex;
  gap: 4px;
}
.rating input { display: none; }
.rating label {
  font-size: 28px;
  color: #ccc;
  cursor: pointer;
}
.rating input:checked ~ label { color: #f7c600; }
.rating label:hover,
.rating label:hover ~ label { color: #ffe07a; }

.import-google-box{
  background:#f7f7f7;
  border:1px solid #ddd;
  padding:18px;
  margin-bottom:25px;
  border-radius:6px;
}
.import-google-box textarea{
  width:100%;
  min-height:130px;
}
.import-google-box h3{
  margin-top:0;
}
</style>

<div class="container">

  <div class="import-google-box"  style="margin-top:50px">
    <form method="post" action="add_avis_g2.php">
      <h3>Import rapide avis Google</h3>
      <p>Coller ici le texte brut de l’avis Google, puis cliquer sur <strong>Pré-remplir</strong>.</p>

      <textarea name="raw_google"><?php echo htmlspecialchars($raw_google, ENT_QUOTES, 'UTF-8'); ?></textarea>
      <br><br>

      <button type="submit" name="preview_google" class="btn btn-warning">
        Pré-remplir
      </button>
    </form>
  </div>

  <form class="form-horizontal" method="post" action="add_avis_g2.php" enctype="multipart/form-data">

    <div class="row">
      <div class="span12">
        <div class="page-header">
          <h1>Ajouter un avis
            <div class="pull-right">
              <button type="submit" name="add" class="btn btn-success"><i class="icon-ok"></i> Enregistrer</button>
              <a href="avis_g.php" class="btn btn-primary"><i class="icon-arrow-left"></i> Retour</a>
            </div>
          </h1>
		  
		  Attention la note est réglée sur 5 veuillez l'adapter ainsi que l'initiale (2 caract.)
        </div>
      </div>
    </div>

    <?php
    echo '<div id="form-content">';
      echo '<div class="row-fluid">';
        echo '<div class="span12">';

          echo '<div class="control-group">';
            echo '<label class="control-label">Titre :&nbsp;</label>';
            echo '<div class="controls">';
              echo '<input required style="width:470px" name="nom" type="text" value="' . htmlspecialchars($blog['nom'], ENT_QUOTES, 'UTF-8') . '">';
            echo '</div>';
          echo '</div>';

          echo '<div class="control-group">';
            echo '<label class="control-label">Initiale(s) :&nbsp;</label>';
            echo '<div class="controls">';
              echo '<input style="width:470px" name="initial" type="text" value="' . htmlspecialchars($blog['initial'], ENT_QUOTES, 'UTF-8') . '">';
            echo '</div>';
          echo '</div>';

          echo '<br><div class="control-group">';
            echo '<label class="control-label">Note :&nbsp;</label>';
            echo '<div class="controls">';
              $note = (int)$blog['note'];
              ?>
              <div class="rating">
                <input type="radio" id="star5" name="note" value="5" <?php if ($note==5) echo 'checked="checked"'; ?> />
                <label for="star5">&#9733;</label>

                <input type="radio" id="star4" name="note" value="4" <?php if ($note==4) echo 'checked="checked"'; ?> />
                <label for="star4">&#9733;</label>

                <input type="radio" id="star3" name="note" value="3" <?php if ($note==3) echo 'checked="checked"'; ?> />
                <label for="star3">&#9733;</label>

                <input type="radio" id="star2" name="note" value="2" <?php if ($note==2) echo 'checked="checked"'; ?> />
                <label for="star2">&#9733;</label>

                <input type="radio" id="star1" name="note" value="1" <?php if ($note==1) echo 'checked="checked"'; ?> />
                <label for="star1">&#9733;</label>
              </div>
              <?php
            echo '</div>';
          echo '</div>';

          echo '<div class="control-group">';
            echo '<label class="control-label">Source :&nbsp;</label>';
            echo '<div class="controls">';
              echo '<input style="width:470px" name="source" type="text" value="' . htmlspecialchars($blog['source'], ENT_QUOTES, 'UTF-8') . '">';
            echo '</div>';
          echo '</div>';

          echo '<div class="control-group">';
            echo '<label class="control-label">Date d&eacute;but US :</label>';
            echo '<div class="controls">';
              echo '<input style="width:287px" name="date_debut" value="' . htmlspecialchars($blog['date_avis'], ENT_QUOTES, 'UTF-8') . '" id="datepicker_debut" type="text" />';
            echo '</div>';
          echo '</div>';

          echo '<div>';
          echo '<br /><br /><br />';
          echo '<label>Contenu : <i>Copi&eacute;/coll&eacute;</i></label>';
          echo '<br />';
          echo '<textarea rows="7" name="content" id="content">' . htmlspecialchars($blog['texte'], ENT_QUOTES, 'UTF-8') . '</textarea>';
          echo '<script>
                var ckedit = CKEDITOR.replace( "content" ,{
                  filebrowserBrowseUrl : "includes/filemanager/dialog.php?type=2&editor=ckeditor&fldr=",
                  filebrowserUploadUrl : "includes/filemanager/dialog.php?type=2&editor=ckeditor&fldr=",
                  filebrowserImageBrowseUrl : "includes/filemanager/dialog.php?type=1&editor=ckeditor&fldr="
                });
                </script>';
          echo '</div>';

        echo '</div>';
      echo '</div>';
    echo '</div>';
    ?>

  </form>
</div>

<script type="text/javascript" src="assets/js/chosen.jquery.js" ></script>
<script type="text/javascript">
var config = {
    '.chosen-select'           : {},
    '.chosen-select-deselect'  : {allow_single_deselect:true},
    '.chosen-select-no-single' : {disable_search_threshold:10},
    '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
    '.chosen-select-width'     : {width:"95%"}
};
for (var selector in config) {
    $(selector).chosen(config[selector]);
}
</script>

<?php
include_once('includes/footer.php');
?>

Anon7 - 2022
AnonSec Team