erreurs php avec la fonction: include_once

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : erreurs php avec la fonction: include_once

Re: erreurs php avec la fonction: include_once

par macgawel » 25 juil. 2011, 18:01

Bonjour.

Je n'ai pas lu le pavé :oops: (et je pense que peu en auront le courage)
Warning: include_once(./atk/include/initial.inc) [function.include-once]: failed to open stream: No such file or directory in C:\wamp\www\achievo\atk.inc on line 15
Attention, le fichier que tu essayes d'ouvrir n'existe pas.

C'est un problème qu'on rencontre souvent à force d'inclure des fichiers qui en incluent d'autres, le tout avec des chemins relatifs.
Affiche le chemin du script courant (celui qui servira de base à l'include) avec echo $_SERVER[SCRIPT_FILENAME];, et compare avec l'include...

Re: erreurs php avec la fonction: include_once

par Nat82 » 25 juil. 2011, 17:48

j'ai oublié le code du fichier ical.php situé dans www/achievo_modules/ical
<?php
  //
  // iCal configuration options
  //
  // Change the config_atkroot so it points to the achievo homedir
  // 
  $config_atkroot = "../../achievo/";
   
  // The number of months that the events go back
  $monthsback = 1;
  // The number of months that the events go in the future
  $monthsahead = 3;

  // below there should be nothing to edit
  include_once($config_atkroot."atk.inc");
  include_once($config_atkroot."version.inc");
  require_once($config_atkroot.moduleDir("ical")."includes/class.iCal.inc.php");
  require_once($config_atkroot.moduleDir("ical")."tools.php");
  
  // check achievo version (if g_db exist it's 1.1 or earlier)
  if (is_object($g_db)) { $achievo = 1; } else { $achievo = 0; }
   
  // check if it's a valid user with ID given in URL
  foreach ($_GET as $key => $value) { $iduser=$key; break; }
  
  // Some programs add there own stuff to the URL, so we strip it here if known!
  // 2006-01-12: Yagoon Time adds _ics
  $nontoken = array("_ics");
  $iduser = str_replace($nontoken,"",$iduser);

  
  // db instance (depends on version of achievo which one to call)
  if ($achievo==1)
  {
      $db = "atk".atkconfig("database")."query";
  } else {
      $db = &atkGetDb();
      $g_db = $db;
  }
  
  // make query to check if user is known
  if ($achievo==1) $query = new $db();
  else $query = &$db->createQuery();
  $query->addTable('ical_preferences');
  $query->addField('*', ' ', 'ical_preferences');
  $query->addCondition("ical_user_url = '".$iduser."'");
  $querystring = $query->buildSelect(TRUE);
  $user = $g_db->getRows($querystring);
  $userid = $user[0]['ical_user_id'];
  
  // No user is found, check if TOKEN is the standard token
  if (count($user)==0)
  {
    $userToken = decrypt($iduser,atkconfig('auth_accountenableexpression'));  
    $userid = explode(":",$userToken);
    
    if (is_numeric($userid[0]))  
    {
     if ($achievo==1) $query = new $db();
     else $query = &$db->createQuery();
    $query->addTable('person');
    $query->addField('userid as ical_user', ' ', 'person');
    $query->addField('id', ' ', 'person');
    $query->addCondition("person.id = '".$userid[0]."'");
    $querystring = $query->buildSelect(TRUE);
    $user = $g_db->getRows($querystring);
    $userid = $user[0]['id'];
    // Show only the calendar events if no prefs are set!
    $user[0]['ical_events'] = 1;
    }

    // NO USER FOR TOKEN show 401
    if (count($user)==0)  
    {
     header('HTTP/1.0 401 Unauthorized');
     die("<h1>You are unauthorized to perform this action</h1>");
    }
  }
  
  // All ready to go!
  if (count($user)>0)
  {
  global $g_db;
  
  $iCal = new iCal('Achievo', 0);
  
  if ($user[0]['ical_events']==1)
  {
    $edate = date('Y-m-d',mktime(12,0,0,date("m")-$monthsback,1,date("Y")));
    $bdate = date('Y-m-d',mktime(12,0,0,date("m")+$monthsahead,1,date("Y")));
    
    if ($achievo==1) $query = new $db();
    else $query = &$db->createQuery();
    $query->addTable('schedule');
    $query->addJoin('schedule_attendee', '', 'schedule_attendee.schedule_id=schedule.id', TRUE);
    $query->addJoin('person', '', 'person.id=schedule_attendee.person_id', TRUE);
    $query->addJoin('person', 'owner', 'owner.id=schedule.owner', TRUE);
    $query->addJoin('schedule_type', 'stype', 'stype.id=schedule.scheduletype', TRUE);

    $query->addField('id', ' ', 'schedule');
    $query->addField('startdate', ' ', 'schedule');
    $query->addField('enddate', ' ', 'schedule');
    $query->addField('starttime', ' ', 'schedule');
    $query->addField('endtime', ' ', 'schedule');
    $query->addField('title', ' ', 'schedule');
    $query->addField('description', ' ', 'schedule');
    $query->addField('location', ' ', 'schedule');
    $query->addField('allday', ' ', 'schedule');
    $query->addField('publicitem', ' ', 'schedule');
    $query->addField('owner', ' ', 'schedule');
    $query->addField('status', ' ', 'schedule');
    $query->addField('all_users', ' ', 'schedule');
    $query->addField('description AS stype', '', 'stype');    
    $query->addField('firstname', ' ', 'owner');    
    $query->addField('lastname', ' ', 'owner');    
    $query->addField('email', ' ', 'owner');    
    $query->addField('id AS personid', ' ', 'person');    
    if ($user[0]['ical_only_events_privat']==1) 
    {
    $query->addCondition("schedule.startdate <='$bdate' AND schedule.enddate >= '$edate' AND (schedule.owner='".$user[0]['ical_user']."' OR person.userid='".$user[0]['ical_user']."')");    
    } else {
    $query->addCondition("(schedule.startdate <='$bdate' AND schedule.enddate >= '$edate')
                          OR (schedule.startdate <='$bdate' AND schedule.enddate >= '$edate' AND (schedule.owner='".$user[0]['ical_user']."' OR person.userid='".$user[0]['ical_user']."'))");
    }
    $query->addGroupBy('schedule.id');
    $query->addOrderBy('startdate,starttime');
    $querystring = $query->buildSelect(TRUE);
    $recs = $g_db->getRows($querystring);


    // Loop thru data
    for ($i=0;$i<count($recs);$i++)
    {
        // Get attendees for event
        $attendees = array();
        $attendee = $g_db->getRows("SELECT DISTINCT person.userid,person.lastname,person.firstname,person.email,person.role FROM schedule_attendee LEFT JOIN person ON person.id=schedule_attendee.person_id WHERE schedule_attendee.schedule_id='".$recs[$i]['id']."'");
        for ($a=0;$a<count($attendee);$a++)
        {
            $attendees[$attendee[$a]['firstname']." ".$attendee[$a]['lastname']]=$attendee[$a]['email'].",3";
        }
        // Get links inside the description
        $links = extractLinks($recs[$i]['description']);
        
        // Only add when event is public or your the owner
        if ($recs[$i]['publicitem']==1 or ($userid==$recs[$i]['owner'] or $userid==$recs[$i]['personid'] and $user[0]['ical_events_privat']==1))
        {
        $organizer = array($recs[$i]['firstname']." ".$recs[$i]['lastname'], $recs[$i]['email']);
        
        $iCal->addEvent($organizer, // SET Organiser for this event
                        ($recs[$i]['allday']=="0" ? timestamp($recs[$i]['startdate'],$recs[$i]['starttime']) : timestamp($recs[$i]['startdate'],"00:00:00",array("0","0","0","0","1","0"))), // Set starttime of event (When its an allday event set it to tommorow 00:00:00)
                       ($recs[$i]['allday']=="0" ? timestamp($recs[$i]['enddate'],$recs[$i]['endtime']) : timestamp($recs[$i]['enddate'],"00:00:00",array("0","0","0","0","1","0"))), // Set endtime of event (When its an allday event set it to tommorow 00:00:00)
                        $recs[$i]['location'], // Set location of the event
                        0, // Set Transparancy (0 = OPAQUE | 1 = TRANSPARENT)
                        array(str_replace("/"," ",$recs[$i]['stype'])), // Set event Categorie
                        preg_replace("/(\r\n|\n|\r)/", " ", str_replace(",","",$recs[$i]['description'])), //Set event description (DSTRIP line breaks, because not all ical programs can handle them!)
                        $recs[$i]['title']." (".$recs[$i]['firstname']." ".$recs[$i]['lastname'].")", // Set title of the event
                        $recs[$i]['publicitem'], // Set kind of class
                        $attendees, // Attendees array(key = attendee name, value = e-mail, role of the attendee [0 = CHAIR | 1 = REQ | 2 = OPT | 3 =NON])
                        1, // Set priority (scale 1 to 9)
                        0, // Set frequency of event (0 = once | 1 = secondly | 2 = minutly | 3 = hourly | 4 = daily | 5 = weekly | 6 = monthly | 7 = yearly) NOTE: is set to 0 for Outlook Compatibility!!
                        ($recs[$i]['allday']=="0" ? 0 : timestamp($recs[$i]['enddate'],$recs[$i]['endtime'])), // set recurrency end ('' = forever | integer = number of times | timestring = explicit date)
                        0, // Set interval for frequency (every 2,3,4 weeks...) NOTE: is set to 0 for Outlook Compatibility!!
                        array(0,1,2,3,4,5,6), // Array with the number of the days the event accures (example: array(0,1,5) = Sunday, Monday, Friday
                        1, // Set startday of the Week (0 = Sunday | 6 = Saturday|1 = Monday)
                        "", // Set exeption dates: Array with timestamps of dates that should not be includes in the recurring event
                        ($user[0]['ical_alarm']=="1" && $starttime>time() ? array(
                                                                                                      0, // Action: 0 = DISPLAY, 1 = EMAIL, (not supported: 2 = AUDIO, 3 = PROCEDURE)
                                                                                                      $user[0]['ical_alarm_time'],  // Trigger: alarm before the event in minutes
                                                                                                      $recs[$i]['title']." (".$recs[$i]['firstname']." ".$recs[$i]['lastname'].")", // Title
                                                                                                      preg_replace("/(\r\n|\n|\r)/", " ", str_replace(",","",$recs[$i]['description'])), // Description
                                                                                                      $attendees, // Array (key = attendee name, value = e-mail, second value = role of the attendee [0 = CHAIR | 1 = REQ | 2 = OPT | 3 =NON])
                                                                                                      5, // Duration between the alarms in minutes
                                                                                                      0  // How often should the alarm be repeated
                                                                                                      ) : "" ), // Set alarm for event
                         ($recs[$i]['status'] == "confirmed" ? ($recs[$i]['status'] == "cancelled" ?  2 : 1) : 0 ), // Set Status of the event
                         $links[0], // Set link for event
                         substr($config_languagefile,0,strpos($config_languagefile,".")), // Set language for event strings
                         $recs[$i]['id'] // Set UID of the event
                         );
        }
    }
  }
  
  if ($user[0]['ical_todo']==1)
  {
    // TODO's from Achievo
    if ($achievo==1) $query = new $db();
    else $query = &$db->createQuery();
    $query->addTable('todo');

    $query->addJoin('person', 'assigned_to', 'todo.assigned_to=assigned_to.id', TRUE);
    $query->addJoin('person', 'owner', 'owner.id=todo.owner', TRUE);
    $query->addJoin('project', 'projectid', 'todo.projectid=projectid.id', TRUE);

    $query->addField('id', ' ', 'todo');
    $query->addField('lastname', ' ', 'owner');
    $query->addField('firstname', ' ', 'owner');
    $query->addField('email', ' ', 'owner');
    $query->addField('id AS ownerid', ' ', 'owner');
    $query->addField('cellular', ' ', 'owner');
    $query->addField('fax', ' ', 'owner');
    $query->addField('status AS ownerstatus', ' ', 'owner');
    $query->addField('name', ' ', 'projectid');
    $query->addField('id AS projectid', ' ', 'projectid');
    $query->addField('title', ' ', 'todo');
    $query->addField('lastname AS lastname_assigned', ' ', 'assigned_to');
    $query->addField('firstname AS firstname_assigned', ' ', 'assigned_to');
    $query->addField('email AS firstname_email', ' ', 'assigned_to');
    $query->addField('id AS id_assigned', ' ', 'assigned_to');
    $query->addField('cellular AS cellular_assigned', '', 'assigned_to');    
    $query->addField('fax AS fax_assigned', ' ', 'assigned_to');    
    $query->addField('status AS status_assigned', ' ', 'assigned_to');    
    $query->addField('entrydate', ' ', 'todo');    
    $query->addField('duedate', ' ', 'todo');    
    $query->addField('updated', ' ', 'todo');    
    $query->addField('priority', ' ', 'todo');    
    $query->addField('description', ' ', 'todo');
    $query->addField('status', ' ', 'todo');
    
    $query->addCondition("assigned_to='".$userid."' OR todo.owner='".$userid."' AND todo.status NOT IN (5,2)");

    $query->addOrderBy('duedate, priority');
    $querystring = $query->buildSelect(TRUE);
    $recs = $g_db->getRows($querystring);
    
    for ($i=0;$i<count($recs);$i++)
    {

    $iCal->addToDo(
               $recs[$i]['title'], // Todo title
               $recs[$i]['description'], // Todo description  
                           '', // Todo location
               timestamp($recs[$i]['entrydate']), // Todo Start time / Entry date  
                           '', // Todo duration [not used, but can be the difference between start - end date]
               timestamp($recs[$i]['duedate']),// Todo End time / Deadline
                           0, // Todo percentage complete [not inluded yet]
               $recs[$i]['priority'], // Todo priority
                           ($recs[$i]['status']=="1" or $recs[$i]['status']=="3" ? 0 : ($recs[$i]['status']=="2" or $recs[$i]['status']=="4" ? 2 : ($recs[$i]['status']=="5" ? 5 : ''))), //Todo status
                           0,// Todo Class (0 = PRIVATE | 1 = PUBLIC | 2 = CONFIDENTIAL)
                           array($recs[$i]['firstname']." ".$recs[$i]['lastname'], $recs[$i]['email']), // Todo organiser
                           array($recs[$i]['firstname_assigned']." ".$recs[$i]['lastname_assigned'], $recs[$i]['email_assigned'],'3'), // Todo attendees (person who as the todo assigned)
                           array($recs[$i]['name']), // Todo categories
                           timestamp(substr($recs[$i]['updated'],0,10),substr($recs[$i]['updated'],11,18)), // Last modification date/time in unix timestamp
                           ($user[0]['ical_alarm']=="1" ? array(0,$user[0]['ical_alarm_time'],$title, $description, $attendees, 5, $user[0]['ical_alarm_repeat']) : 0), // Todo Alarm
                           0, // Todo frequency
                           '', // Todo recurrency end
                           0, // Todo interval for frequency
                           array(0,1,2,3,4,5,6), // Todo day numbers, array with the number of the days the event accures
                           1, // Startday of the Week
                           "", // Exeption dates: Array with timestamps of dates that should not be includes in the recurring event
                           "", // Todo link
                           substr($config_languagefile,0,strpos($config_languagefile,".")), // Language of the Strings
               $recs[$i]['id'] // Optional UID for this TODO
                          );

    }
  }
   
  // RENDER the file
  $filename = "Calendar_".urlencode($user[0]['ical_user'])."_".date("F_j_Y");
  if (empty($user[0]['ical_format'])) $user[0]['ical_format'] = "ics";
  $iCal->outputFile($user[0]['ical_format'],$filename);
  
 }
?>
Merci

erreurs php avec la fonction: include_once

par Nat82 » 25 juil. 2011, 17:45

Bonjour,

j'ai intallé pour tester en local sur WampServer, une application open source Achievo.
J'ai voulu ajoutée un module et comme indiqué dans la doc ; il y a 2 lignes de codes à modifier pour indiquer le chemin du dossier racine Achievo.
le dossier root pour l'application achievo doit être :
www/achievo
Puis mon module intitulé "ical", doit être situé également à la racine :
www/achievo_module/ical
Je dois configurer le fichier du module ical (ical.php) :
 // Change the config_atkroot so it points to the achievo homedir
  // 
  $config_atkroot = "../../achievo/";
Il y a un problème avec la fonction include_once. Voici les erreurs affichées :

Code : Tout sélectionner

( ! ) Warning: include_once(./atk/include/initial.inc) [function.include-once]: failed to open stream: No such file or directory in C:\wamp\www\achievo\atk.inc on line 15 Call Stack # Time Memory Function Location 1 0.0013 513056 {main}( ) ..\ical.php:0 2 0.0016 520040 include_once( 'C:\wamp\www\achievo\atk.inc' ) ..\ical.php:15 ( ! ) Warning: include_once() [function.include]: Failed opening './atk/include/initial.inc' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\achievo\atk.inc on line 15 Call Stack # Time Memory Function Location 1 0.0013 513056 {main}( ) ..\ical.php:0 2 0.0016 520040 include_once( 'C:\wamp\www\achievo\atk.inc' ) ..\ical.php:15 ( ! ) Warning: include_once(./version.inc) [function.include-once]: failed to open stream: No such file or directory in C:\wamp\www\achievo_modules\ical\ical.php on line 16 Call Stack # Time Memory Function Location 1 0.0013 513056 {main}( ) ..\ical.php:0 ( ! ) Warning: include_once() [function.include]: Failed opening './version.inc' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\achievo_modules\ical\ical.php on line 16 Call Stack # Time Memory Function Location 1 0.0013 513056 {main}( ) ..\ical.php:0 ( ! ) Fatal error: Call to undefined function moduleDir() in C:\wamp\www\achievo_modules\ical\ical.php on line 17 Call Stack # Time Memory Function Location 1 0.0013 513056 {main}( ) ..\ical.php:0
J'ai plusieurs fois modifié le chemin dans le fichier ical.php. mais à chaque fois, j'ai les mêmes erreurs. Donc je pense que ces erreurs sont liées aux fichiers suivants :
le fichier atk.inc situé www/achievo/
<?php
  /**
   * ATK Include file.. If you strip out stuff you don't need, you
   * might have some performance improvement.
   * Somethings can't be stripped out.
   */

  /**
   * @internal This variable indicates where to get all the includes. Usually,
   *           this is the current dir.
   */
  $config_atkroot = "./";

  // Atknode is required. Don't remove it.
  include_once($config_atkroot."atk/include/initial.inc");

  // Uniform textbox sizes
  define("TEXT_SMALL", 3);
  define("TEXT_LARGE", 10);

  // Some uniform colors
  define("COLOR_WARNING", "#FCAA60");
  define("COLOR_ERROR", "#FF0000");
  define("COLOR_OK", "#00FF00");

  // Some uniform recordlist highlight color definitions containing the
  // color which can be used when the mousepointer hovers over a row
  define("COLOR_HIGHLIGHT_WARNING", "#FFCC83");
  define("COLOR_HIGHLIGHT_ERROR", "#FF5555");
  define("COLOR_HIGHLIGHT_OK", "#66FF66");

?>[/code]

Puis le fichier index.php situé à la racine www/achievo
[code]<?php

  /**
   * @internal includes
   */
  $config_atkroot = "./";
  include_once("atk.inc");
  include_once("atk/atkbrowsertools.inc");
  include_once("achievotools.inc");
  atksession();
  atksecure();
  include "theme.inc";

  $theme = &atkinstance('atk.ui.atktheme');
  if (atkconfig("fullscreen"))
  {
    // Fullscreen mode. Use index.php as launcher, and launch app.php fullscreen.

    $page = &atkinstance("atk.ui.atkpage");
    $ui = &atkinstance("atk.ui.atkui");
    $theme = &atkinstance("atk.ui.atktheme");
    $output = &atkinstance("atk.ui.atkoutput");

    $page->register_style($theme->stylePath("style.css"));
    $page->register_script(atkconfig("atkroot")."atk/javascript/launcher.js");

    $content = '<script language="javascript">atkLaunchApp(); </script>';
    $content.= '<br><br><a href="#" onClick="atkLaunchApp()">'.atktext('app_reopen', "atk").'</a> &nbsp; '.
    '<a href="#" onClick="window.close()">'.atktext('app_close', "atk").'</a><br><br>';

    $box = $ui->renderBox(array("title"=>atktext("app_launcher"),
    "content"=>$content));

    $page->addContent($box);
    $output->output($page->render(atktext('app_launcher'), true));

    $output->outputFlush();
  }
  else
  {
    if ($theme->getAttribute('useframes',true))
    {
      // Regular mode. app.php can be included directly.
      include "app.php";
    }
    else
    {
      $user = &atkGetUser();
      $indexpage = &atknew('atk.ui.atkindexpage');
      $indexpage->setUsername(getFullUsername());
      $indexpage->setTitle(getAchievoTitle());
      $indexpage->setTopSearchPiece(getSearchPiece());
      $centerpiece="";
      $centerpiecelinks=array();
      getCenterPiece($centerpiece,$centerpiecelinks);
      $indexpage->setTopCenterPieceLinks($centerpiecelinks);
      if($user["name"]=="administrator")
      {
        $destination = array("atknodetype"=>"pim.pim","atkaction"=>"adminpim");
      }
      else 
      {
        $destination = array("atknodetype"=>"pim.pim","atkaction"=>"pim");
      }
      $indexpage->setDefaultDestination($destination);
      $indexpage->generate();
    }
  }
?>
le fichier initial.inc situé www/achievo/atk/include
<?php
  /**
   * This file is part of the Achievo ATK distribution.
   * Detailed copyright and licensing information can be found
   * in the doc/COPYRIGHT and doc/LICENSE files which should be
   * included in the distribution.
   *
   * @package atk
   * @subpackage include
   *
   * @copyright (c)2005 Ibuildings.nl BV
   * @license http://www.achievo.org/atk/licensing ATK Open Source License
   *
   * @version $Revision: 6301 $
   * $Id: initial.inc 6404 2009-06-17 11:26:32Z max $
   */

  /** @internal includes */
  require_once($config_atkroot.'atk/include/basics.inc');
  require_once($config_atkroot.'atk/modules/atkmoduletools.inc');
  require_once($config_atkroot.'atk/include/compatibility.inc');
  if (atkconfig('autoload_classes',    true)) require_once($config_atkroot.'atk/include/autoload.inc');
  if (atkconfig('use_atkerrorhandler', true)) require_once($config_atkroot.'atk/include/errorhandler.inc');
  require_once($config_atkroot.'atk/ui/class.atkoutput.inc');
  require_once($config_atkroot.'atk/session/class.atksessionmanager.inc');
  require_once($config_atkroot."atk/utils/class.atkstring.inc");
  require_once($config_atkroot.'atk/include/security.inc');
  require_once($config_atkroot.'atk/include/debugging.inc');
  if (atkconfig('lock_type')!=="") require_once($config_atkroot.'atk/lock/class.atklock.inc');
  atkPreloadModules();

?>
Le fichier version.inc est situé à la racine www/achievo.

Désolé pour la longueur du post, mais cela permet d'avoir tous les éléments car j'ai vraiment l'impression que tous ces fichiers sont liés entre eux, mais je ne comprends pas leur structure.

Merci beaucoup pour votre précieuse aide.