Beispiel #1
0
 public function update()
 {
     $product_id = 0;
     // Redirect to product create if product_id is not exists
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         // Log hack attempt
         $this->security_log->write('Try to get product without product_id param');
         $this->response->redirect($this->url->link('account/product/create'));
     }
     // Redirect to login page if user is not logged
     if (!$this->auth->isLogged()) {
         $this->response->redirect($this->url->link('account/account/login', 'redirect=' . urlencode($this->url->link('account/product/update', 'product_id=' . $product_id))));
     }
     // Check if user has product
     if (!$this->model_catalog_product->userHasProduct($this->auth->getId(), $product_id)) {
         // Log hack attempt
         $this->security_log->write('Try to get not own\'s product_id #' . $product_id);
         // Redirect to safe page
         $this->response->redirect($this->url->link('account/product'));
     }
     if ('POST' == $this->request->getRequestMethod() && $this->_validateProductForm()) {
         // Load dependencies
         $translate = new Translate();
         $color = new Color();
         // Create languages registry
         $languages = array();
         foreach ($this->model_common_language->getLanguages() as $language) {
             $languages[$language->language_id] = $language->code;
         }
         // Set active directory
         $directory = DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR;
         // Start transaction
         $this->db->beginTransaction();
         // Add product
         $this->model_catalog_product->updateProduct($product_id, $this->request->post['category_id'], $this->request->post['currency_id'], $this->request->post['regular_price'], $this->request->post['exclusive_price'], $this->request->post['withdraw_address'], FilterUri::alias($this->request->post['product_description'][$this->language->getId()]['title']), (int) $this->auth->isVerified());
         // Add 301 rule if product has new URI
         $url = new Url($this->db, $this->request, $this->response, $this->url->link('common/home'));
         $old_url = $this->url->link('catalog/product', 'product_id=' . $product_id);
         $new_url = $url->link('catalog/product', 'product_id=' . $product_id);
         if ($old_url != $new_url) {
             $this->model_common_redirect->createRedirect(301, str_replace($this->url->link('common/home'), false, $old_url), str_replace($this->url->link('common/home'), false, $new_url));
         }
         // Add product description
         $this->model_catalog_product->deleteProductDescriptions($product_id);
         foreach ($this->request->post['product_description'] as $language_id => $product_description) {
             $this->model_catalog_product->createProductDescription($product_id, $language_id, empty(trim($product_description['title'])) ? $translate->string($this->request->post['product_description'][$this->language->getId()]['title'], $this->language->getCode(), $languages[$language_id]) : $product_description['title'], empty(trim($product_description['description'])) ? $translate->string($this->request->post['product_description'][$this->language->getId()]['description'], $this->language->getCode(), $languages[$language_id]) : $product_description['description']);
         }
         // Add Tags
         $this->model_catalog_product->deleteProductToTagByProductId($product_id);
         // Prepare tags from request
         foreach ($this->request->post['product_description'] as $language_id => $product_description) {
             // Process current language not empty field only
             if (!empty($product_description['tags']) && $language_id == $this->language->getId()) {
                 // Separate a tags string and create multilingual registry
                 foreach (explode(',', $product_description['tags']) as $name) {
                     // Get tag id
                     $name = mb_strtolower(trim($name));
                     // Saved tags registry
                     if ($tag = $this->model_catalog_tag->getTagByName($name)) {
                         $tag_id = $tag->tag_id;
                     } else {
                         // Create new tag
                         $tag_id = $this->model_catalog_tag->addTag();
                         // Create descriptions for each language
                         foreach ($languages as $language_id => $code) {
                             $this->model_catalog_tag->addTagDescription($tag_id, $language_id, $translate->string($name, $this->language->getCode(), $code));
                         }
                     }
                     // Save new relations
                     $this->model_catalog_product->addProductToTag($product_id, $tag_id);
                 }
             }
         }
         // Add file
         if ($file_content = file_get_contents($directory . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION)) {
             $this->model_catalog_product->deleteProductFiles($product_id);
             $product_file_id = $this->model_catalog_product->createProductFile($product_id, md5($file_content), sha1($file_content));
             rename($directory . $this->request->post['product_file_id'] . '.' . STORAGE_FILE_EXTENSION, $directory . $product_file_id . '.' . STORAGE_FILE_EXTENSION);
         }
         // Add demos
         $this->model_catalog_product->deleteProductDemos($product_id);
         if (isset($this->request->post['demo'])) {
             foreach ($this->request->post['demo'] as $row => $demo) {
                 $product_demo_id = $this->model_catalog_product->createProductDemo($product_id, $demo['sort_order'], $demo['url'], $this->request->post['main_demo'] == $row ? 1 : 0);
                 foreach ($demo['title'] as $language_id => $title) {
                     $this->model_catalog_product->createProductDemoDescription($product_demo_id, $language_id, empty(trim($title)) ? $translate->string($demo['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
                 }
             }
         }
         // Update images
         $this->model_catalog_product->deleteProductImages($product_id);
         if (isset($this->request->post['image'])) {
             foreach ($this->request->post['image'] as $row => $image) {
                 // Add new images
                 $product_image_id = $this->model_catalog_product->createProductImage($product_id, $image['sort_order'], $this->request->post['main_image'] == $row ? 1 : 0, isset($image['watermark']) ? 1 : 0);
                 // Generate image titles
                 foreach ($image['title'] as $language_id => $title) {
                     $this->model_catalog_product->createProductImageDescription($product_image_id, $language_id, empty(trim($title)) ? $translate->string($image['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
                 }
                 // Extract image colors
                 if ($color->setImage($directory . $image['product_image_id'] . '.' . STORAGE_IMAGE_EXTENSION) && ($colors = $color->getColors())) {
                     foreach ($colors as $key => $value) {
                         $this->model_catalog_product->createProductImageColor($product_image_id, $value['hex'], $value['hue'], $value['saturation'], $value['value'], $value['red'], $value['green'], $value['blue'], $value['frequency']);
                     }
                 }
                 rename($directory . $image['product_image_id'] . '.' . STORAGE_IMAGE_EXTENSION, $directory . $product_image_id . '.' . STORAGE_IMAGE_EXTENSION);
             }
             // Generate unique image if others images is not exists
         } else {
             $product_image_id = $this->model_catalog_product->createProductImage($product_id, 1, 1, 0, 1);
             // Generate image titles from product title
             foreach ($this->request->post['product_description'] as $language_id => $product_description) {
                 $this->model_catalog_product->createProductImageDescription($product_image_id, $language_id, empty(trim($product_description['title'])) ? $translate->string($this->request->post['product_description'][$this->language->getId()]['title'], $this->language->getCode(), $languages[$language_id]) : $product_description['title']);
             }
             $identicon = new Identicon();
             $image = new Image($identicon->generateImageResource(sha1($product_id), PRODUCT_IMAGE_ORIGINAL_WIDTH, PRODUCT_IMAGE_ORIGINAL_HEIGHT), true);
             $image->save(DIR_STORAGE . $this->auth->getId() . DIR_SEPARATOR . $product_image_id . '.' . STORAGE_IMAGE_EXTENSION);
         }
         // Add videos
         $this->model_catalog_product->deleteProductVideos($product_id);
         if (isset($this->request->post['video'])) {
             foreach ($this->request->post['video'] as $video) {
                 $product_video_id = $this->model_catalog_product->createProductVideo($product_id, isset($video['reduce']) ? 1 : 0, $video['sort_order']);
                 foreach ($video['title'] as $language_id => $title) {
                     $this->model_catalog_product->createProductVideoDescription($product_video_id, $language_id, empty(trim($title)) ? $translate->string($video['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
                 }
                 rename($directory . $video['product_video_id'] . '.' . STORAGE_VIDEO_EXTENSION, $directory . $product_video_id . '.' . STORAGE_VIDEO_EXTENSION);
             }
         }
         // Add audios
         $this->model_catalog_product->deleteProductAudios($product_id);
         // Add audios
         if (isset($this->request->post['audio'])) {
             foreach ($this->request->post['audio'] as $audio) {
                 $product_audio_id = $this->model_catalog_product->createProductAudio($product_id, isset($audio['cut']) ? 1 : 0, $audio['sort_order']);
                 foreach ($audio['title'] as $language_id => $title) {
                     $this->model_catalog_product->createProductAudioDescription($product_audio_id, $language_id, empty(trim($title)) ? $translate->string($audio['title'][$this->language->getId()], $this->language->getCode(), $languages[$language_id]) : $title);
                 }
                 rename($directory . $audio['product_audio_id'] . '.' . STORAGE_AUDIO_EXTENSION, $directory . $product_audio_id . '.' . STORAGE_AUDIO_EXTENSION);
             }
         }
         // Add specials
         $this->model_catalog_product->deleteProductSpecials($product_id);
         if (isset($this->request->post['special'])) {
             foreach ($this->request->post['special'] as $special) {
                 $this->model_catalog_product->createProductSpecial($product_id, $special['regular_price'], $special['exclusive_price'], $special['date_start'], $special['date_end'], $special['sort_order']);
             }
         }
         // Add license conditions
         $this->model_catalog_product->deleteLicenseConditions($product_id);
         if (isset($this->request->post['license_conditions'])) {
             foreach ($this->request->post['license_conditions'] as $license_condition_id => $value) {
                 $this->model_catalog_product->addLicenseConditionValue($product_id, $license_condition_id);
             }
         }
         $this->db->commit();
         // Cleaning
         $this->cache->clean($this->auth->getId());
         $this->storage->clean($this->auth->getId());
         // Set success message
         $this->session->setUserMessage(array('success' => tt('Product successfully updated!')));
         // Admin alert if current user is not verified (updated product has been disabled)
         if (!$this->auth->isVerified()) {
             $this->mail->setSender($this->auth->getEmail());
             $this->mail->setFrom($this->auth->getEmail());
             $this->mail->setTo(MAIL_EMAIL_SUPPORT_ADDRESS);
             $this->mail->setSubject(sprintf(tt('Product has been updated - %s'), PROJECT_NAME));
             $this->mail->setText(sprintf(tt('Product ID %s by %s has been updated and waiting for approving!'), $product_id, $this->auth->getUsername()));
             $this->mail->send();
         }
         $this->response->redirect($this->url->link('account/product'));
     }
     $data = $this->_populateForm($this->url->link('account/product/update', 'product_id=' . $product_id));
     $data['footer'] = $this->load->controller('common/footer');
     $data['header'] = $this->load->controller('common/header');
     $data['module_breadcrumbs'] = $this->load->controller('module/breadcrumbs', array(array('name' => tt('Home'), 'href' => $this->url->link('common/home'), 'active' => false), array('name' => tt('Product list'), 'href' => $this->url->link('account/product'), 'active' => false), array('name' => tt('Update product'), 'href' => $this->url->link('account/product/update', 'product_id=' . $product_id), 'active' => true)));
     // Renter the template
     $this->response->setOutput($this->load->view('account/product/product_form.tpl', $data));
 }
Beispiel #2
0
            echo $page == $i ? "selected" : "";
            ?>
><?php 
            echo Translate::string("results.page");
            ?>
 <?php 
            echo $i + 1;
            ?>
 of <?php 
            echo $total;
            ?>
</option>
				<?php 
        }
        ?>
			</select>
			<input type="hidden" id="total-pages" value="<?php 
        echo $total;
        ?>
">
			<a href="" class="btn next-page"><?php 
        echo Translate::string("results.next_page");
        ?>
 &#9654;</a>
		</section>
	<?php 
    }
    ?>
	<script src="lib/js/results-list.js"></script>
<?php 
}
&sub_cat_id=<?php 
        echo $cat["id"];
        ?>
#advert-create"><?php 
        echo Translate::string("categorySub." . Product::slugify($cat["name"]));
        ?>
</a></label>
	</li>
	<?php 
    }
} else {
    ?>
	<li>
		<input type="radio" name="subCategory" value="" id="sub-cat-0">
		<label for="sub-cat-0"><?php 
    echo Translate::string("categories.no_sub_categories");
    ?>
</label>
	</li>
<?php 
}
?>

<script type="text/javascript">
	$("#create-sub-cat li").unbind().click(function (e) {
		e.preventDefault();
		// uncheck whatever was checked before by the php $_GET
		$("#create-sub-cat input").prop("checked", false);
		// make the currently clicked input to checked
		$(this).children("input").prop("checked", true);
	});
Beispiel #4
0
							<div id="uploaded_images"></div>
						</div>
					</div>
				</div>

				<div id="step-2" class="hidden">
					<h1><?php 
    echo Translate::string("create_ad.preview_of_your_advertisement");
    ?>
</h1>
					<div id="preview-container">
						<?php 
    // include("lib/ajax/advertisement-expanded.php");
    ?>
					</div>
					<button class="fullwidth" style="margin:60px 0 10px 0;"><?php 
    echo Translate::string("create_ad.continue_to_next_step");
    ?>
</button>
					<button class="fullwidth" ><?php 
    echo Translate::string("create_ad.make_changes");
    ?>
</button>
				</div>
				<div id="step-3" class="hidden"></div>
			<?php 
}
?>
		</div>
	</section><?php 
// #advert-create
$birthday = $_POST["birthday"];
// optional
$password = $_POST["password"];
$confirm_password = $_POST["confirm_password"];
$javascript = $_POST["javascript"];
$javascript = 1;
$role_id = 2;
$lang_id = 1;
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
    require_once "../classes/" . $class . ".class.php";
});
if ($password != $confirm_password) {
    die(Translate::string("register_alert.passwords_dont_match"));
}
if (empty($name) or empty($email) or empty($phone) or empty($password) or empty($confirm_password)) {
    die(Translate::string("register_alert.fill_out_all_fields"));
} else {
    try {
        $user = new User();
        $user->company_name = $company_name;
        $user->company_number = $company_number;
        $user->company_address = $company_address;
        $user->company_zip = $company_zip;
        $user->phone_2 = $phone_2;
        $user->registerUser($name, $role_id, $email, $password, $phone, $lang_id, $birthday, $javascript, true);
        echo Translate::string("register_alert.registration_success_please_login");
    } catch (Exception $e) {
        echo '' . $e->getMessage();
    }
}
    public function input($settings = array(), $values = array())
    {
        // Setting the defaults
        if (!empty($settings["id"])) {
            $id = $settings["id"];
        } else {
            $id = "";
        }
        if (!empty($settings["type"])) {
            $type = $settings["type"];
        } else {
            $type = "text";
        }
        if (!empty($settings["class"])) {
            $class = $settings["class"];
        } else {
            $class = "";
        }
        if (!empty($settings["inputClass"])) {
            $inputClass = $settings["inputClass"];
        } else {
            $inputClass = "";
        }
        if (!empty($settings["required"])) {
            $required = $settings["required"];
        } else {
            $required = "";
        }
        if (!empty($settings["inlineCss"])) {
            $inlineCss = $settings["inlineCss"];
        } else {
            $inlineCss = "";
        }
        if (!empty($settings["value"])) {
            $value = $settings["value"];
        } else {
            $value = "";
        }
        if (!empty($settings["placeholder"])) {
            $placeholder = $settings["placeholder"];
        } else {
            $placeholder = "";
        }
        if (!empty($settings["label"])) {
            $label = $settings["label"];
        } else {
            $label = "";
        }
        if (!empty($settings["labelID"])) {
            $labelID = $settings["labelID"];
        } else {
            $labelID = "";
        }
        if (!empty($settings["labelClass"])) {
            $labelClass = $settings["labelClass"];
        } else {
            $labelClass = "";
        }
        if (!empty($settings["more"])) {
            $more = $settings["more"];
        } else {
            $more = false;
        }
        if (!empty($settings["name"])) {
            $name = $settings["name"];
        } else {
            $name = "";
        }
        if (!empty($settings["autocomplete"])) {
            $autocomplete = true;
        } else {
            $autocomplete = false;
        }
        $lang = "eng";
        $attribute_name = "name";
        if (isset($_SESSION["lang"])) {
            $lang = $_SESSION["lang"];
            if ($lang == "nor") {
                $attribute_name = "name_nor";
            }
        }
        $count = 1;
        if ($type == "checkbox" or $type == "radio") {
            ?>
			<div class="form-element <?php 
            echo $type;
            ?>
 <?php 
            echo $class;
            ?>
">
				<span><?php 
            echo $label;
            ?>
</span>
				<div class="form-element-wrap">
				<?php 
            foreach ($values as $value) {
                ?>
					<?php 
                $count++;
                if (!($valueName = $value[$attribute_name])) {
                    $valueName = $value["name"];
                }
                ?>
					<div class="element-wrap">
						<input id="<?php 
                echo $value['slug'] . '-' . $count;
                ?>
" <?php 
                if ($inputClass) {
                    echo "class='" . $inputClass . "'";
                }
                ?>
 value="<?php 
                echo $value['slug'];
                ?>
" <?php 
                if ($inlineCss) {
                    echo "style='" . $inlineCss . "'";
                }
                ?>
 <?php 
                if ($required) {
                    echo "required='required'";
                }
                ?>
 <?php 
                if ($name) {
                    echo "name='" . $name . "[]'";
                }
                ?>
 type="<?php 
                echo $type;
                ?>
">
						<label for="<?php 
                echo $value['slug'] . '-' . $count;
                ?>
" ><?php 
                echo $valueName;
                ?>
</label>
					</div>
				<?php 
            }
            ?>
				<?php 
            if ($more) {
                ?>
					<div class="add-more-checkbox-wrap hidden">
						<input type="checkbox" checked="true" ><label></label>
						<input autocomplete="off" type="text" <?php 
                if ($name) {
                    echo "name='" . $name . "[]'";
                }
                ?>
 class="add-more-checkbox-input" >
						<div title="Remove" class="remove-checkbox-input">X</div>
					</div>
					<a href="?more" class="btn add-more-checkbox-btn">+ <?php 
                echo Translate::string("form.add_more_btn");
                ?>
</a>
				<?php 
            }
            ?>
				</div>
			</div>

			<?php 
        } else {
            echo "<div class='form-element {$class}'>";
            if ($label) {
                ?>
<label <?php 
                if ($labelID) {
                    echo "id='" . $labelClass . "'";
                }
                ?>
 <?php 
                if ($id) {
                    echo "for='" . $id . "'";
                }
                ?>
 <?php 
                if ($labelClass) {
                    echo "class='" . $labelClass . "'";
                }
                ?>
 ><?php 
                echo $label;
                ?>
</label> <?php 
            }
            if ($type == "number") {
                ?>
				<div class="number-input-wrap">
			<?php 
            }
            ?>
				<input <?php 
            if ($id) {
                echo "id='" . $id . "'";
            }
            ?>
 <?php 
            if ($inputClass) {
                echo "class='" . $inputClass . "'";
            }
            ?>
 <?php 
            if (!$autocomplete) {
                echo "autocomplete='off'";
            }
            ?>
 <?php 
            if ($placeholder) {
                echo "placeholder='" . $placeholder . "'";
            }
            ?>
 <?php 
            if ($value) {
                echo "value='" . $value . "'";
            }
            ?>
 <?php 
            if ($inlineCss) {
                echo "style='" . $inlineCss . "'";
            }
            ?>
 <?php 
            if ($required) {
                echo "required='required'";
            }
            ?>
 <?php 
            if ($name) {
                echo "name='" . $name . "'";
            }
            ?>
 type="<?php 
            echo $type == "number" ? 'text' : $type;
            ?>
">
			<?php 
            if ($type == "number") {
                ?>
					<div class="number-input-controls">
						<button type="button" class="number-input-up"><img src="lib/images/elements/triangle_up.svg"></button>
						<button type="button" class="number-input-down"><img src="lib/images/elements/triangle_down.svg"></button>
					</div>
				</div>
			<?php 
            }
            echo '</div>';
        }
    }
