Example #1
0
<?php

require_once 'crud/preheader1.php';
include_once 'crud/ajaxCRUD1.class.php';
//just so i can leverage echo_msg_box();
//////tblDem1 est la table dans laquelle on va stocker les swicthes cores/////////////
//////tblDemo2 est la table dans laquelle on va stocker les switches acces ///////////
qr("CREATE TABLE tblDemo(pkID INT PRIMARY KEY AUTO_INCREMENT,fldField1 VARCHAR(45),fldField2 VARCHAR(45),fldCertainFields VARCHAR(40),fldLongField TEXT, fldCheckbox TINYINT);");
$report_msg[] = "TABLE <b>cmdmonitor</b> CREATED\n";
qr("CREATE TABLE tblDemo2(pkID INT PRIMARY KEY AUTO_INCREMENT,Hostname VARCHAR(45),Username VARCHAR(45),Password TEXT);");
$report_msg[] = "TABLE <b>tblDemo2</b> CREATED\n";
if ($success) {
    $report_msg[] = "<b>Example rows entered into demo tables.</b>\n";
}
echo_msg_box();
Example #2
0
 function uploadFile($row_id, $file_field, $upload_folder)
 {
     @($fileName = $_FILES[$file_field]['name']);
     @($tmpName = $_FILES[$file_field]['tmp_name']);
     @($fileSize = $_FILES[$file_field]['size']);
     @($fileType = $_FILES[$file_field]['type']);
     $new_filename = make_filename_safe($fileName);
     if ($this->filename_append_field != "") {
         if ($_REQUEST[$this->filename_append_field] != '') {
             $new_filename = $_REQUEST[$this->filename_append_field] . "_" . $new_filename;
         } else {
             if ($this->filename_append_field == $this->db_table_pk) {
                 $new_filename = $row_id . "_" . $new_filename;
             } else {
                 @($db_value_to_append = q1("SELECT {$this->filename_append_field} FROM {$this->db_table} WHERE {$this->db_table_pk} = {$row_id}"));
                 if ($db_value_to_append != "") {
                     $new_filename = $db_value_to_append . "_" . $new_filename;
                 }
             }
         }
     }
     $destination = $upload_folder . $new_filename;
     $success = move_uploaded_file($tmpName, $destination);
     if ($success) {
         $update_success = qr("UPDATE {$this->db_table} SET {$file_field} = \"{$new_filename}\" WHERE {$this->db_table_pk} = {$row_id}");
         if ($this->onFileUploadExecuteCallBackFunction != '') {
             $file_info_array = array();
             $file_info_array[id] = $row_id;
             $file_info_array[field] = $file_field;
             $file_info_array[fileName] = $new_filename;
             $file_info_array[fileSize] = $fileSize;
             $file_info_array[fldType] = $fldType;
             call_user_func($this->onFileUploadExecuteCallBackFunction, $file_info_array);
         }
     }
     if ($update_success) {
         return true;
         //$report_msg[] = "File Uploaded.";
     } else {
         return false;
         //$error_msg[] = "There was an error uploading your file (or none was selected).";
     }
 }
 function uploadFile($row_id, $file_field, $upload_folder, $allowedExts = "")
 {
     global $report_msg, $error_msg;
     @($fileName = $_FILES[$file_field]['name']);
     @($tmpName = $_FILES[$file_field]['tmp_name']);
     @($fileSize = $_FILES[$file_field]['size']);
     @($fileType = $_FILES[$file_field]['type']);
     if (is_array($allowedExts)) {
         $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
         //gets file ext (lowercase)
         if (!in_array($fileExt, $allowedExts)) {
             $error_msg[] = "Upload failed. Selected file was extention <b>.{$fileExt}</b> but this is not an permitted file extension.";
             return false;
         }
     }
     $new_filename = make_filename_safe($fileName);
     if ($this->filename_append_field != "") {
         if ($_REQUEST[$this->filename_append_field] != '') {
             $new_filename = $_REQUEST[$this->filename_append_field] . "_" . $new_filename;
         } else {
             if ($this->filename_append_field == $this->db_table_pk) {
                 $new_filename = $row_id . "_" . $new_filename;
             } else {
                 @($db_value_to_append = q1("SELECT {$this->filename_append_field} FROM {$this->db_table} WHERE {$this->db_table_pk} = {$row_id}"));
                 if ($db_value_to_append != "") {
                     $new_filename = $db_value_to_append . "_" . $new_filename;
                 }
             }
         }
     }
     $destination = $upload_folder . $new_filename;
     $success = move_uploaded_file($tmpName, $destination);
     if ($success) {
         $update_success = qr("UPDATE {$this->db_table} SET {$file_field} = \"{$new_filename}\" WHERE {$this->db_table_pk} = {$row_id}");
         if ($this->onFileUploadExecuteCallBackFunction != '') {
             $file_info_array = array();
             $file_info_array[id] = $row_id;
             $file_info_array[field] = $file_field;
             $file_info_array[fileName] = $new_filename;
             $file_info_array[fileSize] = $fileSize;
             $file_info_array[fldType] = $fldType;
             call_user_func($this->onFileUploadExecuteCallBackFunction, $file_info_array);
         }
         if ($update_success) {
             return true;
         }
     } else {
         $error_msg[] = "There was an error uploading your file. Check permissions of the destination directory (make sure is set to 777).";
     }
     return false;
 }
