Plugin Directory

Changeset 504332


Ignore:
Timestamp:
02/13/2012 02:59:58 PM (14 years ago)
Author:
roggie
Message:

Major update to support Graph API

Location:
sfce-create-event/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sfce-create-event/trunk/readme.txt

    r401798 r504332  
    55Tags: Simple Facebook Connect, Facebook, event, SFC, create
    66Requires at least: 2.7
    7 Tested up to: 3.1.3
    8 Stable tag:3.96.3
     7Tested up to: 3.3.1
     8Stable tag:4.0.1
    99
    1010Create Facebook events automatically when you create Wordpress posts. This plugin requires the Simple Facebook Connect plugin by Otto.
  • sfce-create-event/trunk/sfce-create-event.php

    r401798 r504332  
    11<?php
    22/*
    3 Plugin Name: SFCe - Create Event
    4 Version: 3.96.3
     3Plugin Name: SFCe - Graph API Create Event
     4Version: 4.00.1
    55Author: Roger Howorth
    66Author URI: http://www.thehypervisor.com
    77Plugin URI: http://www.thehypervisor.com/simple-facebook-connect-extensions
    8 Description: Adds a PHP function to create a Facebook event. Requires Simple Facebook Connect plugin by Otto.
     8Description: Adds a PHP function to create a Facebook event.
    99License: http://www.gnu.org/licenses/gpl.html
    1010
     
    3131*/
    3232
    33 include_once('sfce-invite-people.php');
     33add_action("plugins_loaded", "sfce_graph_create_event_init");
     34add_action("admin_menu", "sfce_graph_create_event_init");
    3435
    35 add_action("plugins_loaded", "sfce_create_event_init");
    36 add_action("admin_menu", "sfce_create_event_init");
    37 
    38 function sfce_create_event_init() {
     36function sfce_graph_create_event_init() {
    3937    $plugin_dir = dirname(plugin_basename(__FILE__));
    4038    load_plugin_textdomain( 'sfce-create-event', null, $plugin_dir . '/languages/');
     
    4846    // See Notes section for possible arguments - http://wiki.developers.facebook.com/index.php/Events.create
    4947    $num_args = func_num_args();
    50     if ( $num_args <> '1' )
    51         wp_die(__('You must pass the correct arguments as an array to sfce_create_event when you invoke the function. See plugin readme for more details.', 'sfce-create-event'));
     48    if ( $num_args <> '1' ) wp_die(__('You must pass the correct arguments as an array to sfce_create_event when you invoke the function. See plugin readme for more details.', 'sfce-create-event'));
    5249    $args = func_get_arg(0);
     50
    5351    // Make Facebook event
    54         // Check if the post is published before creating fb event, disable this line for testing
    55     //  if ( $args['post_id']->post_status == "draft" ) return $args['post_id'];
     52    // Check if the post is published before creating fb event, disable this line for testing
     53    //if ( $args['post_id']->post_status == "draft" ) return $args['post_id'];
    5654
    57         // load Facebook platform
    58         $fboptions = get_option('sfc_options');
    59         $options = get_option('sfce_event_options');
     55    // load Facebook ID etc
     56    $fboptions = get_option('sfc_options');
    6057
    61         include_once WP_PLUGIN_DIR . '/simple-facebook-connect/facebook-platform/facebook.php';
    62         $fb=new Facebook($fboptions['api_key'], $fboptions['app_secret']);
    63         $fb_user = $fb->user;
    64         if ( empty ($fb_user)) {
    65             //$about = $fb->api_client->users_getInfo($fb_user,'about_me');
    66             // Not loggged into FB so don't create an event
    67             return $args['post_id'];
    68         }
     58    $start_time=mktime($args['start_hour'],$args['start_min'],"00",$args['month'],$args['day'],$args['year']);
     59    $start_time = substr(date('c',$start_time),0,16);
    6960
    70         if(!$fb->api_client->users_hasAppPermission('create_event')) {
    71             echo'<script type="text/javascript">window.open("http://www.facebook.com/authorize.php?api_key='.$fb->api_key.'&v=1.0&ext_perm=create_event", "Permission");</script>';
    72             // echo'<meta http-equiv="refresh" content="0; URL=javascript:history.back();">';
    73             wp_die(__('You should have seen a new Facebook window asking if you "Allow Events from [your Facebook page]". This tells Facebook it\'s OK for you to create events on your page. You should grant permission, then return here, press your browser back button and try again. If you did not see the window, your browser is set to not allow pop-ups. You must change your browser settings to allow pop-ups from Facebook and your Wordpress site.', 'sfce-create-event'));
    74         }
    75 
    76         $start_time=mktime($args['start_hour'],$args['start_min'],"00",$args['month'],$args['day'],$args['year']);
    77         $start_time = substr(date('c',$start_time),0,16);
    78 
    79         $end_time=mktime($args['end_hour'],$args['end_min'],"00",$args['month'],$args['day'],$args['year']);
    80         $end_time = substr(date('c',$end_time),0,16);
     61    $end_time=mktime($args['end_hour'],$args['end_min'],"00",$args['month'],$args['day'],$args['year']);
     62    $end_time = substr(date('c',$end_time),0,16);
    8163
    8264    // Add promo link if ok
     
    8466    if ( $options['sfce_show_promo'] ) $args['description'] .= "\nAuto event creation by http://www.thehypervisor.com";
    8567
    86         $event_fb = array("name"=>$args['name'], "host"=>$args['host'], "start_time"=>$start_time, "end_time"=>$end_time,  "description"=>$args['description'], "tagline"=>$args['tagline']);
    87         if ( $args['is_fanpage'] == 'TRUE' ) $event_fb['page_id'] = $fboptions['fanpage']; else if ( $args['is_fanpage'] && $args['page_id'] <> '' ) $event_fb['page_id'] = $args['page_id'];
    88    
    89         if ( $args['privacy'] ) $event_fb['privacy_type'] = $args['privacy'];
    90         $event_fb = array_map(utf8_encode, $event_fb);
     68    $event_data = array(
     69        'name' => $args['name'],
     70        'start_time' => $start_time,
     71        'end_time' => $end_time,
     72        'description' => $args['description'],
     73        'tagline' => $args['tagline'],
     74    );
     75    if ( isset($args['privacy']) ) $event_data['privacy_type'] = $args['privacy'];
    9176
    92         if ( substr($args['photo'],0,4) == 'http' ) wp_die(_e('The path to your photo cannot begin with \'http\'. The photo must be stored on your Wordpress server, and the path must be in the local file system - e.g. /var/www/wordpress/photo.jpg. Your post has been saved but no event created. Press the browser\'s back button to go back and edit your post', 'sfce-create-event'));
     77    if ( $args['is_fanpage'] == 'TRUE' ){
     78        $event_data['page_id'] = $fboptions['fanpage'];
     79        $url = "https://graph.facebook.com/me/events?";
     80        $event_data['access_token'] = $fboptions['page_access_token'];
     81    }
     82    else if ( $args['is_fanpage'] == 'FALSE' )
     83    {
     84        $url = "https://graph.facebook.com/me/events?";
     85        $event_data['access_token'] = $fboptions['access_token'];
     86    }
    9387
    94         if ( $_POST['sfce_event_photo'] <> '' ) {
    95             if (!file_exists($args['photo'])) wp_die(_e('The path to your event image does not point to a valid file. Please check your path and try again. Your post has been saved but no event created. Press the browser\'s back button to go back and edit your post.', 'sfce-create-event'));
     88    $data = wp_remote_post($url, array('body'=>$event_data));
    9689
    97             $pic_dims = getimagesize( $args['photo'] );
    98             if ( $pic_dims[0] < 100 || $pic_dims[1] < 100 ) wp_die(_e('Your event image is too small. Facebook requires event images to be at least 100 pixels wide and 100 pixels tall. Please remove the current image from your event parameters and try again. You post has been saved but no event created. Press the browser\'s back button to go back and edit your post', 'sfce-create-event'));
     90    if (!is_wp_error($data)) {
     91        $resp = json_decode($data['body'],true);
     92        if ($resp['id']) $event_id = $resp['id'];
     93        else
     94        {
     95            foreach ( $resp as $res ) foreach( $res as $re ) $tmptxt .= $re . '<br>';
     96            wp_die( 'Error: ' . $tmptxt . '<br>Use your browser\'s Back button to go back to your post and correct the problem then try again.');
    9997        }
    100 
    101         try{
    102             $event_id=$fb->api_client->events_create(json_encode( $event_fb ), $args['photo']);
    103             /* echo'<meta http-equiv="refresh" content="0; URL=">'; */
    104         } catch(Exception $e) {
    105             if ( $e->getCode() == '200' ) {
    106                 // update_post_meta ( $post_id, 'fb_event', 'created' );
    107                 wp_die(__('You must be an administrator of your Facebook page in order to create events. Please ask an existing Facebook page admin to fix this for you. Other details have been saved, press your browser "Back" button and carry on!', 'sfce-create-event'));
    108             }
    109             echo 'Error message: '.$e->getMessage().' Error code:'.$e->getCode();
    110         }
    111     // Invite people?
    112     if ( $args['group_id'] <> '') {
    113         $invite_ok = sfce_invite_people( array(
    114         'app_id' => $fboptions['appid']
    115         ,'app_secret' => $fboptions['app_secret']
    116         ,'fb' => $fb
    117         ,'group_id' => $args['group_id']
    118         ,'event_id' => $event_id
    119         ,'fb_user' => $fb_user
    120         ,'access_token' => $options['sfce_access_token']
    121         ));
    122     }
    123     if ( $args['invite_page'] <> '' ) {
    124         $invite_ok = sfce_invite_people( array(
    125         'app_id' => $fboptions['appid']
    126         ,'app_secret' => $fboptions['app_secret']
    127         ,'fb' => $fb
    128         ,'page_id' => $args['invite_page']
    129         ,'event_id' => $event_id
    130         ,'fb_user' => $fb_user
    131         ,'access_token' => $options['sfce_access_token']
    132         ));
    13398    }
    13499
    135100    return $event_id;
    136 } //end sfce_create_event
     101}
     102//end sfce_create_event
     103
     104
  • sfce-create-event/trunk/sfce-settings-page.php

    r372466 r504332  
    1313function sfce_event_settings_page() {
    1414    global $sfce_text_inputs;
     15    $options = get_option('sfce_event_options');
    1516
    1617    if ( isset ($_POST['sfce_submit']) )
    1718    {
    1819        if ( !wp_verify_nonce ( $_POST['verify-key'], 'sfce_event') ) die(__('Failed security check. Reload page and retry', 'sfce-create-event'));
    19         if ( $_POST['sfce_event_privacy_visible'] && ( $_POST['sfce_event_privacy'] <> 'OPEN' && $_POST['sfce_event_privacy'] <> 'CLOSED' )) $error .= 'You must provide a Privacy setting if you want to hide this option. Acceptable settings are OPEN or CLOSED.<p>';
     20        if ( $_POST['sfce_event_privacy_visible'] && ( $_POST['sfce_event_privacy'] <> 'OPEN' || $_POST['sfce_event_privacy'] <> 'CLOSED' )) $error .= 'You must provide a Privacy setting if you want to hide this option. Acceptable settings are OPEN or CLOSED.<p>';
    2021        if ( $_POST['sfce_event_start_hour_visible'] && $_POST['sfce_event_start_hour'] == '' ) $error .= 'You must provide a Start Hour if you want to hide this option.<p>';
    2122        if ( $_POST['sfce_event_start_min_visible'] && $_POST['sfce_event_start_min'] == '' ) $error .= 'You must provide a Start Minute if you want to hide this option.<p>';
     
    3233            $options['sfce_hide_postpanel'] = $_POST['sfce_hide_postpanel'];
    3334            $options['sfce_show_promo'] = $_POST['sfce_show_promo'];
    34             $options['sfce_access_token'] = $_POST['sfce_access_token'];
    35             $options['sfce_group_id'] = $_POST['sfce_group_id'];
    3635
    3736            update_option('sfce_event_options', $options);
     
    4746        }
    4847    } // end if isset
    49     $options = get_option('sfce_event_options');
    5048    ?>
    5149    <form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
     
    116114    echo '." /></td></tr></table>';
    117115
    118     echo "<h3>";
    119     _e('Access Token', 'sfce-create-event');
    120     echo '</h3>';
    121     echo '<table><tr><td width="500">';
    122     _e('In order to invite members of a Facebook group to events you need to enter your Facebook access token here. If you use this feature, be careful who you allow to edit or use the plugin because your access token should be kept private. If you want to cancel an access token, change your Facebook password.', 'sfce-create-event');
    123     echo '</td>';
    124     echo '<td width="220"><input type="password"';
    125     echo ' name="sfce_access_token" ';
    126     echo 'title="';
    127     _e('Put a Facebook Access Token here, it should be from an account that has access to the Facebook Group you enter in the box below.', 'sfce-create-event');
    128     echo '"';
    129     echo ' value="';
    130     if ( $options['sfce_access_token'] ) echo $options['sfce_access_token'];
    131     echo '" /></td></tr></table>';
    132 
    133     echo "<h3>";
    134     _e('Group ID', 'sfce-create-event');
    135     echo '</h3>';
    136     echo '<table><tr><td width="500">';
    137     _e('The Facebook Group ID. All members of this group will automatically be invited to events.', 'sfce-create-event');
    138     echo '</td>';
    139     echo '<td width="220"><input type="text"';
    140     echo ' name="sfce_group_id" ';
    141     echo 'title="';
    142     _e('Put you Facebook Group ID here, it is used only to invite group members to events created with this plugin.', 'sfce-create-event');
    143     echo '"';
    144     echo ' value="';
    145     if ( $options['sfce_group_id'] ) echo $options['sfce_group_id'];
    146     echo '" /></td></tr></table>';
    147 
    148116    ?><p class="submit">
    149117    <input type="submit" name="sfce_submit" value="<?php _e('Submit!', 'sfce-create-event'); ?>" />
  • sfce-create-event/trunk/sfce_create_event_post.php

    r401798 r504332  
    3434                    array( 'name' => 'sfce_event_host', 'maxlength' => 30, 'label' =>'Host'),
    3535                    array( 'name' => 'sfce_event_tagline', 'maxlength' => 30, 'label' =>'Tagline'),
    36                     array( 'name' => 'sfce_event_photo', 'maxlength' => 255, 'size' => 60, 'label' =>'Local path to photo', 'title' => 'e.g. /var/www/wordpress/uploads/photo.jpg'),
    37                     array( 'name' => 'sfce_event_is_fanpage', 'default' => 'TRUE', 'maxlength' => 5, 'size' => 6, 'label' => 'Use Fan Page?', 'title' => 'e.g. TRUE or FALSE'),
    38                     array( 'name' => 'sfce_event_privacy', 'maxlength' => 6, 'size' => 6, 'label' =>'Privacy setting', 'default' =>'OPEN', 'title' => 'e.g. OPEN, CLOSED or SECRET' ),
    39                     array( 'name' => 'sfce_event_start_hour', 'maxlength' => 2, 'size' => 2, 'label' =>'Start hour', 'required' => 1),
    40                     array( 'name' => 'sfce_event_start_min', 'maxlength' => 2, 'size' => 2, 'label' =>'Start minute', 'required' => 1),
    41                     array( 'name' => 'sfce_event_end_hour', 'maxlength' => 2, 'size' => 2, 'label' =>'End hour', 'required' => 1),
    42                     array( 'name' => 'sfce_event_end_min', 'maxlength' => 2, 'size' => 2, 'label' =>'End minute', 'required' => 1)
     36                //  array( 'name' => 'sfce_event_photo', 'maxlength' => 255, 'size' => 60, 'label' =>'Local path to photo', 'title' => 'e.g. /var/www/wordpress/uploads/photo.jpg'),
     37                    array( 'name' => 'sfce_event_is_fanpage', 'default' => 'TRUE', 'type' => 'select', 'values' => array('TRUE', 'FALSE'), 'label' => 'Use Fan Page?', 'title' => 'e.g. TRUE or FALSE'),
     38                    array( 'name' => 'sfce_event_privacy', 'maxlength' => 6, 'type' => 'select', 'values' => array( 'OPEN', 'CLOSED', 'SECRET'), 'size' => 6, 'label' =>'Privacy setting', 'default' =>'OPEN', 'title' => 'e.g. OPEN, CLOSED or SECRET' ),
     39                    array( 'name' => 'sfce_event_start_hour', 'type' => 'select', 'values' => array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'),  'label' =>'Start hour', 'required' => 1, 'no-end-br' => '1', 'title' => 'Time when the event will start.'),
     40                    array( 'name' => 'sfce_event_start_min', 'type' => 'select', 'values' => array('00','15','30','45'), 'label' =>'minute', 'required' => 1, 'no-start-br' => '1', 'title' => 'Time when the event will start.'),
     41                    array( 'name' => 'sfce_event_end_hour', 'type' => 'select', 'values' => array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'),  'label' =>'End hour', 'required' => 1, 'no-end-br' => '1', 'title' => 'Time when the event will end.'),
     42                    array( 'name' => 'sfce_event_end_min', 'type' => 'select', 'values' => array('00','15','30','45'), 'label' =>'minute', 'required' => 1, 'no-start-br' => '1', 'title' => 'Time when the event will end.')
    4343                    );
    44 
    4544
    4645$options = get_option('sfce_event_options');
    4746if ( !$options['sfce_hide_postpanel'] ) add_action('edit_form_advanced', 'sfce_create_event_post_hook');
    4847
     48add_action('edit_post', 'sfce_create_event_post');
    4949
    5050function sfce_create_event_post_hook() {
    5151    /* Must be author or above to see this form */
    5252    if ( !current_user_can('2') ) return;
    53    
     53
     54    $fboptions = get_option('sfc_options');
     55
    5456    global $sfce_text_inputs;
    5557    $options = get_option('sfce_event_options');
    5658
     59    global $current_user;
     60    get_currentuserinfo();
     61    $fbuid = get_user_meta($current_user->ID, 'fbuid', true);
     62
     63
     64
    5765    $post_id = $_GET['post'];
    5866    $eeventdate = get_post_meta ($post_id, 'sfce_event_date', true) ;
    59     $sfce_group_id = get_post_meta ($post_id, 'sfce_group_id', true) ;
    60 
    6167    if ( !$eeventdate ) $eeventdate = date('Y-m-d');
    6268
     
    6470
    6571    echo '<div class="postbox"><h3>'; _e('Create Facebook Event', 'sfce-create-event'); echo '</h3><div class="inside">';
     72    if ( empty($fbuid) ) {
     73        echo 'To create Facebook events you must:<br>';
     74        echo '<li>Be logged into Facebook using the same browser - use a different tab.</li>';
     75        echo '<li>Connect your Facebook account to your Wordpress account using the button on your <a href="/wp-admin/profile.php">Wordpress Profile page</a>.</li></div></div>';
     76        return;
     77    }
     78
     79
    6680    echo '<h2><b>'; _e('Event details', 'sfce-create-event') ; echo ':</b></h2>';
    6781    _e('Insert text; [TITLE] for post title; [[name_of_custom_field]] for data from Custom field.');
     
    89103            case 'hidden':
    90104            echo '<input type="hidden" name="' . $input['name'] . '" value="' . $$input['name'] .'" />';
     105            break;
     106
     107            case 'select':
     108            if ( !$input['no-start-br'] ) echo '<li>';
     109            printf(__('%s', 'sfce-create-event'),$input['label']);
     110            echo '&nbsp;<select name="' . $input['name'] . '" title="';
     111            printf(__('%s', 'sfce-create-event'), $input['title']);
     112            echo '" >';
     113            foreach ( $input['values'] as $val ){
     114                echo '<option value="' . $val .'" ';
     115                if ( substr($input['name'],-4) == "hour" && $val == date('H')) echo 'selected="selected" ';
     116                if ( substr($input['name'],-3) == "min" && $val > date('m')) echo 'selected="selected" ';
     117                echo '>' . $val . '</option>';
     118            }
     119            echo '</select>';
     120            if ( $input['no-end-br'] ) echo '&nbsp;'; else echo '</li>';
    91121            break;
    92122
     
    112142    echo '<li>';
    113143    _e('Event date', 'sfce-create-event');
    114     echo ' :<select type="text" name="sfce_event_day">';
     144    echo '&nbsp;<select type="text" name="sfce_event_day">';
    115145    for ( $i = 1; $i < 32; $i++)
    116146    {
     
    145175    echo '</select></li><br />';
    146176
    147     echo "<h3>";
    148     _e('Group ID', 'sfce-create-event');
    149     echo '</h3>';
    150     echo '<table><tr><td width="500">';
    151     _e('The Facebook Group ID. All members of this group will automatically be invited to events.', 'sfce-create-event');
    152     echo '</td>';
    153     echo '<td width="220"><input type="text"';
    154     echo ' name="sfce_group_id" ';
    155     echo 'title="';
    156     _e('Put you Facebook Group ID here, it is used only to invite group members to events created with this plugin.', 'sfce-create-event');
    157     echo '"';
    158     echo ' value="';
    159     if ( $sfce_group_id ) echo $sfce_group_id;
    160     else if ( $options['sfce_group_id'] ) echo $options['sfce_group_id'];
    161     echo '" /></td></tr></table><br>';
    162 
    163 
    164177    $sfce_fb_event_status = get_post_meta($_GET['post'], 'sfce_fb_event_status', true );
    165178    echo '<li>';
     
    169182    echo 'value="1"  />';
    170183
    171     //include_once('sfce-js-authenticate.php');
    172 
    173     // echo '<form name="sfce_create_event" action="sfce-authenticate-fb.php" method="post" ><a href="#" onclick="document.sfce_create_event.submit();" title="Create a Facebook event">Create Event</a></form>';
    174 
    175184
    176185    echo '<p /><small>';
     
    179188
    180189    $existing_events = get_post_meta ($post_id, 'fb_event_id') ;
     190    $j=1;
    181191    if ( $existing_events ) foreach ( $existing_events as $event )
    182192    {
     193        if ( $event == '' ) continue;
    183194        echo '<br /><a href="http://www.facebook.com/event.php?eid=' . $event . '&index=1">';
    184         _e('Facebook event for this post.','sfce-create-event');
     195        echo addOrdinalNumberSuffix($j++) . ' ';
     196        _e('Facebook event for this post','sfce-create-event');
    185197        echo '</a><br />';
    186198    }
     
    221233        }
    222234
    223 
    224235        foreach ( $sfce_text_inputs as $input )
    225236            if ( $input['required'] && $_POST[$input['name']] == '' ) $error .= sprintf(__('You must enter a value for %s', 'sfce-create-event'), $input['label']) . '.<br />';
     
    236247        if ( $_POST['sfce_create_fb_event'] )
    237248        {
    238             if ( $_POST['sfce_group_id'] ) update_post_meta ( $post_id, 'sfce_group_id' , $_POST['sfce_group_id'] );
    239249            foreach ( $sfce_text_inputs as $input)
    240250            {
     
    267277            }
    268278        }
    269         $sfce_fb_event_status = get_post_meta($post_id, 'sfce_fb_event_status', true );
    270         // if ( $_POST['sfce_create_fb_event'] == "1" ) update_post_meta( $post_id, 'sfce_fb_event_status', 'created' ); else update_post_meta( $post_id, 'sfce_fb_event_status', '' );
    271279
    272280        // Call the facebook event creation...
    273         $cookie = get_facebook_cookie3($args['app_id'], $args['app_secret']);
    274         if (function_exists('sfce_create_event') && $_POST['sfce_create_fb_event'] && $sfce_fb_event_status <> "created")
     281        if (function_exists('sfce_create_event') && $_POST['sfce_create_fb_event'] )
    275282        {
    276283            $event_id = sfce_create_event( array(
     
    289296            ,'end_hour' => $_POST['sfce_event_end_hour']
    290297            ,'end_min' => $_POST['sfce_event_end_min']
    291             ,'photo' => $_POST['sfce_event_photo']
    292             ,'group_id' => $_POST['sfce_group_id']
     298        //  ,'photo' => $_POST['sfce_event_photo']
    293299            ));
    294300
    295             if ( $event_id )
    296             {
    297             //  update_post_meta( $post_id, 'fb_event', 'created' );
    298                 update_post_meta( $post_id, 'fb_event_id', $event_id );
    299             }
     301            if ( $event_id ) add_post_meta( $post_id, 'fb_event_id', $event_id );
    300302        }
    301303    }
    302304}
    303305
    304 add_action('edit_post', 'sfce_create_event_post');
    305 
    306 function get_facebook_cookie3($app_id, $application_secret) {
    307   $args = array();
    308   parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
    309   ksort($args);
    310   $payload = '';
    311   foreach ($args as $key => $value) {
    312     if ($key != 'sig') {
    313       $payload .= $key . '=' . $value;
    314     }
    315   }
    316   if (md5($payload . $application_secret) != $args['sig']) {
    317     return null;
    318   }
    319   return $args;
     306function addOrdinalNumberSuffix($num) {
     307    if (!in_array(($num % 100),array(11,12,13))){
     308        switch ($num % 10) {
     309        // Handle 1st, 2nd, 3rd
     310        case 1:  return $num.'st';
     311        case 2:  return $num.'nd';
     312        case 3:  return $num.'rd';
     313        }
     314    }
     315    return $num.'th';
    320316}
     317
     318
Note: See TracChangeset for help on using the changeset viewer.