Beispiel #7
0
<?php

require_once "../includes/session.php";
require_once "../includes/sanitize-all.php";
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
    require_once "../classes/" . $class . ".class.php";
});
if (empty($_POST["email"]) or empty($_POST["token"]) or empty($_POST["new-reset-password"]) or empty($_POST["confirm-reset-password"]) or empty($_POST["javascript"])) {
    die(Translate::string("reset_password_alert.all_fields_required"));
}
if ($_POST["new-reset-password"] != $_POST["confirm-reset-password"]) {
    die(Translate::string("reset_password_alert.passwords_dont_match"));
}
$email = $_POST["email"];
$token = $_POST["token"];
$new_password = $_POST["new-reset-password"];
$session_id = session_id();
$ip_address = $_SERVER['REMOTE_ADDR'];
$javascript = $_POST["javascript"];
$browser = $_SERVER['HTTP_USER_AGENT'];
if (!User::isTokenValid($email, $token)) {
    die(Translate::string("reset_password_alert.token_expired"));
}
$user = new User();
$reset = $user->resetPassword($email, $new_password);
if (!$reset or !$user->destroyToken($token)) {
    die(Translate::string("reset_password_alert.something_went_wrong"));
}
$user->insertLog("password changed", $email, $javascript, $browser, $ip, $session_id);
$user->checkCredentials($email, $new_password, $javascript, $browser, $ip_address, $session_id);
        ?>
			<form id="reset-password-form" action="lib/ajax/reset-password.php" method="post" >
				<input type="hidden" name="token" required="required" value="<?php 
        echo $_GET["reset-password"];
        ?>
