<commit_before><?php
include_once '../include/config.php';

function get_thumbnails($bucket_id, $duid, $limit = -1, $order = "ASC")
{
   if ($limit > 0)
      $limit_string = 'LIMIT %s';
   else
      $limit_string = '';

   $images = db_query('SELECT id,filename FROM photos WHERE bucket_id="%s" ORDER BY id %s ' . $limit_string, $bucket_id, $order, $limit);

   $s3 = new AmazonS3();

   $output = array();
   foreach ($images as $image)
      $output[] = array('id' => $image['id'], 'url' => $s3->get_object_url('divvycam', $image['filename'] . '-thumbnail.jpg', '60 seconds'));

	if ($limit !== 1)
		update_timestamps($duid, $bucket_id);
	
   return $output;
}

if (!isset($_GET['bucket_id']))
{
   echo '{"status":"error","error":"invalid_request"}';
   die();
}

if (!check_if_bucket_exists($_GET['bucket_id']))
{
   echo '{"status":"error","error":"no_such_bucket"}';
   die();
}

if (!check_if_user_belongs_to_bucket($_GET['duid'], $_GET['bucket_id']))
{
	echo '{"status":"error", "error":"permission_denied"}';
	die();
}

if (isset($_GET['order']))
{
   if ($_GET['order'] == 'desc')
      $order = 'DESC';
   else
      $order = 'ASC';
}
else
   $order = 'ASC';

if (!isset($_GET['limit']))
   $limit = -1;
else
   $limit = $_GET['limit'];

echo json_encode(array('status' => 'success', 'bucket_id'=> $_GET['bucket_id'], 'thumbnails' => get_thumbnails($_GET['bucket_id'], $_GET['duid'], $limit, $order)));
?><commit_msg>Added md5 data stamps.<commit_after><?php
include_once '../include/config.php';

function get_thumbnails($bucket_id, $duid, $limit = -1, $order = "ASC")
{
   if ($limit > 0)
      $limit_string = 'LIMIT %s';
   else
      $limit_string = '';

   $images = db_query('SELECT id,filename FROM photos WHERE bucket_id="%s" ORDER BY id %s ' . $limit_string, $bucket_id, $order, $limit);

   $s3 = new AmazonS3();

   $output = array();
   foreach ($images as $image)
      $output[] = array('id' => $image['id'], 'url' => $s3->get_object_url('divvycam', $image['filename'] . '-thumbnail.jpg', '60 seconds'));

	if ($limit !== 1)
		update_timestamps($duid, $bucket_id);
	
   return array('status' => 'success', 'bucket_id' => $bucket_id, 'md5' => md5(serialize($output)), 'thumbnails' => $output);
}

if (!isset($_GET['bucket_id']))
{
   echo '{"status":"error","error":"invalid_request"}';
   die();
}

if (!check_if_bucket_exists($_GET['bucket_id']))
{
   echo '{"status":"error","error":"no_such_bucket"}';
   die();
}

if (!check_if_user_belongs_to_bucket($_GET['duid'], $_GET['bucket_id']))
{
	echo '{"status":"error", "error":"permission_denied"}';
	die();
}

if (isset($_GET['order']))
{
   if ($_GET['order'] == 'desc')
      $order = 'DESC';
   else
      $order = 'ASC';
}
else
   $order = 'ASC';

if (!isset($_GET['limit']))
   $limit = -1;
else
   $limit = $_GET['limit'];

echo json_encode(get_thumbnails($_GET['bucket_id'], $_GET['duid'], $limit, $order));
?>
{'fraction_non_alphanumeric': 0.23584254143646408, 'fraction_numerical': 0.007251381215469613, 'mean_word_length': 4.759443339960239, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4001760', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1053, 'n_words': 215}