update
This commit is contained in:
11
Server/.htaccess
Normal file
11
Server/.htaccess
Normal file
@@ -0,0 +1,11 @@
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_URI} !phpmyadmin
|
||||
RewriteCond %{REQUEST_URI} !szablon
|
||||
RewriteCond %{REQUEST_URI} !crossdomain.xml
|
||||
RewriteCond %{REQUEST_URI} !Admin
|
||||
RewriteCond %{REQUEST_URI} !error.html
|
||||
RewriteCond %{REQUEST_URI} !rekbufor.html
|
||||
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|flv)$ index.php
|
||||
|
||||
php_value upload_max_filesize 30M
|
||||
php_value post_max_size 30M
|
||||
196
Server/controller/ServerController.php
Normal file
196
Server/controller/ServerController.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?
|
||||
|
||||
class ServerController extends Controller {
|
||||
|
||||
public function IndexAction() {
|
||||
|
||||
//ServerController::PerMinuteAction();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function CheckStatus() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function PerHourAction() {
|
||||
|
||||
ServerController::CheckInactiveUser();
|
||||
|
||||
|
||||
// Przyznawanie nagr<67>d
|
||||
$array = RatingDAL::CountRating(true, true);
|
||||
// var_dump($array);
|
||||
|
||||
foreach($array as $row) {
|
||||
if($row && isset($row['id_type'])) {
|
||||
$className = Type::GetTypeClassName($row['id_type']).'DAL';
|
||||
// echo $className.' - '.$row['id_content'];
|
||||
eval('$obj='.$className.'::GetResult(array("'.Type::GetTypeSQLIdName($row['id_type']).'" => '.$row['id_content'].'), 1);');
|
||||
// print_r($obj);
|
||||
|
||||
if(isset($obj[0])) {
|
||||
eval($className.'::AddAward($obj[0]);');
|
||||
}
|
||||
}
|
||||
}
|
||||
//Koniec przyznawania nagr<67>d.
|
||||
}
|
||||
|
||||
public function PerMinuteAction() {
|
||||
ServerController::SendInfoMail();
|
||||
|
||||
}
|
||||
|
||||
public function CheckInactiveUser() {
|
||||
MailingDAL::ClearInactiveUser();
|
||||
}
|
||||
|
||||
public function CountRating() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function SendInfoMail() {
|
||||
$logger = LoggerManager::getLogger(__CLASS__);
|
||||
$objMailing = MailingDAL::GetMailingToSend();
|
||||
//while (($objMailing = MailingDAL::GetMailingToSend())) {
|
||||
|
||||
// }
|
||||
if (is_object($objMailing)) {
|
||||
$logger = LoggerManager::getLogger(__CLASS__);
|
||||
$limit = $objMailing->GetLastSend() + 50;
|
||||
$mailList = array();
|
||||
$logger->info("limit: $limit ".$objMailing->GetLastSend());
|
||||
$mailList = MailingDAL::GetMailingAddressList(2, $objMailing->GetLastSend(), 50);
|
||||
MailingDAL::UpdateLastSend($objMailing->GetId(), $limit);
|
||||
//Utils::ArrayDisplay($mailList);
|
||||
|
||||
// pobiera z tabeli user (jezeli taka istnije w tym przypadku nie potrzebna)
|
||||
// if (!is_array($mailList) || count($mailList) < 50 && $objMailing->GetType() == 1) {
|
||||
// MailingDAL::UpdateLastSend($objMailing->GetId(), 0);
|
||||
// MailingDAL::UpdateType($objMailing->GetId());
|
||||
//
|
||||
// }
|
||||
|
||||
if (!is_array($mailList) || count($mailList) < 50 && $objMailing->GetType() == 2) {
|
||||
MailingDAL::UpdateLastSend($objMailing->GetId(), 0);
|
||||
MailingDAL::SetExecuted($objMailing->GetId());
|
||||
}
|
||||
|
||||
|
||||
//$this->smarty->assign('content', $objMailing->GetText());
|
||||
//$txtmessage = $this->smarty->fetch('MailTxt.tpl');
|
||||
//Utils::ArrayDisplay($mailList);
|
||||
|
||||
foreach ($mailList as $key => $arrayPackage) {
|
||||
foreach ($arrayPackage as $keyPackege => $value) {
|
||||
$subjet = " Mediaflex - ".$objMailing->GetTitle();
|
||||
$mail = new PHPMailer();
|
||||
$mail -> CharSet = "utf-8";
|
||||
$mail -> Subject = $subjet;
|
||||
$mail -> SMTPAuth = true;
|
||||
$mail -> Mailer = 'smtp';
|
||||
|
||||
$mail -> Host = HOST_MAIL;
|
||||
$mail -> Port = 25;
|
||||
$mail ->From = FROM_MAIL;
|
||||
$mail -> FromName = FROM_NAME_MAIL;
|
||||
$mail -> Username = USER_MAIL;
|
||||
$mail -> Password = PASS_MAIL;
|
||||
//$mail->AddAddress('maciek@formix.pl', 'Maciej Kloch');
|
||||
$mail->AddAddress($value['email'], $value['name']);
|
||||
|
||||
$mail -> AddBCC("maciek@formix.pl", "Mailing - ".FROM_NAME_MAIL." ".$value['email']."- ".$value['name']." ".$key."-".$keyPackege);
|
||||
$mail -> Body = $objMailing->GetText();
|
||||
$mail -> Send();
|
||||
}
|
||||
//sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function GenerateModelAction($param) {
|
||||
MFLog::Info(__FUNCTION__);
|
||||
require_once('../core/lib/Smarty/Smarty.class.php');
|
||||
$smarty = new Smarty();
|
||||
$smarty->template_dir = Config::Get('PATH_SMARTY_TEMPLATE');
|
||||
$smarty->compile_dir = Config::Get('PATH_SMARTY_COMPILE');
|
||||
|
||||
$db = Registry::Get('db');
|
||||
|
||||
$sql = " select table_name from information_schema.tables where table_schema <> 'information_schema' ";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
$tables = $stmt->FetchAllRow();
|
||||
foreach ($tables as $table) {
|
||||
|
||||
$tableName = $table[0];
|
||||
$className = ucfirst(Utils::SQLName2PHPName($tableName));
|
||||
|
||||
$smarty->assign('tableName', $tableName);
|
||||
$smarty->assign('className', $className);
|
||||
|
||||
// zależne obiekty/tabele działa dopiero od mySQL 5.1.16
|
||||
// $sql = " select table_name from referential_constraints where constraint_schema <> 'information_schema' and referenced_table_name = '$tableName' ";
|
||||
// $stmt = $db->prepare($sql)
|
||||
// ->execute($sql);
|
||||
//
|
||||
// $refTableNames = array();
|
||||
//
|
||||
// $refTables = $stmt->FetchAllRow();
|
||||
// foreach ($refTables as $refTable) {
|
||||
// $tmp_name = Utils::SQLName2PHPName($refTable[0]);
|
||||
// $refTables[$refTable[0]] = $tmp_name;
|
||||
// }
|
||||
//
|
||||
// $smarty->assign('refTables', $refTables);
|
||||
// kolumny tabeli dla obiektu
|
||||
|
||||
$sql = " select column_name from information_schema.columns where table_name='$tableName'; ";
|
||||
$stmt = $db->prepare($sql)
|
||||
->execute($sql);
|
||||
|
||||
$columnNames = array();
|
||||
|
||||
$columns = $stmt->FetchAllRow();
|
||||
foreach ($columns as $column) {
|
||||
if ($column[0] === 'id_' . $tableName) {
|
||||
$tmp_name = 'id';
|
||||
} else {
|
||||
$tmp_name = Utils::SQLName2PHPName($column[0]);
|
||||
}
|
||||
$columnNames[$column[0]] = $tmp_name;
|
||||
}
|
||||
|
||||
|
||||
$smarty->assign('columnNames', $columnNames);
|
||||
|
||||
$output = '<?php' . $smarty->fetch('templateModel.tpl') . '?>';
|
||||
$file = fopen(PATH_MODEL_TMP . $className . '.class.php', "w");
|
||||
fwrite($file, $output);
|
||||
fclose($file);
|
||||
|
||||
$outputDAL = '<?php' . $smarty->fetch('templateModelDAL.tpl') . '?>';
|
||||
$file = fopen(PATH_MODEL_TMP . $className . 'DAL.class.php', "w");
|
||||
fwrite($file, $outputDAL);
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function preDispatch() {
|
||||
$this->disableTemplates = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
61
Server/index.php
Normal file
61
Server/index.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?
|
||||
#echo $_SERVER["argv"][1];
|
||||
|
||||
//ini_set('default_charset','UTF-8');
|
||||
|
||||
#die();
|
||||
ini_set("display_errors" ,true);
|
||||
include('../core/core.php');
|
||||
|
||||
Core::Init(PageType::SERVER);
|
||||
|
||||
include("../Strona/routes.php");
|
||||
|
||||
|
||||
|
||||
if(isset($_SERVER["argv"][1])) {
|
||||
$action = $_SERVER["argv"][1];
|
||||
} else if (isset($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
} else {
|
||||
$action = "Index";
|
||||
}
|
||||
|
||||
if (isset($_SERVER['argv'][2])) {
|
||||
$controller = $_SERVER['argv'][2];
|
||||
} else if (isset($_REQUEST['controller'])) {
|
||||
$controller = $_REQUEST['controller'];
|
||||
} else {
|
||||
$controller = 'Server';
|
||||
}
|
||||
|
||||
$controller = ucfirst($controller."Controller");
|
||||
$action = ucfirst($action."Action");
|
||||
|
||||
|
||||
echo 'aaaa';
|
||||
|
||||
/**
|
||||
* Autoloader klas
|
||||
*
|
||||
* @param unknown_type $className
|
||||
*/
|
||||
function __autoload($className) {
|
||||
Core::LoadClass($className);
|
||||
}
|
||||
|
||||
include_once(Config::Get('PATH_MAIN') . 'controller' . DIRECTORY_SEPARATOR . $controller . '.php');
|
||||
|
||||
$cnt = new $controller();
|
||||
$cnt->GenerateModelAction(array());
|
||||
|
||||
//Core::LoadSmarty();
|
||||
|
||||
//$front = new FrontController();
|
||||
|
||||
//$front->Dispatch();
|
||||
|
||||
Core::Garbage();
|
||||
|
||||
//echo "CronScript";
|
||||
?>
|
||||
115
Server/template/templateModel.tpl
Normal file
115
Server/template/templateModel.tpl
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
/**
|
||||
* Model dla klasy {$className}
|
||||
*
|
||||
* @author ModGen
|
||||
*/
|
||||
|
||||
class {$className} extends DataObject{literal}{{/literal}
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = '{$tableName}';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_{$tableName}';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
/**
|
||||
* tablica mapująca pola klasy
|
||||
*/
|
||||
static $fields = array(
|
||||
{foreach from=$columnNames key=sqlName item=phpName name=fields}
|
||||
'{$sqlName}' => '{$phpName}'{if !$smarty.foreach.fields.last},
|
||||
{else}
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
);
|
||||
|
||||
|
||||
{foreach from=$columnNames item=phpName name=fields}
|
||||
{if $phpName == 'id'}
|
||||
protected ${$phpName};
|
||||
{else}
|
||||
private ${$phpName};
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
|
||||
{*foreach from=$refTables item=phpName name=fields}
|
||||
public ${$phpName};
|
||||
{/foreach*}
|
||||
|
||||
// -- Konstruktor --
|
||||
|
||||
|
||||
function __construct({foreach from=$columnNames item=phpName name=const}{if $phpName == 'id'} $id = -1 {else} ${$phpName} = null{/if}{if !$smarty.foreach.const.last},{/if}{/foreach}){literal}{{/literal}
|
||||
{foreach from=$columnNames item=phpName}
|
||||
$this->{$phpName} = ${$phpName};
|
||||
{/foreach}
|
||||
{literal}}{/literal}
|
||||
|
||||
|
||||
|
||||
// -- Get-y i Set-y --
|
||||
|
||||
{foreach from=$columnNames item=phpName}
|
||||
public function get{$phpName|ucfirst}(){literal}{{/literal}
|
||||
return $this->{$phpName};
|
||||
{literal}}{/literal}
|
||||
|
||||
public function set{$phpName|ucfirst}(${$phpName}){literal}{{/literal}
|
||||
$this->{$phpName} = ${$phpName};
|
||||
{literal}}{/literal}
|
||||
|
||||
|
||||
{/foreach}
|
||||
|
||||
|
||||
{literal}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klucza głównego tabeli
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera tablice mapującą pola klasy na pola tabeli
|
||||
* @return array
|
||||
*/
|
||||
public function GetFields(){
|
||||
return self::$fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę klasy
|
||||
* @return string
|
||||
*/
|
||||
public function GetClassName(){
|
||||
return self::$className;
|
||||
}
|
||||
|
||||
{/literal}
|
||||
|
||||
{literal}}{/literal}
|
||||
|
||||
126
Server/template/templateModelDAL.tpl
Normal file
126
Server/template/templateModelDAL.tpl
Normal file
@@ -0,0 +1,126 @@
|
||||
|
||||
/**
|
||||
* Klasa obsługi tablicy {$tableName}
|
||||
*
|
||||
*/
|
||||
class {$className}DAL extends DefaultDAL{literal}{{/literal}
|
||||
|
||||
|
||||
protected static $objClassName = '{$className}';
|
||||
protected static $objClassTable = '{$tableName}';
|
||||
protected static $objClassTablePK = 'id_{$tableName}';
|
||||
private static $optClass;
|
||||
|
||||
{if 'published'|array_key_exists:$columnNames}
|
||||
public static function TogglePublishedById(DalData $dalObj) {literal}{{/literal}
|
||||
return self::DefaultToggleFieldById($dalObj, 'published');
|
||||
{literal}}{/literal}
|
||||
{/if}
|
||||
|
||||
{literal}
|
||||
|
||||
public static function Save(DalData $dalObj) {
|
||||
if($dalObj->getObj()->GetId()=='-1') {
|
||||
return self::DefaultInsert($dalObj);
|
||||
} else {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
}
|
||||
|
||||
public static function Insert(DalData $dalObj) {
|
||||
return self::DefaultInsert($dalObj);
|
||||
}
|
||||
|
||||
public static function Update(DalData $dalObj) {
|
||||
return self::DefaultUpdate($dalObj);
|
||||
}
|
||||
|
||||
public static function GetById(DalData $dalObj) {
|
||||
return self::DefaultGetById($dalObj);
|
||||
}
|
||||
|
||||
public static function Delete(DalData $dalObj) {
|
||||
return self::DefaultDelete($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResult(DalData $dalObj) {
|
||||
return self::DefaultGetResult($dalObj);
|
||||
}
|
||||
|
||||
public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
|
||||
{
|
||||
$dalData = new DalData();
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
$dalData->setCondition($data);
|
||||
$dalData->setQueryFields($queryFields);
|
||||
$dalData->setLimit($limit);
|
||||
$dalData->setSortBy($sortBy);
|
||||
$dalData->setCount($count);
|
||||
$dalData->setDataArray("mf_link_id", $id);
|
||||
$dalData->setDataArray("mf_link_table", $table);
|
||||
$dalData->setDataArray("mf_link_destination", $destination);
|
||||
return self::DefaultGetResultByLink($dalData);
|
||||
}
|
||||
|
||||
|
||||
public static function GetObjClassName() {
|
||||
if(self::$objClassName != '') {
|
||||
$class = self::$objClassName;
|
||||
} else {
|
||||
$class = ereg_replace('DAL', '', __CLASS__);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function GetOptClass() {
|
||||
if(self::$optClass!=null) {
|
||||
return self::$optClass;
|
||||
} else {
|
||||
return self::GetObjClassName();
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetObjClassTablePK() {
|
||||
if(self::$objClassTablePK != '') {
|
||||
$return = self::$objClassTablePK;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetClassTablePK();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function GetObjClassTable() {
|
||||
if(self::$objClassTable!='') {
|
||||
$return = self::$objClassTable;
|
||||
} else {
|
||||
$class = self::GetObjClassName();
|
||||
$classObj = new $class();
|
||||
$return = $classObj->GetTableName();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DalData $dalData
|
||||
*/
|
||||
public static function GetDalDataObj($params = array()) {
|
||||
|
||||
$dalData = new DalData($params);
|
||||
$dalData->setObjClassName(self::GetObjClassName());
|
||||
$dalData->setObjClassTable(self::GetObjClassTable());
|
||||
$dalData->setObjClassTablePK(self::GetObjClassTablePK());
|
||||
$dalData->setOptClass(self::GetOptClass());
|
||||
|
||||
return $dalData;
|
||||
}{/literal}
|
||||
|
||||
{literal}}{/literal}
|
||||
|
||||
Reference in New Issue
Block a user