delete rendundant files

parent 9b26136f
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace Drupal\epal\Controller;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\epal\Crypt;
class CreateEncodedData extends ControllerBase {
protected $entity_query;
protected $entityTypeManager;
protected $logger;
protected $connection;
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
QueryFactory $entity_query,
Connection $connection,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->entity_query = $entity_query;
//$connection = Database::getConnection();
$this->connection = $connection;
$this->logger = $loggerChannel->get('epal');
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity.manager'),
$container->get('entity.query'),
$container->get('database'),
$container->get('logger.factory')
);
}
public function createData() {
$crypt = new Crypt();
print_r(date("Y-m-d H:i:s", 1530118246));
print_r(date("Y-m-d H:i:s", 1530205696));
print_r(date("Y-m-d H:i:s", 1530212831));
print_r(date("Y-m-d H:i:s", 1530220482));
print_r("decodedname: " . "<br>");
$name_encoded = $crypt->decrypt("def5020043fd2d3ba4746f43be836efa09e9033a3d041c75104bd8700cb59c03b3fb525773b099e8dbd3e9567a9587c9bed063b5a6d4df0af4e8da0f299045ad363395186e484fae498ea9d86f426747bdc658156ca7bd571f");
print_r("Decrypted: " . $name_encoded);
print_r("<br>");
//ΕΠΑΛ
/*
$sCon = $this->connection
->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'guardian_surname','guardian_name','epaluser_id'))
->condition('eStudent.delapp', 0, '=');
$epalSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalSurnames as $epalSurname) {
if ($epalSurname->guardian_surname != null)
$str1 = $crypt->decrypt($epalSurname->guardian_surname);
else
$str1 = "EMPTY";
//$str1_n = $crypt->decrypt($epalSurname->guardian_name);
$sCon = $this->connection
->select('applicant_users', 'eApplicant')
->fields('eApplicant', array('surname','name'))
->condition('eApplicant.id', $epalSurname->epaluser_id, '=');
$applicantSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$applicantSurname = reset($applicantSurnames);
if ($applicantSurname->surname != null)
$str2 = $crypt->decrypt($applicantSurname->surname);
else
$str2 = "EMPTY";
//$str2_n = $crypt->decrypt($applicantSurname->name);
if ($str1 != $str2
//|| ($str1 == $str2 && $str1_n != $str2_n )
)
{
print_r("id: " . $epalSurname->epaluser_id . " epalSurname: " . $str1 . " applicantName: " . $str2 );
print_r("\r");
}
}
*/
//ΓΕΛ
/*
$sCon = $this->connection
->select('gel_student', 'eStudent')
->fields('eStudent', array('id', 'guardian_surname','guardian_name', 'gel_userid'))
->condition('eStudent.delapp', 0, '=');
$gelSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($gelSurnames as $gelSurname) {
if ($gelSurname->guardian_surname != null)
$str1 = $crypt->decrypt($gelSurname->guardian_surname);
else
$str1 = "EMPTY";
//$str1_n = $crypt->decrypt($gelSurname->guardian_name);
$sCon = $this->connection
->select('applicant_users', 'eApplicant')
->fields('eApplicant', array('surname','name'))
->condition('eApplicant.id', $gelSurname->gel_userid, '=');
$applicantSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$applicantSurname = reset($applicantSurnames);
if ($applicantSurname->surname != null)
$str2 = $crypt->decrypt($applicantSurname->surname);
else
$str2 = "EMPTY";
//$str2_n = $crypt->decrypt($applicantSurname->name);
//if ($str1 != $str2) {
if ( $str1 != $str2
//|| ($str1 == $str2 && $str1_n != $str2_n )
) {
print_r("id: " . $gelSurname->id . " gel_userid: " . $gelSurname->gel_userid . " gelSurname: " . $str1 . " applicantName: " . $str2 );
print_r("\r");
}
}
*/
//ΕΛΕΓΧΟΣ ΕΠΙΒΕΒΑΙΩΣΗΣ
/*
$sCon = $this->connection
->select('gel_student', 'eStudent')
->fields('eStudent', array('id', 'guardian_surname', 'gel_userid'))
->condition('eStudent.delapp', 0, '=');
$gelSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($gelSurnames as $gelSurname) {
if ($gelSurname->id == 739 || $gelSurname->id == 1000 || $gelSurname->id == 1014 || $gelSurname->id == 2588 || $gelSurname->id == 3379 ||
$gelSurname->id == 6919 || $gelSurname->id == 13884 || $gelSurname->id == 13988 || $gelSurname->id == 14255 || $gelSurname->id == 14482 ||
$gelSurname->id == 19543 || $gelSurname->id == 19691 || $gelSurname->id == 23855 || $gelSurname->id == 25097 || $gelSurname->id == 25196 ||
$gelSurname->id == 25773 || $gelSurname->id == 27097 || $gelSurname->id == 28375 || $gelSurname->id == 32468 || $gelSurname->id == 34116 ||
$gelSurname->id == 38145 || $gelSurname->id == 46005 || $gelSurname->id == 47575 || $gelSurname->id == 50425 || $gelSurname->id == 52831 ||
$gelSurname->id == 52916
) {
$sCon = $this->connection
->select('epal_student', 'eEpalStudent')
->fields('eEpalStudent', array('guardian_surname','epaluser_id'))
->condition('eEpalStudent.id', $gelSurname->id, '=');
$epalSurnames = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalSurnames as $epalSurname) {
$name1 = $crypt->decrypt($gelSurname->guardian_surname);
$name2 = $crypt->decrypt($epalSurname->guardian_surname);
print_r("id: " . $gelSurname->id . " gelGuardianSurname: " . $name1 . " epalGuardianSurname: " . $name2);
print_r("\r");
}
}
}
*/
//για ΔΔΕ ΑΧΑΙΑΣ!
/*
$sCon = $this->connection
->select('gel_school', 'eSchool')
->fields('eSchool', array('registry_no', 'name'))
->condition('eSchool.edu_admin_id', 17, '=');
$epalSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalSchools as $epalSchool) {
$sCon = $this->connection
->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'am'))
->condition('eStudent.delapp', 0, '=')
->condition('eStudent.lastschool_registrynumber',$epalSchool->registry_no , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalStudents as $epalStudent) {
if ($epalStudent->am != null) {
print_r("Am," . $crypt->decrypt($epalStudent->am) . ",reg_no," . strval($epalSchool->registry_no) . ", schName," . $epalSchool->name );
print_r("<br/>");
}
}
}
*/
print_r("\rΤΕΛΟΣ!");
}
}
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace Drupal\gel\Controller;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\gel\Crypt;
class CreateGelDemoData extends ControllerBase {
protected $entity_query;
protected $entityTypeManager;
protected $logger;
protected $connection;
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
QueryFactory $entity_query,
Connection $connection,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->entity_query = $entity_query;
$this->connection = $connection;
$this->logger = $loggerChannel->get('gel');
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity.manager'),
$container->get('entity.query'),
$container->get('database'),
$container->get('logger.factory')
);
}
public function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return $sec + $usec * 1000000;
}
public function UniqueRandNum($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
return array_slice($numbers, 0, $quantity);
}
public function createData() {
$crypt = new Crypt();
$transaction = $this->connection->startTransaction();
try {
//insert demo records in entity: gel_student
$entity_manager = \Drupal::entityTypeManager();
$geluserid = \Drupal::currentUser()->id();
//$geluserid = 25;
$schoolIdsList = array();
$sCon = $this->connection->select('gel_school', 'eSchool')
->fields('eSchool', array('name', 'registry_no', 'unit_type_id','edu_admin_id'))
//περιοχή Γ' Αθήνας'
->condition('eSchool.edu_admin_id', 9, '=');
//
//->condition('eSchool.unit_type_id', 3, '=');
$gelSchools = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($gelSchools as $gelSchool) {
array_push($schoolIdsList, $gelSchool->id);
}
for ($i = 1; $i <= 5000; $i++) {
$curclass = rand(1,7);
$lastclass = rand(1,4);
$am = rand(1,100000);
$myschool_id = rand(1,100000);
$lastschool_id = rand(0, sizeof($schoolIdsList));
$lastschool_schoolname = $gelSchools[$lastschool_id]->name;
$lastschool_unittypeid = $gelSchools[$lastschool_id]->unit_type_id;
$lastschool_registrynumber = $gelSchools[$lastschool_id]->registry_no;
//$lastschool_schoolname = "8ο ΗΜΕΡΗΣΙΟ ΓΥΜΝΑΣΙΟ ΙΛΙΟΥ";
//$lastschool_unittypeid = 3;
//$lastschool_registrynumber = "0501067";
$student = array(
'gel_userid' => $geluserid,
'am' => $crypt->encrypt(strval($am)),
'myschool_id' =>$myschool_id,
'name' => $crypt->encrypt("όνομα" . $i),
'studentsurname' => $crypt->encrypt("επώνυμο" . $i),
'birthdate' => '01/01/1970',
'fatherfirstname' => $crypt->encrypt("όνομα_πατέρα" . $i),
'motherfirstname' => $crypt->encrypt("όνομα_μητέρας" . $i),
'regionaddress' => $crypt->encrypt("διεύθυνση" . $i),
'regionarea' => $crypt->encrypt("περιοχή" . $i),
'regiontk' => $crypt->encrypt("ΤΚ" . $i),
'nextclass' => $curclass,
'relationtostudent' => 'Γονέα/Κηδεμόνα',
'telnum' => $crypt->encrypt('6944123456'),
'guardian_name' => $crypt->encrypt('όνομα_κηδεμόνα'),
'guardian_surname' => $crypt->encrypt('επώνυμο_κηδεμόνα'),
'guardian_fathername' => $crypt->encrypt('όνομα_πατέρα_κηδεμόνα'),
'guardian_mothername' => $crypt->encrypt('όνομα_μητέρας_κηδεμόνα'),
'lastschool_class' => $lastclass,
'lastschool_schoolyear' => "2017-2018",
'lastschool_schoolname' => $lastschool_schoolname,
'lastschool_unittypeid' => $lastschool_unittypeid,
'lastschool_registrynumber' => $lastschool_registrynumber,
'agreement' => 1,
'myschool_currentsection' => "ΟΝΟΜΑ ΤΟΜΕΑ / ΟΜΑΔΑΣ ΠΡΟΣΑΝΑΤΟΛΙΣΜΟΥ"
);
$entity_storage_student = $entity_manager->getStorage('gel_student');
$entity_object = $entity_storage_student->create($student);
$entity_storage_student->save($entity_object);
//insert records in entity: gel_student_choices
//...
$created_student_id = $entity_object->id();
//$entity_storage_student->resetCache();
if ($curclass === 3 || $curclass === 7 || $curclass === 2 || $curclass === 6 ) {
$choice_id_OP = 0;
if ($curclass === 3 || $curclass === 7 )
$choice_id_OP = rand(15,17);
else if ($curclass === 2 || $curclass === 6)
$choice_id_OP = rand(15,16);
$studentChoicesOP = array(
'name' => '',
'student_id' =>$created_student_id,
'choice_id' => strval($choice_id_OP),
);
$entity_storage_choice = $entity_manager->getStorage('gel_student_choices');
$entity_object = $entity_storage_choice->create($studentChoicesOP);
$entity_storage_choice->save($entity_object);
}
else if ($curclass === 1 || $curclass === 4 || $curclass === 3 ) {
//$choice_id_EPIL;
if ($curclass === 1 || $curclass === 4)
//$choice_id_EPIL = rand(4,7);
$choice_id_EPIL = $this->UniqueRandNum(4,7,2);
else if ($curclass === 3)
//$choice_id_EPIL = rand(8,13);
$choice_id_EPIL = $this->UniqueRandNum(8,13,2);
for ($j=1; $j <= 2; $j++) {
$studentChoicesEPIL = array(
'name' => '',
'student_id' =>$created_student_id,
'choice_id' => strval($choice_id_EPIL[$j-1]),
'order_id' => $j,
);
$entity_storage_choice = $entity_manager->getStorage('gel_student_choices');
$entity_object = $entity_storage_choice->create($studentChoicesEPIL);
$entity_storage_choice->save($entity_object);
} //end for
} //end if
} //end for
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
$returnmsg = "Αποτυχία καταχώρησης demo data!";
$response = new JsonResponse([$returnmsg]);
// $transaction->rollback();
return $response;
}
$response = new JsonResponse(['hello' => 'world']);
$response->headers->set('X-AUTH-TOKEN', 'HELLOTOKEN');
return $response;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment