Example #1
0
function init($args)
{
    $name = $args['name'];
    $location = $args['location'];
    //check if album already exists
    $cp = new ConfigReader(PF_CONFIG_FILE);
    $albums = $cp->getChildren("settings/albums");
    if ($albums) {
        foreach ($albums as $album) {
            if ($album['attributes']['name'] == $name) {
                error("Album {$name} already exists!");
                return;
            }
        }
    }
    define("ALBUM_DIR", realpath($_SERVER['DOCUMENT_ROOT'] . '/' . $location));
    //check if it exists
    if (!is_dir(ALBUM_DIR)) {
        error("It seems like the directory {$location} does not exist.");
        return;
    }
    //check if directory writeable
    if (!is_writeable(ALBUM_DIR)) {
        error("Could not create album. Could not write to {$location}." . ALBUM_DIR);
        return;
    }
    //get a list of photos (jpg/png)
    //generate thumbnails
    chdir(ALBUM_DIR);
    //try to make thumbnail directory
    if (!is_dir(PF_THUMBNAIL_DIR)) {
        if (!mkdir(PF_THUMBNAIL_DIR)) {
            error("Could not create thumbnails directory in {$location}");
            return;
        }
    }
    //generate thumbnails
    //it seems glob cannot take multiple patterns
    $pattern = array("*.jpg", "*.jpeg", "*.png");
    foreach ($pattern as $pat) {
        foreach (glob($pat) as $file) {
            if (!makeThumbnail($file, PF_THUMBNAIL_DIR . $file)) {
                error("Could not create thumbnail for image {$file}");
                return;
            }
        }
    }
    //add album to config file
    $cp = new ConfigWriter(PF_CONFIG_FILE);
    $attributes = array("name" => $name, "location" => str_replace($_SERVER['DOCUMENT_ROOT'], "", ALBUM_DIR), "theme" => PF_DEFAULT_THEME);
    $cp->addWithAttributes('settings/albums/album', $attributes, "");
    if (!$cp->close()) {
        error("Could not write to configuration file");
    }
    success("Successfully created album {$name} in {$location}.");
}
Example #2
0
 function sendCameraImage($camName, $ImageName, $mode = "full")
 {
     global $hostConfig;
     // Verify Camera definition was loaded..
     if (!isset($this->camList[$camName])) {
         return Framework::debug(DEBUG_FATAL, "<CENTER><H1>Requested Camera [{$camName}] not found</h1></center>");
     }
     // Verify Image file exists
     $ImageFile = $this->camList[$camName]['folder'] . "/{$ImageName}";
     if (!file_exists($ImageFile)) {
         return Framework::debug(DEBUG_FATAL, "<CENTER><H1>Requested Image not found</h1></center>");
     }
     // Return correct varient of image..
     switch ($mode) {
         case 'thumb':
             return makeThumbnail($ImageFile, "{$hostConfig['Folder_Base']}/thumb", $hostConfig['ThumbSize']);
             break;
         case 'full':
             return sendFile_Rangable($this->camList[$camName]['folder'] . "/{$ImageName}", "image/jpeg");
             break;
         default:
             Framework::debug(DEBUG_FATAL, "Unknown 'Mode' parameter");
     }
 }
 //CREATE A UNIX TIMESTAMP
 $stamp = time();
 $date = gmdate("Y-m-d H:i:s", $stamp);
 if ($thumb == "yes") {
     //IF THE EXTENSION IS AN IMAGE EXTENSION, LETS CREATE A THUMBNAIL
     if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "wbmp") {
         //CREATE THE THUMBS FOLDER IF IT DOES NOT EXIST
         if (!file_exists($thumb_path)) {
             mkdir($thumb_path);
         }
         //INSERT INTO OUR FILES OBJECT
         $sql = "INSERT INTO " . $cfg->db_prefix . "_files(name, sys_name, location, extension, note) \n\t\t\t\t  VALUES('{$oldfile}', '{$sys_name}', '{$thumb_location}', '{$ext}', 'thumbnail')";
         $results = $db->DB_Q_C($sql);
         $lastid = mysql_insert_id();
         //CREATE THE THUMBNAIL
         makeThumbnail($target_path, $thumb_path . basename($sys_name), $thumb_size);
     }
 }
 //INSERT INTO OUR FILES OBJECT
 $sql = "INSERT INTO " . $cfg->db_prefix . "_files(name, sys_name, location, extension, note) \n            VALUES('{$oldfile}', '{$sys_name}', '{$location}', '{$ext}', '')";
 $results = $db->DB_Q_C($sql);
 $lastid = mysql_insert_id();
 //LOG THE ACTION
 //GRAB THE MODULE ID
 $sql = "SELECT id FROM " . $cfg->db_prefix . "_modules WHERE name = 'class_files'";
 $results = $db->DB_Q_C($sql);
 $row = mysql_fetch_array($results);
 $sql = "INSERT INTO " . $cfg->db_prefix . "_object(create_date, create_who) \n            VALUES('{$date}', '{$userid}')";
 $results = $db->DB_Q_C($sql);
 $lastobjectid = mysql_insert_id();
 $sql = "INSERT INTO " . $cfg->db_prefix . "_logs(user_id, object_id, module_id, sub_module_id, record_id, action)\n            VALUES('" . $userid . "', {$lastobjectid}, '" . $row[0] . "', 1, {$lastid}, 1)";
