PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : پیغام درخطا در اسکرپیت لطفا کمک کنید ( مهم)



behtash007
August 3rd, 2017, 18:07
با درود من یه اسکریپت املاک دارم موقع اضافه کردن ملک با خظای زیر مواجه میشوم .اضافه میشه ولی با خطای زیر مواجه میشم


Warning: Invalid argument supplied for foreach() in /home/safeira1/amlak.persiannod.ir/controllers/admin/Properties.php on line 322

Warning: Cannot modify header information - headers already sent by (output started at /home/safeira1/amlak.persiannod.ir/controllers/admin/Properties.php:322) in /home/safeira1/amlak.persiannod.ir/libs/framework/Router.php on line 54










Router.php





<?php

namespace Libs;

class Router extends Singleton
{
const DEFAULT_APP = "site";

protected static $instance = null;

private $routeQuery = array();

protected function __construct()
{
parent::__construct();

$db = Database::getInstance();
$db->newConnection("main", new \mysqli(\Config::HOST, \Config::DATABASE_USER, \Config::DATABASE_PASSWORD, \Config::DATABASE), true);
$template = Template::getInstance();

//Define app uri
$file = Inputs::get("SCRIPT_NAME", "", $_SERVER);
$file = explode("/", $file);
array_pop($file);
$file = implode("/", $file) . "/";
define("APP_URI", $file);

$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
$port = ($port) ? ':' . $_SERVER["SERVER_PORT"] : '';
$url = ($isHTTPS ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"] . $port;
define("SITE_URI", $url);

define("APP_FULL_URI", $url . APP_URI);

Template::getInstance()->addHeader("Cache-Control: no-cache, must-revalidate");
Template::getInstance()->addHeader("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
Template::getInstance()->addHeader("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");

}

/**
*
* @return Router
*/
public static function getInstance()
{
return parent::getInstance();
}

public static function redirect($address)
{
$address = strlen(trim($address)) == 0? "/" : $address;
header("Location: $address");
exit();
}

public function route()
{

$config = Application::getGlobalConfig();

//check search engin friendly url status
$uri = null;
$app = null;

if ($config->sef) {
//Start search engin friendly url decoding
//Get request uri
$uri = Inputs::get("REQUEST_URI", "", $_SERVER);
//Debug::out(print_r($uri, true) . "\n" , true);
$uri = trim($uri, "\/");
$uri = str_replace("\\", "/", $uri);
//Get executed file path
$file = Inputs::get("SCRIPT_NAME", "", $_SERVER);
$file = trim($file, "\/");
//remove query string from request
$query = Inputs::get("QUERY_STRING", "", $_SERVER);
$uri = str_replace("?".$query, "", $uri);
//split file path to array
$file = explode("/", $file);
//remove last item which is the file and extention name
$filename = array_pop($file);
//join file path to string.
//Now $file is parent directory of execute file
$file = implode("/", $file);
//remove file directory path from request uri
$uri = str_replace($file, "", $uri);
//remove file name from anywhere in request uri
$uri = str_replace($filename, "", $uri);
//remove any double slash to single slash
$uri = str_replace("//", "/", $uri);
//remove any slashes from sides of string
$uri = trim($uri, "\/");
//split uri to array
$uri = explode("/", $uri);

if (!empty($uri)){
//set route
$this->setRoute($uri);
//Debug::out(print_r($uri, true) . "\n" , true);
if (!empty($uri[0])){
//Check if $uri[0] is a valid app name
if (in_array(strtolower($uri[0]), self::getApps())){
$app = strtolower(trim(array_shift($uri)));
//$app = strtolower(trim($uri[0]));
//unset($uri[0]);
//$uri = array_values($uri);
} else {
$app = self::DEFAULT_APP;
}
}

//setup app and service to $_GET
Inputs::set("app", $app, $_GET);

//regenerate global $_REQUEST
Inputs::regenerateGlobalRequest();
}
}

//Get user required app
$app = self::getAppInstance();

Session::getInstance()->initSession();

return $app->run($uri);

}

public function firstMatch($pattern, $route = null)
{
$retVal = null;
$route = $route !== null? $route : $this->getRoute();
foreach ($route as $key => $value) {
if (preg_match($pattern, $value)){
$retVal = ["key" => $key, "value" => $value];
break;
}
}
return $retVal;
}

public function getRoute()
{
return $this->routeQuery;
}

protected function setRoute($route)
{
$this->routeQuery = $route;
return $this;
}

/**
*
* @return Application
*/
public static function getAppInstance()
{
$app = self::getAppName();
//Create app path
$file = APP_PATH_BASE . DS . "apps" . DS . "$app.php";
if (file_exists($file)){
require_once $file;
$className = "\\Applications\\$app";
return $className::getInstance();
} else {
return null;
}
}

public static function getAppName()
{
$app = explode("_", Inputs::get("app", self::DEFAULT_APP));
$app = array_map("ucfirst", $app);
$app = implode("", $app);
return $app;
}

public static function getApps()
{
$apps = glob(APP_PATH_BASE . DS . "apps" . DS . "*.php");
$apps = array_map(function($value){
return basename($value, ".php");
}, $apps);
return array("admin","site","install");
}

}
?>










Properties.php




<?php

namespace Controllers\Admin;

class Properties extends \Libs\Controller
{

public function __construct()
{
parent::__construct();
$this->setDefaultAction("index");
}

public function route(array &$route = array())
{
parent::route($route);
$action = \Libs\Inputs::get("action");
switch ($action) {
case "index":
if (!empty($route[0])){
\Libs\Inputs::set("callback", $route[0], $_GET);
\Libs\Inputs::regenerateGlobalRequest();
}
break;
case "edit":
case "delete":
if (!empty($route[0])){
\Libs\Inputs::set("id", $route[0], $_GET);
unset($route[0]);
\Libs\Inputs::regenerateGlobalRequest();
}
break;
}
return $this;
}

public function run()
{
parent::run();
$template = \Libs\Template::getInstance();
$template->addPageTitle("املاک");
$template->addBreadcrumb("املاک");
return $this->runAction($this->getAction());
}

public function index(array $options = array())
{
$template = \Libs\Template::getInstance();

$filter = \Libs\Filter::init(true);
$config = \Libs\Configuration::getValues(["general", self::getName()]);

$this->model("Properties");
$model = new \Models\Properties();

if ($filter->has("title")){
$model->where("{$model->getTable()}.title LIKE '%{$filter->title}%'");
}

if ($filter->has("area")){
$model->where("{$model->getTable()}.area >= {$filter->area}");
}

if ($filter->has("address")){
$model->where("{$model->getTable()}.address LIKE '%{$filter->address}%'");
}

if ($filter->has("phone")){
$model->where("{$model->getTable()}.phone LIKE '%{$filter->phone}%'");
}

if ($filter->has("mobile")){
$model->where("{$model->getTable()}.mobile LIKE '%{$filter->mobile}%'");
}

if ($filter->has("property_type_id")){
$model->where("{$model->getTable()}.property_type_id = " . \Libs\Convert::toInt($filter->property_type_id));
}

if ($filter->has("use_type_id")){
$model->where("{$model->getTable()}.use_type_id = " . \Libs\Convert::toInt($filter->use_type_id));
}

if ($filter->has("special")){
$state = \Libs\Convert::toInt($filter->special);
$state = $filter->special == 2? 0 : $state;
$model->where("{$model->getTable()}.special = " . $state);
}

if ($filter->has("market_state")){
$state = \Libs\Convert::toInt($filter->market_state);
$state = $state == 2? 0 : $state;
$model->where("{$model->getTable()}.market_state = " . $state);
}

$model->orderBy("title", "asc");

$page = $filter->has("page")? $filter->page : 1;
$listSize = $filter->has("limit")? $filter->limit : $config->list_size;
$model->getPage($page, $listSize);

$this->model("PropertyTypes");
$types = new \Models\PropertyTypes();
$types->getAll();

$this->model("DealTypes");
$dealTypes = new \Models\DealTypes();
$dealTypes->getAll();

$this->model("UseTypes");
$useType = new \Models\UseTypes();
$useType->getAll();

$models = new \stdClass();
$models->propertiesList = $model;
$models->filter = $filter;
$models->types=$types;
$models->dealTypes = $dealTypes;
$models->useType = $useType;

ob_start();
$this->view("Admin.PropertiesList", $models);
$content = ob_get_contents();
ob_end_clean();

$template->setData("content", $content);
}

public function create(array $options = array())
{
$template = \Libs\Template::getInstance();
$template->addPageTitle("جدید");
$template->addBreadcrumb("جدید");


$this->model("PropertyTypes");
$types = new \Models\PropertyTypes();
$types->getAll();

$this->model("DealTypes");
$dealTypes = new \Models\DealTypes();
$dealTypes->getAll();

$this->model("DocTypes");
$docTypes = new \Models\DocTypes();
$docTypes->getAll();

$this->model("Provinces");
$provinces = new \Models\Provinces();
$provinces->getAll();


$this->model("InternalStatus");
$internalStatus = new \Models\InternalStatus();
$internalStatus->getAll();

$this->model("GeoTypes");
$geoType = new \Models\GeoTypes();
$geoType->getAll();

$this->model("UseTypes");
$useType = new \Models\UseTypes();
$useType->getAll();

$models = new \stdClass();
$models->types = $types;
$models->dealTypes = $dealTypes;
$models->docTypes = $docTypes;
$models->provinces = $provinces;
$models->internalStatus = $internalStatus;
$models->geoType = $geoType;
$models->useType = $useType;
$models->options = (object) \Libs\Configuration::getFields(self::getName(), true);

ob_start();
$this->view("Admin.Properties", $models);
$content = ob_get_contents();
ob_end_clean();
\Libs\Template::getInstance()->setData("content", $content);
}

public function edit(array $options = array())
{
$template = \Libs\Template::getInstance();
$template->addPageTitle("ویرایش");
$template->addBreadcrumb("ویرایش");

$id = \Libs\Inputs::get("id");
if (is_array($id)) {
$id = array_pop($id);
}
$id = \Libs\Convert::toInt($id);

if ($id <= 0) {
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties");
}

$this->model("Properties");
$model = \Models\Properties::find($id);
if ($model == null) {
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties");
}

$this->model("PropertyTypes", "DealTypes", "DocTypes",
"Provinces", "InternalStatus", "GeoTypes",
"UseTypes");

$cities = null;
if ($model->province_id > 0){
$this->model("Cities");
$cities = new \Models\Cities();
$cities->where("province_id = {$model->province_id}");
$cities->get();
}

$this->model("PropertiesDealsStatus");
$pDeals = new \Models\PropertiesDealsStatus();
$pDeals->where("property_id = $id")->getAll();

$models = new \stdClass();
$models->property = $model;
$models->types = \Models\PropertyTypes::all();
$models->dealTypes = \Models\DealTypes::all();
$models->docTypes = \Models\DocTypes::all();
$models->provinces = \Models\Provinces::all();
if($cities != null){
$models->cities = $cities;
}
$models->internalStatus = \Models\InternalStatus::all();
$models->geoType = \Models\GeoTypes::all();
$models->useType = \Models\UseTypes::all();
$models->attributes = $model->propertyType()->attributes();
$models->facilities = $model->propertyType()->facilities();
$models->options = (object) \Libs\Configuration::getFields(self::getName(), true);

ob_start();
$this->view("Admin.Properties", $models);
$content = ob_get_contents();
ob_end_clean();
\Libs\Template::getInstance()->setData("content", $content);
}

public function apply(array $options = array())
{
$result = $this->submit();
if ($result) {
\Libs\Messages::add('با موفقیت ذخیره شد', \Libs\Messages::MESSAGE_SUCCESS, "");
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties/edit/$result");
} else {
\Libs\Messages::add('ذخیره نشد', \Libs\Messages::MESSAGE_CRITICAL, "");
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties");
}
}

public function save(array $options = array())
{
$result = $this->submit();
if ($result) {
\Libs\Messages::add('با موفقیت ذخیره شد', \Libs\Messages::MESSAGE_SUCCESS, "");
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties");
} else {
\Libs\Messages::add('متاسفانه ذخیره نشد', \Libs\Messages::MESSAGE_CRITICAL, "");
}
}

public function cancel(array $options = array())
{
\Libs\Router::getInstance()->redirect(APP_URI ."admin/properties");
}

public function delete(array $options = array())
{
$this->model("Properties");
$ids = \Libs\Inputs::get("id");
if (!is_array($ids)) {
$ids = array(\Libs\Convert::toInt($ids));
}

\Models\Properties::destroy($ids);

\Libs\Messages::add("عملیات حذف انجام شد", \Libs\Messages::MESSAGE_INFO);
\Libs\Router::getInstance()->redirect(APP_URI."admin/properties");
}

protected function submit()
{
$retVal = false;
$id = \Libs\Convert::toInt(\Libs\Inputs::get("id", 0));

$this->model("Properties");
$model = \Models\Properties::findOrNew($id) ;


if ($model === null){
\Libs\Messages::add('متاسفانه رکوردی با شناسه وارد شده پیدا نشد', \Libs\Messages::MESSAGE_CRITICAL, "");
return $retVal;
}

$this->prepare($model);
$retVal = $model->save();

$retVal = $model->getPrimaryKeyValue();

if ($retVal) {

//process deals
$deals = \Libs\Inputs::get("deal_types");
$model->deals()->removeAll();
foreach ($deals as $key => $value) {
$record = array();
$type = \Libs\Convert::toInt($value["deal_type_id"]);
$price = \Libs\Convert::toInt(\Libs\Convert::numberUnformat ($value["price"]));
$rent = \Libs\Convert::toInt(\Libs\Convert::numberUnformat ($value["rent"]));
$record[$type] = array("price" => $price, "rent" => $rent);
$model->deals()->add($record);
}

//process media
$media = \Libs\Inputs::get("media");
$this->model("PropertiesPhotos");
$hasDefault = false;
foreach ($media as $value) {
switch (\Libs\Convert::toInt($value["state"])){
case 1:
$media = new \Models\PropertiesPhotos();
$media->property_id = $retVal;
$media->filepath = $value["path"];
$media->is_default = 0;
$media->is_default = \Libs\Convert::toInt($value["is_default"]);
$media->create();
break;
case -1:
$media = \Models\PropertiesPhotos::find(\Libs\Convert::toIn t($value["id"]));
if ($media != null){
$media->delete();
}
break;
case 0:
$media = \Models\PropertiesPhotos::find(\Libs\Convert::toIn t($value["id"]));
if ($media != null){
$media->is_default = \Libs\Convert::toInt($value["is_default"]);
$media->save();
}
break;
}
}
//\Libs\Debug::out(print_r($media, true));

//process attributes
$attributes = \Libs\Inputs::get("attributes", array());
$model->attributes()->removeAll();
foreach ($attributes as $key => $value) {
$record[$key] = array("value" => $value);
$model->attributes()->add($record);
}

//process facilities
$facilities = \Libs\Inputs::get("facilities", array());
$model->facilities()->removeAll();
foreach ($facilities as $key => $value) {
$model->facilities()->add($value);
}

//process related products
$related = \Libs\Inputs::get("related", array());
$model->related()->removeAll();
foreach ($related as $key => $value) {
$model->related()->add($value);
}

}

return $retVal;
}

protected function prepare(\Models\Properties &$model)
{

$jalali = new \JalaliDateTime();
$model->created_at = \Libs\Inputs::get("created_at");
$model->created_by = \Libs\Inputs::get("created_by");
$model->modified_at = \Libs\Inputs::get("modified_at");
$model->modified_by = \Libs\Inputs::get("modified_by");

$model->title = \Libs\Inputs::get("title");
$model->area = \Libs\Convert::toInt(\Libs\Inputs::get("area"));
$model->property_type_id = \Libs\Convert::toInt(\Libs\Inputs::get("property_type_id"));
$model->doc_type_id = \Libs\Convert::toInt(\Libs\Inputs::get("doc_type_id"));
$model->lenght = \Libs\Inputs::get("lenght");
$model->width = \Libs\Inputs::get("width");
$model->use_type_id = \Libs\Convert::toInt(\Libs\Inputs::get("use_type_id"));
$model->phone = \Libs\Inputs::get("phone");
$model->mobile = \Libs\Inputs::get("mobile");
$model->email = \Libs\Inputs::get("email");
$model->province_id = \Libs\Convert::toInt(\Libs\Inputs::get("province_id"));
$model->city_id = \Libs\Convert::toInt(\Libs\Inputs::get("city_id"));
$model->district = \Libs\Inputs::get("district");
$model->address = \Libs\Inputs::get("address");
$model->address_details = \Libs\Inputs::get("address_details");
$model->cord_x = \Libs\Inputs::get("cord_x");
$model->cord_y = \Libs\Inputs::get("cord_y");
$model->geo_type = \Libs\Convert::jSonEncode(\Libs\Inputs::get("geo_type"));
$model->age = \Libs\Convert::toInt(\Libs\Inputs::get("age"));
$model->internal_status_type_id = \Libs\Convert::toInt(\Libs\Inputs::get("internal_status_type_id"));
$model->seller_id = \Libs\Convert::toInt(\Libs\Inputs::get("seller_id"));
$model->seller_name = \Libs\Inputs::get("seller_name");
$model->special = \Libs\Convert::toInt(\Libs\Inputs::get("special", 0));
$model->market_state = \Libs\Convert::toInt(\Libs\Inputs::get("market_state", 0));
$model->description = \Libs\Inputs::get("description");
$model->options = \Libs\Configuration::encode(\Libs\Inputs::get("options"));

}

}

?>

AliFatehi
August 3rd, 2017, 19:20
وقتی کسی ندونه اسکریپت چی هست و اینکه دمو نذاشتین نمیشه کاری کرد
بهتره دمو بزارید و یا اینکه اسم و لینک دانلود اسکریپت رو قرار بدین
اگر هم اختصاصی هست به طراحش بگید براتون اوکی کنه

behtash007
August 3rd, 2017, 19:24
وقتی کسی ندونه اسکریپت چی هست و اینکه دمو نذاشتین نمیشه کاری کرد دقیقا اروری که مربوط به اون فایل میشه رو قرار دادم نمیشه اصلاح کرد ؟
بهتره دمو بزارید و یا اینکه اسم و لینک دانلود اسکریپت رو قرار بدین
اگر هم اختصاصی هست به طراحش بگید براتون اوکی کنه

با این دوتا کدی که قرار دادم نمیتونید متوجه بشید ؟

- - - Updated - - -

من دقیقا کد مربوط به خطا و خود خطا را در تاپیک گذاشتم نمیتونید خط مربوطه را برطرف کنید :/

AliFatehi
August 3rd, 2017, 19:29
با این دوتا کدی که قرار دادم نمیتونید متوجه بشید ؟

- - - Updated - - -

من دقیقا کد مربوط به خطا و خود خطا را در تاپیک گذاشتم نمیتونید خط مربوطه را برطرف کنید :/

جالبه ، بنده و فکر میکنم اکثر دوستان نمیتونن بدون دیدن سایت و اسکریپت کاری بکنن
بازم اساتید محترم اگر در توانشون هست انجام بدن

behtash007
August 3rd, 2017, 19:51
میتونم مشخصات مدیریت را براتون ارسال کنیم . ولی همون اروری میدهد که در تاپیک ذکر کردم . دوتا فایل php هم برای رفع ان گذاشتم

wapmaster
August 3rd, 2017, 19:56
هر خطایی که بخاطر کدنویسی نیست !
پی اچ پی ورژن رو هم چک کنید شاید گزینه ای از الزامات اسکریپت در پی اچ پی ورژن غیر فعال شده و...

behtash007
August 3rd, 2017, 20:07
مشکل از کد هستش . با تغییر ورژن php هم تغییر بخصوصی نکرد بجز انکه پیغام فریم ورک میدهد که با بالا بردن ورژن مجدد همان پیغام فوق را میدهد