/**
  * 
  * @param type $argv
  * @param type $lo_guardo
  * @return boolean
  */
 public static function hago_informes($argv, $lo_guardo = false)
 {
     if (!isset($argv[1])) {
         echo "ERROR! No existe el usuario.\n";
         return false;
     }
     $usuario = CCStrip($argv[1]);
     if ($usuario == "todos") {
         $query = "SELECT  *\n                    FROM    `users` \n                    WHERE   `activo`=1 AND \n                            `usertype`='ftp'";
     } else {
         $query = "SELECT  *\n                    FROM    `users` \n                    WHERE   `enable_user`=1 AND \n                            `usertype`='ftp' AND \n                            `username`='{$usuario}' LIMIT 1";
     }
     if (sql_select($query, $results)) {
         if ($results->rowCount() == 0) {
             echo "ERROR! " . $usuario . " no corresponde con un usuario cargado en el sistema.\n";
         }
         while ($registro = $results->fetch(PDO::FETCH_ASSOC)) {
             hago_informe($registro, $lo_guardo);
         }
     }
     unset($results);
 }
function CCCollectionToString($ParametersCollection, $RemoveParameters)
{
    $Result = "";
    if (is_array($ParametersCollection)) {
        reset($ParametersCollection);
        foreach ($ParametersCollection as $ItemName => $ItemValues) {
            $Remove = false;
            if (is_array($RemoveParameters)) {
                foreach ($RemoveParameters as $key => $val) {
                    if ($val == $ItemName) {
                        $Remove = true;
                        break;
                    }
                }
            }
            if (!$Remove) {
                if (is_array($ItemValues)) {
                    for ($J = 0; $J < sizeof($ItemValues); $J++) {
                        $Result .= "&" . urlencode(CCStrip($ItemName)) . "[]=" . urlencode(CCStrip($ItemValues[$J]));
                    }
                } else {
                    $Result .= "&" . urlencode(CCStrip($ItemName)) . "=" . urlencode(CCStrip($ItemValues));
                }
            }
        }
    }
    if (strlen($Result) > 0) {
        $Result = substr($Result, 1);
    }
    return $Result;
}
Exemple #3
0
 function Upload($RowNumber = "")
 {
     global $CCSLocales;
     global $TemplateEncoding;
     global $FileEncoding;
     $FieldName = $this->Caption;
     if (strlen($RowNumber)) {
         $ControlName = $this->Name . "_" . $RowNumber;
         $FileControl = $this->Name . "_File_" . $RowNumber;
         $DeleteControl = $this->Name . "_Delete_" . $RowNumber;
     } else {
         $ControlName = $this->Name;
         $FileControl = $this->Name . "_File";
         $DeleteControl = $this->Name . "_Delete";
     }
     $SessionName = CCGetParam($ControlName);
     $this->State = CCGetSession($SessionName, array(null, null));
     if (strlen(CCGetParam($DeleteControl))) {
         // delete file from folder
         $ActualFileName = $this->State[0];
         if (file_exists($this->FileFolder . $ActualFileName)) {
             $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDeleteFile", $this);
             unlink($this->FileFolder . $ActualFileName);
             $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDeleteFile", $this);
         } else {
             if (file_exists($this->TemporaryFolder . $ActualFileName)) {
                 $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDeleteFile", $this);
                 unlink($this->TemporaryFolder . $ActualFileName);
                 $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDeleteFile", $this);
             }
         }
         $this->Value = "";
         $this->Text = "";
         $this->State[0] = "";
     } else {
         if (isset($_FILES[$FileControl]) && $_FILES[$FileControl]["tmp_name"] != "none" && strlen($_FILES[$FileControl]["tmp_name"])) {
             $this->Value = "";
             $this->Text = "";
             $FileName = CCConvertEncoding(CCStrip($_FILES[$FileControl]["name"]), $TemplateEncoding, $FileEncoding);
             $GoodFileMask = 1;
             $meta_characters = array("*" => ".+", "?" => ".", "\\" => "\\\\", "^" => "\\^", "\$" => "\\\$", "." => "\\.", "[" => "\\[", "]" => "\\]", "|" => "\\|", "(" => "\\(", ")" => "\\)", "{" => "\\{", "}" => "\\}", "+" => "\\+", "-" => "\\-");
             if ($this->AllowedFileMasks != "") {
                 $GoodFileMask = 0;
                 $FileMasks = explode(';', $this->AllowedFileMasks);
                 foreach ($FileMasks as $FileMask) {
                     $FileMask = preg_replace("/(\\*|\\?|\\\\|\\^|\\\$|\\.|\\[|\\]|\\||\\(|\\)|\\{|\\}|\\+|\\-)/ei", "\$meta_characters['\\1']", $FileMask);
                     if (preg_match("/^{$FileMask}\$/i", $FileName)) {
                         $GoodFileMask = 1;
                         break;
                     }
                 }
             }
             if ($GoodFileMask && $this->DisallowedFileMasks != "") {
                 $FileMasks = explode(';', $this->DisallowedFileMasks);
                 foreach ($FileMasks as $FileMask) {
                     $FileMask = preg_replace("/(\\*|\\?|\\\\|\\^|\\\$|\\.|\\[|\\]|\\||\\(|\\)|\\{|\\}|\\+|\\-)/ei", "\$meta_characters['\\1']", $FileMask);
                     if (preg_match("/^{$FileMask}\$/i", $FileName)) {
                         $GoodFileMask = 0;
                         break;
                     }
                 }
             }
             if ($_FILES[$FileControl]["size"] > $this->FileSizeLimit) {
                 $this->Errors->addError($CCSLocales->GetText('CCS_LargeFile', $this->Caption));
             } else {
                 if (!$GoodFileMask) {
                     $this->Errors->addError($CCSLocales->GetText('CCS_WrongType', $this->Caption));
                 } else {
                     // move uploaded file to temporary folder
                     $file_exists = true;
                     $index = 0;
                     while ($file_exists) {
                         $ActualFileName = date("YmdHis") . $index . "." . $FileName;
                         $file_exists = file_exists($this->FileFolder . $ActualFileName) || file_exists($this->TemporaryFolder . $ActualFileName);
                         $index++;
                     }
                     if (move_uploaded_file($_FILES[$FileControl]["tmp_name"], $this->TemporaryFolder . $ActualFileName)) {
                         $this->Value = $ActualFileName;
                         $this->Text = $ActualFileName;
                         if (isset($this->State[0]) && strlen($this->State[0])) {
                             if (file_exists($this->TemporaryFolder . $this->State[0])) {
                                 $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDeleteFile", $this);
                                 unlink($this->TemporaryFolder . $this->State[0]);
                                 $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDeleteFile", $this);
                                 $this->State[0] = $ActualFileName;
                             } else {
                                 if (!is_dir($this->TemporaryFolder . $this->State[1]) && file_exists($this->TemporaryFolder . $this->State[1])) {
                                     $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDeleteFile", $this);
                                     unlink($this->TemporaryFolder . $this->State[1]);
                                     $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDeleteFile", $this);
                                 }
                                 $this->State[1] = $ActualFileName;
                             }
                         } else {
                             $this->State[0] = $ActualFileName;
                         }
                     } else {
                         $this->Errors->addError($CCSLocales->GetText('CCS_TempInsufficientPermissions', $this->Caption));
                     }
                 }
             }
         } else {
             $this->SetValue(strlen($this->State[1]) ? $this->State[1] : $this->State[0]);
         }
     }
 }