setAuth() public static méthode

Set AWS access key and secret key
public static setAuth ( string $accessKey, string $secretKey ) : void
$accessKey string Access key
$secretKey string Secret key
Résultat void
Exemple #1
0
 static function get_s3()
 {
     if (!self::$_s3) {
         require_once MODPATH . "aws_s3/lib/s3.php";
         S3::setAuth(module::get_var("aws_s3", "access_key"), module::get_var("aws_s3", "secret_key"));
         S3::$useSSL = module::get_var("aws_s3", "use_ssl", false);
     }
     return self::$_s3;
 }
 public function execute()
 {
     $this->AWS_ACCESS_KEY = 'YOUR_AWS_ACCESS_KEY';
     $this->AWS_SECRET_KEY = 'YOUR_AWS_SECRET_KEY';
     $this->AWS_S3_BUCKET = 'YOUR_AWS_S3_BUCKET';
     $this->AWS_S3_PUBLIC = true;
     $this->AWS_S3_SSL = false;
     $s3 = new S3();
     $s3->setAuth($this->AWS_ACCESS_KEY, $this->AWS_SECRET_KEY);
     $s3->useSSL = $this->AWS_S3_SSL;
     // In my situation the images were in two different S3 buckets already. It will search these locations to try and find it.
     // Your images are probably local already, so you may need to modify the code further down to work with local directories.
     //$s3Buckets = array(...);
     $dbw = wfGetDB(DB_MASTER);
     $counter = 0;
     $iIncrement = 10000;
     for ($i = 0;; $i += $iIncrement) {
         $res = $dbw->select(array('image', 'imagelinks', 'page'), array('image.img_name', 'image.img_path', 'page.page_title'), 'image.img_name = imagelinks.il_to and imagelinks.il_from = page.page_id and page.page_namespace = 0 limit ' . $i . ', ' . $iIncrement, array());
         if (!$res) {
             echo 'No for rows.\\n';
             exit;
         }
         $logoPath = '';
         foreach ($res as $row) {
             echo "counter:{$counter}\n";
             echo "i:{$i}\n";
             ++$counter;
             if (!$row->img_name || !$row->img_path) {
                 continue;
             }
             echo 'img_name:' . $row->img_name . "\n";
             echo 'img_path:' . $row->img_path . "\n";
             echo 'page_title:' . $row->page_title . "\n";
             $file = wfFindFile($row->img_name, array());
             if ($file) {
                 $path = $file->getFullUrl();
                 $path = str_replace('http://s3.amazonaws.com/' . $this->AWS_S3_BUCKET . '/', '', $path);
                 echo "path:{$path}\n";
                 // If you have images that are already stored locally, you will need to modify this section. Instead of an S3::copyObject you
                 // may need to use the S3::putObject method to upload your local copy.
                 foreach ($s3Buckets as $s3Bucket) {
                     if ($s3->copyObject($s3Bucket, $row->img_path, $this->AWS_S3_BUCKET, $path, $this->AWS_S3_PUBLIC ? S3::ACL_PUBLIC_READ : S3::ACL_PRIVATE)) {
                         echo 'SUCCESS:' . $row->img_name . "\n";
                         break;
                     } else {
                         echo 'ERROR1:' . $row->img_name . "\n";
                     }
                 }
             } else {
                 echo 'ERROR2:' . $row->img_name . "\n";
             }
             echo "\n";
         }
     }
 }
 /**
  * Prepare the S3 connection for requests to this bucket.
  *
  * @param $settings
  */
 private function _prepareForRequests($settings = null)
 {
     if (is_null($settings)) {
         $settings = $this->getSettings();
     }
     if (is_null($this->_s3)) {
         $this->_s3 = new \S3($settings->keyId, $settings->secret);
     }
     \S3::setAuth($settings->keyId, $settings->secret);
     $this->_s3->setEndpoint(static::getEndpointByLocation($settings->location));
 }
