Пример #1
0
function contenuassoc_contenu()
{
    if ($_GET['type'] == 1) {
        $objet = new Produit();
        $objet->charger($_GET['objet']);
    } else {
        $objet = new Rubrique();
        $objet->charger($_GET['objet']);
    }
    $contenu = new Contenu();
    $query = "select * from {$contenu->table} where dossier=\"" . $_GET['id_dossier'] . "\"";
    $resul = $contenu->query($query);
    while ($resul && ($row = $contenu->fetch_object($resul))) {
        $contenuassoc = new Contenuassoc();
        if ($contenuassoc->existe($objet->id, $_GET['type'], $row->id)) {
            continue;
        }
        $contenudesc = new Contenudesc();
        $contenudesc->charger($row->id);
        ?>
			<option value="<?php 
        echo $row->id;
        ?>
"><?php 
        echo $contenudesc->titre;
        ?>
</option>
		<?php 
    }
}
Пример #2
0
function ancien_rewrite_cont($id, $lang = 1)
{
    $cont = new Contenu();
    $cont->charger($id);
    $dosfinal = $cont->dossier;
    $chem = chemin_dos($dosfinal);
    if (!empty($chem)) {
        $dossierdesc = new Dossierdesc();
        $listdos = "";
        $dossierdesc->charger($chem[count($chem) - 1]->dossier, $lang);
        $listdos .= $dossierdesc->titre . "__";
        $dossierdesc->charger($chem[0]->dossier, $lang);
        $listdos .= $dossierdesc->dossier . "_";
        for ($i = count($chem) - 2; $i >= 0; $i--) {
            $dossierdesc->charger($chem[$i]->dossier, $lang);
            $listdos .= $dossierdesc->titre . "_";
        }
        $contenudesc = new Contenudesc();
        if (!$contenudesc->charger($cont->id, $lang)) {
            return "";
        }
        $listdos .= $contenudesc->titre . "_" . $cont->id . ".html";
        return eregurl($listdos);
    } else {
        return "";
    }
}
 /**
  * 
  * todo : utiliser cette methode pour la gestion des contenus associés aux produit // actuellement uniquement pour rubrique
  */
 public function add($contentToAddId, $type, $object)
 {
     if ($type == 1) {
         $objectInstance = new Produit();
         $objectInstance->charger($object);
     } else {
         $objectInstance = new Rubrique();
         $objectInstance->charger($object);
     }
     $contentToAdd = new Contenu();
     $this->id = '';
     if (!$this->existe($object, $type, $contentToAddId) && $contentToAdd->charger($contentToAddId)) {
         $classement = $this->getMaxRanking($objectInstance->id, $type) + 1;
         $this->objet = $objectInstance->id;
         $this->type = $type;
         $this->contenu = $contentToAdd->id;
         $this->classement = $classement;
         parent::add();
         if ($this->type == 1) {
             ActionsModules::instance()->appel_module("modprod", $objectInstance);
         } else {
             ActionsModules::instance()->appel_module("modrub", $objectInstance);
         }
     }
 }
