コード例 #1
0
  static function ValidateRequest($input,&$output)
  {
    $errors = validateDownloadLink($input["downloadLink"]);
    if ($errors)
      return $errors;

    if (!$input["reason"])
      return array("no changing without a good reason !");

    $prod = PouetProd::Spawn( $_REQUEST["prod"] );
    if (!$prod)
      return array("nice try :|");

    if (strcmp($prod->download,$input["downloadLink"])===0)
      return array("you didn't change anything :|");

    $output["oldDownloadLink"] = $input["oldDownloadLink"];
    $output["downloadLink"] = $input["downloadLink"];
    $output["reason"] = $input["reason"];
    return array();
  }
コード例 #2
0
  function Validate( $data )
  {
    global $currentUser;
    $errormessage = array();

    if(!$currentUser)
    {
  	  $errormessage[]="you need to be logged in first.";
  	  return $errormessage;
  	}
    if (!$currentUser->CanSubmitItems())
    {
      $errormessage[] = "you there. please do not add prods.";
  	  return $errormessage;
  	}

    if(!$data["name"])
    {
  	  $errormessage[]="sorry, alien prophets already did a demo with no title!";
  	  return $errormessage;
  	}

    $e = validateDownloadLink( $data["download"] );
    if (count($e))
      $errormessage = array_merge($errormessage,$e);


    if( ($data["releaseDate_month"]&&$data["releaseDate_year"]) )
    {
      if ( ($data["releaseDate_month"]>date('m')&&$data["releaseDate_year"]==date('Y')) || ($data["releaseDate_year"]>date('Y')) )
      {
        $errormessage[]="you can't submit a prod released in the future, sorry =)";
      }
    }

    if(!count($data["type"])) {
      $errormessage[] = "you must select at least one type for this prod";
    }
    if(!count($data["platform"])) {
      $errormessage[] = "you must select at least one platform";
    }

    if($data["partyYear"] && !$data["partyID"])
      $errormessage[] = "please either select a party AND a year, or neither !";
    if(($data["partyID"] && !$data["partyYear"]) && $data["partyID"] != NO_PARTY_ID)
      $errormessage[] = "please either select a party AND a year, or neither !";
    if($data["partyRank"] && !$data["partyID"])
      $errormessage[] = "please select a party before you select a ranking !";

    if($data["invitationParty"] && !$data["invitationYear"])
      $errormessage[] = "please either select an invitation party AND a year, or neither !";

    $extension = "";
    if(is_uploaded_file($_FILES["screenshot"]["tmp_name"]))
    {
      list($width,$height,$type) = GetImageSize($_FILES["screenshot"]["tmp_name"]);
      if($type!=IMAGETYPE_GIF && $type!=IMAGETYPE_JPEG && $type!=IMAGETYPE_PNG) {
        $errormessage[]="the screenshot is not a valid .gif/jpg or .png file";
      }
      if($width > 400) {
        $errormessage[]="the width of the screenshot must not be greater than 400 pixels";
      }
      if($height > 300) {
        $errormessage[]="the height of the screenshot must not be greater than 300 pixels";
      }
      if(filesize($_FILES["screenshot"]["tmp_name"]) > 65536) {
        $errormessage[]="the size of the screenshot must not be greater than 64Kb";
      }
    }
    // check the .nfo
    if(is_uploaded_file($_FILES["nfofile"]["tmp_name"]))
    {
      if (!$currentUser->IsGloperator()) // gloperators are exempt from size limits
      {
        if(filesize($_FILES["nfofile"]["tmp_name"]) > 32768) {
          $errormessage[]="the size of the infofile must not be greater than 32Kb";
        }
      }
    }

    return $errormessage;
  }