Exemple #4
0
 /**
  * Retrieves a list of buckets
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getBuckets()
 {
     S3::setAuth($this->key, $this->secret);
     $data = S3::listBuckets();
     if (!$data) {
         return false;
     }
     $buckets = array();
     foreach ($data as $item) {
         $bucket = new stdClass();
         $bucket->title = $item;
         // Get bucket location
         $location = S3::getBucketLocation($item);
         $bucket->locationTitle = $this->getLocationTitle($location);
         $bucket->location = $location;
         $buckets[] = $bucket;
     }
     return $buckets;
 }
 /**
  * component constructor - set up local vars based on settings array in controller
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     parent::__construct($collection, $settings);
     // setup the instance vars
     if (!empty($settings)) {
         foreach ($settings as $var => $val) {
             $this->{$var} = $val;
         }
     } else {
         if ($config = Configure::read('CakeS3')) {
             foreach ($config as $var => $val) {
                 $this->{$var} = $val;
             }
         }
     }
     if (empty($this->s3Key) || empty($this->s3Secret)) {
         throw new Exception('S3 Keys not set up. Unable to connect');
     }
     S3::setAuth($this->s3Key, $this->s3Secret);
     S3::setEndpoint($this->endpoint);
 }
 function save_image($temp_file)
 {
     //generate a random ID for this image
     // $this->image_key = md5(uniqid(rand(), true));
     //use an md5 of the file as a hash to prevent reuploads of the same file
     $this->image_key = md5_file($temp_file);
     //copy original
     $original_file_name = IMAGES_DIR . "/original/" . $this->image_key . ".jpg";
     $moved = rename($temp_file, $original_file_name);
     if (!$moved) {
         trigger_error("Failed to move image");
     } else {
         S3::setAuth(AWS_KEY, AWS_SECRET);
         //save large
         $this->save_sized_image($original_file_name, $this->image_key, IMAGE_LARGE_SIZE, "large");
         //save medium
         $this->save_sized_image($original_file_name, $this->image_key, IMAGE_MEDIUM_SIZE, "medium");
         //save small
         $this->save_sized_image($original_file_name, $this->image_key, IMAGE_SMALL_SIZE, "small");
         //save thumbnail
         $this->save_sized_image($original_file_name, $this->image_key, IMAGE_THUMBNAIL_SIZE, "thumbnail");
     }
 }
function yss_s3_edit($id = false)
{
    global $wpdb, $yss_post_assoc;
    $checked = array();
    $s3file = yss_get($id);
    $sql = 'SELECT ID, post_title
			FROM ' . $wpdb->posts . '
			WHERE post_status = "publish"
			AND post_type IN ("page","post")
			ORDER BY post_title';
    $posts = $wpdb->get_results($sql);
    if ($id) {
        $sql = 'SELECT post_id
				FROM ' . $yss_post_assoc . '
				WHERE s3_id = ' . $id;
        $results = $wpdb->get_results($sql);
        foreach ($results as $result) {
            $checked[] = $result->post_id;
        }
    }
    echo ym_start_box($id ? 'Edit Video' : 'Add Video');
    if (!$id) {
        require_once YSS_CLASSES_DIR . 'S3.php';
        $s3 = new S3();
        $s3->setAuth(get_option('yss_user_key'), get_option('yss_secret_key'));
    }
    echo '
			<table class="widefat form-table" style="width: 100%;" cellspacing="10">
				<tr valign="top">
					<td>
						' . __('S3 Bucket/file', "ym") . '
					</td>
					<td>';
    if (!$id) {
        echo '
						<select name="s3_file_select">
						';
        foreach ($s3->listBuckets() as $bucket) {
            $thisbucket = $s3->getBucket($bucket);
            foreach ($thisbucket as $file) {
                echo '<option ';
                if ($s3file->bucket . '/' . $s3file->resource_path == $bucket . '/' . $file['name']) {
                    echo 'selected="selected"';
                }
                echo '>' . $bucket . '/' . $file['name'] . '</option>';
            }
        }
        echo '
	</select>
';
    } else {
        echo $s3file->bucket . '/' . $s3file->resource_path;
        echo '<input type="hidden" name="s3_file_select" value="' . $s3file->bucket . '/' . $s3file->resource_path . '" />';
    }
    echo '
					</td>
				</tr>
				<tr valign="top">
					<td>
						' . __('Your Members Package Types access', "ym") . '
						<div style="font-size: 10px; color: gray; margin-top: 10px;">Your videos can be protected by account type here. If none of the boxes are checked then it will fall back to the next section (post protection)</div>
					</td><td>';
    echo '	<div>';
    if ($data = get_option('ym_account_types')) {
        $types = $data->types;
        $ac_checked = array();
        if ($selected = @$s3file->account_types) {
            $ac_checked = explode('||', $selected);
        }
        foreach ((array) $types as $type) {
            $checked_string = '';
            if (in_array($type, $ac_checked)) {
                $checked_string = 'checked="checked"';
            }
            echo '  <div class="ym_setting_list_item">
				<label>
				    <input type="checkbox" class="checkbox" name="account_types[]" value="' . $type . '" ' . $checked_string . ' /> ' . __($type) . '
				</label>
			    </div>';
        }
    } else {
        echo '<div>The system is unable to find any YM account types. Is there a problem with the install?</div>';
    }
    echo '</div>';
    echo '				</td>
				</tr>				
				<tr valign="top">
					<td>
						' . __('Restrict access by post/page?', "ym") . ' <input type="checkbox" name="memberonly" ' . (@$s3file->members ? "checked='checked'" : '') . ' /> (Check to activate)
						<div style="font-size: 10px; color: gray; margin-top: 10px;">If the above account type check fails or you choose not to use it then you can optionally use this section. This will check access against a number of posts or pages and if at least one has access then the video will be shown.<br /><br />If the restrict access checkbox is unticked then YSS will assume that the video should remain unprotected (if you are not using the account type protection)</div>
					</td>
					<td>
						<br /><select name="link_to_post_id[]" multiple size=10 style="height: 250px; width: 450px;">';
    foreach ($posts as $row) {
        $selected = in_array($row->ID, $checked) ? 'selected="selected"' : '';
        echo '<option value="' . $row->ID . '" ' . $selected . ' >' . $row->post_title . '</option>';
    }
    echo '				</select>
					</td>
				</tr>';
    echo '	</table>
					
			<p class="submit">
				<div style="float: right;">
					<input type="submit"  class="button" name="submit_edit_s3" value="' . __('Save', 'yss') . '" />
				</div>
				<input type="submit" value="' . __('Back', 'yss') . '" />
				<div class="ym_clear">&nbsp;</div>
			</p>
			
			<input type="hidden" name="task" value="save" />
			<input type="hidden" name="s3s_id" value="' . @$s3file->id . '" /> 
';
    echo ym_end_box();
}
Exemple #8
0
<?php

/*
* $Id: yss_s3.php 1754 2012-01-03 16:45:50Z BarryCarlyon $
* $Revision: 1754 $
* $Date: 2012-01-03 16:45:50 +0000 (Tue, 03 Jan 2012) $
*/
if ($task = @$_REQUEST['buckettask']) {
    $s3 = new S3();
    $s3->setAuth(get_option('yss_user_key'), get_option('yss_secret_key'));
    switch ($task) {
        case 'buckets':
            echo '<select name="origin" id="origin">
				<option value="">--Select--</option>
				';
            foreach ($s3->listBuckets() as $bucket) {
                echo '<option value="' . $bucket . '">' . $bucket . '</option>';
            }
            echo '
			</select>';
            break;
        default:
            echo 'Nothing to do: ' . $task;
    }
    exit;
}
echo '<p>' . __('There is currently nothing to see here', 'yss') . '</p>';
Exemple #9
0
 public static function buckets($detailed = false)
 {
     global $globals;
     S3::setAuth($globals['Amazon_access_key'], $globals['Amazon_secret_key']);
     return S3::listBuckets($detailed);
 }
