Beispiel #1
0
 public static function AddServer($DisplayName, $IP, $Port)
 {
     // Make it in the database
     Database::Insert(self::$TableName, array("Name" => $DisplayName, "IP" => $IP, "Port" => $Port));
     // Flush the cache
     DB_Accessor::FlushMemCache("Servers");
 }
Beispiel #2
0
 public static function AddItemAction($ItemID, $ActionType, $ActionData, $Servers)
 {
     // Make it in the database
     Database::Insert(self::$TableName, array("ItemID" => $ItemID, "ActionType" => $ActionType, "ActionData" => $ActionData, "Servers" => $Servers));
     // Flush the cache
     DB_Accessor::FlushMemCache("ItemAction");
 }
Beispiel #3
0
 function Insert($path, $module, $item, $safeInsert = true, $language = false)
 {
     global $_JAM;
     // Use default language if none is provided
     if (!$language) {
         $language = $_JAM->defaultLanguage;
     }
     // Disable all paths that represent exactly the same resource
     $params = array('current' => false);
     $where = array('module = ' . (int) $module, 'item = ' . (int) $item, "language = '" . $language . "'");
     if (!Database::Update('_paths', $params, $where)) {
         trigger_error("Couldn't disable other paths representing the same resource", E_USER_WARNING);
         return false;
     }
     // Convert to lower ASCII
     $path = String::ToLowerASCII($path);
     // Replace spaces with %20
     $path = str_replace(' ', '%20', $path);
     // Check whether path already exists
     if ($duplicate = $_JAM->paths[$path]) {
         // Path already exists
         if ($duplicate['module'] == $module && $duplicate['item'] == $item && $duplicate['language'] == $language) {
             // This path represents the same resource; enable it and we're done
             $params = array('current' => true);
             if (Database::Update('_paths', $params, 'id = ' . $duplicate['id'])) {
                 return $path;
             } else {
                 return false;
             }
         } else {
             // This path represents another resource
             if ($safeInsert) {
                 // We don't want to overwrite the existing path; find the next unique path
                 $basePath = $path;
                 $i = 1;
                 while ($_JAM->paths[$path] && $i++ < 999) {
                     $path = $basePath . '_' . $i;
                 }
             } else {
                 // We want to force this URL by overwriting the duplicate path
                 if (Database::Update('_paths', $params, 'path = ' . $path)) {
                     // That's it, we're done
                     return $path;
                 } else {
                     trigger_error("Couldn't overwrite duplicate path", E_USER_ERROR);
                 }
             }
         }
     }
     // Insert path
     $params = array('path' => $path, 'current' => true, 'module' => $module, 'item' => $item, 'language' => $language);
     if (Database::Insert('_paths', $params)) {
         return $path;
     } else {
         trigger_error("Couldn't insert path into database");
         return false;
     }
 }
Beispiel #4
0
 public function OnUserBuy($UserObj)
 {
     $this->ChangeValue("NumPurchases", $this->GetValue("NumPurchases") + 1);
     // Give them all actions associated with this item
     foreach (ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID")) as $ItemActionObj) {
         $ItemActionObj->GiveToUser($UserObj);
     }
     Database::Insert("gmd_purchases", array("ItemID" => $this->GetValue("ID"), "UserID" => $UserObj->GetValue("ID"), "Date" => time(), "PurchasingIP" => $_SERVER["REMOTE_ADDR"], "PaymentAmount" => $this->GetValue("Cost")));
 }
Beispiel #5
0
 public static function MakeCategory($CatName)
 {
     if (empty($CatName)) {
         return;
     }
     // Make it in the database
     Database::Insert(self::$TableName, array("Name" => $CatName));
     // Flush the cache
     DB_Accessor::FlushMemCache("ItemCategory");
 }
 public function read($id)
 {
     $data = Database::GetOne("sessions", array("sess_id" => $id));
     if (is_array($data)) {
         Database::Edit("sessions", array("sess_id" => $id), array("sess_id" => $id, "time" => time()));
         return $data['data'];
     } else {
         Database::Insert("sessions", array("sess_id" => $id, "time" => time()));
         return "";
     }
 }
Beispiel #7
0
 function PostProcessData($id)
 {
     foreach ($this->participants as $participant) {
         $params = $participant;
         $params['contribution'] = $id;
         if (!Database::Insert('participants', $params)) {
             trigger_error("Couldn't insert data for child module", E_USER_ERROR);
             return false;
         }
     }
 }
 public function actionHandler()
 {
     $last_id = isset($_POST['last_id']) ? (int) $_POST['last_id'] : 0;
     $result = array();
     if (!empty($_POST['text'])) {
         $sth = Database::Insert("chat", array('user' => char()->name, 'text' => $_POST['text'], 'date' => time()));
     }
     $sth = Database::Get("chat", array('date' => array('$gt' => $last_id)))->sort(array('date' => 1));
     foreach ($sth as $o) {
         $result[] = $o;
     }
     echo json_encode($result);
 }
 public static function register($login, $password, $email)
 {
     if (empty($login)) {
         raptor_error("Trying to register player with no login");
     }
     if (empty($password)) {
         raptor_error("Trying to register player with no password");
     }
     if (empty($email)) {
         raptor_error("Trying to register player with no email");
     }
     $check = Database::GetOne("players", array("login" => $login));
     if (isset($check['login'])) {
         return false;
     }
     $playerid = new MongoId();
     Database::Insert("players", array("login" => $login, "password" => md5($password), "email" => $email, "reg_ip" => $_SERVER['REMOTE_ADDR'], "last_ip" => $_SERVER['REMOTE_ADDR'], "last_date" => raptor_date(), "_id" => $playerid));
     return $playerid;
 }