Example #4
0
function onAddCallBackFunction($array)
{
    global $idsAdded, $report_msg, $error_msg;
    $newID = $array['pkAttendeeID'];
    $fkEventID = $array['fkEventID'];
    $firstName = $array['fldFirstName'];
    $lastName = $array['fldLastName'];
    $countMatchingRows = q1("SELECT COUNT(*) FROM tblEventAttendee WHERE fldFirstName = \"{$firstName}\" AND fldLastName = \"{$lastName}\" AND fkEventID = {$fkEventID}");
    if ($countMatchingRows > 1) {
        $success = qr("DELETE FROM tblEventAttendee WHERE pkAttendeeID = {$newID}");
        if ($success) {
            $error_msg[] = "Ignore that last message...it seems you have added yourself TWICE! You idiot! The system automatically deleted your second entry.";
            return;
        } else {
            $error_msg[] = "Error deleting the second database entry.";
            return;
        }
    }
    $idsAdded[] = $newID;
    //array push
    //set cookie 10 years in the future
    setcookie("ajaxCRUDEventID_{$newID}", "cookieset", time() + 10 * 365 * 24 * 60 * 60);
    //print_r($_COOKIE);
}
function private_and_public_qr($bill)
{
    global $pdf;
    $p = $bill->p;
    $y = $bill->y + 0.6;
    $priv_y = $y + 0.3;
    $line_height = 0.08;
    $pdf->SetFont($font, '', 5);
    quick_text($bill, 'Private Key (Used to transfer coins)', $priv_y - 0.05, 'L');
    qr($bill, $bill->priv, $priv_y, 'L', 0.6, 1.125);
    $size = 0.8;
    $y = $bill->y + 0.65;
    $nudge = 1.2;
    $link = 'http://blockexplorer.com/q/addressbalance/' . $bill->pub;
    $size = 0.6;
    quick_text($bill, 'Check Balance at this QR link', $y - $line_height * 2, 'R');
    quick_text($bill, 'with a smartphone barcode scanner', $y - $line_height, 'R');
    qr($bill, $link, $y, 'R', 0.6, 0.6);
    $y = $bill->y + 1.5;
    quick_text($bill, "Fund this bill at this public address", $y - $line_height * 2, 'R');
    quick_text($bill, $bill->pub, $y - $line_height, 'R');
    qr($bill, $bill->pub, $y, 'R', $size, $size, 0);
}
Example #6
0
<?php