Exemple #10
0
 static function validate_access_details($access_key, $secret_key, $bucket_name)
 {
     require_once MODPATH . "aws_s3/lib/s3.php";
     S3::setAuth($access_key, $secret_key);
     S3::$useSSL = false;
     $success_test = S3::putObjectString((string) time(), $bucket_name, ".s3_test");
     if ($success_test) {
         S3::deleteObject($bucket_name, ".s3_test");
     }
     return $success_test;
 }
Exemple #11
0
<?php

//include the S3 class
if (!class_exists('S3')) {
    require_once 'S3.php';
}
//AWS access info
if (!defined('awsAccessKey')) {
    define('awsAccessKey', 'AKIAICZOEWVDZ4COBAQQ');
}
if (!defined('awsSecretKey')) {
    define('awsSecretKey', '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');
}
//instantiate the class
S3::setAuth(awsAccessKey, awsSecretKey);
Exemple #12
0
function yss_s3_distribution($type, $id)
{
    global $ym_formgen, $yss_cloudfront, $yss_db, $wpdb;
    // file details
    $s3file = yss_get($id);
    if ($_POST) {
        // here we go
        $distro = $_POST['distro'];
        list($can, $oai, $bucket, $file, $domain, $type) = explode('|', $distro);
        $packet = array('type' => 'CanonicalUser', 'id' => $can, 'name' => 'CloudFront Origin Access Identity ' . $oai, 'permission' => 'READ');
        $acp = array();
        require_once YSS_CLASSES_DIR . 'S3.php';
        $s3 = new S3();
        $s3->setAuth(get_option('yss_user_key'), get_option('yss_secret_key'));
        //get existing and merge
        $acp = $s3->getAccessControlPolicy($bucket, $file);
        $acp['acl'][] = $packet;
        if ($s3->setAccessControlPolicy($bucket, $file, $acp)) {
            $acp = $s3->getAccessControlPolicy($bucket, $file);
            // store
            $distribution = json_decode($s3file->distribution);
            if ($type == 'stream') {
                $distribution->streaming = $domain;
            } else {
                $distribution->download = $domain;
            }
            $distribution = json_encode($distribution);
            $sql = 'UPDATE ' . $yss_db . ' SET
						distribution = \'' . $distribution . '\'
					WHERE id = ' . $id;
            $wpdb->query($sql);
            echo '<div id="message" class="updated"><p>Permissions updated</p></div>';
            yss_s3_list();
            return;
        } else {
            echo '<div id="message" class="error"><p>Permissions update failed</p></div>';
        }
    }
    if ($type == 'stream') {
        $data = $yss_cloudfront->get_streaming();
    } else {
        $data = $yss_cloudfront->get_distribution();
    }
    if (is_array($data)) {
        $test = array_keys($data);
        if ($test[0] != '0') {
            $data = array($data);
        }
    }
    if (is_array($data)) {
        echo ym_box_top('Deploy');
        echo '
<form action="" method="post">
	<fieldset>
		<p>You can select a distribution to expose the file, ' . $s3file->bucket . '/' . $s3file->resource_path . ' onto</p>
		<table class="form-table">
			';
        $items = array('blank' => 'Select');
        foreach ($data as $item) {
            $bucket = $item['S3Origin']['DNSName']['value'];
            list($bucket, $null) = explode('.', $bucket, 2);
            $enabled = $item['Enabled']['value'];
            if ($enabled == 'true' && $s3file->bucket == $bucket) {
                // Distribution is enabled and is for this bucket matches
                $status = $item['Status']['value'];
                $domain = $item['DomainName']['value'];
                $oai = $item['S3Origin']['OriginAccessIdentity']['value'];
                list($null, $nulm, $oai) = explode('/', $oai);
                // oai needs canonical
                $canonical = $yss_cloudfront->get_oai_canonical($oai);
                $value = $canonical . '|' . $oai . '|' . $bucket . '|' . $s3file->resource_path . '|' . $domain . '|' . $type;
                //echo '<option value="' . $value . '">' . $domain . '</option>';
                $items[$value] = $domain;
            }
        }
        $ym_formgen->render_combo_from_array_row('Distribution', 'distro', $items, '', 'Which Distribution to expose this file on');
        echo '
		</table>
		<p class="submit">
			<input type="submit" value="Deploy!" />
		</p>
	</fieldset>
</form>
';
        echo ym_box_bottom();
    } else {
        echo '<div id="message" class="error"><p>Failed to load Distributions or none available</p></div>';
    }
}
 public function deletestoryAction(Request $request)
 {
     /****** Admin session checking**********/
     $response = $this->checkAdmin($request->getSession());
     if ($response) {
         return $response;
     }
     $story = new Story();
     $em = $this->getDoctrine()->getManager();
     $awsAccessKey = $this->container->get('mytrip_admin.helper.amazon')->getOption('awsAccessKey');
     $awsSecretKey = $this->container->get('mytrip_admin.helper.amazon')->getOption('awsSecretKey');
     $bucket = $this->container->get('mytrip_admin.helper.amazon')->getOption('bucket');
     \S3::setAuth($awsAccessKey, $awsSecretKey);
     /*****Single Story delete*******/
     $id = $request->query->get('id');
     if ($id != '') {
         $storyimage = $em->createQuery("SELECT u FROM MytripAdminBundle:StoryImage u WHERE u.story ={$id}")->getArrayResult();
         if (!empty($storyimage)) {
             foreach ($storyimage as $simage) {
                 /*$file_path="img/story/".$simage['image'];
                 		if($simage['image']!='' && file_exists($file_path)){
                 			unlink($file_path);
                 		}*/
                 $deleteobject = \S3::deleteObject($bucket, $simage['image']);
                 $em->createQuery("DELETE FROM MytripAdminBundle:StoryImage b WHERE b.storyImageId =" . $simage['storyImageId'])->execute();
             }
         }
         $storybanner = $em->createQuery("SELECT u FROM MytripAdminBundle:Banner u WHERE u.bannerType='Story' AND u.typeId={$id}")->getArrayResult();
         if (!empty($storybanner)) {
             foreach ($storybanner as $bimage) {
                 /*$file_path="img/story/".$bimage['image'];
                 		if($simage['image']!='' && file_exists($file_path)){
                 			unlink($file_path);
                 		}*/
                 $deleteobject = \S3::deleteObject($bucket, $bimage['image']);
                 $em->createQuery("DELETE FROM MytripAdminBundle:Banner b WHERE b.bannerId=" . $bimage['bannerId'])->execute();
             }
         }
         $em->createQuery("DELETE FROM MytripAdminBundle:Story u WHERE u.storyId ={$id}")->execute();
         $this->get('session')->getFlashBag()->add('error', '<div class="success msg">Story deleted successfully</div>');
         return $this->redirect($this->generateUrl('mytrip_admin_story'));
     }
     /********Multiple Story delete**********/
     if ($request->getMethod() == "POST") {
         $storyid = $request->request->get('action');
         $storyid = implode(",", $storyid);
         $storyimage = $em->createQuery("SELECT u FROM MytripAdminBundle:StoryImage u WHERE u.story IN ({$storyid})")->getArrayResult();
         if (!empty($storyimage)) {
             foreach ($storyimage as $simage) {
                 /*$file_path="img/story/".$simage['image'];
                 		if($simage['image']!='' && file_exists($file_path)){
                 			unlink($file_path);
                 		}*/
                 $deleteobject = \S3::deleteObject($bucket, $simage['image']);
                 $em->createQuery("DELETE FROM MytripAdminBundle:StoryImage b WHERE b.storyImageId =" . $simage['storyImageId'])->execute();
             }
         }
         $storybanner = $em->createQuery("SELECT u FROM MytripAdminBundle:Banner u WHERE u.bannerType='Story' AND u.typeId IN ({$storyid})")->getArrayResult();
         if (!empty($storybanner)) {
             foreach ($storybanner as $bimage) {
                 /*$file_path="img/story/".$bimage['image'];
                 		if($simage['image']!='' && file_exists($file_path)){
                 			unlink($file_path);
                 		}*/
                 $deleteobject = \S3::deleteObject($bucket, $bimage['image']);
                 $em->createQuery("DELETE FROM MytripAdminBundle:Banner b WHERE b.bannerId=" . $bimage['bannerId'])->execute();
             }
         }
         $em->createQuery("DELETE FROM MytripAdminBundle:Story u WHERE u.storyId IN (" . $storyid . ")")->execute();
         $this->get('session')->getFlashBag()->add('error', '<div class="success msg">Stories deleted successfully</div>');
         return $this->redirect($this->generateUrl('mytrip_admin_story'));
     }
     if ($id == '' && $request->getMethod() != "POST") {
         $this->get('session')->getFlashBag()->add('error', '<div class="error msg">Sorry, Story record not available</div>');
         return $this->redirect($this->generateUrl('mytrip_admin_story'));
     }
 }
