<?php

namespace Craft;

EmbeddedAssetsPlugin::loadDependencies();
/**
 * This hack overrides the `move_uploaded_file()` function in the Craft namespace, and allows it to support files
 * injected into the `$_FILES` array.
 *
 * The `move_uploaded_files()` function, as stated in the PHP docs, will only work if the file was submitted through a
 * POST request, which isn't the case when injecting. The override calls another similar function that doesn't have this
 * restriction if the original function fails.
 *
 * @param $filename
 * @param $destination
 * @return bool
 */
function move_uploaded_file($filename, $destination)
{
    return \move_uploaded_file($filename, $destination) || rename($filename, $destination);
}
class EmbeddedAssetsService extends BaseApplicationComponent
{
    private $_purifier = null;
    private $_ogProperties = array('title' => \Opengraph\Opengraph::OG_TITLE, 'description' => \Opengraph\Opengraph::OG_DESCRIPTION, 'providerName' => \Opengraph\Opengraph::OG_SITE_NAME, 'thumbnailUrl' => \Opengraph\Opengraph::OG_IMAGE, 'thumbnailWidth' => \Opengraph\Opengraph::OG_IMAGE_WIDTH, 'thumbnailHeight' => \Opengraph\Opengraph::OG_IMAGE_HEIGHT);
    public function __construct()
    {
        require_once Craft::getPathOfAlias('system.vendors.htmlpurifier') . '/HTMLPurifier.standalone.php';
        $whitelist = EmbeddedAssetsPlugin::getWhitelist();
        foreach ($whitelist as $i => $url) {
            $whitelist[$i] = preg_quote($url);