Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions src/snapchat_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,35 @@ public function hash($first, $second) {
* TRUE if the blob looks like a media file, FALSE otherwise.
*/
function isMedia($data) {
return isImage($data) || isVideo($data);
}

/**
* Checks to see if a blob looks like an image file.
*
* @param data $data
* The blob data (or just the header).
*
* @return bool
* TRUE if the blob looks like an image (jpeg), FALSE otherwise.
*/
function isImage($data) {
// Check for a JPG header.
if ($data[0] == chr(0xFF) && $data[1] == chr(0xD8)) {
return TRUE;
}

return ($data[0] == chr(0xFF) && $data[1] == chr(0xD8));
}

/**
* Checks to see if a blob looks like a video file.
*
* @param data $data
* The blob data (or just the header).
*
* @return bool
* TRUE if the blob looks like an video (mp4), FALSE otherwise.
*/
function isVideo($data) {
// Check for a MP4 header.
if ($data[0] == chr(0x00) && $data[1] == chr(0x00)) {
return TRUE;
}

return FALSE;
return ($data[0] == chr(0x00) && $data[1] == chr(0x00));
}

/**
Expand Down