public function work($json) { if (!isset($json['project'])) { return; } if (!isset($json['body']['current']) || !isset($json['body']['target'])) { return; } if (!isset($json['body']['current']['Major']) || !isset($json['body']['current']['Minor']) || !isset($json['body']['current']['Build'])) { return; } if (!isset($json['body']['target']['Major']) || !isset($json['body']['target']['Minor']) || !isset($json['body']['target']['Build'])) { return; } if (!projectExists($json['project'], $this->config)) { return; } $current = versionToString($json['body']['current']['Major'], $json['body']['current']['Minor'], $json['body']['current']['Build']); $target = versionToString($json['body']['target']['Major'], $json['body']['target']['Minor'], $json['body']['target']['Build']); $projects_dir = "./" . $this->config['projects_root']; $project_name = $json['project']; $project_dir = $projects_dir . DIRECTORY_SEPARATOR . $project_name; $versionDifference = array_reverse(versionsBetween($current, $target, $project_name, $this->config)); $changed_files = array(); foreach ($versionDifference as $vd) { foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($project_dir . DIRECTORY_SEPARATOR . $vd)) as $filename) { // filter out "." and ".." if ($filename->isDir()) { continue; } $file = str_replace($project_dir . DIRECTORY_SEPARATOR . $vd, "", $filename->getPath()); $file = $file . DIRECTORY_SEPARATOR . $filename->getFileName(); if (startsWith($file, DIRECTORY_SEPARATOR)) { $file = substr($file, 1); } if (!array_key_exists($file, $changed_files)) { $changed_files[$file] = $filename->getSize(); } } } $this->addBody("new_sizes", $changed_files); }
public function work($json) { if (!isset($json['project'])) { return; } if (!projectExists($json['project'], $this->config)) { return; } $versions = allVersions($json['project'], $this->config); if ($versions != -1) { $versions_desc = array_reverse($versions); $latest = $versions_desc[0]; $versionParts = explode(".", $latest); $this->addBody("Latest", $latest); $this->addBody("Major", (int) $versionParts[0]); $this->addBody("Minor", (int) $versionParts[1]); $this->addBody("Build", (int) $versionParts[2]); } else { $this->error("NOT_FOUND"); } }
public function work($json) { if (!isset($json['project'])) { return; } if (!isset($json['body']['version']) || !isset($json['body']['remote_path'])) { return; } if (!isset($json['body']['version']['Major']) || !isset($json['body']['version']['Minor']) || !isset($json['body']['version']['Build'])) { return; } $remote_path = $json['body']['remote_path']; $project = $json['project']; $version = versionToString($json['body']['version']['Major'], $json['body']['version']['Minor'], $json['body']['version']['Build']); if (!projectExists($project, $this->config) || !versionExists($version, $json['project'], $this->config)) { $this->error('NOT_FOUND'); return; } $path_before_version = getPathToProject($project, $this->config) . DIRECTORY_SEPARATOR; $path_after_version = DIRECTORY_SEPARATOR . $remote_path; $file_path = $path_before_version . $version . $path_after_version; if (file_exists($file_path)) { $this->setResponseAsFile(); $this->setContent(file_get_contents($file_path)); return; } else { $lowerVersions = array_reverse(versionsLower($version, $project, $this->config)); foreach ($lowerVersions as $v) { $newPath = $path_before_version . $v . $path_after_version; if (file_exists($newPath)) { $this->setResponseAsFile(); $this->setContent(file_get_contents($newPath)); return; } } $this->error('NOT_FOUND'); $this->addBody("path", $file_path); $this->addBody("rel", $remote_path); } }
<?php include "../util/DbUtil.php"; session_start(); $projectName = mysql_real_escape_string($_POST['projectName']); $isPrivate = $_POST['isPrivate']; //Response will be json. $formattableResponse = '{ "status":"%s", "projectId":%d, "projectName":"%s" }'; $response = ""; $projectId = null; if (strlen($projectName) > 50) { $response = sprintf($formattableResponse, "Project Name too long.", 0, ""); } else { $db_conn = getConnectedDb(); if (is_null($db_conn)) { $response = sprintf($formattableResponse, "Error connecting to database", 0, ""); } elseif (projectExists($db_conn, $projectName)) { $response = sprintf($formattableResponse, "Project already exists", 0, ""); } elseif (is_null($projectId = addProject($db_conn, $projectName, $isPrivate, $_SESSION['userid']))) { $response = sprintf($formattableResponse, "Unknown error occurred.", 0, ""); } else { $response = sprintf($formattableResponse, "success", $projectId, $projectName); } } echo $response;
unset($projects['__bundle']); if (projectExists($bundleProjectIdentifier, $bundleProjectApiKey) === FALSE) { echo 'Project ' . $bundleProjectIdentifier . ' does not exist, please create it in Crowdin.' . PHP_EOL; exit(1); } $filesEntryContent = ''; foreach ($projects as $identifier => $projectData) { $projectPath = '/' . $projectData['path']; $filesEntryContent .= sprintf($filesEntryTemplate, $projectPath, $projectPath); } $configurationFileContent = sprintf($configurationFileTemplate, $bundleProjectIdentifier, $bundleProjectApiKey, $filesEntryContent); $configurationfilePathAndFilename = realpath(__DIR__ . '/../../../') . '/crowdin.yaml'; file_put_contents($configurationfilePathAndFilename, $configurationFileContent); echo 'Wrote ' . $configurationfilePathAndFilename . PHP_EOL; } else { foreach ($projects as $identifier => $projectData) { if (!isset($projectData['apiKey'])) { echo 'Project ' . $projectData['name'] . ' has no apiKey set.' . PHP_EOL; continue; } if (projectExists($identifier, $projectData['apiKey']) === FALSE) { echo 'Project ' . $projectData['name'] . ' does not exist, please create it in Crowdin.' . PHP_EOL; continue; } $filesEntryContent = sprintf($filesEntryTemplate, '', ''); $configurationFileContent = sprintf($configurationFileTemplate, $identifier, $projectData['apiKey'], $filesEntryContent); $configurationfilePathAndFilename = realpath(__DIR__ . '/../../../' . $projectData['path']) . '/crowdin.yaml'; file_put_contents($configurationfilePathAndFilename, $configurationFileContent); echo 'Wrote ' . $configurationfilePathAndFilename . PHP_EOL; } }
<?php require_once 'includes/globals.inc'; emitTop('Peanut Butter -> Save Project', '/pb/'); if (!isset($_POST['name']) || !isset($_POST['description']) || !isset($_POST['keywords']) || !isset($_POST['status']) || !isset($_POST['progress']) || !isset($_POST['priority'])) { errAndDie('Missing data.'); } $name = $_POST['name']; if (projectExists($name) && !isset($_POST['modified'])) { errAndDie('Project already exists.'); } if ($userType != ADMIN && $userType != SITEADMIN) { errAndDie('Sorry, only admins/siteadmins may save projects.'); } $mName = mysql_escape_string($name); $urlname = urlencode($name); $mOwner = mysql_escape_string($userName); $mDescription = mysql_escape_string($_POST['description']); $mKeywords = mysql_escape_string($_POST['keywords']); $mStatus = mysql_escape_string($_POST['status']); $mProgress = mysql_escape_string($_POST['progress']); $mPriority = mysql_escape_string($_POST['priority']); $mNotes = !isset($_POST['notes']) ? '' : mysql_escape_string($_POST['notes']); $mDeadline = !isset($_POST['deadline']) ? '' : mysql_escape_string($_POST['deadline']); if ($mPriority < 1 || $mPriority > 10) { if ($mPriority > 10) { $mPriority = 10; } elseif ($mPriority < 1) { $mPriority = 1; } print "<h3>'priority' has been changed to: {$mPriority}</h3>";