Пример #4
0
function contenuassoc_contenu($request)
{
    if ($request->query->get('type') == 1) {
        $objet = new Produit();
        $objet->charger($request->query->get('objet'));
    } else {
        $objet = new Rubrique();
        $objet->charger($request->query->get('objet'));
    }
    $contenu = new Contenu();
    $query = "select * from {$contenu->table} where dossier=\"" . $request->query->get('id_dossier') . "\"";
    $resul = $contenu->query($query);
    while ($resul && ($row = $contenu->fetch_object($resul))) {
        $contenuassoc = new Contenuassoc();
        if (!in_array($row->id, explode('-', $request->query->get('force_show_content'))) && $contenuassoc->existe($objet->id, $request->query->get('type'), $row->id) || in_array($row->id, explode('-', $request->query->get('force_hide_content')))) {
            continue;
        }
        $contenudesc = new Contenudesc();
        $contenudesc->charger($row->id);
        ?>
<option value="<?php 
        echo $row->id;
        ?>
"><?php 
        echo $contenudesc->titre;
        ?>
</option>
        <?php 
    }
}
Пример #5
0
function lister_contenuassoc($type, $objet)
{
    if ($type == 1) {
        $obj = new Produit();
        $obj->charger($objet);
    } else {
        $obj = new Rubrique();
        $obj->charger($objet);
    }
    $contenuassoc = new Contenuassoc();
    $contenua = new Contenu();
    $contenuadesc = new Contenudesc();
    $query = "select * from {$contenuassoc->table} where type='{$type}' and objet='{$obj->id}' order by classement";
    $resul = $contenuassoc->query($query);
    $i = 0;
    while ($resul && ($row = $contenuassoc->fetch_object($resul))) {
        $fond = $i++ % 2 ? "fonce" : "claire";
        $contenua->charger($row->contenu);
        $contenuadesc->charger($contenua->id);
        $dossierdesc = new Dossierdesc();
        $dossierdesc->charger($contenua->dossier);
        ?>
		<li class="<?php 
        echo $fond;
        ?>
">
				<div class="cellule" style="width:260px;"><?php 
        echo $dossierdesc->titre;
        ?>
</div>
				<div class="cellule" style="width:260px;"><?php 
        echo $contenuadesc->titre;
        ?>
</div>
				<div class="cellule_supp"><a href="javascript:contenuassoc_supprimer(<?php 
        echo $row->id;
        ?>
, <?php 
        echo $type;
        ?>
,'<?php 
        echo $objet;
        ?>
')"><img src="gfx/supprimer.gif" /></a></div>
		</li>
<?php 
    }
}
Пример #6
0
function substitcontenu($texte)
{
    global $motcle, $id_contenu;
    $tcontenu = new Contenu();
    $tcontenudesc = new Contenudesc();
    $url = "";
    if ($id_contenu) {
        if ($tcontenu->charger($id_contenu)) {
            $tcontenudesc->charger($tcontenu->id);
            $url = $tcontenudesc->getUrl();
        }
    }
    $texte = str_replace("#CONTENU_URL", $url, $texte);
    $texte = str_replace("#CONTENU_ID", "{$id_contenu}", $texte);
    $texte = str_replace("#CONTENU_MOTCLE", "{$motcle}", $texte);
    $texte = str_replace("#CONTENU_NOM", $tcontenudesc->titre, $texte);
    $texte = str_replace("#CONTENU_CHAPO", $tcontenudesc->chapo, $texte);
    $texte = str_replace("#CONTENU_DESCRIPTION", $tcontenudesc->description, $texte);
    $texte = str_replace("#CONTENU_POSTSCRIPTUM", $tcontenudesc->postscriptum, $texte);
    return $texte;
}
 public function add($title, $folder)
 {
     $contentdesc = new Contenudesc();
     $contentdesc->titre = $title;
     if ($contentdesc->titre !== '') {
         $this->datemodif = date('Y-m-d H:i:s');
         $this->dossier = $folder;
         $this->ligne = 1;
         $this->classement = $this->getMaxRanking($folder) + 1;
         $this->id = parent::add();
         $contentdesc->lang = ActionsLang::instance()->get_id_langue_courante();
         $contentdesc->contenu = $this->id;
         $contentdesc->id = $contentdesc->add();
         $contentdesc->reecrire();
         ActionsModules::instance()->appel_module("ajoutcont", new Contenu($this->id));
         redirige('contenu_modifier.php?id=' . $this->id . '&dossier=' . $this->dossier);
     } else {
         throw new TheliaAdminException("impossible to add new content", TheliaAdminException::CONTENT_ADD_ERROR, null, $contentdesc);
     }
 }
Пример #8
0
 public function insert($position, Contenu $content)
 {
     $max = $this->_write + 1;
     if ($position < 0 || $position > $max) {
         throw new MethodParametersException('Nouvelle position invalide');
     }
     for ($i = $position; $i < $max; $i += 1) {
         $content->add($this->_content[$i]);
         if ($i < $max - 1) {
             $content->add_sauts();
         }
     }
     $this->_write = $position;
     $content->rewind();
     while ($content->valid()) {
         if ($content->key() > 0) {
             $this->add_sauts();
         }
         $this->resetLine()->add($content->current());
         $content->next();
     }
 }
