function _db_add_field($table, $field, $fieldtype, $default, $after) { $table = table_by_key($table); if (!_db_field_exists($table, $field)) { $query = "ALTER TABLE {$table} ADD COLUMN {$field} {$fieldtype} DEFAULT '{$default}' AFTER {$after}"; return db_query($query); } else { printdebug("field already exists: {$table}.{$field}"); return false; } }
function process_file() { global $_POST; global $global_error_message; $result = 0; printdebug("!!! START !!!"); $filename = $_FILES['uploadedfile']['name']; $error_message = ""; printdebug("name: {$filename}"); printdebug("type: " . $_FILES['uploadedfile']['type']); printdebug("size: " . $_FILES['uploadedfile']['size']); printdebug("tmp: " . $_FILES['uploadedfile']['tmp_name']); printdebug("error: " . $_FILES['uploadedfile']['error']); $lat = $_POST['lat']; $lon = $_POST['lon']; $author = $_POST['author']; if (isset($_POST['ref'])) { $ref = $_POST['ref']; } else { $ref = "none"; } $note = $_POST['note']; printdebug("ref: " . $ref); printdebug("note: " . $note); printdebug("before lat:lon:author - {$lat}:{$lon}:{$author}"); $author = preg_replace('/[^-a-zA-Z0-9_ěščřžýáíéĚŠČŘŽÁÍÉúůÚľĽ .]/', '', $author); $note = preg_replace('/[^-a-zA-Z0-9_ěščřžýáíéĚŠČŘŽÁÍÉúůÚľĽ .]/', '', $note); $lat = preg_replace('/[^0-9.]/', '', $lat); $lon = preg_replace('/[^0-9.]/', '', $lon); $ref = preg_replace('/[^a-zA-Z0-9.]/', '', $ref); printdebug("after lat:lon:author - {$lat}:{$lon}:{$author}"); $file = basename($filename); $target_path = "uploads/" . $file; $final_path = "img/guidepost/" . $file; printdebug("target: {$target_path}"); $error_message = "OK"; if ($_FILES['uploadedfile']['error'] == "1") { $error_message = "soubor je prilis velky"; $result = 0; } if (file_exists($_FILES['uploadedfile']['tmp_name'])) { printdebug("soubor byl uspesne uploadnut do tmp\n"); $result = 1; } else { printdebug("cannot upload file\n"); $error_message = "nepodarilo se uploadnout soubor"; $result = 0; } if ($author == "") { $error_message = "author nezadan"; $result = 0; } if ($author === "android" or $author === "autor") { $error_message = "zmente vase jmeno"; $result = 0; } #sanitize filename if (strpos($filename, ';') !== FALSE) { $error_message = "spatny soubor strednik"; $result = 0; } if (strpos($filename, '&') !== FALSE) { $error_message = "spatny soubor divnaosmicka"; $result = 0; } $file_parts = pathinfo($filename); $ext = $file_parts['extension']; if ($ext !== "jpg" && $ext !== "JPG") { $error_message = "spatny soubor, pouzijte jpeg " . $file_parts['extension']; $result = 0; } if (file_exists("img/guidepost/{$file}")) { $error_message = "file already exists ({$file}), please rename your copy"; $result = 0; } if ($result) { if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { printdebug("File '{$file}' has been moved from tmp to {$target_path}"); if (!$lat && !$lon) { printdebug("soubor byl poslan se souradnicemi 0,0 -> exifme"); $command = "/var/www/mapy/exifme.pl '{$target_path}' '{$author}' img/guidepost/ '{$ref}' '{$note}'"; $out = system($command, $errlvl); printdebug("command:output(exit code) - {$command}:{$out}({$errlvl})"); if (!$errlvl) { $result = 1; } else { $result = 0; $error_message = "poslano latlon 0,0 a nepodarilo se zjistit souradnice z exif" . $out; printdebug("exifme error {$error_message}"); } } else { printdebug("soubor byl poslan se souradnicemi ve formulari"); if (!copy("uploads/{$file}", "img/guidepost/{$file}")) { $error_message = "failed to copy {$file} to destination ... "; $result = 0; } else { $ret_db = insert_to_db($lat, $lon, $final_path, $file, $author, $ref, $note); if ($ret_db) { if (!unlink("uploads/{$file}")) { printdebug("{$file} cannot be deleted from upload, inserted successfuly"); } } else { $error_message = "failed to insert to db" . $global_error_message; $result = 0; } } } printdebug("error message:" . $error_message); } else { $error_message = "Chyba pri otevirani souboru, mozna je prilis velky"; $result = 0; } } else { printdebug("Upload refused: " . $error_message); } if ($result == 0 and $error_message == "") { $error_message = "Divna chyba"; } if (get_param("source") == "mobile") { print "{$result}-{$error_message}"; } else { print " </head>\n"; print " <body>\n"; print "\n <div id='x'></div>\n <script language='javascript' type='text/javascript'>\n \$('#x').text('*** OK ***');\n \$('#x').hide();\n \$('#x').show('highlight',{color: 'lightgreen'},'2000');\n\n parent.stop_upload(" . $result . ",'" . $error_message . "', '" . $filename . "');\n </script>\n"; } printdebug("!!! END !!!"); return $result; }
break; case "GetRecord": $packet = getRecord_OAI($self, $ws_client_url, $xslPath, $identifier, $metadataPrefix); break; case "ListSets": $packet = ListSets_OAI($self, $ws_client_url, $xslPath, $resumptionToken); break; case "ListIdentifiers": case "ListRecords": //$metadataPrefix2 = $metadataPrefix; // $metadataPrefix perde seu valor original apos o IF abaixo. if ($resumptionToken && !parseResumptionToken($resumptionToken)) { $packet = createOAIErrorpacket($self, $verb, "badResumptionToken"); break; } if ($from && !isDatestamp($from)) { $packet = createOAIErrorpacket($self, $verb, "badArgument", "Invalid date format"); break; } if ($until && !isDatestamp($until)) { $packet = createOAIErrorpacket($self, $verb, "badArgument", "Invalid date format"); break; } $packet = ListIdOrRecords_OAI($verb, $self, $ws_client_url, $xslPath, $metadataPrefix, $set, $from, $until, $control); break; default: $packet = createOAIErrorpacket($self, $verb, "badVerb", "Illegal OAI verb"); break; } printdebug(); header("Content-Type: text/xml"); echo $packet;
function upgrade_1284() { # migrate the ALL domain to the superadmin column # Note: The ALL domain is not (yet) deleted to stay backwards-compatible for now (will be done in a later upgrade function) $result = db_query("SELECT username FROM " . table_by_key('domain_admins') . " where domain='ALL'"); if ($result['rows'] > 0) { while ($row = db_array($result['result'])) { printdebug("Setting superadmin flag for " . $row['username']); db_update('admin', 'username', $row['username'], array('superadmin' => db_get_boolean(true))); } } }