Beispiel #1
0
function checkBoxList($table, $id_field, $value_field, $id_value, $field_name, $condition = '', $chars = 25)
{
    $out = '';
    $uneq_string = randomStringUtil(5);
    if ($condition) {
        $condition = " where " . $condition;
    }
    $sql = "select {$id_field} , {$value_field} from {$table} {$condition} order by {$value_field} ASC";
    $res = mysql_query($sql);
    $rows = mysql_num_rows($res);
    if ($rows > 0) {
        $i = 0;
        while ($i < $rows) {
            $id = mysql_result($res, $i, $id_field);
            $name = mysql_result($res, $i, $value_field);
            $class = 'chebox_0';
            $che = '';
            if (is_array($id_value)) {
                if (in_array($id, $id_value)) {
                    $class = 'chebox_1';
                    $che = ' checked ';
                }
            }
            $out .= '<div class="' . $class . '" onclick="chekBoxSel(\'' . $uneq_string . '\',' . $i . ')" id="chDiv' . $uneq_string . $i . '">
			<input type="checkbox" ' . $che . ' name="' . $field_name . '[]" id="ch' . $uneq_string . $i . '" value="' . $id . '" style="display:none" /> 
			<b>' . ucfirst(limit($name, $chars)) . '</b></div>';
            $i++;
        }
    }
    return $out;
}
Beispiel #2
0
<?  session_start();
// if($_SESSION["enterCMS"] == 'go'){
	include_once('../../../../config.php'); 
	include_once('../../../common/dbConnection.php'); 
	include_once('../../dbUtils.php');	
	$upfolder="../../../../uploads/temp/";
	if(!file_exists($upfolder)){
		mkdir($upfolder, 0777);
	}
	if (!empty($_FILES)) {
		$availableEx = array("jpg","gif","png","jpeg","pdf","doc","docx","xls","xlsx","flv","mp4","wmv","avi");
		//$videoEx = array("flv","mp4","wmv");	
		$fileNameParts = explode(".",$_FILES['Filedata']['name']);
		$Ex =strtolower(end($fileNameParts));
		if(in_array($Ex,$availableEx)){
			$rund=randomStringUtil(5);
			$NewFileName=date('U').'_'.$rund.'.'.$Ex;
			$NewFileName_s=date('U').'_'.$rund.'_s.'.$Ex;
			$targetFile = $upfolder.$NewFileName;
			$tempFile = $_FILES['Filedata']['tmp_name'];
			if(move_uploaded_file($tempFile,$targetFile)){
				echo $NewFileName;
				$wh=getimagesize($targetFile);
				if($wh[0]<80 && $wh[1]<80){
					copy($targetFile,$upfolder.$NewFileName_s);
				}else{
					resizeToFile ($targetFile, 80, 80,$upfolder.$NewFileName_s);
				}
			}
		}
	}
Beispiel #3
0
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $targetPath = str_replace('//', '/', $targetPath);
    $targetFile = $targetPath . $_FILES['Filedata']['name'];
    $realName = str_replace(" ", "_", $_FILES['Filedata']['name']);
    $photo = $realName;
    while (file_exists($targetPath . $photo)) {
        $fileNameParts = explode(".", "{$photo}");
        $fileExtension = end($fileNameParts);
        // part behind last dot
        $ext = $fileExtension . "";
        $photo = $fileNameParts[0] . "1." . $ext;
    }
    $targetFile = $targetPath . $photo;
    $fileNameParts = explode(".", $_FILES['Filedata']['name']);
    $fileExtension = end($fileNameParts);
    if (in_array($ext, $videoEx)) {
        $thumbFile = 'video';
    } else {
        $thumbFile = "mcith/mcith_" . randomStringUtil(20) . '.' . $fileExtension;
    }
    $ext = strtolower(end(explode('.', $photo)));
    if (in_array($ext, $availableEx)) {
        move_uploaded_file($tempFile, $targetFile);
        $SQL = "INSERT INTO galleries_photos (photo , description , thumb, folder ) VALUES ('{$photo}','&nbsp;','{$thumbFile}' ,'{$upfolder}' )";
        $result = mysql_query($SQL);
        if ($result) {
            echo 1;
        }
    }
}
Beispiel #4
0
function uploadimageToGal($fieldName, $gal_name, $src)
{
    $folder = "../../uploads";
    $realName = str_replace(" ", "_", $_FILES[$fieldName]['name']);
    while (file_exists($folder . "/" . $realName)) {
        $fileNameParts = explode(".", "{$realName}");
        $fileExtension = end($fileNameParts);
        $ext = $fileExtension . "";
        $realName = $fileNameParts[0] . "1." . $ext;
    }
    $small = "mcith/mcith_" . randomStringUtil(20) . '.' . $fileExtension;
    $uploadfile = $folder . "/" . $realName;
    if (move_uploaded_file($_FILES[$fieldName]['tmp_name'], $uploadfile)) {
        $newPhotoId = getNewId("galleries_photos", "id");
        $sql = "INSERT INTO `galleries_photos`(`id`,`photo`,`description`,`thumb`)\n\t\tVALUES('{$newPhotoId}','{$realName}', '', '{$small}');";
        if (mysql_query($sql)) {
            $newGalId = getNewId("galleries_galleries", "id");
            $sql = "INSERT INTO `galleries_galleries` \n\t\t\t(`id`,`gallery_name_en`,`gallery_name_ar`,`description_en`,`main_photo`,`photos`,`src` )VALUES\n\t\t\t('{$newGalId}','{$gal_name}','','', '{$newPhotoId}' , '{$newPhotoId}' ,'{$src}');";
            if (mysql_query($sql)) {
                return $newGalId;
            } else {
                return 'x';
            }
        } else {
            return 'x';
        }
    }
}