">
				<input type="hidden" name="email" required="required" value="<?php 
        echo $_GET["email"];
        ?>
">
				<input class="hidden javascript-check" type="checkbox" name="javascript" value="1">
				<?php 
        FormElement::input(array('id' => "new-reset-password", 'name' => "new-reset-password", 'label' => Translate::string("reset_password.new_passoword_label"), 'placeholder' => Translate::string("reset_password.new_passoword_placeholder"), 'type' => "password", 'required' => true));
        FormElement::input(array('id' => "confirm-reset-password", 'name' => "confirm-reset-password", 'label' => Translate::string("reset_password.new_passoword_confirm_label"), 'placeholder' => Translate::string("reset_password.new_passoword_confirm_placeholder"), 'type' => "password", 'required' => true));
        ?>
				<button>Reset Password</button>
			</form>
			
			<?php 
        $reset_password_modal_content = ob_get_contents();
        ob_end_clean();
        // end recording
    } else {
        $reset_password_modal_content = "<p>" . Translate::string("reset_password.expired_token") . "</p>";
    }
    $reset_password_modal_id = "reset-password";
    $reset_password_modal_title = Translate::string("reset_password.modal_title");
    $reset_password_modal_footer = '<a href="#">' . Translate::string("reset_password.modal_footer") . '</a>';
    // get the modal
    DocElement::modal($reset_password_modal_id, $reset_password_modal_title, $reset_password_modal_content, $reset_password_modal_footer);
}
Beispiel #9
0
// Get language registry
$statement = $db->query('SELECT * FROM `language`');
$languages = array();
foreach ($statement->fetchAll() as $language) {
    $languages[$language->language_id] = $language->code;
}
// Translate product descriptions
$statement = $db->query("SELECT * FROM `product_description` WHERE `title` = '' OR description = ''");
if ($statement->rowCount()) {
    foreach ($statement->fetchAll() as $untranslated) {
        // Get translated data
        $translated = $db->prepare("SELECT `product_id`, `language_id`, `title`, `description` FROM `product_description` WHERE `title` <> '' AND `description` <> '' AND `product_id` = ? LIMIT 1");
        $translated->execute(array($untranslated->product_id));
        if ($translated->rowCount() && ($translated = $translated->fetch())) {
            // Translate title
            if (empty($untranslated->title) && false !== ($title = $translate->string($translated->title, $languages[$translated->language_id], $languages[$untranslated->language_id]))) {
                $update = $db->prepare("UPDATE `product_description` SET `title` = ? WHERE `product_id` = ? AND `language_id` = ? LIMIT 1");
                $update->execute(array($title, $untranslated->product_id, $untranslated->language_id));
                $total_translated++;
            }
            // Translate description
            if (empty($untranslated->description) && false !== ($description = $translate->string($translated->description, $languages[$translated->language_id], $languages[$untranslated->language_id]))) {
                $update = $db->prepare("UPDATE `product_description` SET `description` = ? WHERE `product_id` = ? AND `language_id` = ? LIMIT 1");
                $update->execute(array($description, $untranslated->product_id, $untranslated->language_id));
                $total_translated++;
            }
        }
    }
}
// Translate tag descriptions
$statement = $db->query("SELECT * FROM `tag_description` WHERE `name` = ''");
Beispiel #10
0
        require_once "../classes/" . $class . ".class.php";
    });
    require_once "../includes/sanitize-all.php";
    require_once "../includes/session.php";
    $top_ad_page = $_POST["top_ad_page"];
    $categoryID = $_POST["categoryID"];
    $hidden = "hidden";
} else {
    $hidden = "";
    $top_ad_page = 0;
    $categoryID = "%";
}
?>
	<div class="container">
		<h2><?php 
