Please Select"; //create dropdown list for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); //echo "0".$qryItemRs[0].""; $str .= ""; } return $str; } function buildDropDownref_general1($table, $id, $name, $cond, $gid, $postItem)//($qryItem,$postItem) { include('config.php'); mysql_select_db($database, $connection); if ($gid == '') { $query_reference = "SELECT $id, $name FROM $table order by $name ASC"; } else { $query_reference = "SELECT $id, $name FROM $table WHERE $cond='$gid' order by $name ASC"; } echo $query_reference; $qryItem = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); //find number of rows $qryItemNumRows = mysql_num_rows($qryItem); //create nulls value for dropdown $str = "Please Select"; //create dropdown list for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); //echo "0".$qryItemRs[0].""; $str .= ""; } return $str; } function buildDropDownref_general1_noselect($table, $id, $name, $cond, $gid, $postItem)//($qryItem,$postItem) { include('config.php'); mysql_select_db($database, $connection); if ($gid == '') { $query_reference = "SELECT $id, $name FROM $table order by $name ASC"; } else { $query_reference = "SELECT $id, $name FROM $table WHERE $cond='$gid' order by $name ASC"; } echo $query_reference; $qryItem = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); //find number of rows $qryItemNumRows = mysql_num_rows($qryItem); //create nulls value for dropdown //$str = "Please Select"; //create dropdown list for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); //echo "0".$qryItemRs[0].""; $str .= ""; } return $str; } function buildDropDownref_general_page($table, $id, $name, $cond, $gid, $postItem,$not)//($qryItem,$postItem) { global $database, $connection; mysql_select_db($database, $connection); if ($gid == '') { $query_reference = "SELECT $id, $name FROM $table where advertisement_status !=1 order by $name ASC"; } elseif($not=='') { $query_reference = "SELECT $id, $name FROM $table WHERE $cond='$gid' and advertisement_status !=1 order by $name ASC"; } else { $query_reference = "SELECT $id, $name FROM $table WHERE $not AND $cond='$gid' and advertisement_status !=1 order by $name ASC"; } echo $query_reference; $qryItem = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); //find number of rows $qryItemNumRows = mysql_num_rows($qryItem); //create nulls value for dropdown $str = "-Please select-"; //create dropdown list for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); //echo "0".$qryItemRs[0].""; $str .= ""; } return $str; } function refname($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM ref_general WHERE ref_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['ref_name']; mysql_free_result($reference); return $namareference; } function convert_name($table, $ref_id, $id, $display) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT $display as ref_name FROM $table WHERE $ref_id='$id'"; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['ref_name']; mysql_free_result($reference); return $namareference; } function convert_namewhere($table, $ref_id, $id, $display, $where2) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT $display as ref_name FROM $table WHERE $where2 and $ref_id='$id'"; echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['ref_name']; mysql_free_result($reference); return $namareference; } function prod_name($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM product_cat WHERE cat_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['cat_name']; mysql_free_result($reference); return $namareference; } function get_sales_id($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM dealer_staff WHERE dealer_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['staff_id']; mysql_free_result($reference); return $namareference; } function get_content_detail($path_code, $slot_id, $page_id, $width, $height) { global $database, $connection; mysql_select_db($database, $connection); $str = ''; $query_reference = "SELECT * FROM page_content WHERE page_id='$page_id' AND slot_id='$slot_id'"; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $str = ""; for ($x = 0; $x < $totalRows_reference; $x++) { $row_reference = mysql_fetch_array($reference); $filename = 'files/' . $path_code . '/' . $row_reference['content_file']; // echo $filename; if (file_exists($filename)) { //echo "The file $filename exists"; $c2 = $filename; } else { //echo "The file $filename does not exist"; $c2 = "images/no-image1.png"; } if ($row_reference['content_type'] == 'IMG') { $str .= ""; $type = 'IMG'; } else { $str .= ""; $type = 'VIDEO'; } } /* if (($type =='IMG')|| (empty($type))) { $str .= "IMG"; } */ $str .= ""; $namareference = $str; //rtrim($str, ""); //$str; //$row_reference['dealer_id']; mysql_free_result($reference); return $namareference; } function get_content_total($path_code, $slot_id, $page_id, $width, $height) { global $database, $connection; mysql_select_db($database, $connection); $str = ''; $query_reference = "SELECT * FROM page_content WHERE page_id='$page_id' AND slot_id='$slot_id'"; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); //mysql_free_result($totalRows_reference); return $totalRows_reference; } function get_slot_data($slot_id, $slot_code, $page, $terminal, $width, $height, $path_code, $type, $orientation) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM page_content WHERE fmt_id='$terminal' and slot_id='$slot_id' and page_id='$page' "; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); //$img1 = $row_reference['content_file']; $filename = 'files/' . $path_code . '/' . $row_reference['content_file']; //echo $filename; if (file_exists($filename)) { //echo "The file $filename exists"; $c2 = 'thumbnailer.php?file='.urlencode($filename).'&width='.$width; } else { //echo "The file $filename does not exist"; $c2 = '';// "images/no-image1.png"; } //$data = "" ; $content = ''; if ($row_reference['content_type'] == 'IMG') { // $data .= $slot_code; // $data .= ""; } else if (($row_reference['content_type'] == 'MP4') || ($row_reference['content_type'] == 'AVI')) { $video_url = 'popup.php?file=' . $filename .'&width='.($width*1.5).'&height='.($height*1.5); // $data .= $slot_code; $c2 = 'img/terminal/video_logo1.png'; // $content = ' // // '; // } else { // $data .= $slot_code; // $data = ""; } $link_add = "content.php?action=add&slot_id=$slot_id&page_id=$page&fmt_id=$terminal&orientation=$orientation"; $link_view = "content.php?action=list&slot_id=$slot_id&page_id=$page&fmt_id=$terminal&type=$type&orientation=$orientation"; if($type!=3) { $content .= '[Add Content]'; $content .= ' [View Content]'; } $data = ''; $data .= ''.$slot_code. ''.$content; $data .= "\n".''; if($slot_id=='28') { $data = ''.$data; } if($slot_id=='30') { $data .= '';} mysql_free_result($reference); return $data; } function get_client_id($kod) { global $database, $connection; mysql_select_db($database, $connection); $str = ''; $query_reference = "SELECT Distinct(client_id) FROM user_client WHERE user_id='$kod'"; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); for ($x = 0; $x < $totalRows_reference; $x++) { $row_reference = mysql_fetch_array($reference); $str .= "-" . convert_name('client', 'client_id', $row_reference['client_id'], 'client_name') . ""; } $namareference = rtrim($str, ""); //$str; //$row_reference['dealer_id']; mysql_free_result($reference); return $namareference; } function get_dealer_id($kod) { global $database, $connection; mysql_select_db($database, $connection); $str = ''; $query_reference = "SELECT * FROM dealer_cat WHERE cat_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); for ($x = 0; $x < $totalRows_reference; $x++) { $row_reference = mysql_fetch_array($reference); $str .= $row_reference['dealer_id'] . "|"; } $namareference = $str; //$row_reference['dealer_id']; mysql_free_result($reference); return $namareference; } function convert_staff($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM users WHERE staff_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['user_name']; mysql_free_result($reference); return $namareference; } function usertype_staff($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM user_ref WHERE type_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['type_name']; mysql_free_result($reference); return $namareference; } function convert_company_type($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM dealer_type_code WHERE type_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['dealer_type']; mysql_free_result($reference); return $namareference; } function convert_dealer_group_type($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM dealer_group_code WHERE type_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['dealer_type']; mysql_free_result($reference); return $namareference; } function convert_country($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM country WHERE country_id='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['country_name']; mysql_free_result($reference); return $namareference; } function convert_email_ref($kod) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM email_ref WHERE type_code='$kod'"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['type_name']; mysql_free_result($reference); return $namareference; } function check_page($kod, $search_data, $search) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM page WHERE fmt_id='$kod' and $search = $search_data"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $namareference = $row_reference['page_id']; mysql_free_result($reference); return $namareference; } function page_protect() { session_start(); if (isset($_COOKIE['userid']) && isset($_COOKIE['username'])) { $_SESSION['userid'] = $_COOKIE['userid']; $_SESSION['username_m3'] = $_COOKIE['username']; } //if (!isset($_SESSION['user_id'])){ if (!isset($_SESSION['userid'])) { header("Location: index.php"); } } /* function reArrayFiles(&$file_post){ $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i=0; $i<$file_count; $i++){ foreach ($file_keys as $key){ $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } */ function encrypt($sData) { // $sData = trim($sData); $sKey = 'm3online'; $sResult = ''; for ($i = 0; $i < strlen($sData); $i++) { $sChar = substr($sData, $i, 1); $sKeyChar = substr($sKey, ($i % strlen($sKey)) - 1, 1); $sChar = chr(ord($sChar) + ord($sKeyChar)); $sResult .= $sChar; } return encode_base64($sResult); } function decrypt($sData) { //$sData = trim($sData); $sKey = 'm3online'; $sResult = ''; $sData = decode_base64($sData); for ($i = 0; $i < strlen($sData); $i++) { $sChar = substr($sData, $i, 1); $sKeyChar = substr($sKey, ($i % strlen($sKey)) - 1, 1); $sChar = chr(ord($sChar) - ord($sKeyChar)); $sResult .= $sChar; } return $sResult; } function encode_base64($sData) { $sBase64 = base64_encode($sData); return strtr($sBase64, '+/', '-_'); } function decode_base64($sData) { $sBase64 = strtr($sData, '-_', '+/'); return base64_decode($sBase64); } function get_prod_cat_list($country, $list_selected) { //echo $country; global $database, $connection; $prod = explode('|', $list_selected); $connection_data = $connection; mysql_select_db($database, $connection_data); $query_reference = "SELECT * FROM product_cat WHERE country_id = '" . $country . "' and status='1'"; $qryItem = mysql_query($query_reference, $connection_data) or die(mysql_error()); // echo $database_data." - ".$query_reference.""; //find number of rows checked="yes" $qryItemNumRows = mysql_num_rows($qryItem); //create nulls value for dropdown $str = " "; //create dropdown list for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); //echo "0".$qryItemRs[0].""; $str .= ""; } return $str; } function buildDropDown_refer1($table, $id, $name, $postItem, $datalist) { $datalist1 = str_replace('|', ',', $datalist); global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT $id, $name FROM $table where status='1' order by country_id, company, $name ASC"; //$id in ($datalist1) and $qryItem = mysql_query($query_reference, $connection) or die(mysql_error()); $qryItemNumRows = mysql_num_rows($qryItem); $str = ""; for ($x = 0; $x < $qryItemNumRows; $x++) { $qryItemRs = mysql_fetch_array($qryItem); $str .= ""; } return $str; } function upload($file_id, $folder = "", $types = "") { if (!$_FILES[$file_id]['name']) return array('', 'No file specified'); $file_title = $_FILES[$file_id]['name']; $file_title = str_replace(" ", "_", $file_title); //Get file extension $ext_arr = split("\.", basename($file_title)); $ext = strtolower($ext_arr[count($ext_arr) - 1]); //Get the last extension //Not really uniqe - but for all practical reasons, it is $uniqer = substr(md5(uniqid(rand(), 1)), 0, 3); $file_title1 = explode(".", $file_title); $file_name = $file_title1[0] . '_' . $uniqer . '.' . $file_title1[1]; //Get Unique Name $all_types = explode(",", strtolower($types)); if ($types) { if (in_array($ext, $all_types)) ; else { $result = " '" . $_FILES[$file_id]['name'] . "' is not a valid file. Please upload file with\"" . strtolower($types) . "\" extension only"; //Show error if any. return array('', $result); } } //Where the file must be uploaded to if ($folder) $folder .= '/'; //Add a '/' at the end of the folder $uploadfile = $folder . $file_name; $result = ''; //Move the file from the stored location to the new location if (!move_uploaded_file($_FILES[$file_id]['tmp_name'], $uploadfile)) { $result = "Cannot upload the file '" . $_FILES[$file_id]['name'] . "'"; //Show error if any. if (!file_exists($folder)) { $result .= " : Folder don't exist."; } elseif (!is_writable($folder)) { $result .= " : Folder not writable."; } elseif (!is_writable($uploadfile)) { $result .= " : File not writable."; } $file_name = ''; } else { if (!$_FILES[$file_id]['size']) { //Check if the file is made @unlink($uploadfile); //Delete the Empty file $file_name = ''; $result = "Empty file found - please use a valid file."; //Show the error message } else { chmod($uploadfile, 0777); $result = "Data Successfull Upload. Click Close button to exit"; //Make it universally writable. } } return array($file_name, $result); } function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } function createThumbs($pathToImages, $fname, $pathToThumbs, $thumbWidth) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if (strtolower($info['extension']) == 'jpg') { //echo "Creating thumbnail for {$fname} "; // load image and get image size $img = imagecreatefromjpeg("{$pathToImages}{$fname}"); $width = imagesx($img); $height = imagesy($img); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor($height * ( $thumbWidth / $width )); // create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); // copy and resize old image into new image imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // save thumbnail into a file imagejpeg($tmp_img, "{$pathToThumbs}{$fname}"); } else if (strtolower($info['extension']) == 'png') { //echo "Creating thumbnail for {$fname} "; // load image and get image size $img = imagecreatefrompng("{$pathToImages}{$fname}"); $width = imagesx($img); $height = imagesy($img); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor($height * ( $thumbWidth / $width )); // create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); // copy and resize old image into new image imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // save thumbnail into a file imagejpeg($tmp_img, "{$pathToThumbs}{$fname}"); } return array("{$pathToThumbs}{$fname}"); } function get_librarylist($width_slot,$height_slot,$type) { global $database, $connection; mysql_select_db($database, $connection); $query_reference = "SELECT * FROM content_library WHERE content_type='$type' and width='$width_slot' and height='$height_slot' "; //echo $query_reference; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); $row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); $width = $width_slot*0.15; $height = $height_slot*0.15; $data=''; //$img1 = $row_reference['content_file']; for ($x = 0; $x < $totalRows_reference; $x++) { $filename = 'files/library/' . $row_reference['content_file']; //echo $filename; if (file_exists($filename)) { //echo "The file $filename exists"; $c2 = 'thumbnailer.php?file='.urlencode($filename).'&width='.$width; } else { //echo "The file $filename does not exist"; $c2 = '';// "images/no-image1.png"; } //$data = "" ; $content = ''; if ($row_reference['content_type'] == 'IMG') { // $data .= $slot_code; // $data .= ""; } else if (($row_reference['content_type'] == 'MP4') || ($row_reference['content_type'] == 'AVI')) { $video_url = 'popup.php?file=' . $filename .'&width='.($width*1.5).'&height='.($height*1.5); // $data .= $slot_code; $c2 = 'img/terminal/video_logo1.png'; // $content = ' // // '; // } else { // $data .= $slot_code; // $data = ""; } $data .= ''; $data .= ''.$slot_code. ''.$content; $data .= "\n".''; } mysql_free_result($reference); return $data; } function check_main($kod) { global $database, $connection; mysql_select_db($database, $connection); $data =''; $query_reference = "SELECT * FROM page WHERE fmt_id='$kod' and (main_page_status='1' OR advertisement_status='1')"; $reference = mysql_query($query_reference, $connection) or die(mysql_error()); //$row_reference = mysql_fetch_assoc($reference); $totalRows_reference = mysql_num_rows($reference); if ($totalRows_reference >'0') { for($x=0;$x<$totalRows_reference; $x++) { $row_reference = mysql_fetch_array($reference); $data .=$row_reference['page_id'].","; } //echo $data; $data = rtrim($data,','); $query_reference1 = "SELECT * FROM page_content WHERE fmt_id = '$kod' AND page_id IN ($data)"; //echo $query_reference1; $reference1 = mysql_query($query_reference1, $connection) or die(mysql_error()); $row_reference1 = mysql_fetch_assoc($reference1); $totalRows_reference = mysql_num_rows($reference1); //$namareference = $row_reference['staff_id']; mysql_free_result($reference); } else { $totalRows_reference ='0'; } return $totalRows_reference; } ?>