Example #4
0
}
if($_POST['action'] == 'editshipping') {
	
	
	$row['embryo_shipping_price'] = $_POST['embryo_shipping_price'];
	$row['embryo_shipping_desc'] = $_POST['embryo_shipping_desc'];
	$row['semen_shipping_price_1'] = $_POST['semen_shipping_price_1'];
	$row['semen_shipping_price_2'] = $_POST['semen_shipping_price_2'];
	$row['semen_shipping_desc'] = $_POST['semen_shipping_desc'];
	$row['semen_shipping_image'] =  $_POST['semen_shipping_image'];
	
	
	if($_FILES['semen_shipping_image']['name'] != '') {//upload image yo!
		$filename = time().fixFilename($_FILES['semen_shipping_image']['name']);
		uploadFile($_FILES['semen_shipping_image'], $filename);
		makeThumbnail($filename, UPLOAD_DIR, 480, '', 'medium');
		
		$row['semen_shipping_image'] = $filename;
	}
	
	dbPerform('store_shipping', $row, 'update', 'shipping_id = 1');
	
	addMessage("Updated shipping information successfully");
	redirect(PAGE_STORE."?section=shipping&action=editshipping");
	
	
	
}

switch($_GET['section']){ 
case 'manage':
Example #5
0
    $mediaType = intval($_POST['mediaType']);
    # 0 - pictures, 1 - videos
    $postid = idGenerator(7);
    $file_tmp = $_FILES["file"]["tmp_name"];
    file_put_contents("submitData.txt", $file_tmp);
    $file_path = "uploads/" . $userid . "/";
    if (!file_exists($file_path)) {
        mkdir($file_path, 0777, true);
    }
    if ($mediaType == 1) {
        $file_path = $file_path . $postid . '.mp4';
        move_uploaded_file($file_tmp, $file_path);
    } else {
        $file_path = $file_path . $postid . '.jpg';
        move_uploaded_file($file_tmp, $file_path);
        makeThumbnail($file_path, $mediaType);
    }
    if ($submitOK == true) {
        if (file_exists($file_path)) {
            $add = "INSERT INTO posts_tbl (Title, Caption, Location, Latitude, Longitude, votes, userid, postid, timestamp, mediaType, IP_client, IP_server)\n\t\t\t\t\t\tVALUES('" . $title . "', '" . $caption . "', '" . $file_path . "', " . $lat . ", " . $long . ", 0, '" . $userid . "', '" . $postid . "', " . time() . ", " . $mediaType . ", '" . $_SERVER['REMOTE_ADDR'] . "', \t\t\t\t\t\t'" . $_SERVER['HTTP_X_FORWARDED_FOR'] . "');";
            echo true;
        } else {
            echo false;
        }
        mysqli_query($conn, $add);
    } else {
        file_put_contents($debug_log, $errormsg);
    }
    mysqli_close($conn);
} else {
    if ($postType == "reply") {
Example #6
0
<?php

include "makeThumbnail.php";
$url = $_POST['url'];
$filename = basename($url);
$path = $_SERVER['DOCUMENT_ROOT'] . "/images/";
$thumbpath = $path . "/thumbs/";
if (!file_exists($path)) {
    mkdir($path, 0777, true);
}
if (!file_exists($thumbpath)) {
    mkdir($thumbpath, 0777, true);
}
$file = file_get_contents($url);
file_put_contents($path . $filename, $file);
makeThumbnail($path . $filename, $thumbpath . $filename);
echo $filename;
Example #7
0
        $uploadOK = 0;
        $fail_msg = 'Not jpg, png or jpeg.';
    }
    if ($uploadOK == 0) {
    } else {
        if (move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) {
            $fail_msg = 'File uploaded.';
            $connection = new mysqli($db_hostname, $db_username, $db_password, $db_database);
            $ti_temp = mysql_entities_fix_string($connection, $title);
            $query = "INSERT INTO user_images(user_id, title, path)\n                          VALUES ('{$user_id}', '{$ti_temp}', '{$target_path}')";
            $result = $connection->query($query);
            if (!$result) {
                die($connection->error);
            }
            $connection->close();
            makeThumbnail($target_dir, $target_file);
        } else {
            $fail_msg = 'There was an error.';
        }
    }
}
function validate_title($field)
{
    if (strlen($field) > 64) {
        return "Stop it.";
    } elseif (!preg_match("/^[a-zA-Z0-9 ']+\$/", $field)) {
        return "Invalid title. Currently only accepts a-z, A-Z and 0-9.";
    } else {
        return "";
    }
}
Example #8
0
        } else {
            for ($i = 0; $i < count($_FILES['edit_notes']['name']); $i++) {
                $tmpFilePath = $_FILES['edit_notes']['tmp_name'][$i];
                if ($tmpFilePath != "") {
                    $shortname = $_FILES['edit_notes']['name'][$i];
                    $file_name = date('d-m-Y-H-i-s') . '-' . $_FILES['edit_notes']['name'][$i];
                    $full_upload_path = $upload_path . $file_name;
                    if (move_uploaded_file($tmpFilePath, $full_upload_path)) {
                        $files[] = $shortname;
                        $stmt = $ndb->prepare("INSERT INTO Uploads (id, name, file_name, location) VALUES (:id, :name, :filename, :location)");
                        $stmt->bindValue(':id', $_POST['Edit_Note_Save'], SQLITE3_TEXT);
                        $stmt->bindValue(':name', $shortname, SQLITE3_TEXT);
                        $stmt->bindValue(':filename', $file_name, SQLITE3_TEXT);
                        $stmt->bindValue(':location', $full_upload_path, SQLITE3_TEXT);
                        $stmt->execute();
                        makeThumbnail($upload_path, $file_name);
                    }
                }
            }
        }
    }
}
// Change system settings
if (isset($_POST['ChangeSystem'])) {
    $stmt = $db->prepare("UPDATE Misc SET Enable_Max_Amps=:enablemaxamps, Max_Amps=:maxamps, Relay_Stats_Volts=:statvolts, Relay_Stats_Cost=:statcost, Relay_Stats_Currency=:statcurrency, Relay_Stats_DayofMonth=:statdayofmonth, Login_Message=:loginmessage, Refresh_Time=:refreshtime");
    $stmt->bindValue(':enablemaxamps', (int) $_POST['enable_max_amps'], SQLITE3_INTEGER);
    $stmt->bindValue(':maxamps', (double) $_POST['max_amps'], SQLITE3_FLOAT);
    $stmt->bindValue(':statvolts', (int) $_POST['relay_stats_volts'], SQLITE3_INTEGER);
    $stmt->bindValue(':statcost', (double) $_POST['relay_stats_cost'], SQLITE3_FLOAT);
    $stmt->bindValue(':statcurrency', $_POST['relay_stats_currency'], SQLITE3_TEXT);
    $stmt->bindValue(':statdayofmonth', (int) $_POST['relay_stats_dayofmonth'], SQLITE3_INTEGER);
Example #9
0
 function ocd_update()
 {
     $this->pageTitle = "Новости : режим редактирования";
     $this->pageHeader = "Новости : режим редактирования";
     $id = $this->GetGP("id");
     $article = $this->enc($this->GetValidGP("article", "Краткое описание", VALIDATE_NOT_EMPTY));
     $title = $this->enc($this->GetValidGP("title", "Заголовок", VALIDATE_NOT_EMPTY));
     if ($this->errors['err_count'] > 0) {
         $this->fill_form("update", FORM_FROM_GP);
     } else {
         $date = mktime(0, 0, 0, $this->GetGP("dateMonth"), $this->GetGP("dateDay"), $this->GetGP("dateYear"));
         $description = $this->enc($this->GetGP("progress"));
         $this->db->ExecuteSql("Update {$this->object} Set z_date='{$date}', article='{$article}', title='{$title}', description='{$description}' Where item_id='{$id}'");
         $physical_path = $this->sitePath;
         if (array_key_exists("photo", $_FILES) and $_FILES['photo']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo']['name'];
             $tmp_name = $_FILES['photo']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 move_uploaded_file($tmp_name, $physical_path . "data/news/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $new_name, 0777);
                 copy($physical_path . "data/news/" . $new_name, $physical_path . "data/news/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/news/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/news/" . $new_name, 1);
                 $this->db->ExecuteSql("Update {$this->object} Set photo='{$short_name}' Where item_id='{$id}'");
             }
         }
         if (array_key_exists("photo2", $_FILES) and $_FILES['photo2']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo2']['name'];
             $tmp_name = $_FILES['photo2']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 move_uploaded_file($tmp_name, $physical_path . "data/news/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $new_name, 0777);
                 copy($physical_path . "data/news/" . $new_name, $physical_path . "data/news/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/news/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/news/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/news/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/news/" . $new_name, 1);
                 $this->db->ExecuteSql("Update {$this->object} Set photo2='{$short_name}' Where item_id='{$id}'");
             }
         }
         $this->Redirect($this->pageUrl . "?mes=up");
     }
 }
Example #10
0
function storePicture($picture, $title, $description, $userID, $galleryID)
{
    $SMALL_WIDTH = 64;
    $SMALL_HEIGHT = 64;
    $MEDIUM_WIDTH = 128;
    $MEDIUM_HEIGHT = 128;
    $LARGE_WIDTH = 512;
    $LARGE_HEIGHT = 512;
    $dimensions = getimagesize($picture);
    $picture_width = $dimensions[0];
    $picture_height = $dimensions[1];
    //dohvati ID
    $id = getIdentificator("identifikatori.txt", 'id_slike');
    //spremi u bazu
    $handle = fopen("slike.txt", "a");
    if ($handle) {
        fwrite($handle, $id . ';' . htmlentities($title) . ';' . htmlentities($description) . ';' . $userID . ';' . $galleryID . "\n");
        fclose($handle);
    } else {
        echo "error happened while opening file";
    }
    //save to disk
    $imagesDir = './images';
    if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {
        $name = $id . '_original';
        if (move_uploaded_file($picture, "{$imagesDir}/{$name}")) {
            makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_small', $SMALL_WIDTH, $SMALL_HEIGHT, 100);
            if ($picture_height > $MEDIUM_HEIGHT && $picture_width > $MEDIUM_WIDTH) {
                makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_medium', $MEDIUM_WIDTH, $MEDIUM_HEIGHT, 100);
                if ($picture_height > $LARGE_HEIGHT && $picture_width > $LARGE_WIDTH) {
                    makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_large', $LARGE_WIDTH, $LARGE_HEIGHT, 100);
                }
            }
        } else {
            echo "failed to upload, please try again.";
        }
    }
}
Example #11
0
 function ocd_update()
 {
     $gallery_id = $this->GetStateValue("gallery_id", 0);
     $c_title = $this->db->GetOne("Select title From `pgalleries` Where gallery_id='{$gallery_id}'", "");
     $this->pageHeader = "Фотографии галереи '{$c_title}' : режим редактирования";
     $this->pageTitle = "Фотографии галереи '{$c_title}' : режим редактирования";
     $id = $this->GetGP("id");
     $content = $this->enc($this->GetValidGP("content", "Описание", VALIDATE_NOT_EMPTY));
     $z_date = mktime(0, 0, 0, $this->GetGP("dateMonth"), $this->GetGP("dateDay"), $this->GetGP("dateYear"));
     $gallery_id = $this->GetGP("gallery_id", 0);
     if ($this->errors['err_count'] > 0) {
         $this->fill_form("update", FORM_FROM_GP);
     } else {
         if (array_key_exists("photo", $_FILES) and $_FILES['photo']['error'] < 3) {
             $symbs = getUnID(5);
             $oldname = $_FILES['photo']['name'];
             $tmp_name = $_FILES['photo']['tmp_name'];
             $short_name = $id . "_" . $symbs;
             $new_name = $short_name . ".jpg";
             $thumb_name = "small_" . $new_name;
             if (is_uploaded_file($tmp_name)) {
                 $physical_path = $this->sitePath;
                 move_uploaded_file($tmp_name, $physical_path . "data/photos/" . $new_name);
                 $cmd = "chmod 666 " . $physical_path . "data/photos/" . $new_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/photos/" . $new_name, 0777);
                 copy($physical_path . "data/photos/" . $new_name, $physical_path . "data/photos/" . $thumb_name);
                 $cmd = "chmod 666 " . $physical_path . "data/photos/" . $thumb_name;
                 @exec($cmd, $output, $retval);
                 @chmod($physical_path . "data/photos/" . $thumb_name, 0777);
                 makeThumbnail($physical_path . "data/photos/" . $thumb_name, 0);
                 makeThumbnail($physical_path . "data/photos/" . $new_name, 1);
                 $this->db->ExecuteSql("Update `{$this->object}` Set photo='{$new_name}' Where photo_id='{$id}'");
             }
         }
         $this->db->ExecuteSql("Update `{$this->object}` Set z_date='{$z_date}', gallery_id='{$gallery_id}', content='{$content}' Where photo_id='{$id}'");
         $this->Redirect($this->pageUrl);
     }
 }
Example #12
0
<?php

/* This script is used with swfupload */
/* We are going to be upload and storing the gallery images /*
/* Create thumbnails and return a true statement! */
include 'application.php';
if ($_FILES['Filedata']['name'] != "" && isset($_POST['gallery_id'])) {
    $filename = time() . fixFilename($_FILES['Filedata']['name']);
    uploadFile($_FILES['Filedata'], $filename);
    foreach ($galleryImageSizes as $name => $size) {
        makeThumbnail($filename, UPLOAD_DIR, $size, '', $name);
    }
    $row['gallery_id'] = $_POST['gallery_id'];
    $row['gallery_image_filename'] = $filename;
    $row['gallery_date_added'] = time();
    $row['gallery_image_caption'] = '';
    dbPerform('gallery_images', $row, 'insert');
    $imageID = dbInsertID();
    //get total images then add one for the sort order number!
    $imgResults = dbQuery('SELECT gallery_image_id FROM gallery_images WHERE gallery_id = ' . $_POST['gallery_id']);
    $count = dbNumRows($imgResults);
    $next = $count++;
    $row2['gallery_image_sort_order'] = $next;
    dbPerform('gallery_images', $row2, 'update', 'gallery_image_id = ' . $imageID);
    echo "FILEID:" . UPLOAD_DIR_URL . getThumbnailFilename($filename, 'thumb');
} else {
    return false;
    die;
}
Example #13
0
/**
 * This is the main function for all module search functions.
 * 
 * @param array $search_result - variables given from the module or droplep
 * @param array $search_parameter - variables given from the LEPTON search to the module
 * @return boolean true if the search result of the module match or false in all other cases
 */
function print_excerpt2($search_result, $search_parameter)
{
    // check the search result variables
    if ($search_result['text'] == "") {
        return false;
    }
    if (!isset($search_result['page_link'])) {
        $search_result['page_link'] = $search_parameter['page_link'];
    }
    if (!isset($search_result['page_link_target'])) {
        $search_result['page_link_target'] = "";
    }
    if (!isset($search_result['page_title'])) {
        $search_result['page_title'] = $search_parameter['page_title'];
    }
    if (!isset($search_result['page_description'])) {
        $search_result['page_description'] = $search_parameter['page_description'];
    }
    if (!isset($search_result['page_modified_when'])) {
        $search_result['page_modified_when'] = $search_parameter['page_modified_when'];
    }
    if (!isset($search_result['page_modified_by'])) {
        $search_result['page_modified_by'] = $search_parameter['page_modified_by'];
    }
    if (!isset($search_result['text'])) {
        $search_result['text'] = "";
    }
    if (!isset($search_result['max_excerpt_num'])) {
        $search_result['max_excerpt_num'] = $search_parameter['default_max_excerpt'];
    }
    // special: image links
    if (!isset($search_result['pic_link'])) {
        $search_result['pic_link'] = '';
    }
    if (!isset($search_result['image_link'])) {
        $search_result['image_link'] = $search_result['pic_link'];
    }
    if (!isset($search_result['no_highlight'])) {
        $search_result['no_highlight'] = false;
    }
    if (isset($search_result['ext_charset'])) {
        $search_result['ext_charset'] = strtolower($search_result['ext_charset']);
    } else {
        $search_result['ext_charset'] = '';
    }
    if ($search_result['no_highlight']) {
        // suppress highlighting of search results
        $search_result['page_link_target'] = "&amp;nohighlight=1" . $search_result['page_link_target'];
    }
    // clean the text:
    $search_result['text'] = preg_replace('#<(br|dt|/dd|/?(?:h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $search_result['text']);
    $search_result['text'] = preg_replace('#<(!--.*--|style.*</style|script.*</script)>#iU', ' ', $search_result['text']);
    $search_result['text'] = preg_replace('#\\[\\[.*?\\]\\]#', '', $search_result['text']);
    //Filter droplets from the page data
    // strip_tags() is called below
    if ($search_result['ext_charset'] != '') {
        // data from external database may have a different charset
        require_once CAT_PATH . '/framework/functions-utf8.php';
        switch ($search_result['ext_charset']) {
            case 'latin1':
            case 'cp1252':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'CP1252');
                break;
            case 'cp1251':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'CP1251');
                break;
            case 'latin2':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-2');
                break;
            case 'hebrew':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-8');
                break;
            case 'greek':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-7');
                break;
            case 'latin5':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-9');
                break;
            case 'latin7':
                $search_result['text'] = charset_to_utf8($search_result['text'], 'ISO-8859-13');
                break;
            case 'utf8':
            default:
                $search_result['text'] = charset_to_utf8($search_result['text'], 'UTF-8');
        }
    } else {
        $search_result['text'] = entities_to_umlauts($search_result['text'], 'UTF-8');
    }
    $content_locked = '';
    $add_anchor = true;
    if (isset($_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT])) {
        // show non-public contents, so add some extra informations
        if (isset($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT]) && !empty($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT])) {
            // link to a special page, defined in search as CFG_LINK_NON_PUBLIC_CONTENT
            $search_result['page_link'] = CAT_URL . $_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT];
        } else {
            $search_result['page_link'] = '';
        }
        // $_SESSION reset
        unset($_SESSION[SESSION_SEARCH_NON_PUBLIC_CONTENT]);
        unset($_SESSION[SESSION_SEARCH_LINK_NON_PUBLIC_CONTENT]);
        $add_anchor = false;
    }
    $anchor_text = $search_result['text'];
    // make an copy containing html-tags
    $search_result['text'] = strip_tags($search_result['text']);
    $search_result['text'] = str_replace(array('&gt;', '&lt;', '&amp;', '&quot;', '&#039;', '&apos;', '&nbsp;'), array('>', '<', '&', '"', '\'', '\'', ' '), $search_result['text']);
    $search_result['text'] = '.' . trim($search_result['text']) . '.';
    // create empty image array
    $images = array();
    if ($search_parameter['settings'][CFG_SEARCH_IMAGES] || $search_parameter['settings'][CFG_CONTENT_IMAGE]) {
        // we need a image array for the search
        preg_match_all('/<img[^>]*>/', $anchor_text, $matches);
        foreach ($matches as $match) {
            foreach ($match as $img_tag) {
                // <img ...> zerlegen
                preg_match_all('/([a-zA-Z]*[a-zA-Z])\\s{0,3}[=]\\s{0,3}("[^"\\r\\n]*)"/', $img_tag, $attr);
                foreach ($attr as $attributes) {
                    $img = array();
                    foreach ($attributes as $attribut) {
                        if (strpos($attribut, "=") !== false) {
                            list($key, $value) = explode("=", $attribut);
                            $value = trim($value);
                            $value = substr($value, 1, strlen($value) - 2);
                            $img[strtolower(trim($key))] = trim($value);
                        }
                    }
                    if (isset($img['src'])) {
                        $images[] = $img;
                    }
                }
            }
        }
    }
    if (!$search_parameter['settings'][CFG_SEARCH_IMAGES] && $search_parameter['settings'][CFG_CONTENT_IMAGE] == CONTENT_IMAGE_NONE) {
        // Do a fast scan over the search result first. This may speedup things a lot.
        if ($search_parameter['search_match'] == SEARCH_TYPE_ALL) {
            if (!is_all_matched($search_result['text'], $search_parameter['search_words'])) {
                return false;
            }
        } elseif (!is_any_matched($search_result['text'], $search_parameter['search_words'])) {
            return false;
        }
    } else {
        // create a dummy string to check matches in the images
        $divider = '.';
        $image_text = '';
        foreach ($images as $image) {
            $file = basename($image['src']);
            $file = urldecode(substr($file, 0, strrpos($file, '.')));
            $alt = isset($image['alt']) && !empty($image['alt']) ? $image['alt'] : '';
            $title = isset($image['title']) && !empty($image['title']) ? $image['title'] : '';
            $image_text .= $alt == $title ? $divider . $alt . $divider . $file . $divider : $divider . $alt . $divider . $title . $divider . $file . $divider;
        }
        if ($search_parameter['search_match'] == SEARCH_TYPE_ALL) {
            if (!is_all_matched($search_result['text'] . $image_text, $search_parameter['search_words'])) {
                return false;
            }
        } elseif (!is_any_matched($search_result['text'] . $image_text, $search_parameter['search_words'])) {
            return false;
        }
    }
    // search for an better anchor - this have to be done before strip_tags() (may fail if search-string contains <, &, amp, gt, lt, ...)
    $anchor = make_url_target($search_result['page_link_target'], $anchor_text, $search_parameter['search_words']);
    // make the link from $mod_page_link, add anchor
    $link = "";
    if (!empty($search_result['page_link'])) {
        $link = page_link($search_result['page_link']);
        if (strpos($search_result['page_link'], 'http:') === false) {
            $link .= make_url_searchstring($search_parameter['search_match'], $search_parameter['search_url_array']);
        }
        // add anchor only if content is not locked!
        if ($add_anchor) {
            $link .= $anchor;
        }
    }
    // now get the excerpt
    $excerpt = "";
    $excerpt_array = array();
    // dont create excerpts if we are only searching for images!
    if ($search_parameter['search_match'] != SEARCH_TYPE_IMAGE && $search_result['max_excerpt_num'] > 0) {
        if (false !== ($excerpt_array = get_excerpts($search_result['text'], $search_parameter['search_words'], $search_result['max_excerpt_num']))) {
            $excerpt = prepare_excerpts($excerpt_array, $search_parameter['search_words'], $search_result['max_excerpt_num']);
        }
    }
    // no image matches now ...
    $image_match = false;
    $image_array = array();
    if ($search_parameter['settings'][CFG_SEARCH_IMAGES] || $search_parameter['search_match'] == SEARCH_TYPE_ALL) {
        // ok - now we are looking for matching images ...
        foreach ($images as $image) {
            $file = urldecode(basename($image['src']));
            $file = substr($file, 0, strrpos($file, '.'));
            $alt = isset($image['alt']) && !empty($image['alt']) ? $image['alt'] : '';
            $title = isset($image['title']) && !empty($image['title']) ? $image['title'] : '';
            $image_text = $alt == $title ? $divider . $alt . $divider . $file . $divider : $divider . $alt . $divider . $title . $divider . $file . $divider;
            if (false !== ($excerpt_array = get_excerpts($image_text, $search_parameter['search_words'], $search_result['max_excerpt_num']))) {
                // image match!
                $image_excerpt = prepare_excerpts($excerpt_array, $search_parameter['search_words'], $search_result['max_excerpt_num']);
                // accept only images with complete URL
                if (false === strpos($image['src'], CAT_URL)) {
                    continue;
                }
                $src = str_ireplace(CAT_URL, CAT_PATH, urldecode($image['src']));
                $target = CAT_PATH . '/temp/search/' . urldecode(basename($image['src']));
                makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH]);
                $image_array[] = array('excerpt' => $image_excerpt, 'src' => CAT_URL . '/temp/search/' . urldecode(basename($image['src'])), 'alt' => isset($image['alt']) ? $image['alt'] : '', 'title' => isset($image['title']) ? $image['title'] : '', 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]);
                $image_match = true;
            }
        }
    }
    // leave here if nothing matches ...
    if (empty($excerpt) && !$image_match) {
        return false;
    }
    $thumb_array = array();
    // if no images are matching to the search it's possible to show a image
    // of the content or to use a desired image_link from the module
    $use_thumb = 0;
    if (!$image_match && ($search_parameter['settings'][CFG_CONTENT_IMAGE] != CONTENT_IMAGE_NONE || !empty($search_result['image_link']))) {
        if (!empty($search_result['image_link'])) {
            if (strpos($search_result['image_link'], CAT_URL) === false) {
                $src = CAT_PATH . MEDIA_DIRECTORY . DIRECTORY_SEPARATOR . $search_result['image_link'];
            } else {
                $src = str_ireplace(CAT_URL, CAT_PATH, $search_result['image_link']);
            }
            // the path to the temporary thumbnail
            $target = CAT_PATH . '/temp/search/' . basename($search_result['image_link']);
            // create a thumbnail and place it in the temporary directory
            if (makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH])) {
                $thumb_array = array('src' => CAT_URL . '/temp/search/' . urldecode(basename($search_result['image_link'])), 'alt' => $search_result['page_title'], 'title' => $search_result['page_title'], 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]);
                $use_thumb = 1;
            } else {
                $use_thumb = 0;
            }
        } else {
            switch ($search_parameter['settings'][CFG_CONTENT_IMAGE]) {
                case CONTENT_IMAGE_FIRST:
                    $i = 0;
                    break;
                case CONTENT_IMAGE_LAST:
                    $i = count($images) - 1;
                    break;
                case CONTENT_IMAGE_RANDOM:
                    $i = rand(0, count($images) - 1);
                    break;
                default:
                    $i = 0;
            }
            if (isset($images[$i]['src']) && false !== strpos($images[$i]['src'], CAT_URL)) {
                $src = str_ireplace(CAT_URL, CAT_PATH, urldecode($images[$i]['src']));
                // the path to the temporary thumbnail
                $target = CAT_PATH . '/temp/search/' . urldecode(basename($images[$i]['src']));
                // create a thumbnail and place it in the temporary directory
                if (makeThumbnail($src, $target, $search_parameter['settings'][CFG_THUMBS_WIDTH])) {
                    $thumb_array = array('src' => CAT_URL . '/temp/search/' . urldecode(basename($images[$i]['src'])), 'alt' => isset($images[$i]['alt']) ? $images[$i]['alt'] : '', 'title' => isset($images[$i]['title']) ? $images[$i]['title'] : '', 'width' => $search_parameter['settings'][CFG_THUMBS_WIDTH]);
                    $use_thumb = 1;
                } else {
                    $use_thumb = 0;
                }
            } else {
                $use_thumb = 0;
            }
        }
    } else {
        $use_thumb = 0;
    }
    list($date, $time) = get_page_modified($search_result['page_modified_when']);
    list($username, $displayname) = get_page_modified_by($search_result['page_modified_by'], $search_parameter['users']);
    $item = array('page' => array('link' => $link, 'title' => $search_result['page_title'], 'description' => $search_result['page_description'], 'excerpt' => $excerpt, 'images' => array('items' => $image_array, 'count' => count($image_array)), 'thumb' => array('active' => $use_thumb, 'image' => $thumb_array), 'last_changed' => array('unix_time' => $search_result['page_modified_when'], 'date_formatted' => $date, 'time_formatted' => $time), 'visibility' => $search_parameter['page_visibility']), 'user' => array('name' => $username, 'display_name' => $displayname));
    // all search results are temporary saved in the $_SESSION['SEARCH_RESULT_ITEMS']
    if (!isset($_SESSION[SESSION_SEARCH_RESULT_ITEMS])) {
        $_SESSION[SESSION_SEARCH_RESULT_ITEMS] = array();
    }
    $_SESSION[SESSION_SEARCH_RESULT_ITEMS][] = $item;
    return true;
}
Example #14
0
<?php