echo Translate::string("top_ads.title");
?>
</h2>
		<!--ajax-->
		<div class="top-ad-container">
			<div id="top-ad-pages">
				<div class="top-ad-page<?php 
echo $top_ad_page;
?>
 top-ad-page <?php 
echo $hidden;
?>
 currentTopAdPage" data-top-ad-page-id="<?php 
echo $top_ad_page;
?>
">
Beispiel #11
0
    public function getSelectOfAllCategories($settings = array())
    {
        // name, order, first-option, id, class
        // Setting the defaults
        if (!empty($settings["id"])) {
            $id = $settings["id"];
        } else {
            $id = false;
        }
        if (!empty($settings["class"])) {
            $class = $settings["class"];
        } else {
            $class = false;
        }
        if (!empty($settings["name"])) {
            $name = $settings["name"];
        } else {
            $name = "category";
        }
        if (!empty($settings["required"])) {
            $required = $settings["required"];
        } else {
            $required = false;
        }
        if (!empty($settings["multiple"])) {
            $multiple = $settings["multiple"];
        } else {
            $multiple = false;
        }
        if (!empty($settings["inlineCss"])) {
            $inlineCss = $settings["inlineCss"];
        } else {
            $inlineCss = false;
        }
        if (!empty($settings["price"])) {
            $price = $settings["price"];
        } else {
            $price = false;
        }
        if (!empty($settings["order"])) {
            $order = $settings["order"];
        } else {
            $order = "name ASC";
        }
        if (!empty($settings["first-option"])) {
            $first_option = $settings["first-option"];
        } else {
            $first_option = "-- Select Category --";
        }
        $this->query("SELECT DISTINCT m.* FROM categories_main as m, categories_sub as s WHERE m.id = s.main_cat_id ORDER BY " . $order);
        $mainCategories = $this->fetchAll();
        ?>
		<select name="<?php 
        echo $name;
        ?>
" <?php 
        if ($id) {
            echo "id='" . $id . "'";
        }
        ?>
 <?php 
        if ($class) {
            echo "class='" . $class . "'";
        }
        ?>
 <?php 
        if ($required) {
            echo "required";
        }
        ?>
 <?php 
        if ($multiple) {
            echo "multiple";
        }
        ?>
 <?php 
        if ($inlineCss) {
            echo "style='" . $inlineCss . "'";
        }
        ?>
>
			<option value=""><?php 
        echo $first_option;
        ?>
</option>
			<?php 
        if ($mainCategories) {
            ?>
				<?php 
            foreach ($mainCategories as $mCat) {
                ?>
					<optgroup label="<?php 
                echo Translate::string("categoryMain." . Product::slugify($mCat['name']));
                ?>
">
						<?php 
                $this->query("SELECT id, name FROM categories_sub WHERE main_cat_id = :mCatID ORDER BY " . $order);
                $this->bind(':mCatID', $mCat['id']);
                $subCategories = $this->fetchAll();
                ?>
						<?php 
                foreach ($subCategories as $sCat) {
                    ?>
							<option value="<?php 
                    echo $sCat['id'];
                    ?>
" ><?php 
                    echo Translate::string("categorySub." . Product::slugify($sCat['name']));
                    // if ($price) { echo " (".$sCat['price_dkk']." DKK)"; }
                    ?>
</option>
						<?php 
                }
                ?>
					</optgroup>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
		</select>
		<?php 
    }
Beispiel #12
0
?>
</em> <?php 
echo $user_info["name"];
?>
</p>
		<p><em><?php 
echo Translate::string("contact_seller_modal.email");
?>
</em> <a href="mailto:<?php 
echo $user_info["email"];
?>
"><?php 
echo $user_info["email"];
?>
</a></p>
		<p><em><?php 
echo Translate::string("contact_seller_modal.phone");
?>
</em> <a href="tel:<?php 
echo $user_info["phone"];
?>
"><?php 
echo $user_info["phone"];
?>
</a></p>
		<?php 
// 	$modal_content = ob_get_contents();
// ob_end_clean(); // end recording
// echo $modal_content;
// get the modal
// DocElement::modal($alert_modal_id, $title, $modal_content, $footer);
Beispiel #13
0
        <a href="#" class="left" id="logo" style="position: relative;">
            <img src="lib/images/elements/logo.svg" alt="finnplus logo image">
            <span style="font-family: 'Lato', sans-serif; font-weight: 300; font-size: 1rem; position: absolute; left: 0; bottom: 2.2rem; color: #2b3990;" >New or Used</span>
            <span style="font-family: 'Lato', sans-serif; font-weight: 300; font-size: 1rem; position: absolute; right: 1.2rem; bottom: 2.2rem; color: #2b3990;" >Buy or Sell</span>
        </a>

        <div class="two-third right">
            <div id="search-container">
                <form id="search-form" action="main-search.php" method="GET" role="search">
                    <?php 
$select_options = array("id" => "search-cat-select", "class" => "btn", "name" => "category", "first-option" => Translate::string("header.main_search_category_first_option"), "required" => false);
$db->getSelectOfAllCategories($select_options);
?>
                    <span id="search-cat-span" class="btn"><?php 
echo Translate::string("header.main_search_category_first_option");
?>
</span>
                    <input type="text" name="search" placeholder="<?php 
echo Translate::string("header.main_search_placeholder");
?>
" required="required">
                    <button type="submit" id="search-btn"><?php 
echo Translate::string("header.main_search_button");
?>
</button>
                </form>
            </div>
        </div>
    </div>
</section><?php 
// #header
Beispiel #14
0
if (!$_SESSION) {
    session_start();
}
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
    require_once "../classes/" . $class . ".class.php";
});
if (empty($_POST["email"])) {
    die(Translate::string("forgot_password.email_missing"));
} else {
    require_once "../includes/sanitize-all.php";
    $email = $_POST["email"];
    if (!User::userEmailExist($email)) {
        die(Translate::string("forgot_password.wrong_email"));
    }
    $token = User::insertToken($email);
    if (!$token) {
        die("token insert failed");
    }
    $reset_link = "http://www.finnplus.no/?reset-password="******"&email=" . urlencode($email);
    $mailto = $email;
    $subject = Translate::string("forgot_password.email_subject");
    $headers = "Mime-Version: 1.0 \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
    $headers .= "From: <*****@*****.**> \r\n";
    // $headers .= "Reply-to: info@finnplus.no \r\n";
    $message = sprintf(Translate::string("forgot_password.email_message"), "<br><a href='" . $reset_link . "'>", $reset_link . "</a><hr>");
    $send_mail = mail($mailto, $subject, $message, $headers);
    // Send the email
    echo $send_mail ? Translate::string("forgot_password.email_send_success_message") : Translate::string("forgot_password.email_send_failure_message");
}
Beispiel #15
0
    public function getCompareItem($advert_id)
    {
        $db = new Database();
        $db->query("SELECT id, title, price, currency, city_name, country_code, zip, date_created FROM products_view WHERE id = :id LIMIT 1");
        $db->bind(":id", $advert_id);
        $advert = $db->single();
        if ($advert) {
            $db->query("SELECT uuid FROM product_images WHERE product_id = :id ORDER BY date_uploaded ASC LIMIT 1");
            $db->bind(":id", $advert_id);
            $advert_img = $db->single();
            ?>
			<div class="compare-item row">
				<div class="cell"><div class="compare-thumb"><img alt="test image" src="lib/images/uploads/thumbnail/<?php 
            echo $advert_img["uuid"];
            ?>
"></div></div>
				<div class="cell"><?php 
            echo $advert["id"];
            ?>
</div>
				<div class="cell"><?php 
            echo $advert["title"];
            ?>
</div>
				<div class="cell"><?php 
            echo $advert["price"];
            ?>
 <?php 
            echo $advert["currency"];
            ?>
</div>
				<div class="cell"><?php 
            echo $advert["city_name"];
            ?>
 (<?php 
            echo $advert["zip"];
            ?>
), <?php 
            echo strtoupper($advert["country_code"]);
            ?>
</div>
				<div class="cell"><?php 
            echo $advert["date_created"];
            ?>
</div>
				<div class="cell"><a data-id="<?php 
            echo $advert["id"];
            ?>
<" class="remove-link remove-from-compare-btn"><?php 
            echo Translate::string("compare.remove");
            ?>
</a></div>
			</div>
			<?php 
        } else {
            echo "<p>No advert found for compare</p>";
        }
    }