Exemple #14
0
 public static function s3AuthenticatedURL($uri)
 {
     S3::setAuth(S3_ACCESS_KEY, S3_SECRET_KEY);
     //Save logging status
     $save_logging = error_reporting();
     // Turn off logging for S3
     error_reporting(0);
     $authUrl = S3::getAuthenticatedURL(S3_BUCKET, $uri, 10 * 24 * 60 * 60, false, true);
     //10 days
     // Restore logging status
     error_reporting($save_logging);
     //Debug results from Auth access
     //error_log("s3Auth: $uri $authUrl");
     return $authUrl;
 }
Exemple #15
0
 /**
  * Checks to see if image exists in the cloud
  * @param string $imageName
  * @return bool
  */
 protected function imageExistsS3($imageName)
 {
     //Don't look for resizeds since we already looked in the db
     if (strpos($imageName, 'w:')) {
         error_log("S3: don't look for thumbnails {$imageName}");
         return false;
     }
     S3::setAuth(S3_ACCESS_KEY, S3_SECRET_KEY);
     try {
         if (!($result = S3::getObject(S3_BUCKET, 'image/' . $imageName, false))) {
             error_log("image not found on s3");
             return false;
         }
         //Use to Debug S3 filecheck
         //error_log("imageExistsS3: $imageName . ".print_r($result->code,true));
         if ($result->code == 200) {
             return true;
         }
         return false;
     } catch (Exception $e) {
         throw new Exception("imageExistsS3:getObject caught: {$e} imageName");
     }
 }
