Example #1
0
 function testShouldSaveAsHash()
 {
     $imageData = '<pretend this is image data>';
     $saver = new Saver($imageData);
     $saver->save();
     $this->assertTrue(file_exists('./data/images/427d0d1bb2c597b5faceb50786c0d6cfb9bdee0d'));
 }
Example #2
0
 public function run()
 {
     $return = $this->experiment->run();
     // Save experiment to temporary storage
     $saver = new Saver(new Results($this->experiment), $this->getPayloadSaver(), $this->getStorage());
     $saver->save();
     if ($this->experiment->hasException()) {
         throw $this->experiment->getExcepion();
     }
     return $return;
 }
Example #3
0
 /**
  * @copydoc Saver::save
  *
  * @note After saving site data it creates new section, translations and rights.
  */
 public function save()
 {
     $mainTableName = 'share_sites';
     if (isset($_POST[$mainTableName]['site_is_default']) && $_POST[$mainTableName]['site_is_default'] !== '0') {
         $this->dbh->modify(QAL::UPDATE, $mainTableName, array('site_is_default' => '0'));
     }
     $result = parent::save();
     $id = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName('site_id')->getRowData(0);
     //Сохраняем информацию о доменах
     $domainIDs = $this->dbh->getColumn('SELECT domain_id FROM share_domains WHERE domain_id NOT IN (SELECT domain_id FROM share_domain2site)');
     if (!empty($domainIDs)) {
         foreach ($domainIDs as $domainID) {
             $this->dbh->modify(QAL::INSERT, 'share_domain2site', array('site_id' => $id, 'domain_id' => $domainID));
         }
     }
     //Записываем информацию в таблицу тегов
     $tm = new TagManager($this->dataDescription, $this->data, 'share_sites');
     $tm->save($id);
     if ($this->getMode() == QAL::INSERT) {
         //При создании нового проекта   ищем параметр конфигурации указывающий на идентификатор
         //шаблонного раздела
         if (isset($_POST['copy_site_structure'])) {
             $this->copyStructure((int) $_POST['copy_site_structure'], $id);
         } else {
             $this->createMainPage($id);
         }
     }
     return $result;
 }
Example #4
0
 protected function savePoints()
 {
     parent::savePoints();
     $starV = \App\StarsValue::where('star', $this->data['star'])->first();
     $this->userInstance->points()->increment('stars', 1);
     $value = $starV->value * $starV->modifier;
     if ($value > 0) {
         $this->userInstance->points()->increment('points', $value);
     }
 }
Example #5
0
 public function __construct(\App\Myclasses\Checks\checkMulti $checker)
 {
     parent::__construct($checker);
     $this->address = $checker->getAddress();
     $this->addrId = $this->address->id;
     try {
         $this->saveCenter();
         $this->finalize();
     } catch (\PDOException $e) {
         $this->rollback();
     }
 }
Example #6
0
 public function __construct(\App\Myclasses\Checks\checkPlanet $checker)
 {
     parent::__construct($checker);
     $this->address = $checker->getAddress();
     $this->addrId = $this->address->id;
     $this->user = \Auth::user();
     //remembering the user who made a discovery
     $this->checker->setUserData($this->user->id);
     $status = $this->checker->getSmartCheckMessage();
     $this->status = $status['type'];
     $this->saveIt();
     $this->finalize();
 }
Example #7
0
 /**
  * Save data into the table of uploads and tags.
  */
 public function save()
 {
     $result = parent::save();
     $entityID = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName($this->pk)->getRowData(0);
     $tm = new TagManager($this->dataDescription, $this->data, $this->mainTableName);
     $tm->save($entityID);
     // обновление записей из _uploads таблицы, в которых PK = NULL по ID сессии
     if ($result && $this->dbh->tableExists($this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX)) {
         $id = is_int($result) ? $result : (int) $_POST[$this->getTableName()][$this->getPK()];
         //throw new SystemException($id);
         $this->dbh->modify(QAL::UPDATE, $this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX, array($this->getPK() => $id), array($this->getPK() => null, 'session_id' => session_id()));
     }
     return $result;
 }