Beispiel #16
0
<?php

if (!$_SESSION) {
    session_start();
}
// define('ALLOW_ACCESS', true); // allow access to this page
defined('ALLOW_ACCESS') or die('Restricted access');
// Security to prevent direct access to php files.
?>
<section id="advert-intro">
	<div class="container">
		<h2><?php 
echo Translate::string("create_ad.main_title");
?>
</h2>
		<h3><?php 
echo Translate::string("create_ad.main_sub_title");
?>
</h3>
	</div>
</section><?php 
#advert-intro
Beispiel #17
0
				<p class="ad-detail">
					<span class="ad-detail-label"><?php 
    echo Translate::string("ad_item.location");
    ?>
</span>
					<span class="ad-detail-text"><?php 
    echo $p["city_name"];
    ?>
 (<?php 
    echo $p["zip"];
    ?>
)</span>
				</p>
				<p class="ad-detail">
					<span class="ad-detail-label"><?php 
    echo Translate::string("ad_item.created");
    ?>
 </span>
					<span class="ad-detail-text"><?php 
    echo strftime("%d. %B %Y", strtotime($p["date_created"]));
    ?>
</span>
				</p>
			<footer>
				<p class="price"><?php 
    echo $p["price"];
    ?>
 <?php 
    echo $p["currency"];
    ?>