Exemple #16
0
 public static function purgeUnusedFiles()
 {
     throw new Exception("Now sharded");
     self::requireLibrary();
     // Get all used files and files that were last deleted more than a month ago
     $sql = "SELECT MD5(CONCAT(hash, filename, zip)) AS file FROM storageFiles\n\t\t\t\t\tJOIN storageFileItems USING (storageFileID)\n\t\t\t\tUNION\n\t\t\t\tSELECT MD5(CONCAT(hash, filename, zip)) AS file FROM storageFiles\n\t\t\t\t\tWHERE lastDeleted > NOW() - INTERVAL 1 MONTH";
     $files = Zotero_DB::columnQuery($sql);
     S3::setAuth(Z_CONFIG::$S3_ACCESS_KEY, Z_CONFIG::$S3_SECRET_KEY);
     $s3Files = S3::getBucket(Z_CONFIG::$S3_BUCKET);
     $toPurge = array();
     foreach ($s3Files as $s3File) {
         preg_match('/^([0-9a-g]{32})\\/(c\\/)?(.+)$/', $s3File['name'], $matches);
         if (!$matches) {
             throw new Exception("Invalid filename '" . $s3File['name'] . "'");
         }
         $zip = $matches[2] ? '1' : '0';
         // Compressed file
         $hash = md5($matches[1] . $matches[3] . $zip);
         if (!in_array($hash, $files)) {
             $toPurge[] = array('hash' => $matches[1], 'filename' => $matches[3], 'zip' => $zip);
         }
     }
     Zotero_DB::beginTransaction();
     foreach ($toPurge as $info) {
         S3::deleteObject(Z_CONFIG::$S3_BUCKET, self::getPathPrefix($info['hash'], $info['zip']) . $info['filename']);
         $sql = "DELETE FROM storageFiles WHERE hash=? AND filename=? AND zip=?";
         Zotero_DB::query($sql, array($info['hash'], $info['filename'], $info['zip']));
         // TODO: maybe check to make sure associated files haven't just been created?
     }
     Zotero_DB::commit();
     return sizeOf($toPurge);
 }