require_once '../preheader.php';
$success = q1("CREATE TABLE tblDemo(pkID INT PRIMARY KEY AUTO_INCREMENT,fldField1 VARCHAR(45),fldField2 VARCHAR(45),fldCertainFields VARCHAR(40),fldLongField TEXT);");
if ($success) {
    echo "TABLE <b>tblDemo</b> CREATED <br /><br />\n";
}
$success = q1("CREATE TABLE tblDemo2(pkID INT PRIMARY KEY AUTO_INCREMENT,fldField1 VARCHAR(45),fldField2 VARCHAR(45),fldCertainFields VARCHAR(40),fldLongField TEXT);");
if ($success) {
    echo "TABLE <b>tblDemo2</b> CREATED <br /><br />\n";
}
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Testing\", \"Testing2\", \"CRUD\", \"First ajaxCRUD Test\")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Testing\", \"Testing2\", \"CRUD\", \"Second ajaxCRUD Test\")");
if ($success) {
    echo "Example rows entered into <b>tblDemo</b> and <b>tblDemo2</b><br /><br />\n";
}
echo "<p><a href='example.php'>Try out the demo</a></p>\n";
echo "<p><a href='example.php'>Try out a demo with two ajaxCRUD tables.</a></p>\n";
Example #7
0
//populate tblDemo and tblDemo2
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Adam\", \"Smith\", \"CRUD\", \"First ajaxCRUD Test. A founding father.\")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Justin\", \"Beiber\", \"CRUD\", \"Second ajaxCRUD Test. A man who should be deported. \")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Sean\", \"Dempsey\", \"CRUD\", \"Third ajaxCRUD Test. A man without a cause.\")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Justin\", \"Rigby\", \"Allowable Value1\", \"Fourth ajaxCRUD Test. A man with a plan. \")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Glenn\", \"Beck\", \"Allowable Value2\", \"Fifth ajaxCRUD Test. Brilliant, crazy, eccentric, or just plain mad? \")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Ron\", \"Paul\", \"Allowable Value2\", \"Sixth ajaxCRUD Test. Should have been president. \")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Ayn\", \"Rand\", \"Allowable Value2\", \"Seventh ajaxCRUD Test.\")");
$success = qr("INSERT INTO tblDemo (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Conan\", \"O'Brien\", \"Dropdown Value\", \"Eighth ajaxCRUD Test. A great man of power and excellence. \")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Jack\", \"Black\", \"Blue\", \"First ajaxCRUD Test. A comedian/actor. OR is it actor/comedian? \")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Ryan Dempsey\", \"Twiddle\", \"Blue\", \"Third ajaxCRUD Test. A great band in rural VT. Check 'em out\")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Jefferson\", \"Airplane\", \"Red\", \"Fourth ajaxCRUD Test. He is more airplane than man. \")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Correct this\", \"Splling Mistake\", \"Green\", \"Fifth ajaxCRUD Test. See if you can spot the mistake! \")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Chuck\", \"Mangione\", \"Periwinkle\", \"Sixth ajaxCRUD Test. A soulful trumpet, indeed. \")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Chuck\", \"Woolery\", \"Periwinkle\", \"Seventh ajaxCRUD Test. Wollery is a large and powerful man.\")");
$success = qr("INSERT INTO tblDemo2 (fldField1, fldField2, fldCertainFields, fldLongField) VALUES (\"Emma\", \"Watson\", \"Blue\", \"Eighth ajaxCRUD Test. Too hot for words.\")");
//populate tblFriend
$success = qr("INSERT INTO `tblFriend` (`pkFriendID`, `fldName`, `fldAddress`, `fldCity`, `fldState`, `fldZip`, `fldPhone`, `fldEmail`, `fldBestFriend`, `fldDateMet`, `fldFriendRating`, `fldOwes`, `fldPicture`, `fkMarriedTo`) VALUES(1, 'Sean Dempsey', '13 Back River Road', 'Dover', 'NH', '03820', '(603) 978-8841', '*****@*****.**', 'N', '2011-10-27', '5', 122.01, '', 1),(2, 'Justin Rigby', '22 Farmington Rd', 'Rochester', 'VT', '05401', '(802) 661-4051', '*****@*****.**', '', '2011-10-19', '1', 22.00, '', 2),(3, 'Ryan Dempsey', '', '', 'VT', '', '', '*****@*****.**', '', '2011-10-20', '', 0.00, '',3);");
//populate tblLadies
$success = qr("INSERT INTO tblLadies (fldName, fldSort) VALUES ('Jackie Benson', 1)");
$success = qr("INSERT INTO tblLadies (fldName, fldSort) VALUES ('Sharon Nelson', 2)");
$success = qr("INSERT INTO tblLadies (fldName, fldSort) VALUES ('Kirsten Dunst', 3)");
$success = qr("INSERT INTO tblLadies (fldName, fldSort) VALUES ('Emma Watson', 4)");
$success = qr("INSERT INTO tblLadies (fldName, fldSort) VALUES ('Shirley Temple', 5)");
if ($success) {
    $report_msg[] = "<b>Example rows entered into demo tables.</b>\n";
}
echo_msg_box();
echo "<p><a href='example.php'>Try out a basic demo</a></p>\n";
echo "<p><a href='example2.php'>Try out a demo with two ajaxCRUD tables.</a></p>\n";
echo "<p><a href='example3.php'>Try out a demo with validation, masking, file upload, pk/fk relationship, and csv export enabled.</a></p>\n";