</p>
Beispiel #18
0
?>
";
		var form_view_all_elements = "<?php 
echo Translate::string('form.view_all_elements');
?>
";
		var results_list_title = "<?php 
echo Translate::string('results_list_title');
?>
";
		var alert_reset_password_success = "<?php 
echo Translate::string('alert_reset_password_success');
?>
";
		var save_advertisement_max_imagex = "<?php 
echo Translate::string('save_advertisement_max_imagex');
?>
";
	</script>
	<?php 
require_once "lib/includes/categories.php";
require_once "lib/includes/compare.php";
?>
<section id="top-ads"><?php 
require_once "lib/includes/top-ads.php";
?>
</section><?php 
require_once "lib/includes/results.php";
require_once "lib/includes/create-advert/advert-intro.php";
require_once "lib/includes/create-advert/advert-header.php";
require_once "lib/includes/create-advert/advert-create.php";
?>
</p>
					</div>
				</div>
				<a class="btn contact-seller" data-user-id="<?php 
echo $user_info["id"];
?>
"><?php 
echo Translate::string("ad_expanded.contact_seller");
?>
</a>
				<a data-advert-id="<?php 
echo $product_id;
?>
" class="add-to-compare-btn btn"><?php 
echo Translate::string("ad_expanded.add_to_compare");
?>
</a>
			</div>
			<aside class="gallery_container">
				<div class="result_gallery">
					<div class="img-navigation"><button class="prev-gallery-img"></button></div>
					<div class="img-navigation"><button class="next-gallery-img"></button></div>
					<img src="lib/images/uploads/medium/<?php 
