/** * returns the configured maximum of results for smint-related queries * a max of 100 and a default of 3 will be used if other values are given * * @return integer * @author jochum */ public function getSmintMaxQueryResults() { $max = mysfConfig::get('app_view_query_maxrelated'); $max = is_int($max) ? $max : 3; $max = $max > 100 ? 3 : $max; return $max; }
public function executeGenre($request) { // write session, so it won't lock other requests session_write_close(); $this->getResponse()->setContentType('application/json'); $limit = $request->getParameter('limit'); $limit_default = mysfConfig::get('app_ajax_autocomplete_results', 5); $limit = isset($limit) ? $limit : $limit_default; $term = $request->getParameter('term'); $title = FiledescPeer::retrieveForSelect($term, $limit, "Genre"); return $this->renderText(json_encode($title)); }
protected function doClean($values) { $username = isset($values['username']) ? $values['username'] : ''; $name = isset($values['name']) ? $values['name'] : ''; $email = isset($values['email']) ? $values['email'] : ''; $organization = isset($values['organization']) ? $values['organization'] : ''; $reuse = isset($values['reuse']) && $values['reuse'] == 1 ? true : false; $newuser = $user = sfContext::getInstance()->getUser()->getAttribute('newuser'); $newuser = is_null($newuser) ? false : true; if (!$newuser) { $existingUser = SmintUserPeer::retrieveByUniqueColumnValues($username, $name, $email, $organization); } $confirmExisting = mysfConfig::get('app_login_settings_confirm_existing_users', true); // if the user exists show warning/question to reuse user if (!$newuser && !$reuse && isset($existingUser) && $confirmExisting) { throw new sfValidatorErrorSchema($this, array('reuse' => new sfValidatorError($this, 'user already exists !!! change name / email / organization or activate option to reuse the same user.'), 'name' => new sfValidatorError($this, ''), 'email' => new sfValidatorError($this, ''), 'organization' => new sfValidatorError($this, ''))); } else { // check username/password return parent::doClean($values); } // $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; // $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : ''; // $remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : ''; // // // user exists? // if ($user = sfGuardUserPeer::retrieveByUsername($username)) // { // // password is ok? // if ($user->checkPassword($password)) // { // return array_merge($values, array('user' => $user)); // } // } // // if ($this->getOption('throw_global_error')) // { // throw new sfValidatorError($this, 'invalid'); // } // // throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); }
<!-- BEGIN _result --> <?php use_helper('JavascriptBase'); ?> <?php // init values $columnnames = sfConfig::get('app_names_columnnames'); $showcolumns = mysfConfig::get('app_view_columns'); $showoptions = mysfConfig::get('app_view_options'); $tracknr = isset($tracknr) ? $tracknr : "NOTRACKNR"; $queryTrackIsUploaded = isset($queryTrackIsUploaded) ? $queryTrackIsUploaded : false; $distancetypeid = sfConfig::get('app_defaults_distancetypeid', 0); $featurevectortypeid = sfConfig::get('app_defaults_featurevectortypeid', 0); // init rating system $maxScore = 4; $ratingColumnWidth = $maxScore * 17 + 17 . 'px'; $queryString = ""; $original_queryString = ""; $seedLabel = isset($seedLabel) ? $seedLabel : ""; $metadataquery = isset($metadataquery) ? $metadataquery : ""; $empty_metadatafilteredquery = isset($empty_metadatafilteredquery) ? $empty_metadatafilteredquery : false; ?> <!-- if the result contains md queries paginate --> <div id="paginate_controls"> <?php if (isset($filespager)) { ?> <?php $files = $filespager->getResults();
/** Performs live query with Smafe * Also tries to start the server if it seems to be down. In this case, an exception is thrown with explanation * @param $filepath The file to query (local file path) * @param $aSegmSearch Associative array with data about segmented search * @param $autostart if true, the server is tried to started if it seems to be down. Default = true */ public static function queryFile($filepath, $aSegmSearch, $autorestart = true) { // The command $exec_command; if ($aSegmSearch['enabled']) { // segmented search $command = mysfConfig::get('app_live_settings_command_segmentedsearch', ""); $command = str_replace('$LIVEFILE', $filepath, $command); $command = str_replace('$BEGINTIME', smintTools::convertTimeMsToMM_SS_HH($aSegmSearch['startSegment']), $command); $command = str_replace('$ENDTIME', smintTools::convertTimeMsToMM_SS_HH($aSegmSearch['endSegment']), $command); $exec_command = $command; } else { // normal search $command = mysfConfig::get('app_live_settings_command', ""); $command = str_replace('$LIVEFILE', $filepath, $command); $exec_command = $command; } $exec_output = array(); $exec_err = array(); mysfLog::log(self::$context, "INFO - executing live query: {$exec_command}"); exec($exec_command, $exec_output, $exec_result); if ($exec_result != 0) { if ($autorestart) { // try to start server try { mysfLog::log(self::$context, "INFO: Server seems not to be running. STARTING the SERVER."); self::restartServer($aSegmSearch['enabled']); throw new Exception("Server was restarted. Try again in a few minutes. Log: " . print_r($exec_output, true)); } catch (Exception $e) { // restart failed mysfLog::log(self::$context, "STARTING the SERVER failed: " . $e->getMessage()); throw new Exception($e->getMessage()); } } else { // do not start the smafedistd server but return error message $result_array = array("command" => $exec_command, "result" => $exec_result, "error" => $exec_output); $error_message = "ERROR during live query. " . print_r($result_array, true); mysfLog::log(self::$context, $error_message); throw new Exception($error_message); } } $result_array = array("output" => $exec_output, "result" => $exec_result); return $result_array; }
/** * Performs the file conversion, ie, calls external tool, checks if it worked correctly, and returns the filename of the output file * Note that the output files can be deleted safely. On the other hand this function also checks if the file has already been converted. * If so, it will not be converted a second time. * @param filename the filename including path (local) * @param formatcode Currently these codes are supported: * - ogg * - mp3 * - waveform * - waveformpng * * * To add another type: * - Add command_XXX in app.yml. The command must follow the same conventions as command_mp3 and _ogg ($INfile, ...) * - XXX is also used as the file suffix for the output file */ public static function doFileConversion($filename, $formatcode = "ogg") { $exec_output = array(); $exec_err = array(); $current_date = date("_Ymd_His_"); // get command as configured in app.yml $exec_cmd_raw = mysfConfig::get('app_conversion_setting_command_' . $formatcode, ""); // replace placeholder with real file name, infile $exec_cmd = str_replace('$INfile', escapeshellcmd($filename), $exec_cmd_raw); // replace outfile placeholder. outfile is : upload dir, basename of infile, and ogg suffix if ($formatcode === 'waveform') { // extra file ending for waveform, since waveform is not recognized by apache $outfile = smintUploadFileHelper::getUploadPath() . basename($filename) . "." . $formatcode . ".txt"; } else { $outfile = smintUploadFileHelper::getUploadPath() . basename($filename) . "." . $formatcode; } $exec_cmd = str_replace('$OUTfile', escapeshellcmd($outfile), $exec_cmd); // check for pixels per second variable. If found, replace it with config param if (substr_count($exec_cmd, '$PIXELSPERSECOND') > 0) { $pixelspersecond = sfConfig::get('app_defaults_waveform_resolution'); $exec_cmd = str_replace('$PIXELSPERSECOND', escapeshellcmd($pixelspersecond), $exec_cmd); } $exec_cmd_escaped = $exec_cmd; // before conversion check if file exists already if (file_exists($outfile)) { mysfLog::log(self::$context, "INFO: file {$outfile} exists, using it."); } else { mysfLog::log(self::$context, "INFO: starting conversion. Command = {$exec_cmd_escaped}"); // executing, redirecting stderr to stdout exec($exec_cmd_escaped . " 2>&1", $exec_err, $exec_result); if ($exec_result != 0 || !file_exists($outfile)) { $result_array = array("command" => $exec_cmd_escaped, "result" => $exec_result, "error" => $exec_err); $error_message = "ERROR during conversion. " . print_r($result_array, true); mysfLog::log(self::$context, $error_message); throw new Exception($error_message); } mysfLog::log(self::$context, "INFO: conversion done"); } return $outfile; }