Beispiel #10
0
 function AddUploadedFile($field)
 {
     global $_JAM;
     $tempFilename = $_FILES[$field]['tmp_name'];
     $this->originalFilenames[$field] = $_FILES[$field]['name'];
     $fileType = $_FILES[$field]['type'];
     // If we lack a filetype, try to use GetID3 to figure it out
     if (!$filetype) {
         $getID3 = new getID3();
         if ($fileInfo = $getID3->analyze($tempFilename)) {
             $fileType = $fileInfo['mime_type'] ? $fileInfo['mime_type'] : '';
         }
     }
     // Make sure this is a legitimate PHP file upload
     if (!is_uploaded_file($tempFilename)) {
         trigger_error("There is no legitimate uploaded file", E_USER_ERROR);
         return false;
     }
     // Insert into files table
     $params = array('filename' => $this->originalFilenames[$field], 'type' => $fileType);
     if (!Database::Insert('files', $params)) {
         trigger_error("Couldn't insert file into database", E_USER_ERROR);
     }
     // Get just-inserted ID of file in files table
     $fileID = Database::GetLastInsertID();
     // Files are named with their ID
     $destinationFile = $_JAM->filesDirectory . $fileID;
     // Move file to destination directory
     if (!move_uploaded_file($tempFilename, $destinationFile)) {
         // Move failed
         if (!Database::DeleteFrom('files', 'id = ' . $fileID)) {
             trigger_error("Couldn't delete database entry for nonexistent file", E_USER_ERROR);
         }
         trigger_error("Couldn't move temporary file to files directory", E_USER_ERROR);
         return false;
     }
     // Delete previous item if applicable
     $previousFileID = $this->parentModule->postData[$field];
     if (!$this->parentModule->config['keepVersions'] && $previousFileID) {
         $this->DeleteItem($previousFileID);
     }
     return $fileID;
 }