echo $product_images[0]["uuid"];
?>
" data-id="<?php 
echo $product_images[0]["id"];
?>
" class="result_img" alt="advertisment gallery image">
				</div>
            $value = array_filter($value);
            // remove empty elements of array
            foreach ($value as $key1 => $value1) {
                // check for bad words
                if (is_array($value1)) {
                    $value1 = array_filter($value1);
                    // remove empty elements of array
                    foreach ($value1 as $key2 => $value2) {
                        if (strpos($bad_words_string, " " . strtolower($value2) . ",")) {
                            die(sprintf(Translate::string("save_advertisement.remove_bad_word_4"), "<em>" . strtoupper($value2) . "</em>"));
                        }
                    }
                } else {
                    if (strpos($bad_words_string, " " . strtolower($value1) . ",")) {
                        die(sprintf(Translate::string("save_advertisement.remove_bad_word_5"), "<em>" . strtoupper($value1) . "</em>"));
                    }
                }
            }
        } else {
            if (strpos($bad_words_string, " " . strtolower($value) . ",")) {
                die(sprintf(Translate::string("save_advertisement.remove_bad_word_6"), "<em>" . strtoupper($value) . "</em>"));
            }
        }
        $details[$key] = $value;
    }
}
// ======================
// SAVE AD TO DATABASE
// ======================
$advertisment = new Product($user, $_POST["subCategory"], $_POST["title"], $_POST["price"], $_POST["currencyID"], $_POST["paymentMethod"], $_POST["zip"], $_POST["city_name"], $_POST["country_code"], $_POST["languageID"], $description, $details, $_POST["advert-img"]);
$advertisment->insertToDB();
Beispiel #21
0
<?php

require_once "../includes/session.php";
require_once "../includes/sanitize-all.php";
// Auto load the class when it is beeing created
spl_autoload_register(function ($class) {
    require_once "../classes/" . $class . ".class.php";
});
if (!empty($_POST["email"]) && !empty($_POST["password"]) && !empty($_POST["javascript"])) {
    require_once "../classes/Inspekt.php";
    $email = $_POST["email"];
    $password = $_POST["password"];
    $javascript = $_POST["javascript"];
    $browser = $_SERVER['HTTP_USER_AGENT'];
    $session_id = session_id();
    $ip_address = $_SERVER['REMOTE_ADDR'];
    if (!Inspekt::isEmail($email)) {
        die(Translate::string("login_alert.incorrect_email"));
    }
    $user = new User();
    $login = $user->checkCredentials($email, $password, $javascript, $browser, $ip_address, $session_id);
    if ($login) {
        echo "success";
    }
    // if ajax return is success javascript will redirect
} else {
    echo Translate::string("login_alert.insert_username_and_password");
}
Beispiel #22
0
}
?>
								</ul>
							</section>

							<section id="create-sub-cat" class="third left radio-switch">
								<h3><?php 
echo Translate::string("create_ad.select_sub_category");
?>
</h3>
								<ul class="unstyled">
									<?php 
include "lib/ajax/getSubCategoriesAsRadioList.php";
?>
								</ul>
							</section>
						<noscript> </div> </noscript>

						<section id="create-basics" class="third left">
							<noscript>
								<h3><?php 
echo Translate::string("create_ad.continue_sentence");
?>
</h3>
								<label for="step-1a-checkbox" class="btn left fullwidth"><?php 
echo Translate::string("create_ad.continue_button");
?>
</label>
							</noscript>
						</section>
					
Beispiel #23
0
<?php

if (!$_SESSION) {
    session_start();
}
# checkbox needs to be here! manipulated with css, if clicked, compare section is hidden
?>
		
<input id="compare-checkbox" type="checkbox" class="hidden" <?php 
echo isset($_GET["compare"]) ? '' : 'checked="checked"';
?>
 >
<section id="compare">
	<div class="container">
		<h2><?php 
echo sprintf(Translate::string("compare.title"), '<span id="compare-title-count">' . count($_SESSION["compare"]) . '</span>');
?>
</h2>
		<div class="table">
			<div class="compare-header row">
				<div class="cell"></div>
				<div class="cell"><a class="compare-feature">ID</a></div>
				<div class="cell"><a class="compare-feature">Title</a></div>
				<div class="cell"><a class="compare-feature">Price</a></div>
				<div class="cell"><a class="compare-feature">Location</a></div>
				<div class="cell"><a class="compare-feature ">Date Created</a></div>
				<div class="cell"><a href="#"></a></div>
			</div>

			<?php 
