mirror of
https://github.com/pierre42100/comunic
synced 2025-07-12 21:12:57 +00:00
First commit
This commit is contained in:
22
3rdparty/analysing_page/LICENSE
vendored
Executable file
22
3rdparty/analysing_page/LICENSE
vendored
Executable file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Communiquons
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
BIN
3rdparty/analysing_page/PHP-content-of-a-page-analyser-master-1.0.zip
vendored
Executable file
BIN
3rdparty/analysing_page/PHP-content-of-a-page-analyser-master-1.0.zip
vendored
Executable file
Binary file not shown.
9
3rdparty/analysing_page/README.md
vendored
Executable file
9
3rdparty/analysing_page/README.md
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
# PHP content of a page analyser
|
||||
Analysing the content of a page in PHP
|
||||
|
||||
This PHP project will allow you to analyse with your page the global content of another page. It would be useful for an easier integration of an external page in yours
|
||||
|
||||
Has been translateed in :
|
||||
|
||||
French
|
||||
English
|
49
3rdparty/analysing_page/analyser_en.php
vendored
Executable file
49
3rdparty/analysing_page/analyser_en.php
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
//This file extract the title, the description and the image of a webpage, which are indicated in <meta og: markups
|
||||
function analyse_source_page($source)
|
||||
{
|
||||
//Préparation de l'analyse
|
||||
$page_title = null;
|
||||
$page_description = null;
|
||||
$page_image = null;
|
||||
|
||||
//Analysing datas
|
||||
preg_match_all('#<meta (.*?)>#is', $source, $result,PREG_PATTERN_ORDER);
|
||||
|
||||
//Fetching
|
||||
$liste_types = array(
|
||||
array('title' => 'page_title', 'pattern' => '<property="og:title">', 'begining' => 'content="', 'ending' => '"'),
|
||||
array('title' => 'page_title', 'pattern' => "<property='og:title'>", 'begining' => "content='", 'ending' => "'"),
|
||||
array('title' => 'page_description', 'pattern' => "<property='og:description'>", 'begining' => "content='", 'ending' => "'"),
|
||||
array('title' => 'page_description', 'pattern' => '<property="og:description">', 'begining' => 'content="', 'ending' => '"'),
|
||||
array('title' => 'page_image', 'pattern' => '<property="og:image">', 'begining' => 'content="', 'ending' => '"'),
|
||||
array('title' => 'page_image', 'pattern' => "<property='og:image'>", 'begining' => "content='", 'ending' => "'"),
|
||||
);
|
||||
|
||||
//Analysing list
|
||||
foreach($result[1] as $fetching)
|
||||
{
|
||||
//Parcours des types de traitement
|
||||
foreach($liste_types as $fetching_infos)
|
||||
{
|
||||
|
||||
//Preparing
|
||||
$fetching = str_replace(' =', '=', $fetching);
|
||||
|
||||
//Vérification de la présence des informations
|
||||
if(preg_match($fetching_infos['pattern'], $fetching))
|
||||
{
|
||||
$begining = $fetching_infos['begining'];
|
||||
$ending = $fetching_infos['ending'];
|
||||
$title = $fetching_infos['title'];
|
||||
$content = strstr($fetching, $begining);
|
||||
$content = str_replace($begining, '', $content);
|
||||
$content = strstr($content, $ending, true);
|
||||
${$title} = $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Sending result
|
||||
return array('title' => $page_title, 'description' => $page_description, 'image' => $page_image);
|
||||
}
|
49
3rdparty/analysing_page/analyser_fr.php
vendored
Executable file
49
3rdparty/analysing_page/analyser_fr.php
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
//Fonction d'analyse du contenu d'une page pour en extraire la description, le titre et l'image
|
||||
function analyse_source_page_extrait_description($source)
|
||||
{
|
||||
//Préparation de l'analyse
|
||||
$titre_page = null;
|
||||
$description_page = null;
|
||||
$image_page = null;
|
||||
|
||||
|
||||
//Analyse des données
|
||||
preg_match_all('#<meta (.*?)>#is', $source, $resultat,PREG_PATTERN_ORDER);
|
||||
|
||||
//Traitement
|
||||
$liste_types = array(
|
||||
array('titre' => 'titre_page', 'masque' => '<property="og:title">', 'debut' => 'content="', 'fin' => '"'),
|
||||
array('titre' => 'titre_page', 'masque' => "<property='og:title'>", 'debut' => "content='", 'fin' => "'"),
|
||||
array('titre' => 'description_page', 'masque' => "<property='og:description'>", 'debut' => "content='", 'fin' => "'"),
|
||||
array('titre' => 'description_page', 'masque' => '<property="og:description">', 'debut' => 'content="', 'fin' => '"'),
|
||||
array('titre' => 'image_page', 'masque' => '<property="og:image">', 'debut' => 'content="', 'fin' => '"'),
|
||||
array('titre' => 'image_page', 'masque' => "<property='og:image'>", 'debut' => "content='", 'fin' => "'"),
|
||||
);
|
||||
|
||||
//Parcours de la liste
|
||||
foreach($resultat[1] as $traiter)
|
||||
{
|
||||
//Parcours des types de traitement
|
||||
foreach($liste_types as $infos_traitement)
|
||||
{
|
||||
//Pré-traitement
|
||||
$traiter = str_replace(' =', '=', $traiter);
|
||||
|
||||
//Vérification de la présence des informations
|
||||
if(preg_match($infos_traitement['masque'], $traiter))
|
||||
{
|
||||
$debut = $infos_traitement['debut'];
|
||||
$fin = $infos_traitement['fin'];
|
||||
$titre = $infos_traitement['titre'];
|
||||
$contenu = strstr($traiter, $debut);
|
||||
$contenu = str_replace($debut, '', $contenu);
|
||||
$contenu = strstr($contenu, $fin, true);
|
||||
${$titre} = $contenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Renvoi du résultat
|
||||
return array('titre' => $titre_page, 'description' => $description_page, 'image' => $image_page);
|
||||
}
|
Reference in New Issue
Block a user