<commit_before><?php

/**
 *
 * @package    sfFacebookConnectPlugin
 * @author     <NAME>
 *
 */
class sfFacebook
{
  protected static
    $client          = null; // Facebook instance
  protected static
    $guard_adapter   = null;
  protected static
    $is_js_loaded       = false;



  public static function getFacebookCookie()
  {
//    $app_id = self::getApiKey();
//    $application_secret = self::getApiSecret();
//    $args = array();
//    var_dump($_COOKIE);
//    parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
//    ksort($args);
//    $payload = '';
//    foreach ($args as $key => $value) {
//      if ($key != 'sig') {
//        $payload .= $key . '=' . $value;
//      }
//    }
//    if (md5($payload . $application_secret) != $args['sig']) {
//      return null;
//    }
//    return $args;
  }

  /**
   * gets the facebook client instance
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   * @since 2010-05-12 <NAME> <<EMAIL>>: new Facebook php-sdk
   */
  public static function getFacebookClient()
  {
    if (self::$client === null)
    {
      $params = array(
        'appId'  => self::getApiKey(),
        'secret' => self::getApiSecret(),
        'cookie' => self::getApiCookie(),
        'domain' => self::getApiDomain()
      );

      self::$client = new Facebook($params);
    }

    if (!self::$client)
    {
      error_log('Could not create facebook client.');
    }

    return self::$client;
  }

  /**
   * get the facebook session
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getSession()
  {

    return self::getFacebookClient()->getSession();
  }

  /**
   * get the facebook user
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getUser()
  {

    return self::getFacebookClient()->getUser();
  }

  /**
   * get datas through the faceook graph api
   * @see http://developers.facebook.com/docs/api
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getFacebookApi($param)
  {

    return self::getFacebookClient()->api($param);
  }

   /**
   * gets the facebook api key
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   */
  public static function getApiKey()
  {

    return sfConfig::get('app_facebook_api_key');
  }

   /**
   * gets the facebook api secret
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   */
  public static function getApiSecret()
  {

    return sfConfig::get('app_facebook_api_secret');
  }

  /**
   * get the facebook app cookie support
   *
   * @return Boolean
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-12
   */
  public static function getApiCookie()
  {

    return sfConfig::get('app_facebook_api_cookie', true);
  }

  /**<commit_msg>[master] Correct the parameters sent to the facebook class<commit_after><?php

/**
 *
 * @package    sfFacebookConnectPlugin
 * @author     <NAME>
 *
 */
class sfFacebook
{
  protected static
    $client          = null; // Facebook instance
  protected static
    $guard_adapter   = null;
  protected static
    $is_js_loaded       = false;



  public static function getFacebookCookie()
  {
    $app_id = self::getApiId();
    $application_secret = self::getApiSecret();
    $args = array();
    parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
    ksort($args);
    $payload = '';
    foreach ($args as $key => $value)
    {
      if ($key != 'sig')
      {
        $payload .= $key . '=' . $value;
      }
    }
    if (md5($payload . $application_secret) != $args['sig'])
    {
      return null;
    }

    return $args;
  }

  /**
   * gets the facebook client instance
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   * @since 2010-05-12 <NAME> <<EMAIL>>: new Facebook php-sdk
   * @since 2010-09-03 <NAME> : correct the parameters sent to the facebook class constructor
   */
  public static function getFacebookClient()
  {
    if (self::$client === null)
    {
      $params = array(
        'appId'  => self::getApiId(),
        'secret' => self::getApiSecret(),
        'cookie' => self::getApiCookie(),
        'domain' => self::getApiDomain()
      );

      self::$client = new Facebook($params);
    }

    if (!self::$client)
    {
      error_log('Could not create facebook client.');
    }

    return self::$client;
  }

  /**
   * get the facebook session
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getSession()
  {

    return self::getFacebookClient()->getSession();
  }

  /**
   * get the facebook user
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getUser()
  {

    return self::getFacebookClient()->getUser();
  }

  /**
   * get datas through the faceook graph api
   * @see http://developers.facebook.com/docs/api
   *
   * @return Array
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-13
   */
  public static function getFacebookApi($param)
  {

    return self::getFacebookClient()->api($param);
  }

  /**
   * gets the facebook api key
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   */
  public static function getApiKey()
  {

    return sfConfig::get('app_facebook_api_key');
  }

  /**
   * gets the facebook api secret
   *
   * @return Facebook
   * @author fabriceb
   * @since 2009-05-17
   */
  public static function getApiSecret()
  {

    return sfConfig::get('app_facebook_api_secret');
  }

  /**
   * get the facebook app id
   *
   * @return integer
   * @author <NAME> <<EMAIL>>
   * @since 2010-09-03
   */
  public function getAppIpd()
  {

    return sfConfig::get('app_facebook_api_id');
  }

  /**
   * get the facebook app cookie support
   *
   * @return Boolean
   * @author <NAME> <<EMAIL>>
   * @since 2010-05-12
   */
  public static function getApiCookie()
  {

    return sfConfig::get('app_facebook_api_cookie', true);
  }

  /**
{'fraction_non_alphanumeric': 0.1568724279835391, 'fraction_numerical': 0.02403292181069959, 'mean_word_length': 2.409652076318743, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1517846', 'n_tokens_mistral': 2159, 'n_tokens_neox': 1984, 'n_words': 462}