if (isset($_SESSION["compare"]) && count($_SESSION["compare"]) > 1) {
Beispiel #24
0
 &#9660;</option>
				</select>
				<?php 
// <label id="sort-by-label" for="sort-by-select" class="right">Sort by: </label>
?>

				<label for="compare-checkbox" id="compare-btn" class="btn left <?php 
echo isset($_GET["compare"]) ? 'btn-active' : '';
?>
"><?php 
echo Translate::string("results_controller.compare_btn", $lang);
?>
</label>
				<input type="checkbox" id="result-refine-checkbox" class="hidden" checked>
				<label for="result-refine-checkbox" class="btn left"><?php 
echo Translate::string("results_controller.refine_search_btn", $lang);
?>
</label>

				<noscript>
					<input type="submit" value="Apply!" class="btn left">
				</noscript>

				<div id="result-refine-container" class="left">
					<select name="price" class="btn select-arrow">
						<option value="">Car Type:</option>
						<option value="0-99">Sedan</option>
						<option value="100-199">Coupee</option>
						<option value="100-199">Race-Car</option>
						<option value="100-199">Truck</option>
						<option value="100-199">Jeep</option>
                        if (!move_uploaded_file($value, $upload_dir . "temp/" . $uuid)) {
                            $images = array("error" => "Server Error<br/>Reported to Admin");
                        } else {
                            if (!chmod($upload_dir . "temp/" . $uuid, 0777)) {
                                $images = array("error" => "Server Error2<br/>Reported to Admin");
                            } else {
                                $images[] = array('file_name' => $uuid);
                                $_SESSION["upload_img_count"]++;
                            }
                        }
                    } else {
                        $images = array("error" => Translate::string("upload_images_alert.only_images_allowed"));
                    }
                }
            }
        }
    }
} else {
    $images = array("error" => sprintf(Translate::string("upload_images_alert.too_big_images"), 8));
}
?>
<html>
 <body>
  <script type="text/javascript">
  window.parent.Uploader.done('<?php 
echo json_encode($images);
?>
');
  </script>
 </body>
</html>
Beispiel #26
0
</p>
				<span class="step-number">2</span>
				<div class="create-symbol"></div><?php 
// specify the appropriate image like this: " #create-merchandise > .create-symbol {background...} "
?>
				<h3><?php 
echo Translate::string("create_ad.step2_title");
?>
</h3>
			</div>
			<?php 
//step header
?>
			<div id="create-release" class="create-step">
				<p><?php 
echo Translate::string("create_ad.step");
?>
</p>
				<span class="step-number">3</span>
				<div class="create-symbol"></div><?php 
// specify the appropriate image like this: " #create-merchandise > .create-symbol {background...} "
?>
				<h3><?php 
echo Translate::string("create_ad.step3_title");
?>
</h3>
			</div>
		</div>
	</div>
</section><?php 
// #advert-header
Beispiel #27
0
 public function setBirthday($birthday)
 {
     if (Validate::isDate($birthday)) {
         $this->_birthday = $birthday;
     } else {
         throw new Exception(Translate::string("user.wrong_date"), 1);
     }
 }
Beispiel #28
0
echo Translate::string("footer.legal_info");
?>
</p>
				<p><?php 
echo Translate::string("footer.address");
?>
</p>
				<img src="lib/images/elements/logo_footer.svg" alt="Finnplus footer logo square">
			</footer>
		</section><?php 
// #footer
?>

		<?php 
// Alert Modal
$title = Translate::string("alert_modal.title");
$message = "";
$footer = "";
if (isset($_GET["title"])) {
    $title = $_GET["title"];
}
if (isset($_GET["alert"])) {
    $message = $_GET["alert"];
}
if (isset($_GET["footer"])) {
    $footer = $_GET["footer"];
}
$alert_modal_id = "alert";
$alert_modal_content = "<p id='alert-paragraph'>" . Inspekt::noTags($message) . "</p>";
// $alert_modal_content = '<img src="http://maps.googleapis.com/maps/api/staticmap?center=56.1138608,10.1577942&zoom=13&size=300x300&sensor=false">';
$alert_modal_title = Inspekt::noTags($title);
Beispiel #29
0
    ?>
" href="?cat_id=<?php 
    echo $cat['id'];
    ?>
">
					<div class="category-thumb">
						<img src="lib/images/main-categories/id/<?php 
    echo $cat['id'];
    ?>
.jpg" alt="<?php 
    echo Translate::string("categoryMain." . Product::slugify($cat["name"]));
    ?>
 Category">						
					</div>
					<span class="category-label"><?php 
    echo Translate::string("categoryMain." . Product::slugify($cat["name"]));
    ?>
</span>
				</a>
			</div>
		<?php 
}
?>

		<div id="sub-category-container" class="<?php 
echo $load ? "" : "hidden";
?>
">
			<?php 
if ($load) {
    require_once "lib/ajax/getSubCategories.php";
Beispiel #30
0
				</li>
			</ul>
		</div>
	</div> -->

</section>

<section id="step-1b-column-3" class="third left">
	<h3><?php 
echo Translate::string("create_ad.extra_details");
?>
</h3>

	<?php 
Product::getAttributes($subCatID, "only-checkboxes", 5);
?>


</section>

<button class="btn fullwidth" style="margin:60px 0 10px 0;"><?php 
echo Translate::string("create_ad.continue_to_next_step");
?>
</button>
<label id="back-to-step1a" for="step-1a-checkbox" class="btn fullwidth" ><?php 
echo Translate::string("create_ad.back_to_prev_step");
?>
</label>