Permalink
Browse files

moved name from application object to version object, add uncrush png…

… icons
  • Loading branch information...
1 parent 981107b commit b593dbdd9a5963d31f5495e0e707c6e84bca1f77 @pcans pcans committed Jul 17, 2011
Showing with 411 additions and 349 deletions.
  1. +16 −4 back/application_list.php
  2. +139 −143 back/application_upload.php
  3. +3 −1 back/invitation_list.php
  4. +1 −1 back/invitation_new.php
  5. +1 −1 back/invitation_send.php
  6. +12 −0 constants.php
  7. +9 −35 core/Entities/Application.php
  8. +26 −0 core/Entities/Version.php
  9. +115 −115 profile.php
  10. +3 −3 register.php
  11. +20 −17 runthisapp.php
  12. +7 −7 sign.php
  13. +59 −22 tools.php
@@ -25,6 +25,7 @@
Entities\Tester,
Entities\Version;
+ require_once __DIR__ . '/../constants.php';
require_once __DIR__ . '/../core/index.php';
require_once __DIR__ . '/../tools.php';
@@ -62,10 +63,21 @@
echo '<ul>';
foreach ($applications AS $application) {
- echo '<li>Application: <br/>->name: ' . $application->getName() . '<br />' .
- '->bundle: ' . $application->getBundleId() . '<br />' .
- '->app link: <a href="' . Tools::rel2abs('../app/' . $application->getToken() . '/app_bundle.ipa', Tools::current_url()) . '">' . $application->getName() . '.ipa</a><br />' .
- '->install on device: <a href="itms-services://?action=download-manifest&url=' . Tools::rel2abs('../app/' . $application->getToken() . '.plist', Tools::current_url()) . '">Install on device</a></li>' . PHP_EOL;
+ echo '<li>Application: <br/>'
+ .'->bundle name: ' . $application->getBundleName() . '<br />'
+ .'->bundle id: ' . $application->getBundleId() . '<br />'
+ .'->icon: <img src="'.'../'.UPLOAD_PATH. $application->getBundleId().'.png"><br />';
+
+ echo '<ul>';
+ foreach ($application->getVersions() AS $version) {
+ echo '<li>Version:<br/>'
+ .'->version: '.$version->getVersion().'<br />'
+ .'->date upload: '.$version->getDateUpload()->format(DEFAULT_DATETIME_FORMAT).'<br />'
+ .'->app link: <a href="' . Tools::rel2abs('../app/' . $version->getToken() . '/app_bundle.ipa', Tools::current_url()) . '">' . $version->getName() . '.ipa</a><br />'
+ .'->install on device: <a href="itms-services://?action=download-manifest&url=' . Tools::rel2abs('../app/' . $version->getToken() . '.plist', Tools::current_url()) . '">Install on device</a></li>' . PHP_EOL;
+
+ }
+ echo '</ul>' . PHP_EOL;
}
echo '</ul>' . PHP_EOL;
@@ -24,15 +24,18 @@
require_once __DIR__ . '/../lib/cfpropertylist/CFPropertyList.php';
require_once __DIR__ . '/../tools.php';
require_once __DIR__ . '/../core/index.php';
+ require_once __DIR__ . '/../constants.php';
+ require_once __DIR__ . '/../lib/PngCompote/PngCompote.php';
+
function unzipApplication($upload_path, $filename) {
$zip = new ZipArchive;
$res = $zip->open($upload_path . $filename);
if ($res === TRUE) {
- $appName = substr($filename, 0, strpos($filename,'.'));
- $zip->extractTo('../app/' . $upload_path . $appName . '/');
+ $appName = substr($filename, 0, -4);
+ $zip->extractTo($upload_path . $appName . '/');
$zip->close();
return true;
@@ -42,38 +45,6 @@ function unzipApplication($upload_path, $filename) {
}
}
- function fillAppInfoWithPlist($plistfile, $application) {
-
- $plistValue = file_get_contents($plistfile);
- if (empty($plistValue)) {
- return NULL;
- } else {
- $plist = new CFPropertyList();
- $plist->parse( $plistValue, CFPropertyList::FORMAT_AUTO);
- $plistData = $plist->toArray();
-
- //TODO if '${PRODUCT_NAME}' use <app_ame>
- $application->setName($plistData['CFBundleDisplayName']);
-
- //Get icon, if empty use 'Icon.png'
- if ( isset($plistData['CFBundleIconFile']) && $plistData['CFBundleIconFile'] != 0 ) {
- $iconFile = $plistData['CFBundleIconFile'];
- } else {
- $iconFile = 'Icon.png';
- }
- $application->setIconFile($iconFile);
-
- //TODO if contains('${PRODUCT_NAME:rfc1034identifier}') replace by <app_ame>
- $application->setBundleId($plistData['CFBundleIdentifier']);
-
- $version = new Version();
- $version->setVersion($plistData['CFBundleVersion']);
- $version->setDateUpload(new \DateTime("now"));
-
- return $version;
- }
- }
-
?>
<!doctype html>
@@ -95,116 +66,141 @@ function fillAppInfoWithPlist($plistfile, $application) {
</div>
<div>
- <?php
+<?php
+
+ // If we have uploaded a file we process it else we ask for it
+if (!empty($_FILES['app_file'])) {
+
+ if ($_FILES['app_file']['error'] > 0) {
+ if ($_FILES['app_file']['error'] == 1) {
+ echo 'Error: The uploaded file exceeds the upload_max_filesize directive in php.ini.<br />';
+ } else if ($_FILES['app_file']['error'] == 4) {
+ echo 'Error: No file was uploaded.<br />';
+ } else {
+ echo 'Error: code #' . $_FILES['app_file']['error'] . '<br />';
+ }
+ } else {
+
+ //echo 'Upload: ' . $_FILES['app_file']['name'] . '<br />';
+ echo 'Type: ' . $_FILES['app_file']['type'] . '<br />';
+ echo 'Size: ' . ($_FILES['app_file']['size'] / 1024) . ' Kb<br />';
+
+ $error = '';
+
+ // Configuration options
+ $allowed_filetypes = array('jpg', 'png', 'ipa'); // Types of file allowed
+ $max_filesize = 20971520; // Maximum filesize in BYTES (currently 20MB)
+
+ $folder_token = Tools::randomAppleRequestId();
+
+ $filename = $_FILES['app_file']['name']; // Get the name of the file (including file extension).
+ $ext = pathinfo($filename, PATHINFO_EXTENSION); // Get the extension from the filename.
+ // Check if the filetype is allowed
+ if (!in_array($ext, $allowed_filetypes)) {
+ $error = 'Error: The file you attempted to upload is not allowed: ' . $ext . '<br />';
+ }
+ // Now check the filesize
+ if (filesize($_FILES['app_file']['tmp_name']) > $max_filesize) {
+ $error = 'Error: The file you attempted to upload is too large.<br />';
+ }
+ $upload_path = '../' . UPLOAD_PATH;
+ // Check if we can upload to the specified path
+ if (!is_writable($upload_path)) {
+ $error = 'Error: You cannot upload to the directory ' . $upload_path . ', please CHMOD it to 777.<br />';
+ }
+ if ($error == '') {
+ // Upload the file to your specified path.
+ mkdir($upload_path . $folder_token, 0700);
+ $file_path = $upload_path . $folder_token . '/app_bundle.ipa';
+ if (move_uploaded_file($_FILES['app_file']['tmp_name'], $file_path)) {
+ echo 'Your file upload was successful at: ' . $file_path . '<br />';
+
+ $zip = new ZipArchive;
+ //$res = $zip->open($file_path . $folder_token . '/');
+ if (unzipApplication($upload_path . $folder_token . '/', 'app_bundle.ipa')) {
+ echo 'Unzip ok.<br>';
+
+ // We get the Info.plist of the app if it exists else <app_name>-Info.plist
+ $plistfile = Tools::getInfoPlistPath($folder_token);
+ echo 'Plist file: ' . $plistfile . '<br />';
+ $plistValue = file_get_contents($plistfile);
+
+ if (!empty($plistValue)) {
+ $plist = new CFPropertyList();
+ $plist->parse($plistValue, CFPropertyList::FORMAT_AUTO);
+ $plistData = $plist->toArray();
+
+ //TODO connect to apple and be sure a profile exists for this app.
+ //Create an application object and set basic data here
+ $entityManager = initDoctrine();
+
+ // Retrieve the developer connected (unique)
+ $developer = $entityManager->getRepository('Entities\Developer')->find($_SESSION['developerId']);
+
+ //verify if the application does not already exist (Ask to create an new version if it exists)
+ $application = $entityManager->getRepository('Entities\Application')->findOneBy(array('bundleId' => $plistData['CFBundleIdentifier']));
+ if ($application == NULL) {
+
+ $application = new Application();
+ $application->setDeveloper($developer);
+ $application->setBundleId($plistData['CFBundleIdentifier']);
+ $application->setBundleName($plistData['CFBundleName']);
+ }
+
+ //ensure version doesn't already exists.
+ //TODO version can be unspefied, handle this case.
+ $version = $entityManager->getRepository('Entities\Version')->findOneBy(array('version' => $plistData['CFBundleVersion']));
+ if ($version == NULL) {
+ $version = new Version();
+ $version->setVersion($plistData['CFBundleVersion']);
+ $version->setApplication($application);
+ } else {
+ // old version will be linked with new data folder using new token,
+ // but delete old data folder before
+ $versionToken = $version->getToken();
+ Tools::deleteVersionDataFiles($versionToken);
+ }
+ $version->setName($plistData['CFBundleDisplayName']);
+ $version->setToken($folder_token);
+ $version->setDateUpload(new \DateTime('now'));
+ $entityManager->persist($application);
+ $entityManager->persist($version);
+ $entityManager->flush();
+
+ //even if application already exists, update icon with last version uploaded.
+ //Get icon, if empty use 'Icon.png'
+ if (isset($plistData['CFBundleIconFile']) && $plistData['CFBundleIconFile'] != 0) {
+ $iconFile = $plistData['CFBundleIconFile'];
+ } else {
+ $iconFile = 'Icon.png';
+ }
+ //uncrush icon
+ $pngPath = '../' . UPLOAD_PATH . $folder_token . '/app_bundle/Payload/'.$version->getName().'.app/'.$iconFile;
+ if (file_exists($pngPath)){
+ $png = new PngFile($pngPath);
+ $newPngPath = '../' . UPLOAD_PATH . $application->getBundleId().'.png';
+ $png->revertIphone($newPngPath);
+ }
+
+ echo '<a href="application_list.php">Go back to Application list</a>';
+ } else {
+ echo 'Error: Unable to read application plist file.<br />';
+ }
+ } else {
+ echo 'Error: Unzip failed.<br />';
+ }
+ } else {
+ echo 'Error: There was an error during the file upload. Please try again.<br />';
+ }
+ } else {
+ echo $error;
+ }
+ }
+} else {
+ echo '<p>Error: you can\'t call this page directly.</p>';
+}
- // If we have uploaded a file we process it else we ask for it
- if ( !empty($_FILES['app_file']) ) {
-
- if ($_FILES['app_file']['error'] > 0) {
- if ($_FILES['app_file']['error'] == 1) {
- echo 'Error: The uploaded file exceeds the upload_max_filesize directive in php.ini.<br />';
- } else if ($_FILES['app_file']['error'] == 4) {
- echo 'Error: No file was uploaded.<br />';
- } else {
- echo 'Error: code #' . $_FILES['app_file']['error'] . '<br />';
- }
- } else {
-
- //echo 'Upload: ' . $_FILES['app_file']['name'] . '<br />';
- echo 'Type: ' . $_FILES['app_file']['type'] . '<br />';
- echo 'Size: ' . ($_FILES['app_file']['size'] / 1024) . ' Kb<br />';
-
- $error = '';
-
- // Configuration options
- $allowed_filetypes = array('jpg','png','ipa'); // Types of file allowed
- $max_filesize = 20971520; // Maximum filesize in BYTES (currently 20MB)
-
- $upload_path = '../app/'; // The place where files will be uploaded
- $folder_token = Tools::randomAppleRequestId();
-
- $filename = $_FILES['app_file']['name']; // Get the name of the file (including file extension).
- $ext = pathinfo($filename, PATHINFO_EXTENSION); // Get the extension from the filename.
-
- // Check if the filetype is allowed
- if(!in_array($ext, $allowed_filetypes)) {
- $error = 'Error: The file you attempted to upload is not allowed: ' . $ext . '<br />';
- }
- // Now check the filesize
- if(filesize($_FILES['app_file']['tmp_name']) > $max_filesize) {
- $error = 'Error: The file you attempted to upload is too large.<br />';
- }
- // Check if we can upload to the specified path
- if(!is_writable($upload_path)) {
- $error = 'Error: You cannot upload to the specified directory, please CHMOD it to 777.<br />';
- }
- if ( $error == '' ) {
- // Upload the file to your specified path.
- mkdir($upload_path . $folder_token, 0700);
- $file_path = $upload_path . $folder_token . '/app_bundle.ipa';
- if(move_uploaded_file($_FILES['app_file']['tmp_name'], $file_path)) {
- echo 'Your file upload was successful at: ' . $file_path . '<br />';
-
- $zip = new ZipArchive;
- //$res = $zip->open($file_path . $folder_token . '/');
- if (unzipApplication($upload_path . $folder_token . '/', 'app_bundle.ipa')) {
- echo 'Unzip ok.<br>';
-
- // We get the Info.plist of the app if it exists else <app_name>-Info.plist
- $plistfile = Tools::getInfoPlistPath($folder_token);
- echo 'Plist file: ' . $plistfile . '<br />';
-
- //TODO connect to apple and be sure a profile exists for this app.
-
- //Create an application object and set basic data here
- $entityManager = initDoctrine();
- date_default_timezone_set('Europe/Paris');
-
- // Retrieve the developer connected (unique)
- //TODO replace '1' by the user connected in session
- $developer = $entityManager->getRepository('Entities\Developer')->findOneBy(array('id' => 1));
-
- //TODO: verify if the application does not already exist (Ask to create an new version if it exists)
-
- $application = new Application();
- $application->setDeveloper($developer);
- $application->setToken($folder_token);
-
- $version = fillAppInfoWithPlist($plistfile, $application);
- if ( $version != NULL ) {
-
- $entityManager->persist($application);
- $entityManager->flush();
-
- $version->setApplication($application);
- $entityManager->persist($version);
- $entityManager->flush();
-
- echo '<a href="application_list.php">Go back to Application list</a>';
-
- } else {
- echo 'Error: Unable to read application plist file.<br />';
- }
-
-
- } else {
- echo 'Error: Unzip failed.<br />';
- }
-
- } else {
- echo 'Error: There was an error during the file upload. Please try again.<br />';
- }
-
- } else {
- echo $error;
- }
- }
-
- } else {
- echo '<p>Error: you can\'t call this page directly.</p>';
- }
-
- ?>
+?>
</div>
</div>
@@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+require_once __DIR__ . '/../constants.php';
+
?><!doctype html>
<html>
<head>
@@ -57,7 +59,7 @@
echo '<ul>';
foreach ($invitations AS $invitation) {
- echo '<li>Invitation: ' . $invitation->getTester()->getEmail() . ' - ' . $invitation->getDateSent()->format('d/m/Y H:i:s') . ' - ' . $invitation->getStatus() . '</li>' . PHP_EOL;
+ echo '<li>Invitation: ' . $invitation->getTester()->getEmail() . ' - ' . $invitation->getDateSent()->format(DEFAULT_DATETIME_FORMAT) . ' - ' . $invitation->getStatus() . '</li>' . PHP_EOL;
}
echo '</ul>' . PHP_EOL;
@@ -61,7 +61,7 @@
foreach ($applications as $application) {
$versions = $application->getVersions();
foreach ($versions as $version) {
- echo '<option value="' . $version->getId() . '">' . $application->getName() . ' v' . $version->getVersion() . '</option>' . PHP_EOL;
+ echo '<option value="' . $version->getId() . '">' . $version->getName() . ' v' . $version->getVersion() . '</option>' . PHP_EOL;
}
}
?>
@@ -56,7 +56,7 @@ function sendInvitationForDevice($device, $mailer, $url, $version, $msg, $entity
$mail = $device->getTester()->getEmail();
$token = Tools::randomAppleRequestId();
- $app = $version->getApplication()->getName();
+ $app = $version->getName();
$ver = $version->getVersion();
if (empty($udid)) {
View
@@ -0,0 +1,12 @@
+<?php
+
+
+date_default_timezone_set('Europe/Paris');
+
+define('UPLOAD_PATH', 'app/'); // The place where files will be uploaded
+define('DEFAULT_DATETIME_FORMAT', 'd/m/Y H:i:s'); // The place where files will be uploaded
+
+
+
+
+?>
Oops, something went wrong.

0 comments on commit b593dbd

Please sign in to comment.