Exemple #17
0
 public function __construct($accessKey = null, $secretKey = null)
 {
     S3::setAuth($accessKey, $secretKey);
 }
Exemple #18
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     S3::setAuth(self::$config['s3AccessKey'], self::$config['s3SecretKey']);
     API::userClear(self::$config['userID']);
 }
<?php

$monitor_dir = '/var/spool/asterisk/monitor';

$link = mysql_connect('localhost:3306','asteriskuser','amp109');
if ($link === false) {
    die('Could not connect: ' . mysql_error());
}
else
{
	// Initialize Amazon S3 Support
	require_once 'S3.php';
	S3::setAuth('AKIAJV4IUPEV4MWFF7TA','HNikf2ZgOcjgaN4iPcjer7ZU5tg7unQhBJ7qLbvN');
	
	// Get Names of Recordings
	$files = glob($monitor_dir.'/*.wav');
	
	foreach ($files as $file)
	{
		preg_match('/\-([\d]+\.[\d]+)\.([a-z\d]{3})/i', $file, $match);
		
		if (isset($match[1]))
		{
			$uniqueid = $match[1];
			$file_audio_ext = $match[2];
			
			$q = mysql_query("SELECT * FROM asteriskcdrdb.cdr WHERE uniqueid = '$uniqueid' LIMIT 1",$link);
			
			if (mysql_num_rows($q) > 0)
			{
				passthru('sh convert_audio.sh '.$file);