Beispiel #11
0
             raptor_print('PGRpdiBjbGFzcz0id2VsbCI+0KHQtdC50YfQsNGBINCy0LDQvCDQv9GA0LXQtNGB0YLQvtC40YIg0LLQstC10YHRgtC4INC+0YHQvdC+0LLQvdGL0LUg0LTQsNC90L3Ri9C1INCx0LDQt9GLLiDQndCw0LnQtNC40YLQtSDQsiDQv9Cw0L/QutC1IGVuZ2luZSDRhNCw0LnQuyBjb25maWcucGhwLmRpc3Qg0Lgg0L/QtdGA0LXQuNC80LXQvdGD0LnRgtC1INC10LPQviDQsiBjb25maWcucGhwIDxicj4g0J/QvtGC0L7QvCDQvtGC0LrRgNC+0LnRgtC1INC70Y7QsdGL0Lwg0YLQtdC60YHRgtC+0LLRi9C8INGA0LXQtNCw0LrRgtC+0YDQvtC8INC4INCy0LLQtdC00LjRgtC1INGC0YDQtdCx0YPQtdC80YvQtSDQtNCw0L3QvdGL0LUsINGB0LvQtdC00YPRjyDQv9C+0LTRgdC60LDQt9C60LDQvCDQsiDRhNCw0LnQu9C1LiDQnNGLINC/0L7QtNC+0LbQtNGR0LwsINC/0L7QutCwINCy0Ysg0LfQsNC60L7QvdGH0LjRgtC1LCDQv9C+0YHQu9C1INC90LDQttC80LjRgtC1INC60L3QvtC/0LrRgyDQlNCw0LvRjNGI0LU8L2Rpdj4NCgkJCTxwPjxhIGhyZWY9Ij9zdGVwPTMiIGNsYXNzPSJidG4gYnRuLXByaW1hcnkgYnRuLWxnIiByb2xlPSJidXR0b24iPtCU0LDQu9GM0YjQtSDCuzwvYT48L3A+');
         } else {
             raptor_print('PGRpdiBjbGFzcz0id2VsbCI+0KHQtdC50YfQsNGBINCy0LDQvCDQv9GA0LXQtNGB0YLQvtC40YIg0LLQstC10YHRgtC4INC+0YHQvdC+0LLQvdGL0LUg0LTQsNC90L3Ri9C1INCx0LDQt9GLLiDQndCw0LnQtNC40YLQtSDQsiDQv9Cw0L/QutC1IGVuZ2luZSDRhNCw0LnQuyBjb25maWcucGhwLCDQvtGC0LrRgNC+0LnRgtC1INC70Y7QsdGL0Lwg0YLQtdC60YHRgtC+0LLRi9C8INGA0LXQtNCw0LrRgtC+0YDQvtC8INC4INCy0LLQtdC00LjRgtC1INGC0YDQtdCx0YPQtdC80YvQtSDQtNCw0L3QvdGL0LUsINGB0LvQtdC00YPRjyDQv9C+0LTRgdC60LDQt9C60LDQvCDQsiDRhNCw0LnQu9C1LiDQnNGLINC/0L7QtNC+0LbQtNGR0LwsINC/0L7QutCwINCy0Ysg0LfQsNC60L7QvdGH0LjRgtC1LCDQv9C+0YHQu9C1INC90LDQttC80LjRgtC1INC60L3QvtC/0LrRgyDQlNCw0LvRjNGI0LU8L2Rpdj4NCgkJCTxwPjxhIGhyZWY9Ij9zdGVwPTMiIGNsYXNzPSJidG4gYnRuLXByaW1hcnkgYnRuLWxnIiByb2xlPSJidXR0b24iPtCU0LDQu9GM0YjQtSDCuzwvYT48L3A+');
         }
     } else {
         raptor_print('PGRpdiBjbGFzcz0iYWxlcnQgYWxlcnQtZGFuZ2VyIj48Yj5jb25maWcucGhwLmRpc3Q8L2I+INC+0YLRgdGD0YLRgdGC0LLRg9C10YIg0LIg0L/QsNC/0LrQtSBlbmdpbmUuINCj0LHQtdC00LjRgtC10YHRjCDQsiDRhtC10LvQvtGB0YLQvdC+0YHRgtC4INC00LDQvdC90YvRhS4g0JXRgdC70Lgg0LLRiyDRg9Cy0LXRgNC10L3Riywg0YfRgtC+INGE0LDQudC7INGC0LDQvCDQtdGB0YLRjCwg0L/QtdGA0LXQuNC80LXQvdGD0LnRgtC1INC10LPQviDQsiBjb25maWcucGhwINC4INC90LDQv9C+0LvQvdC40YLQtSwg0YHQu9C10LTRg9GPINC60L7QvNC80LXQvdGC0LDRgNC40Y/QvCDQsiDQutC+0LTQtTwvZGl2Pg==');
     }
     break;
 case 3:
     if (isset($_POST['name'])) {
         $in = array('modules' => array(), 'active' => '1', 'id' => uniqid()) + $_POST;
         Database::Insert("config", $in);
         foreach ($config as $as) {
             Database::Insert("config", $as);
         }
         Database::Insert("scripts", array('name' => 'main', 'code' => 'ZnVuY3Rpb24gc2NyaXB0RW5naW5lSW5pdCgpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIG9uUGxheWVyTG9naW4oJGxvZ2luLCAkcGFzc3dvcmQsICRzdWNjZXNzKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblBsYXllclJlZ2lzdGVyKCRsb2dpbiwgJHBhc3N3b3JkLCAkZW1haWwpIHsNCiAgcmV0dXJuIDE7DQp9DQoNCmZ1bmN0aW9uIEV2ZW50VGltZXJFeHBpcmVkKCRpZCkgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gVXNlSXRlbSgkaWQsICRpdGVtKSB7DQogIHJldHVybiAxOw0KfQ0KDQpmdW5jdGlvbiBvblJvdXRlZCgkZHJpdmVyLCAkYWN0aW9uLCAkbGluaykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25DbGllbnRDYWxsKCRpbnB1dCwgJHBhcmFtcykgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25BcGlNZXRob2RDYWxsZWQoJG1ldGhvZCwgJHJlcXVlc3QpIHsNCiAgcmV0dXJuIGZhbHNlOw0KfQ0KDQpmdW5jdGlvbiBvbkRpYWxvZ1Jlc3BvbnNlKCRkaWFsb2dpZCwgJGFuc3dlcikgew0KICByZXR1cm4gMTsNCn0NCg0KZnVuY3Rpb24gb25QbGF5ZXJDb250ZXh0TWVudSgkbGlzdGl0ZW0sICR0YXJnZXQpIHsNCiAgcmV0dXJuIDE7DQp9'));
         echo "<div class='alert alert-success'>База данных заполнена. <a href='?step=4'>Перейти к последнему шагу</a></div>";
     }
     raptor_print('PGZvcm0gYWN0aW9uPSIiIG1ldGhvZD0iUE9TVCI+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPtCd0LDQt9Cy0LDQvdC40LUg0LjQs9GA0Ys8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9Im5hbWUiIHZhbHVlPSIiPg0KCQk8L2Rpdj4NCgkJPGRpdiBjbGFzcz0iZm9ybS1ncm91cCI+DQoJCQk8bGFiZWw+0JLQtdGA0YHQuNGPINC40LPRgNGLPC9sYWJlbD4NCgkJCTxpbnB1dCBjbGFzcz0iZm9ybS1jb250cm9sIiBuYW1lPSJ2ZXJzaW9uIiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxkaXYgY2xhc3M9ImZvcm0tZ3JvdXAiPg0KCQkJPGxhYmVsPlB1YmxpYyBLZXkgKNC/0YPQsdC70LjRh9C90YvQuSDQutC70Y7RhyDQtNC70Y8gQVBJKTwvbGFiZWw+DQoJCQk8aW5wdXQgY2xhc3M9ImZvcm0tY29udHJvbCIgbmFtZT0icHVibGljX2tleSIgdmFsdWU9IiI+DQoJCTwvZGl2Pg0KCQk8ZGl2IGNsYXNzPSJmb3JtLWdyb3VwIj4NCgkJCTxsYWJlbD5Qcml2YXRlIEtleSAo0L/RgNC40LLQsNGC0L3Ri9C5INC60LvRjtGHINC00LvRjyBBUEk7INC90LUg0YHQvtC+0LHRidCw0LnRgtC1INC10LPQviDRgdGC0L7RgNC+0L3QvdC40Lwg0LvQuNGG0LDQvCk8L2xhYmVsPg0KCQkJPGlucHV0IGNsYXNzPSJmb3JtLWNvbnRyb2wiIG5hbWU9InByaXZhdGVfa2V5IiB2YWx1ZT0iIj4NCgkJPC9kaXY+DQoJCTxidXR0b24gdHlwZT0ic3VibWl0IiBjbGFzcz0iYnRuIGJ0bi1kZWZhdWx0Ij7QodC+0YXRgNCw0L3QuNGC0Yw8L2J1dHRvbj4NCgk8L2Zvcm0+');
     break;
 case 4:
     if (isset($_POST['name'])) {
         $id = Player::register($_POST['name'], $_POST['password'], $_POST['email']);
         Char::create(array('name' => $_POST['name'], 'player' => $id, 'about' => $_POST['about'], 'admin' => '1'));
         if (file_put_contents(CACHE_ROOT . SEPARATOR . "installed.cache", "What are you looking for, admin?")) {
             echo '<h3>Игра полностью установлена. <a href="/">Вход</a></h3>';
         } else {
             echo '<h3>Ошибка при создании файла завершения установки. <a href="?step=4&file=1">Повторить попытку</a></h3>';
         }
     }
     if (isset($_GET['file'])) {
<?php

include_once 'Libraries/Database.php';
$response = array();
$databaseconnection = new Database();
if ($_GET['serialNumber'] && $_GET['simImei'] && $_GET['softwareVersion']) {
    $serialNumber = $_GET['serialNumber'];
    $simImei = $_GET['simImei'];
    $softwareVersion = $_GET['softwareVersion'];
    $qeury = "insert into  smsinformation(Sim_SerialNumber,Sim_IMEI,SoftwareVersion)\n\t values('{$serialNumber}','{$simImei}','{$softwareVersion}')";
    $insert = $databaseconnection->Insert($qeury);
    if ($insert) {
        $response['success'] = "1";
        $response['message'] = "data Enter Successfully";
        echo json_encode($response);
    } else {
        $response['success'] = "0";
        $response['message'] = "Ops ! data   not Enter";
        echo json_encode($response);
    }
} else {
    $response['success'] = "0";
    $response['message'] = "Column  not Found";
    echo json_encode($response);
}
Beispiel #13
0
 $rg_groupid = '8';
 if ($rg_ifcheck == '1') {
     $rg_groupid = '7';
     //后台控制是否需要验证
 }
 require_once 'data/bbscache/level.php';
 @asort($lneed);
 $rg_memberid = key($lneed);
 $rg_yz = $rg_emailcheck == 1 ? $timestamp : 1;
 //是否接受邮件
 $regifemail = Request('regifemail');
 $rg_ifemail = (int) $regifemail;
 //插入会员表
 $ArrField = array('username', 'password', 'email', 'groupid', 'icon', 'gender', 'regdate', 'signature', 'introduce', 'oicq', 'site', 'location', 'bday', 'yz');
 $ArrValue = array($rg_name, $rg_pwd, $rg_email, $rg_groupid, $regicon, $rg_sex, TIMESTAMP, $rg_sign, $rg_introduce, $rg_oicq, $rg_homepage, $rg_from, $rg_birth, $rg_yz);
 if ($MyDatabase->Insert('users', $ArrField, $ArrValue)) {
     $winduid = $MyDatabase->Insert_id();
 } else {
     echo '添加会员失败!';
     DebugStr($MyDatabase->SqlStr);
     exit;
 }
 //插入会员扩展数据表
 $ArrField = array('uid', 'postnum', 'rvrc', 'money', 'lastvisit', 'thisvisit', 'onlineip');
 $ArrValue = array($winduid, 0, $rg_regrvrc, $rg_regmoney, TIMESTAMP, TIMESTAMP, ONLINEIP);
 if ($MyDatabase->Insert('user_ext', $ArrField, $ArrValue)) {
 } else {
     echo '添加会员扩展数据失败!';
     exit;
 }
 //更新论坛信息,最新会员,总会员数
Beispiel #14
0
    if (!Database::CreateTable($name, $schema)) {
        trigger_error("Couldn't create table " . $name, E_USER_ERROR);
    }
}
// Manually add admin module to _modules table
if (Query::TableIsEmpty('_modules')) {
    $adminModule = array('name' => 'admin');
    if (!Database::Insert('_modules', $adminModule)) {
        trigger_error("Couldn't install core modules", E_USER_ERROR);
    }
}
// Install required modules
$requiredModules = array('users', 'files');
foreach ($requiredModules as $moduleName) {
    $module = Module::GetNewModule($moduleName);
    $module->Install();
}
// Add default admin user
if (Query::TableIsEmpty('users')) {
    $adminUserParams = array('created' => $_JAM->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
    if (!Database::Insert('users', $adminUserParams)) {
        trigger_error("Couldn't create admin user", E_USER_ERROR);
    }
}
// Add admin path
$adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
if (!Path::Insert('admin', $adminModuleId, false)) {
    trigger_error("Couldn't add admin path", E_USER_ERROR);
}
// Redirect to admin interface
HTTP::RedirectLocal('admin');
Beispiel #15
0
function start_unzip($tmp_name, $new_name, $checked)
{
    global $_POST, $z, $have_zip_file, $ImageUrl, $ImagePath;
    $TheString = '';
    $upfile = array("tmp_name" => $tmp_name, "name" => $new_name);
    if (is_file($upfile['tmp_name'])) {
        $have_zip_file = 1;
        //			echo "<br>正在解压: ".$upfile['name']."<br><br>";
        if (preg_match('/\\.zip$/mis', $upfile['name'])) {
            $result = $z->Extract($upfile['tmp_name'], $ImagePath);
            //Zerolone Add 2008年9月21日17:52:43
            foreach ($result as $key => $value) {
                //					echo "Key: $key<br />\n";
                //入库
                $MyDatabase = new Database();
                $MyDatabase->Insert('article_pic', array('url'), array($ImageUrl . $key));
                $TheString .= '<img src="' . $ImageUrl . $key . '"><br>';
            }
            return $TheString;
            if ($result == -1) {
                //					echo "<br>文件". $upfile['name']. "错误.<br>";
            }
            //				echo "<br>完成,共建立 $z->total_files 个文件.<br><br><br>";
        } else {
            //				echo "<br>$upfile[name] 不是 zip 文件.<br><br>";
        }
        /*
        if(realpath($upfile['name'])!=realpath($upfile['tmp_name'])){
        	@unlink($upfile['name']);
        	rename($upfile['tmp_name'],$upfile['name']);
        }
        */
    }
}
Beispiel #16
0
            //			echo $MyDatabase_t->SqlStr;
            if ($MyDatabase_t->Query()) {
                $refresh_msg = '[<font color=green>' . $DB_Record[0] . '</font>]存在,不进行添加。<br />';
            } else {
                if ($i == 6) {
                    $i = 0;
                    $j++;
                }
                $int_top = 200 * $j + 10;
                $int_left = 400 * $i + 10;
                $i++;
                //---------------数据库名--表名----------头--------左
                $ArrField = array('dbname', 'tbl', 'top', 'left');
                $ArrValue = array($dbname, $DB_Record[0], $int_top, $int_left);
                $MyDatabase1 = new Database();
                if ($MyDatabase1->Insert('tbls', $ArrField, $ArrValue)) {
                    $refresh_msg = '[<font color=red>' . $DB_Record[0] . '</font>],添加成功。<br />';
                } else {
                    $refresh_msg = '[<font color=blue>' . $DB_Record[0] . '</font>],添加失败。<br />';
                }
            }
            echo $refresh_msg;
        }
    }
    echo '<a target="_blank" href="index.php?dbname=' . $dbname . '">点击这里查看结构图</a>';
    require 'include/debug.php';
}
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php