include "makeThumbnail.php";
$file = $_FILES['file'];
$path = $_SERVER['DOCUMENT_ROOT'] . "/images/";
$thumbpath = $path . "/thumbs/";
if (!file_exists($path)) {
    mkdir($path, 0777, true);
}
if (!file_exists($thumbpath)) {
    mkdir($thumbpath, 0777, true);
}
if (move_uploaded_file($file['tmp_name'], $path . $file['name'])) {
    makeThumbnail($path . $file['name'], $thumbpath . $file['name']);
    echo $file['name'];
}
Example #15
0
        $err .= 'The file: ' . $_FILES['upload']['name'] . ' has not the allowed extension type.';
    }
    if ($_FILES['upload']['size'] > $imgsets['maxsize'] * 1000) {
        $err .= '\\n Maximum file size must be: ' . $imgsets['maxsize'] . ' KB.';
    }
    // if(isset($width) && isset($height)) {
    //   if($width > $imgsets['maxwidth'] || $height > $imgsets['maxheight']) $err .= '\\n Width x Height = '. $width .' x '. $height .' \\n The maximum Width x Height must be: '. $imgsets['maxwidth']. ' x '. $imgsets['maxheight'];
    //   if($width < $imgsets['minwidth'] || $height < $imgsets['minheight']) $err .= '\\n Width x Height = '. $width .' x '. $height .'\\n The minimum Width x Height must be: '. $imgsets['minwidth']. ' x '. $imgsets['minheight'];
    // }
    // If no errors, upload the image, else, output the errors
    if ($err == '') {
        if (move_uploaded_file($_FILES['upload']['tmp_name'], $uploadpath)) {
            $server_name = $_SERVER['SERVER_NAME'] == 'localhost' ? 'localhost' : '182.50.133.83';
            $conn = new mysqli($server_name, 'manojkt', 'krishna@2005', 'thecorrespondentdotin');
            $imagefilename = basename($_FILES["upload"]["name"]);
            $thumbnailfilename = makeThumbnail($uploadpath, $upload_dir, $imagefilename);
            $conn->query("insert into storyimage (imagefilename,thumbnailfilename) values('{$imagefilename}','{$thumbnailfilename}');");
            $CKEditorFuncNum = $_GET['CKEditorFuncNum'];
            $url = $site . $upload_dir . $img_name;
            $message = $img_name . ' successfully uploaded: \\n- Size: ' . number_format($_FILES['upload']['size'] / 1024, 3, '.', '') . ' KB \\n- Image Width x Height: ' . $width . ' x ' . $height;
            $re = "window.parent.CKEDITOR.tools.callFunction({$CKEditorFuncNum}, '{$url}', '{$message}')";
        } else {
            $re = 'alert("Unable to upload the file")';
        }
    } else {
        $re = 'alert("' . $err . '")';
    }
}
function makeThumbnail($uploadpath, $upload_dir, $imagefilename)
{
    $thumbnailfilename = preg_replace('/\\.(.+?)$/', '.thumb.\\1', $imagefilename);
Example #16
0
					
					if($_FILES['event_image']['name'] != '') {
						//uploading image!
						$filename = time()."_".$_FILES['event_image']['name'];
						uploadFile($_FILES['event_image'], $filename);
						makeThumbnail($filename, UPLOAD_DIR, 150, '', 'small');
						makeThumbnail($filename, UPLOAD_DIR, 50, '', 'xsmall');
						makeThumbnail($filename, UPLOAD_DIR, 250, '', 'large');
						$event['calendar_events_image'] = $filename;
					}
					
					if($_FILES['event_main_image']['name'] != '') {
						//uploading image!
						$filename = time()."_".$_FILES['event_main_image']['name'];
						uploadFile($_FILES['event_main_image'], $filename);
						makeThumbnail($filename, UPLOAD_DIR, 660, '', 'main');
						$event['calendar_events_main_image'] = $filename;
					}
					
					
					dbQuery('DELETE FROM calendar_events_categories WHERE calendar_events_id = ' . $_POST['id']);
					if($_POST['keywords']) {
						foreach($_POST['keywords'] as $key=>$val) {
							if($val != "") {
								$c['calendar_events_id'] = $_POST['id'];
								$c['calendar_events_categories_title'] = $val;
								dbPerform('calendar_events_categories', $c, 'insert');
								
							}
						}
					}
Example #17
0
					
					$blog['title'] = input($_POST['title']);
					$blog['content'] = $_POST['content'];
					$blog['publish_date'] = $publishDateStart;
					$blog['author'] = $_POST['author'];
					$blog['snippet'] = $_POST['snippet'];
					$blog['status'] = $_POST['status'];
					
					if($_FILES['file']['name'] != "" ) { //uploading flash file
						$filename = fixFilename($_FILES['file']['name']);
						uploadFile($_FILES['file'], $filename);
						makeThumbnail($filename, UPLOAD_DIR, 150, '', 'medium');
						makeThumbnail($filename, UPLOAD_DIR, 50, '', 'thumb');
						makeThumbnail($filename, UPLOAD_DIR, 400, '', 'large');
						makeThumbnail($filename, UPLOAD_DIR, 600, '', 'xlarge');
						makeThumbnail($filename, UPLOAD_DIR, 250, '', 'post');
						$blog['filename'] = $filename;
					}
					if($_FILES['file']['podcast'] != "" ) { //uploading flash file
						$filename = fixFilename($_FILES['file']['podcast']);
						uploadFile($_FILES['file'], $filename);
						$blog['podcast'] = $filename;
					}
					dbPerform('blog', $blog, 'update', 'id = ' . $_POST['id']);
					
					addMessage("Blog post updated successfully");
					redirect(PAGE_MANAGE."?section=blog");
	
	break;
	case 'podcasts':
					$publish = explode('/', $_POST['pod_casts_publish_date']);