Пример #9
0
function supprimer($id, $parent)
{
    $contenu = new Contenu($id);
    $contenu->delete();
    ActionsModules::instance()->appel_module("supcont", $contenu);
    redirige("listdos.php?parent=" . $parent);
    exit;
}
Пример #10
0
require_once __DIR__ . "/../../fonctions/divers.php";
if (!est_autorise("acces_contenu")) {
    exit;
}
header('Content-Type: text/html; charset=utf-8');
list($modif, $id) = explode("_", lireParam("id", "string"));
if (strstr($modif, "dos") !== false) {
    $obj = new Dossier();
    $obj->charger($id);
    $objdesc = new Dossierdesc();
    $objdesc->charger($obj->id);
    $point_entree = "moddcont";
    $champ_parent = "parent";
} else {
    if (strstr($modif, "cont") !== false) {
        $obj = new Contenu();
        $obj->charger($id);
        $objdesc = new Contenudesc();
        $objdesc->charger($obj->id);
        $point_entree = "moddos";
        $champ_parent = "dossier";
    } else {
        exit;
    }
}
switch ($modif) {
    case 'titrecont':
    case 'titredos':
        $objdesc->titre = lireParam("value", "string");
        echo $objdesc->titre;
        break;
Пример #11
0
    $obj = new Rubrique();
    $obj->modifier_classement($id, $classement);
    echo "rubrique|";
} else {
    if ($modif == "classementprod" && est_autorise("acces_catalogue")) {
        $obj = new Produit();
        $obj->modifier_classement($id, $classement);
        echo "produit|";
    } else {
        if ($modif == "classementdossier" && est_autorise("acces_catalogue")) {
            $obj = new Dossier();
            $obj->modifier_classement($id, $classement);
            echo "...";
        } else {
            if ($modif == "classementcontenu" && est_autorise("acces_catalogue")) {
                $obj = new Contenu();
                $obj->modifier_classement($id, $classement);
                echo "...";
            } else {
                if ($modif == "classementcarac" && est_autorise("acces_configuration")) {
                    $obj = new Caracteristique();
                    $obj->modifier_classement($id, $classement);
                    echo "...";
                } else {
                    if ($modif == "classementdecli" && est_autorise("acces_configuration")) {
                        $obj = new Declinaison();
                        $obj->modifier_classement($id, $classement);
                        echo "...";
                    } else {
                        if ($modif == "classementplugin" && est_autorise("acces_configuration")) {
                            $obj = new Modules();
Пример #12
0
function boucleContenu($texte, $args, $type = 0)
{
    global $page, $totbloc, $id_contenu;
    // récupération des arguments
    $dossier = lireTag($args, "dossier", "int");
    $ligne = lireTag($args, "ligne", "int");
    $deb = lireTag($args, "deb", "int");
    $num = lireTag($args, "num", "int");
    $bloc = lireTag($args, "bloc", "int");
    $id = lireTag($args, "id", "int_list");
    $motcle = lireTag($args, "motcle", "string+\\s\\'");
    $classement = lireTag($args, "classement", "string");
    $aleatoire = lireTag($args, "aleatoire", "int");
    $produit = lireTag($args, "produit", "int");
    $rubrique = lireTag($args, "rubrique", "int");
    $profondeur = lireTag($args, "profondeur", "int");
    $courant = lireTag($args, "courant", "int");
    $exclusion = lireTag($args, "exclusion", "int_list");
    $forcepage = lireTag($args, "forcepage", "int");
    if ($bloc) {
        $totbloc = $bloc;
    }
    if (!$deb) {
        $deb = 0;
    }
    if ($page) {
        $_SESSION['navig']->page = $page;
    }
    if (!$page || $page == 1) {
        $page = 0;
    }
    if (!$totbloc) {
        $totbloc = 1;
    }
    if ($page) {
        $deb = ($page - 1) * $totbloc * $num + $deb;
    }
    if ($forcepage != "") {
        if ($forcepage == 1) {
            $forcepage = 0;
            $deb = 0;
        }
        if ($forcepage) {
            $deb = ($forcepage - 1) * $totbloc * $num + $deb;
        }
    }
    // initialisation de variables
    $search = "";
    $order = "";
    $comptbloc = 0;
    $virg = "";
    $limit = "";
    $res = "";
    // preparation de la requete
    if ($dossier != "") {
        if ($profondeur == "") {
            $profondeur = 0;
        }
        $rec = arbreBoucle_dos($dossier, $profondeur);
        $rec = rtrim($rec, ",");
        if ($rec) {
            $virg = ",";
        }
        $search .= " and dossier in('{$dossier}'{$virg}{$rec})";
    }
    if ($ligne == "") {
        $ligne = "1";
    }
    $search .= " and ligne=\"{$ligne}\"";
    if ($id != "") {
        $search .= " and id in({$id})";
    }
    if ($courant == "1") {
        $search .= " and id='{$id_contenu}'";
    } else {
        if ($courant == "0") {
            $search .= " and id!='{$id_contenu}'";
        }
    }
    if ($exclusion != "") {
        $search .= " and id not in({$exclusion})";
    }
    if ($bloc == "-1") {
        $bloc = "999999999";
    }
    if ($bloc != "" && $num != "") {
        $limit .= " limit {$deb},{$bloc}";
    } else {
        if ($num != "") {
            $limit .= " limit {$deb},{$num}";
        }
    }
    $liste = "";
    if ($rubrique != "" || $produit != "") {
        if ($rubrique) {
            $type_obj = 0;
            $objet = $rubrique;
        } else {
            $type_obj = 1;
            $objet = $produit;
        }
        $contenuassoc = new Contenuassoc();
        $query = "select * from {$contenuassoc->table} where objet=\"" . $objet . "\" and type=\"" . $type_obj . "\"";
        $resul = CacheBase::getCache()->query($query);
        if (empty($resul)) {
            return "";
        }
        foreach ($resul as $row) {
            $liste .= "'" . $row->contenu . "',";
        }
        $liste = rtrim($liste, ",");
        if ($liste != "") {
            $search .= " and id in ({$liste})";
        } else {
            $search .= " and id in ('')";
        }
        $type_obj = "";
    }
    if ($aleatoire) {
        $order = "order by " . " RAND()";
    } else {
        if ($classement == "manuel") {
            $order = "order by classement";
        } else {
            if ($classement == "inverse") {
                $order = "order by classement desc";
            } else {
                if ($classement == "date") {
                    $order = "order by datemodif desc";
                }
            }
        }
    }
    $contenu = new Contenu();
    $contenudesc = new Contenudesc();
    if ($motcle) {
        $motcle = $contenu->escape_string(strip_tags(trim($motcle)));
        $liste = "";
        $query = "\n\t\t\t\tSELECT cd.contenu FROM\n\t\t\t\t\t{$contenudesc->table} cd\n\t\t\t\tWHERE\n                    cd.lang = " . ActionsLang::instance()->get_id_langue_courante() . "\n                AND (\n\t\t\t\t\tmatch(cd.titre, cd.chapo, cd.description, cd.postscriptum) AGAINST ('{$motcle}' IN BOOLEAN MODE)\n\t\t\t\tOR\n\t\t\t\t\tcd.titre REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t  \tcd.chapo REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tcd.description REGEXP '[[:<:]]{$motcle}[[:>:]]'\n\t\t\t\tOR\n\t\t\t\t \tcd.postscriptum REGEXP '[[:<:]]{$motcle}[[:>:]]'\n    \t\t\t)\n\t\t\t";
        $resul = CacheBase::getCache()->query($query);
        if (empty($resul)) {
            return "";
        }
        foreach ($resul as $row) {
            $liste .= "'{$row->contenu}',";
        }
        $liste = rtrim($liste, ',');
        $query = "select * from {$contenu->table} where id in ({$liste}) and ligne=\"{$ligne}\" {$limit}";
        $saveReq = "select * from {$contenu->table} where id in ({$liste}) and ligne=\"{$ligne}\"";
    } else {
        $query = "select * from {$contenu->table} where 1 {$search} {$order} {$limit}";
    }
    $saveReq = "select * from {$contenu->table} where 1 {$search}";
    $resul = CacheBase::getCache()->query($query);
    if (empty($resul)) {
        return "";
    }
    // substitutions
    if ($type) {
        return $query;
    }
    $saveReq = str_replace("*", "count(*) as totcount", $saveReq);
    $saveRes = CacheBase::getCache()->query($saveReq);
    $countRes = $saveRes[0]->totcount;
    $compt = 1;
    foreach ($resul as $row) {
        if ($num > 0) {
            if ($comptbloc >= ceil($countRes / $num) && $bloc != "") {
                continue;
            }
        }
        if ($comptbloc == 0) {
            $debcourant = 0;
        } else {
            $debcourant = $num * $comptbloc;
        }
        $comptbloc++;
        $dossierdesc = new Dossierdesc();
        $dossierdesc->charger($row->dossier);
        $contenudesc = new Contenudesc();
        $contenudesc->charger($row->id);
        $temp = $texte;
        $temp = str_replace("#DATE", substr($row->datemodif, 0, 10), $temp);
        $temp = str_replace("#HEURE", substr($row->datemodif, 11), $temp);
        $temp = str_replace("#DEBCOURANT", "{$debcourant}", $temp);
        $temp = str_replace("#ID", "{$row->id}", $temp);
        $temp = str_replace("#DOSSIER", "{$row->dossier}", $temp);
        $temp = str_replace("#TITRE", "{$contenudesc->titre}", $temp);
        $temp = str_replace("#STRIPTITRE", strip_tags($contenudesc->titre), $temp);
        $temp = str_replace("#CHAPO", "{$contenudesc->chapo}", $temp);
        $temp = str_replace("#STRIPCHAPO", strip_tags($contenudesc->chapo), $temp);
        $temp = str_replace("#DESCRIPTION", str_replace("../", "", $contenudesc->description), $temp);
        $temp = str_replace("#POSTSCRIPTUM", "{$contenudesc->postscriptum}", $temp);
        $temp = str_replace("#STRIPDESCRIPTION", strip_tags($contenudesc->description), $temp);
        $temp = str_replace("#URL", $contenudesc->getUrl(), $temp);
        $temp = str_replace("#REWRITEURL", $contenudesc->getUrl(), $temp);
        $temp = str_replace("#DOSTITRE", "{$dossierdesc->titre}", $temp);
        $temp = str_replace("#PRODUIT", "{$produit}", $temp);
        $temp = str_replace("#RUBRIQUE", "{$rubrique}", $temp);
        $temp = str_replace("#COMPT", "{$compt}", $temp);
        $res .= $temp;
        $compt++;
    }
    return $res;
}
Пример #13
0
         $reecriture->charger($a->url);
         $reecriture->actif = 0;
         $reecriture->maj();
         $reecriture_new = new Reecriture();
         $reecriture_new->url = $reecriture->url;
         $reecriture_new->fond = 'nexisteplus';
         $reecriture_new->param = $reecriture->param . '&ancienfond=' . $reecriture->fond;
         $reecriture_new->actif = 1;
         $reecriture_new->lang = $reecriture->lang;
         $reecriture_new->add();
     }
     break;
 case 'contenu':
     preg_match("#id_contenu=([0-9]+)([^[0-9]])*#", $a->param, $match);
     $id = $match[1];
     $contenu = new Contenu();
     if (!$contenu->charger($id)) {
         $reecriture = new Reecriture();
         $reecriture->charger($a->url);
         $reecriture->actif = 0;
         $reecriture->maj();
         $reecriture_new = new Reecriture();
         $reecriture_new->url = $reecriture->url;
         $reecriture_new->fond = 'nexisteplus';
         $reecriture_new->param = $reecriture->param . '&ancienfond=' . $reecriture->fond;
         $reecriture_new->actif = 1;
         $reecriture_new->lang = $reecriture->lang;
         $reecriture_new->add();
     }
     break;
 case 'rubrique':
Пример #14
0
function lister_contenus($parent, $critere, $order, $alpha)
{
    $contenu = new Contenu();
    $contenudesc = new Contenudesc();
    if ($alpha == "alpha") {
        $query = "select c.id, c.ligne, c.classement from {$contenu->table} c LEFT JOIN {$contenudesc->table} cd ON cd.contenu = c.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where dossier=\"{$parent}\" order by cd.{$critere} {$order}";
    } else {
        $query = "select id, ligne, classement from {$contenu->table} where dossier=\"{$parent}\" order by {$critere} {$order}";
    }
    $resul = $contenu->query($query);
    $i = 0;
    while ($resul && ($row = $contenu->fetch_object($resul))) {
        $contenudesc = new Contenudesc();
        $contenudesc->charger($row->id);
        if (!$contenudesc->affichage_back_office_permis()) {
            continue;
        }
        $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce") . "_rub";
        ?>

	<ul class="<?php 
        echo $fond;
        ?>
">
		<li style="width:627px;">
		<span id="titrecont_<?php 
        echo $row->id;
        ?>
" <?php 
        if ($contenudesc->est_langue_courante()) {
            echo 'class="texte_edit"';
        }
        ?>
><?php 
        echo substr($contenudesc->titre, 0, 90);
        if (strlen($contenudesc->titre) > 90) {
            echo " ...";
        }
        ?>
</span></li>
		<li style="width:54px;">
			<input type="checkbox" id="cont_ligne_<?php 
        echo $row->id;
        ?>
" name="ligne[]" class="sytle_checkbox" onchange="checkvalues('lignecont','<?php 
        echo $row->id;
        ?>
')" <?php 
        if ($row->ligne) {
            ?>
 checked="checked" <?php 
        }
        ?>
 />
		</li>
		<li style="width:54px;"></li>
		<li style="width:34px;"><a href="contenu_modifier.php?id=<?php 
        echo $row->id;
        ?>
&dossier=<?php 
        echo $parent;
        ?>
" class="txt_vert_11"><?php 
        echo trad('editer', 'admin');
        ?>
</a></li>
		<li style="width:71px;">
		 <div class="bloc_classement">
		    <div class="classement"><a href="contenu_modifier.php?id=<?php 
        echo $row->id;
        ?>
&action=modclassement&parent=<?php 
        echo $parent;
        ?>
&type=M"><img src="gfx/up.gif" border="0" /></a></div>
		    <div class="classement"><span id="classementcontenu_<?php 
        echo $row->id;
        ?>
" class="contenudos_edit"><?php 
        echo $row->classement;
        ?>
</span></div>
		    <div class="classement"><a href="contenu_modifier.php?id=<?php 
        echo $row->id;
        ?>
&action=modclassement&parent=<?php 
        echo $parent;
        ?>
&type=D"><img src="gfx/dn.gif" border="0" /></a></div>
		 </div>
		</li>
		<li style="width:37px; text-align:center;"><a href="javascript:supprimer_contenu('<?php 
        echo $row->id;
        ?>
', '<?php 
        echo $parent;
        ?>
');"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li>
	</ul>

	<?php 
    }
}
Пример #15
0
<?php

if (php_sapi_name() != 'cli') {
    echo 'CGI Mode !';
    exit;
}
if ($argc < 2) {
    exit('paramètre manquant !');
}
$path = __DIR__ . '/pages/' . $argv[1];
if (strpos($path, '.php') === false) {
    $path = $path . '.php';
}
require 'core/contenu.php';
$file = fopen($path, 'w');
$contenu = new Contenu();
$contenu->add('Voici la page generer par le framework')->add_sauts(1)->addTab()->add('<h1>je vous invite a modifier son contenu</h1>')->add_sauts(1)->add('<hr>By jenaye');
$contenu->writeFile($file);
fclose($file);
chmod($path, 0777);
Пример #16
0
<?php

if (php_sapi_name() != 'cli') {
    echo 'CGI Mode !';
    exit;
}
if ($argc < 2) {
    exit('paramètre manquant !');
}
$path = __DIR__ . '/functions/' . $argv[1];
if (strpos($path, '.php') === false) {
    $path = $path . '.php';
}
require 'core/contenu.php';
$file = fopen($path, 'w');
// var_dump($argv);
// recuperation du nom de la function tappé
$name = ucfirst(basename($path, '.php'));
$contenu = new Contenu();
$contenu->add('<?php')->add_sauts(2)->add("class {$name} {")->add_sauts(2)->addTab(1)->add('public function Votrefunction() {')->add_sauts(1)->addTab(2)->add('return "Une phrase par exemple";')->add_sauts(1)->addTab(6)->add('} ')->add_sauts(1)->addTab(3)->add('}')->add_sauts(1)->addTab(2)->add('// Ceci est un commentaire php')->add_sauts(1)->add('?>');
$contenu->writeFile($file);
fclose($file);
chmod($path, 0777);