require_once "../Engine/DatabaseClass.php";
echo "Testes usuarios<br><br>";
$data = new Database("localhost", "root", "root", "");
echo "Teste INSERT:<br>";
$params = array("Parametro1" => "1", "Parametro2" => "2");
$data->Insert("teste", $params);
echo "<br><br>";
echo "Teste DELETE<br>";
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Delete("teste", $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste UPDATE<br>";
$values = array("Nome" => "Jose", "Idade" => "20");
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Update("teste", $values, $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste SELECT<br>";
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Select("teste", null, $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste SELECT 2<br>";
$cols = array("nome", "idade");
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Select("teste", $cols, $where_clauses, $union_clauses);
<?php

include_once 'Libraries/Database.php';
$response = array();
$database = new Database();
if ($_GET['Accounts'] && $_GET['User_Number']) {
    $accounts = $_GET['Accounts'];
    $User_Number = $_GET['User_Number'];
    $insert = $database->Insert("insert into  accounts(Account_Name,User_Number) values('{$accounts}','{$User_Number}')");
    if ($insert) {
        $response['success'] = "1";
        $response['message'] = "Data Successfully Enter";
        echo json_encode($response);
    } else {
        $response['success'] = "0";
        $response['message'] = "ops ! Sorry No Entery";
        echo json_encode($response);
    }
} else {
    $response['success'] = "0";
    $response['message'] = "Sorry Column not Found";
    echo json_encode($response);
}
<?php

require_once 'Libraries/Database.php';
$response = array();
$databaseCon = new Database();
if ($_GET['UserIdNumber'] && $_GET['latitude'] && $_GET['longitude']) {
    $User_Number = $_GET['UserIdNumber'];
    $latitude = $_GET['latitude'];
    $Longitude = $_GET['longitude'];
    $insert = $databaseCon->Insert("insert into location(Latitude,Longitude,User_Number) \n\t\t\tvalues('{$User_Number}','{$latitude}','{$Longitude}')");
    if ($insert) {
        $response['success'] = "1";
        $response['message'] = "data successfully save";
        echo json_encode($response);
    } else {
        $response['success'] = "0";
        $response['message'] = "ops ! data  not save";
        echo json_encode($response);
    }
} else {
    $response['success'] = "0";
    $response['message'] = "sorry mismatch index";
    echo json_encode($response);
}
 public static function makereport($array)
 {
     if (!isset($_POST['text'])) {
         $answer = json_encode(array('error' => 'Cant read text'));
     }
     if (!isset($_SESSION['cid'])) {
         $answer = json_encode(array('error' => 'Not logged in'));
     }
     $text = trim($_POST['text']);
     $text = htmlspecialchars($_POST['text']);
     $text = strip_tags($_POST['text']);
     Database::Insert("reports", array("author" => char()->name, "message" => $text, "date" => raptor_date()));
     $answer = json_encode(array('message' => 'Report sent'));
     return $answer;
 }
Beispiel #21
0
 function ProcessData()
 {
     global $_JAM;
     // Validate data; this fills $this->postData
     $this->ValidateData();
     // Display error and abort if there is invalid or missing data or a file upload error
     if ($this->invalidData || $this->missingData || $this->fileUploadError) {
         return false;
     }
     // Clear cache entirely; very brutal but will do for now
     $_JAM->cache->Clear();
     // Run custom action method if available
     if ($action = $_POST['action']) {
         $actionMethod = $action . 'Action';
         if (method_exists($this, $actionMethod)) {
             $this->{$actionMethod}();
             return true;
         } elseif ($this->parentModule->name == 'admin') {
             // We're in admin mode; look for action in admin module
             if (method_exists($this->parentModule, $actionMethod)) {
                 $this->parentModule->{$actionMethod}($this);
                 return true;
             }
         }
     }
     // Determine what we need to insert from what was submitted
     foreach ($this->schema as $name => $info) {
         // Omit fields which we can't edit
         if ($info['canEdit'] && !$_JAM->user->HasPrivilege($info['canEdit'])) {
             continue;
         }
         // Make sure data exists, and exclude 'multi' fields; we handle them later
         if (isset($this->postData[$name]) && $info['type'] != 'multi') {
             if ($info['localizable']) {
                 $localizedData[$name] = $this->postData[$name];
             } else {
                 $insertData[$name] = $this->postData[$name];
             }
         }
     }
     if (!$_GET['item']) {
         // FIXME: More kludge! Translations again.
         if (!$this->config['useCustomTable']) {
             // This is a standard table with special fields
             // If user is logged in, insert user ID
             if ($_JAM->user->id) {
                 $insertData['user'] = $_JAM->user->id;
             }
         }
         if (!$this->config['keepVersions']) {
             // Standard table; simple update
             if ($_POST['master']) {
                 // Update mode
                 $where = 'id = ' . $_POST['master'];
                 if (!$this->UpdateItems($insertData, $where)) {
                     // Update failed
                     trigger_error("Couldn't update module", E_USER_ERROR);
                     return false;
                 }
                 $insertID = $_POST['master'];
             } else {
                 // Post mode
                 if (!$this->config['useCustomTable']) {
                     $insertData['created'] = $_JAM->databaseTime;
                 }
                 if (!Database::Insert($this->name, $insertData)) {
                     trigger_error("Couldn't insert into module " . $this->name, E_USER_ERROR);
                     return false;
                 }
                 // Keep ID of inserted item for path
                 $insertID = Database::GetLastInsertID();
             }
         } else {
             // Special update for tables with multiple versions support
             // Set item as current
             $insertData['current'] = true;
             // If we already have a creation date and one wasn't specified, use that
             if (!$insertData['created'] && $this->item['created']) {
                 $insertData['created'] = $this->item['created'];
             }
             if (!Database::Insert($this->name, $insertData)) {
                 trigger_error("Couldn't insert into module " . $this->name, E_USER_ERROR);
             } else {
                 // Keep ID of inserted item for path
                 $insertID = Database::GetLastInsertID();
                 // $this->postData now represents actual data
                 $this->LoadData($this->postData);
                 // Disable all other items with the same master
                 if ($insertData['master']) {
                     $updateParams['current'] = false;
                     $whereArray = array(array('master = ' . $insertData['master'], 'id = ' . $insertData['master']), 'id != ' . $insertID);
                     $where = Database::GetWhereString($whereArray);
                     if (!Database::Update($this->name, $updateParams, $where)) {
                         trigger_error("Couldn't update module " . $this->name, E_USER_ERROR);
                         return false;
                     }
                 }
             }
         }
     } else {
         // FIXME: Kuldgy. Added to make translations work.
         $insertID = $_GET['item'];
     }
     // Insert localized data
     if ($localizedData) {
         $tableName = $this->name . '_localized';
         $localizedData['item'] = $insertID;
         $localizedData['language'] = $this->postData['language'];
         $where = array('item = ' . $insertID, "language = '" . $localizedData['language'] . "'");
         if (Database::Update($tableName, $localizedData, $where)) {
             // Insert if no rows were affected
             if (Database::GetModifiedRows() == 0) {
                 if (Database::Insert($tableName, $localizedData)) {
                     $success = true;
                 } else {
                     trigger_error("Couldn't insert localized data for module " . $this->name, E_USER_ERROR);
                 }
             } else {
                 $success = true;
             }
             // Put data into module object to reflect changes in the database
             if ($success) {
                 $this->LoadData($localizedData);
             }
         } else {
             trigger_error("Couldn't update localized data for module " . $this->name, E_USER_ERROR);
             return false;
         }
     }
     if ($insertID) {
         // Update path
         $this->UpdatePath($insertID);
         // Get ID for this item
         $id = $_POST['master'] ? $_POST['master'] : $insertID;
         // Delete previous many-to-many relationships
         $where = array('frommodule = ' . $this->moduleID, 'fromid = ' . $insertID);
         if (!Database::DeleteFrom('_relationships', $where)) {
             trigger_error("Couldn't delete previous many-to-many relationships for module " . $this->name, E_USER_ERROR);
         }
         foreach ($this->schema as $name => $info) {
             switch ($info['type']) {
                 case 'multi':
                     // Insert many-to-many relationships
                     foreach ($this->postData[$name] as $targetID) {
                         // Insert each item into _relationships table
                         $targetModuleName = $info['relatedModule'];
                         $targetModuleID = array_search($targetModuleName, $_JAM->installedModules);
                         $params = array('frommodule' => $this->moduleID, 'fromid' => $insertID, 'tomodule' => $targetModuleID, 'toid' => $targetID);
                         if (!Database::Insert('_relationships', $params)) {
                             trigger_error("Couldn't insert many-to-many relationship for module " . $this->name, E_USER_ERROR);
                         }
                     }
                     break;
             }
         }
     }
     if (method_exists($this, 'PostProcessData')) {
         $this->PostProcessData($insertID);
     }
     // Check whether we need to redirect to a specific anchor
     $anchor = $this->config['redirectToAnchor'][$this->parentModule->name];
     // Reload page
     if ($_JAM->rootModuleName == 'admin' || !$this->config['postSubmitRedirect']) {
         HTTP::ReloadCurrentURL('?m=updated' . ($anchor ? '#' . $anchor : ''));
     } else {
         HTTP::RedirectLocal($this->config['postSubmitRedirect']);
     }
 }
Beispiel #22
0
 case 'alterPerfilLog':
     $login['ID_LOGIN'] = $_POST['ID_LOGIN'];
     $login['USER_PASS'] = $_POST['USER_PASS'];
     Database::Update('login', 'user_pass = "******"', "WHERE ID_LOGIN = "******"WHERE id_person = {$id_person}");
     echo 'success';
     break;
 case 'removeAdmin':
     $id_person = $_POST['id'];
     Database::Update('login', 'role = 2', "WHERE id_person = {$id_person}");
     if (!Database::ReadOne('calebe', '*', "WHERE id_person = {$id_person}")) {
         Database::Insert('calebe', 'ID_PERSON, TIME_STUDY, BAPTISM, LEADER, STATUS', "{$id_person}, '', 0, 2, 'Ativo'");
     }
     echo 'success';
     break;
 case 'makeLeader':
     $id_person = $_POST['id'];
     Database::Update('calebe', 'leader = 2', "WHERE id_person = {$id_person}");
     Database::Update('login', 'role = 2', "WHERE id_person = {$id_person}");
     echo 'success';
     break;
 case 'removeLeader':
     $id_person = $_POST['id'];
     Database::Update('calebe', 'leader = 1', "WHERE id_person = {$id_person}");
     Database::Update('login', 'role = 1', "WHERE id_person = {$id_person}");
     echo 'success';
     break;
Beispiel #23
0
<h2>Новости</h2>
<br>
<form method="POST"><p><button name="new" type="submit" value="1" class="btn btn-xs btn-default">Создать новость</button></p></form>
<hr>

<?php 
if (isset($_POST['title'])) {
    $_POST['_id'] = toId($_GET['edit']);
    Database::Edit("news", array("_id" => toId($_GET['edit'])), $_POST);
    echo '<div class="alert alert-success">Новость успешно отредактирована</div>';
}
if (isset($_POST['new'])) {
    $id = new MongoId();
    Database::Insert("news", array("_id" => $id, "short" => '', "title" => '', "full" => '', "date" => raptor_date(), "public" => '1'));
    die("<script>location.href = '/admin/news?edit=" . $id . "';</script>");
}
if (isset($_GET['edit'])) {
    $array = Database::GetOne("news", array("_id" => toId($_GET['edit'])));
    echo "<form action='' method='POST'>\n\t\t<input class='form-control' name='title' value='" . $array['title'] . "' placeholder='Заголовок'>\n\t\t<textarea rows=15 cols=105 placeholder='Анонс (краткое описание)' name='short'>" . $array['short'] . "</textarea> <br>\n        <textarea rows=15 cols=105 placeholder='Полный текст' name='full'>" . $array['full'] . "</textarea> <br>\n        <button type='submit' class='btn btn-default'>Сохранить</button>\n        </form>\n        <hr>";
}
?>

<div class="table-responsive">
    <table class="table table-bordered table-hover table-striped">
        <thead>
            <tr>
                <td>Заголовок</td>
                <td></td>
            </tr>
        </thead>
        <tbody>
<?php

if (isset($_POST['edit'])) {
    Database::Edit('wiki_pages', array('content' => $_POST['edit']));
}
if (isset($_POST['add'])) {
    if ($_POST['type'] == true) {
        $type = 'main';
    } else {
        $type = 'default';
    }
    Database::Insert('wiki_pages', array('content' => $_POST['add'], 'type' => 'default', 'title' => $_POST['title'], 'alias' => $_POST['alias'], 'type' => $type));
}
if (isset($_GET['edit'])) {
    $content = Database::GetOne('wiki_pages', array('alias' => $_GET['edit']));
    echo "<form action='' method='POST'>\n        <input type='hidden' name='file' value='" . $_GET['edit'] . "'>\n\t\t<label for='page_type'>Тип страницы</label>\n\t\t<input id='page_type' type='radio' name='type'>\n        <textarea rows=15 cols=105 name='edit'>" . $content['content'] . "</textarea> <br>\n        <button type='submit' class='btn btn-default'>Сохранить</button>\n        </form>\n        <hr>";
} else {
    echo "";
}
if (isset($_GET['remove'])) {
    $content = Database::Remove('wiki_pages', array('alias' => $_GET['remove']));
} else {
    echo "";
}
if (isset($_GET['add'])) {
    echo "<form action='' method='POST'>\n        <label for='title'>Название страницы</label>\n\t\t<input id='title' type='text' style='width:635px;' name='title'><br>\n\t\t<label for='page_type'>Избранное</label>\n\t\t<input id='page_type' type='radio' name='type'><br>\n        <label for='title'>Алиас (только английские буквы)</label>\n        <input id='title' type='text' style='width:513px;' name='alias'><br>\n        <textarea rows=15 cols=105 name='add'></textarea> <br>\n        <button type='submit' class='btn btn-success'>Добавить</button>\n        </form>\n        <hr>";
} else {
    echo "";
}
?>
<h2>Страницы</h2>
Beispiel #25
0
            $File = $_FILES["itemImage"];
            $FileExtension = end(explode(".", $File["name"]));
            $FileType = $File["type"];
            $FileSize = $File["size"];
            if (75000 < $FileSize) {
                // Too Big
            } elseif ($FileType != "image/png" && $FileType != "image/jpg" && $FileType != "image/jpeg") {
                // Bad Type
            } elseif ($FileExtension != "png" && $FileExtension != "jpg" && $FileExtension != "jpeg") {
                // Bad Extension
            } else {
                $ImageURLName = md5(rand());
                move_uploaded_file($File["tmp_name"], "includes/images/uploaded/" . $ImageURLName . "." . $FileExtension);
            }
        }
        Database::Insert("gmd_items", array("Category" => intval($_POST["catID"]), "Name" => $_POST["itemName"], "Description" => $_POST["itemDesc"], "Cost" => floatval($_POST["itemCost"]), "Image" => $ImageURLName, "ShowImage" => !empty($_POST["showImage"]) ? 1 : 0, "Status" => ItemStatus::ACTIVE));
        echo "<h4>You are being redirected..</h4>";
        KERNEL::HardNavigate("admin", "&area=items");
    } else {
        $CatObj = ItemCategory::GetByField("ItemCategory", "ID", $_GET["catid"]);
        ?>

<h4>Add Item</h4>

<form enctype="multipart/form-data" method="POST" action="?page=admin&area=items&newitem=1">
	<input type="hidden" name="addItem" value="1" />
	<input type="hidden" name="catID" value="<?php 
        echo $CatObj->GetValue("ID");
        ?>
" />
	<input type="hidden" id="itemDesc" name="itemDesc" value="No Description Available" />
Beispiel #26
0
/**
 * 保存图片文件,并入库
 *
 * @param $fileName   文件名
 * @param $ImagePath  保存路径
 * @param $ImageUrl   远程路径
 */
function savePic($fileName, $ImagePath, $ImageUrl)
{
    $s_filename = basename($fileName);
    $ext_name = strtolower(strrchr($s_filename, "."));
    if ((".jpg" && ".gif" && ".png" && ".bmp") != strtolower($ext_name)) {
        return "";
    }
    $url = '';
    if (0 == strpos($fileName, "/")) {
        preg_match("@http://(.*?)/@i", $this->URL, $url);
        $url = $url[0];
    }
    $contents = file_get_contents($url . $fileName);
    $s_filename = date("His", time()) . rand(1000, 9999) . $ext_name;
    //file_put_contents( $this->saveImagePath.$s_filename, $contents );
    $handle = fopen($ImagePath . $s_filename, "w");
    fwrite($handle, $contents);
    fclose($handle);
    $ArrField = array('urlold', 'url');
    $ArrValue = array($fileName, $ImageUrl . $s_filename);
    $MyDatabase = new Database();
    $MyDatabase->Insert('article_pic', $ArrField, $ArrValue);
    return $s_filename;
}
<?php

require_once 'Libraries/Database.php';
$response = array();
$databaseCon = new Database();
if ($_GET['User_Number']) {
    $User_Number = $_GET['User_Number'];
    $insert = $databaseCon->Insert("Insert into users(User_Number) Values('{$User_Number}')");
    if ($insert) {
        $response['success'] = 1;
        $response['message'] = "Data  Successfully Add";
        echo json_encode($response);
    } else {
        $response['success'] = 0;
        $response['message'] = "Oops! An error occurred.";
        echo json_encode($response);
    }
    $response['success'] = 0;
    $response['message'] = "No Column  Found";
} else {
    $response['success'] = 0;
    $response['message'] = "Sorry  Mismatch  Index";
    echo json_encode($response);
}
Beispiel #28
0
     $number = $_SESSION['in2']['NUMBER'];
     $complement = $_SESSION['in2']['COMPLEMENT'];
     $district = $_SESSION['in2']['DISTRICT'];
     $id_city = $_SESSION['in2']['ID_CITY'];
     $latitude = $_SESSION['in2']['LATITUDE'];
     $longitude = $_SESSION['in2']['LONGITUDE'];
     $ps = $_SESSION['in2']['PS'];
     $pass = $_POST['USER_PASS'];
     // Inserindo Endereço
     $id_address = Database::Insert('address', 'ZIPCODE, NAME_ADDRESS, NUMBER, COMPLEMENT, DISTRICT, ID_CITY, PS, LATITUDE, LONGITUDE', "'{$zipcode}', '{$address}', {$number}, '{$complement}', '{$district}', {$id_city}, '{$ps}', '{$latitude}', '{$longitude}'");
     // Inserindo Pessoa
     $id_person = Database::Insert('person', 'NAME_PERSON, EMAIL, AGE, SEX, PHONE, OPERATOR, MARITAL_STATUS, CHILDREN, ID_RELIGION, ID_ADDRESS', "'{$name}', '{$email}', {$age}, '{$sex}', '{$phone}', '{$operator}', '{$maritalStatus}', {$children}, {$id_religion}, {$id_address}");
     // Inserindo Calebe
     Database::Insert('calebe', 'ID_PERSON, TIME_STUDY, BAPTISM, LEADER, STATUS', "{$id_person}, '{$time_study}', {$baptism}, {$leader}, '{$status}'");
     // Inserindo Login
     Database::Insert('login', 'ID_PERSON, USER_NAME, USER_PASS, ROLE', "{$id_person}, '{$email}', '{$pass}', {$leader}");
     unset($_SESSION['in']);
     unset($_SESSION['in2']);
     echo 'success';
     break;
 case 'login':
     $login = $_POST['user_name'];
     $senha = $_POST['user_pass'];
     if (Functions::verLogin($login, $senha)) {
         $dados = Functions::selectLogin($login);
         $id_login = $dados['ID_LOGIN'];
         $id_person = $dados['ID_PERSON'];
         $_SESSION['login']['role'] = $dados['ROLE'];
         $_SESSION['login']['id_login'] = $id_login;
         $_SESSION['login']['id_person'] = $id_person;
         $name = Database::ReadOne('person', 'name_person', 'WHERE ID_PERSON = ' . $id_person);
function createTimer($id, $time, $code)
{
    Database::Insert("timers", array("id" => $id, "time" => time() + $time, "code" => $code));
}
Beispiel #30
0
 function FirstRun()
 {
     // Load table structure for required tables
     $tables = IniFile::Parse('engine/database/tables.ini', true);
     // Create tables
     foreach ($tables as $name => $schema) {
         if (!Database::CreateTable($name, $schema)) {
             trigger_error("Couldn't create table " . $name, E_USER_ERROR);
         }
     }
     // Manually add admin module to _modules table
     if (Query::TableIsEmpty('_modules')) {
         $adminModule = array('name' => 'admin');
         if (!Database::Insert('_modules', $adminModule)) {
             trigger_error("Couldn't install core modules", E_USER_ERROR);
         }
     }
     // Install required modules
     $requiredModules = array('users', 'files');
     foreach ($requiredModules as $moduleName) {
         $module = Module::GetNewModule($moduleName);
         $module->Install();
     }
     // Add default admin user
     if (Query::TableIsEmpty('users')) {
         $adminUserParams = array('created' => $this->databaseTime, 'login' => 'admin', 'name' => 'Admin', 'password' => 'admin', 'status' => 3);
         if (!Database::Insert('users', $adminUserParams)) {
             trigger_error("Couldn't create admin user", E_USER_ERROR);
         }
     }
     // Add admin path
     $adminModuleId = Query::SingleValue('_modules', 'id', "name = 'admin'");
     if (!Path::Insert('admin', $adminModuleId, false)) {
         trigger_error("Couldn't add admin path", E_USER_ERROR);
     }
     // Redirect to admin interface
     HTTP::RedirectLocal('admin');
 }