function render_fbjs_ajax_fbml_recursive($impl, &$array)
{
    foreach ($array as $key => $value) {
        if (substr($key, 0, 5) == 'fbml_') {
            $array[$key] = fbml_sample_parse($value, $impl);
        } else {
            if (is_array($value)) {
                render_fbjs_ajax_fbml_recursive($impl, $array[$key]);
            }
        }
    }
}
Exemple #2
0
/**
 * Checks the syntax of the markup for a feed story, filtering and replacing as necessary
 *
 * @param   string $title
 * @param   string $body
 * @param   string $image_1
 * @param   string $image_2
 * @param   string $image_3
 * @param   string $image_4
 * @param   string &$error - contains the error on an unsuccessful call
 * @return  array if successful, error string or false if not
 *
 */
function application_create_feed_story($app_id, $user, $require_user_link, $title, $body, $image_1, $image_1_link, $image_2, $image_2_link, $image_3, $image_3_link, $image_4, $image_4_link, &$error)
{
    // Get rid of nulls from input
    $title = str_replace("", '', $title);
    $body = str_replace("", '', $body);
    // Check title length
    if (strlen(strip_tags($title)) > $GLOBALS['API_FEED']['MAX_TITLE']) {
        $error = 'error_title_length';
        return false;
    }
    $num_matches = preg_match_all('/<a /', $title, $matches);
    if ($num_matches > 1) {
        $error = 'error_title_link';
        return false;
    }
    // FBOPEN:NOTE - you may with to create separate flavors here.
    /*
    if ($require_user_link) {
      $flavor = new FeedTitleWithNamesFBMLFlavor($env);
    } else {
      $flavor = new FeedTitleFBMLFlavor($env);
    }
    */
    // Check for user links in title if necessary
    if ($require_user_link) {
        // FBOPEN:NOTE Add your checking here.
    }
    // Check body
    if ($body) {
        if (strlen(strip_tags($body)) > $GLOBALS['API_FEED']['MAX_BODY']) {
            $error = 'error_body_length';
            return false;
        }
        // See how it renders to make sure it doesn't come out blank
        $env = array('user' => $user, 'app_id' => $app_id);
        // FBOPEN:NOTE - you may wish to use a different flavor or implementation here.
        // This is just a sample.
        $fbml_flavor = new FBMLCanvasPageFlavor($env);
        $fbml_impl = new FBJSEnabledFacebookImplementation($fbml_flavor);
        $html = fbml_sample_parse($body, $fbml_impl);
        if (!$html || need_illegal_story_check($app_id) && is_illegal_feed_story($app_id, $body)) {
            $error = 'error_illegal_content';
            return false;
        }
    }
    $images = api_feed_validate_images($app_id, $image_1, $image_1_link, $image_2, $image_2_link, $image_3, $image_3_link, $image_4, $image_4_link, $do_proxy = true, $error);
    if (false === $images) {
        // error has been set by api_feed_validate_images
        return false;
    }
    $short_info = application_get_short_info($app_id);
    return array('title' => $title, 'body' => $body, 'images' => $images, 'allow_names' => $require_user_link);
}
Exemple #3
0
    $path_str = '/' . $url_suffix;
    if (($char_pos = strpos($path_str, '?', 0)) !== false) {
        $path_str = substr($path_str, 0, $char_pos);
    }
    $char_pos = strrpos($path_str, '/', 0);
    if ($char_pos > 0) {
        $path_str = substr($path_str, 0, $char_pos + 1);
    }
    try {
        try {
            $fbml_from_callback = http_post($url, $post_vars, array('post_tuples' => $post_tuples));
        } catch (HTTPErrorException $e) {
            print "got http exception: " . $e->getCode();
            exit;
            header('HTTP/1.x ' . $e->getCode());
            //Respect the 400+ status codes
            throw $e;
            //rethrow, so that the page renders properly
        }
    } catch (HTTPException $e) {
        $fbml_from_callback = isset($e->_content) ? $e->_content : '';
    }
}
$fbml_flavor = new FBMLCanvasPageFlavor($fbml_env);
$fbml_impl = new FBJSEnabledFacebookImplementation($fbml_flavor);
$html = fbml_sample_parse($fbml_from_callback, $fbml_impl);
// Note: These act as blocks so that getParentId will never actually get the
// true <body> element in js.
echo '<div id="' . fbml_css_app_box_id($app_id) . '" class="' . fbml_css_app_box_id($app_id) . ' "><div>';
echo $html;
echo '</div></div>';