Example #8
0
    $num = count($_POST['txt']);
    $full = array();
    #Pages, pre, code
    for ($i = 0; $i < $num; ++$i) {
        if (empty($_POST['txt'][$i])) {
            continue;
        }
        if (isset($_POST['code'][$i])) {
            $_POST['txt'][$i] = preg_replace_callback(array('#<(pre)([^>]*)>(.*?)</pre>#si', '#<(code)([^>]*)>(.*?)</code>#si'), create_function('$x', 'return "<$x[1]$x[2]>".htmlspecialchars($x[3],0)."</$x[1]>";'), $_POST['txt'][$i]);
        }
        $full[] = array($i + 1, &$_POST['txt'][$i], isset($_POST['br'][$i]) + (isset($_POST['emo'][$i]) ? 2 : 0) + (isset($_POST['code'][$i]) ? 4 : 0));
    }
    #Prepare data
    $art = array('pages' => count($full), 'cat' => (int) $_POST['cat'], 'dsc' => clean($_POST['dsc']), 'name' => clean($_POST['name']), 'author' => clean($_POST['author']), 'access' => isset($_POST['access']), 'priority' => (int) $_POST['priority']);
    try {
        $e = new Saver($art, $id, 'arts');
        #DB query
        if ($id) {
            $art['ID'] = $id;
            $q = $db->prepare('UPDATE ' . PRE . 'arts SET cat=:cat, access=:access, name=:name,
			dsc=:dsc, author=:author, priority=:priority, pages=:pages WHERE ID=:ID');
        } else {
            $q = $db->prepare('INSERT INTO ' . PRE . 'arts (cat,name,dsc,date,author,access,priority,pages)
			VALUES (:cat,:name,:dsc,"' . gmdate('Y-m-d H:i:s') . '",:author,:access,:priority,:pages)');
        }
        $q->execute($art);
        #Get new ID
        if (!$id) {
            $id = $db->lastInsertId();
        }
        #Prepare query for pages
Example #9
0
if (EC != 1) {
    exit;
}
#Action: save as new
if (isset($_POST['asNew'])) {
    $id = 0;
}
#Page title
$view->title = $id ? $lang['edit5'] : $lang['add5'];
#Action: save
if ($_POST) {
    $news = array('opt' => isset($_POST['br']) + (isset($_POST['emo']) ? 2 : 0) + (isset($_POST['fn']) ? 4 : 0), 'name' => clean($_POST['name']), 'img' => clean($_POST['img']), 'txt' => &$_POST['txt'], 'cat' => (int) $_POST['cat'], 'access' => isset($_POST['access']));
    #Full text
    $full =& $_POST['text'];
    try {
        $e = new Saver($news, $id, 'news');
        #Query
        if ($id) {
            $news['ID'] = $id;
            $q = $db->prepare('UPDATE ' . PRE . 'news SET cat=:cat, access=:access,
			name=:name, txt=:txt, img=:img, opt=:opt WHERE ID=:ID');
        } else {
            $news['author'] = UID;
            $news['date'] = gmdate('Y-m-d H:i:s');
            $q = $db->prepare('INSERT INTO ' . PRE . 'news (cat,access,name,txt,date,author,img,opt)
				VALUES (:cat,:access,:name,:txt,:date,:author,:img,:opt)');
        }
        $q->execute($news);
        #Get new ID
        if (!$id) {
            $id = $db->lastInsertId();
Example #10
0
<?php

if (EC != 1) {
    exit;
}
#Action: save as new
if (isset($_POST['asNew'])) {
    $id = 0;
}
#Page title
$view->title = $id ? $lang['edit4'] : $lang['add4'];
#Action: save
if ($_POST) {
    $link = array('cat' => (int) $_POST['cat'], 'dsc' => clean($_POST['dsc']), 'adr' => clean(str_replace(array('javascript:', 'vbscript:'), '', $_POST['adr'])), 'name' => clean($_POST['name']), 'nw' => isset($_POST['nw']), 'access' => isset($_POST['access']), 'priority' => (int) $_POST['priority']);
    try {
        $e = new Saver($link, $id, 'links', 'cat,access');
        #Prepare query
        if ($id) {
            $link['ID'] = $id;
            $q = $db->prepare('UPDATE ' . PRE . 'links SET cat=:cat, access=:access,
			name=:name, dsc=:dsc,adr=:adr, priority=:priority, nw=:nw WHERE ID=:ID');
        } else {
            $q = $db->prepare('INSERT INTO ' . PRE . 'links (cat,access,name,dsc,adr,priority,nw)
				VALUES (:cat,:access,:name,:dsc,:adr,:priority,:nw)');
        }
        $q->execute($link);
        if (!$id) {
            $id = $db->lastInsertId();
        }
        #Apply changes
        $e->apply();
Example #11
0
<?php

if (EC != 1) {
    exit;
}
#Action: save as new
if (isset($_POST['asNew'])) {
    $id = 0;
}
#Page title
$view->title = $id ? $lang['edit2'] : $lang['add2'];
#Action: save
if ($_POST) {
    $file = array('cat' => (int) $_POST['cat'], 'dsc' => clean($_POST['dsc']), 'name' => clean($_POST['name']), 'file' => clean($_POST['file']), 'size' => clean($_POST['size']), 'fulld' => &$_POST['full'], 'author' => clean($_POST['author']), 'access' => isset($_POST['access']), 'priority' => (int) $_POST['priority']);
    try {
        $e = new Saver($file, $id, 'files');
        #Prepare query
        if ($id) {
            $file['ID'] = $id;
            $q = $db->prepare('UPDATE ' . PRE . 'files SET cat=:cat, access=:access, name=:name,
			author=:author, dsc=:dsc, file=:file, size=:size, priority=:priority, fulld=:fulld WHERE ID=:ID');
        } else {
            $q = $db->prepare('INSERT INTO ' . PRE . 'files (cat, name, author, date, dsc,
				file, access, size, priority, fulld) VALUES (:cat, :name, :author, "' . gmdate('Y-m-d H:i:s') . '", :dsc, :file, :access, :size, :priority, :fulld)');
        }
        $q->execute($file);
        if (!$id) {
            $id = $db->lastInsertId();
        }
        #Apply changes
        $e->apply();
Example #12
0
if (empty($_FILES['my'])) {
    die_with_code(400, "No data");
} else {
    $clnt_loader = new Loader($_FILES['my']['tmp_name']);
    $clnt_plan_set = $clnt_loader->load_plan_set();
    $find_user = $db->prepare("SELECT * FROM users WHERE login = :login AND password = :password");
    $find_user->execute(array(":login" => $clnt_plan_set->login, ":password" => $clnt_plan_set->password));
    $row = $find_user->fetch();
    if ($row == null) {
        die_with_code(400, "Invalid login/password");
    }
    $uid = $row['id'];
    header("Content-Type: text/plain");
    $serv_loader = new Loader("db/{$uid}.sqlite");
    $serv_plan_set = $serv_loader->load_plan_set();
    $merged_plan_set = merge_plan_sets($serv_plan_set, $clnt_plan_set);
    $tmp_filename = tempnam(sys_get_temp_dir(), "planaris");
    $saver = new Saver("db/{$uid}.sqlite");
    $saver->save_plan_set($merged_plan_set);
    $saver = new Saver($tmp_filename);
    $saver->save_plan_set($merged_plan_set);
    readfile($tmp_filename);
    unlink($tmp_filename);
}
function get_option($db, $optname)
{
    $get_opt = $db->prepare("SELECT value FROM options WHERE name = :name");
    $get_opt->execute(array(":name" => $optname));
    $row = $get_opt->fetch();
    return $row[0];
}
Example #13
0
<?php

if (EC != 1) {
    exit;
}
#Action: save as new
if (isset($_POST['asNew'])) {
    $id = 0;
}
#Page title
$view->title = $id ? $lang['edit3'] : $lang['add3'];
#Action: save
if ($_POST) {
    $img = array('cat' => (int) $_POST['cat'], 'name' => clean($_POST['name']), 'author' => clean($_POST['author']), 'file' => clean($_POST['file']), 'th' => clean($_POST['fm']), 'access' => isset($_POST['access']), 'priority' => (int) $_POST['priority'], 'type' => (int) $_POST['type'], 'dsc' => &$_POST['dsc'], 'size' => $_POST['s1'] ? $_POST['s1'] . '|' . $_POST['s2'] : '');
    try {
        $e = new Saver($img, $id, 'imgs');
        #Prepare query
        if ($id) {
            $img['ID'] = $id;
            $q = $db->prepare('UPDATE ' . PRE . 'imgs SET cat=:cat, access=:access,
				name=:name, author=:author, dsc=:dsc, file=:file, th=:th,
				priority=:priority, type=:type, size=:size WHERE ID=:ID');
        } else {
            $img['date'] = gmdate('Y-m-d H:i:s');
            $q = $db->prepare('INSERT INTO ' . PRE . 'imgs (cat,access,name,dsc,type,date,
				priority,author,file,th,size) VALUES (:cat,:access,:name,:dsc,:type,
				:date,:priority,:author,:file,:th,:size)');
        }
        $q->execute($img);
        #New ID
        if (!$id) {