$filename .= rand(10, 99);
            }
        }
        if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) {
            return array('success' => true);
        } else {
            return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
        }
    }
}
db_connect('dam');
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array("zip");
// max file size of 2 gigabytes
$sizeLimit = 2 * 1024 * 1024 * 1024;
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($dss_fileshare . $_REQUEST["projectId"] . "/");
// if successful, up-zip the file and sync the items with the database
if ($result['success']) {
    $filename = $_REQUEST['qqfile'];
    $rc = system("unzip -d " . $dss_fileshare . $_REQUEST["projectId"] . " " . $dss_fileshare . $_REQUEST["projectId"] . "/{$filename} >/dev/null 2>&1");
    unlink($dss_fileshare . $_REQUEST["projectId"] . "/{$filename}");
    $numberSynced = metasync($_REQUEST["projectId"]);
    if (trim($numberSynced["success"]) != "") {
        $result = array('success' => "There " . displayNumberWords($numberSynced["success"], "was", "were", "item", "items") . " synced.");
    } elseif (trim($numberSynced["error"]) != "") {
        $result = array('error' => $numberSynced["error"]);
    }
}
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/
if ($dss_userId == 0) {
    header("Location: /index.php");
    exit;
}
if (trim($_REQUEST["projectId"]) != "") {
    $dss_currentProject = $_REQUEST["projectId"];
    /* See if this user can view this project. */
    if ($dss_accessLevel == 0) {
        $projectQuery = db_query("SELECT id FROM project WHERE workgroupId={$dss_currentWorkgroup} AND id=" . escapeValue($dss_currentProject));
        if (db_numrows($projectQuery) == 0) {
            header("Location: /project_list.php?errorMessage=" . rawurlencode("Invalid project identifier."));
            exit;
        }
    }
    db_query("UPDATE session SET currentProject=" . escapeValue($dss_currentProject) . " WHERE id=" . escapeQuote($dss_sessionCookie));
}
$numberSynced = metasync($dss_currentProject);
if (trim($numberSynced["success"]) != "") {
    $infoMessage = rawurlencode("There " . displayNumberWords($numberSynced["success"], "was", "were", "item", "items") . " synced.");
} elseif (trim($numberSynced["error"]) != "") {
    $errorMessage = rawurlencode($numberSynced["error"]);
} else {
    $infoMessage = rawurlencode("No items where synced.");
}
header("Location: item_list.php?projectId={$dss_currentProject}&infoMessage={$infoMessage}&errorMessage={$errorMessage}");