Example #1
0
 public function __construct($conn = NULL, $database = "{DATABASE}")
 {
     $this->traceID = "Books";
     if (is_null($conn)) {
         $this->conn = GenFun::hostConnect($database);
     }
 }
Example #2
0
 function __construct($conn = NULL, $database = NULL)
 {
     if (is_null($conn)) {
         $this->conn = GenFun::hostConnect($database);
     }
     //Trace::register($this, $this->traceID);
 }
Example #3
0
 public static function sendDefault($obj)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "sendDefault");
     $emailObj;
     //----------------------------------------------------------
     GenFun::errorKey_CHK($obj, array("emailTo", "message"));
     //----------------------------------------------------------
     $message = '<div style = "padding:20px; width:500px; background-color:#999999; font-family: arial; font-size:12px; color: #FFFFFF;">';
     $message .= $obj['message'] . ' <br><br>';
     //----------------------------------------------------------
     if (!is_null($obj['link'])) {
         $message .= '<a href = "' . $obj['link'] . '">' . $obj['linkTxt'] . '</a>';
     }
     //----------------------------------------------------------
     $message .= '</div>';
     $message = GenFun::html($message);
     $emailObj = array("emailTo" => $obj['emailTo'], "nameFrom" => GlobalMas::$name, "emailFrom" => GlobalMas::$email, "message" => $message, "subject" => $obj['subject']);
     //----------------------------------------------------------
     $chk = $chk["bool"] ? SendEmail_v0::go($emailObj) : $chk;
     //----------------------------------------------------------
     return $chk;
 }
Example #4
0
 function __construct($tabelID, $whereArr, $obj = NULL)
 {
     GenFun::hostConnect();
     $this->tableID = $tabelID;
     $this->whereArr = $whereArr;
     parent::__construct($this->getQueryString(), $obj);
 }
Example #5
0
 public static function getExCss($file)
 {
     if ($file[0] == "/") {
         $file = GenFun::get_full_url($file);
     }
     return '<link rel="stylesheet" type="text/css" href="' . $file . '">';
 }
Example #6
0
 function __construct()
 {
     GenFun::hostConnect();
     $this->absolute_CFG();
     $this->rootPath = Import::getImportPath();
     // $this->largeImg_dir = $this->rootPath.$this->largeImg_dir;
     //$this->thumbImg_dir = $this->rootPath.$this->thumbImg_dir;
 }
Example #7
0
 function __construct($conn = NULL, $database = NULL)
 {
     if (is_null($conn)) {
         $this->conn = GenFun::hostConnect($database);
     }
     $_REQUEST['dir'] = "swfmngr_v0";
     $this->uploadClass = new UploadHandler(null, false);
     //Trace::register($this, $this->traceID);
 }
Example #8
0
 function __construct($img, $obj = NULL)
 {
     $this->img = $img;
     SetPublicProp::go($this, $obj);
     if (is_null($this->dir)) {
         $this->dir = $_SERVER['DOCUMENT_ROOT'] . "/" . $this->projectPath;
     }
     $this->fullURL = GenFun::get_full_url($this->dir);
 }
Example #9
0
 public static function arrayToParams($obj, $params, $func)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $obj = GenFun::varChkAll($obj);
     //----------------------------------------------------------
     $params = SetPublicProp::go($params, $obj, false);
     //----------------------------------------------------------
     return call_user_func_array($func, $params);
 }
Example #10
0
 public static function init()
 {
     GlobalMas::$host = 'mydatabase.ctla99hip1d5.us-west-2.rds.amazonaws.com:3306';
     GlobalMas::$user = '******';
     GlobalMas::$pass = '******';
     GlobalMas::$database = "compiler";
     GlobalMas::$filesPath_relative = "/Modules/generated_files/compiler/";
     GlobalMas::$filesPath_absolute = $_SERVER["DOCUMENT_ROOT"] . GlobalMas::$filesPath_relative;
     GlobalMas::$filesPath_web = GenFun::get_full_url(GlobalMas::$filesPath_absolute) . "/";
     //------------------------------------------------------
     ProjectGlobal::$compileObj = array("compile" => array(array("save_path" => "", "compileType" => "inject", "outputContent" => array("saveas" => "index.html"), "imagesProp" => array("base64" => true, "fileProp" => array("fileTypeProp" => array("png" => array("quality" => 100), "jpeg" => array("quality" => 90)))), "files" => array("data.js" => array("base64" => false)), "getIncluded" => false, "minify" => true)));
 }
Example #11
0
 public static function go($email, $traceID = NULL)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = $traceID != NULL ? array("bool" => 1, "func" => $traceID . ": validEmail") : array("bool" => 1, "func" => ": validEmail");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array("email" => $email));
     //----------------------------------------------------------
     $chk = (bool) $chk["bool"] ? self::_validEmail($email, $traceID) : $chk;
     //----------------------------------------------------------
     return $chk;
 }
Example #12
0
 private function updateAvgRating($content_id)
 {
     $chk = GenFun::error_chk(array($this->setRating_tbl, $this->avgRating_tbl));
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $queryString = "UPDATE " . $this->avgRating_tbl . " SET " . $this->avgRating_tbl . ".avg_rating = (SELECT AVG(" . $this->setRating_tbl . ".rating) FROM " . $this->setRating_tbl . " WHERE content_id = '{$content_id}') WHERE " . $this->avgRating_tbl . ".id = '{$content_id}'";
     $chk = Result::go($queryString, array('resetQueries' => true));
     //----------------------------------------------------------
     return $chk;
 }
Example #13
0
 function __construct($initialize = true)
 {
     $options = json_decode(stripslashes($_REQUEST['options']), true);
     $default_local_url = GenFun::get_local_url('/Modules/generated_files');
     $default_url = GenFun::get_full_url('/Modules/generated_files');
     $this->options = array('script_url' => $default_local_url, 'upload_dir' => isset($_REQUEST['dir']) ? $default_local_url . "/" . $_REQUEST['dir'] . '/' : $default_local_url . '/', 'upload_url' => isset($_REQUEST['dir']) ? $default_url . "/" . $_REQUEST['dir'] . '/' : $default_url . '/', 'user_dirs' => false, 'mkdir_mode' => 0755, 'param_name' => 'files', 'delete_type' => 'DELETE', 'access_control_allow_origin' => '*', 'access_control_allow_credentials' => false, 'access_control_allow_methods' => array('OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'), 'access_control_allow_headers' => array('Content-Type', 'Content-Range', 'Content-Disposition'), 'download_via_php' => false, 'inline_file_types' => '/\\.(gif|jpe?g|png)$/i', 'accept_file_types' => '/.+$/i', 'max_file_size' => null, 'min_file_size' => 1, 'max_number_of_files' => null, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'orient_image' => true, 'image_versions' => array('thumbnail' => array('max_width' => 80, 'max_height' => 80)));
     if ($options) {
         $this->options = array_merge($this->options, $options);
     }
     if ($initialize) {
         $this->initialize();
     }
 }
Example #14
0
 public static function init()
 {
     Compiler::init(array("css" => "min_single", "js" => "min_single", "getServices" => array("except" => Import::getImportPath() . "service.php"), "global" => array("copy" => array(Import::$uber_src_path . "service.php", Import::getImportPath() . "index.php"), "getImages" => true, "code" => array("tmpl" => array("replace" => array("replaceSrc" => false, "\${images}" => Import::$uber_src_path . "/global/images/")))), "compile" => array(array("id" => "min_single", "minify" => true, "copy" => array(), "code" => array("css" => array("singleFile" => true, "path" => "global/css/"), "js" => array("singleFile" => true, "path" => "global/js/"))), array("id" => "min_multi", "minify" => true, "code" => array("css" => array("singleFile" => false, "path" => "global/css/"), "js" => array("singleFile" => false, "path" => "global/js/"))), array("id" => "unmin", "code" => array("css" => array("singleFile" => false, "path" => "global/css/"), "js" => array("singleFile" => false, "path" => "global/js/"))), array("id" => "unmin_raw", "raw" => true))));
     //------------------------------------------------
     GlobalMas::$host = self::$host;
     GlobalMas::$pass = self::$pass;
     GlobalMas::$user = self::$user;
     GlobalMas::$database = self::$database;
     UploadHandler::$projectFilesPath = ProjectGlobal::$projectFilesPath;
     //UploadHandler::$rootFilesPath = "/upload/generated_files/";
     self::$filesLocalPath = $_SERVER['DOCUMENT_ROOT'] . "/" . UploadHandler::$rootFilesPath . self::$projectFilesPath;
     self::$filesPath = GenFun::get_full_url(self::$filesLocalPath);
 }
Example #15
0
 public static function obj_CFG($class, $valueArr, $throwError = true)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = $traceID != NULL ? array("bool" => true, "func" => $traceID . ": setPublicProp") : array("bool" => true, "func" => ": setPublicProp");
     $bool = true;
     //----------------------------------------------------------
     if (is_null($valueArr)) {
         $chk['message'] = "valueArr is 'NULL";
         return $class;
     }
     //----------------------------------------------------------
     foreach ($valueArr as $i => $value) {
         if (gettype($class) == "object" and !property_exists($class, $i)) {
             $bool = false;
         } else {
             if (gettype($class) == "array" and empty($class[$i])) {
                 $bool = false;
             }
         }
         //--------------------------------------------------
         $class = SetPublicProp::findObj($class, $i);
         $i = $class['string'];
         $class = $class['class'];
         //--------------------------------------------------
         if (!$bool && $throwError) {
             $error = array_merge($chk, array("bool" => 0, "result" => $i . " is not a property"));
             $error['$valueArr'] = print_r($valueArr, true);
             print_r($error);
             trigger_error($i . " is not a property in '" . get_class($class) . "'", E_USER_ERROR);
         }
         //--------------------------------------------------
         if ($bool && gettype($class) == "object") {
             $valueArr[$i] = GenFun::constCHK($valueArr[$i]);
             $class->{$i} = $valueArr[$i];
         } else {
             if (gettype($class) == "array") {
                 $valueArr[$i] = GenFun::constCHK($valueArr[$i]);
                 $class[$i] = $valueArr[$i];
             }
         }
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $class;
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #16
0
 public static function go($fileName, $content, $fileLocation, $force)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "func" => "createFile");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array('fileName' => $fileName, 'content' => $content));
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $defaultLocation = $_SERVER["DOCUMENT_ROOT"];
     //----------------------------------------------------------
     if (substr($defaultLocation, -1) != "/") {
         $defaultLocation .= "/";
     }
     //----------------------------------------------------------
     $fileLocation = is_null($fileLocation) ? $defaultLocation : $defaultLocation . $fileLocation;
     //----------------------------------------------------------
     if (!is_dir($fileLocation)) {
         if ($force) {
             $fileLocation = GenFun::getPathFromFileLocation($fileLocation);
         }
         //------------------------------------------
         if (!is_dir($fileLocation)) {
             $chk['bool'] = false;
             $chk['message'] = $fileLocation . " directory does not exist";
             return $chk;
         }
     }
     //----------------------------------------------------------
     $file = $fileLocation . $fileName;
     //----------------------------------------------------------
     DupIncluded::createFolderStructure($file);
     //----------------------------------------------------------
     if (file_put_contents($file, $content)) {
         $chk['message'] = $file . " has been successfully created!!!!!";
     } else {
         $chk['bool'] = false;
         $chk['message'] = $file . " was not saved or did not save properly.";
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #17
0
 public static function chk($username, $accounts_id = NULL)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'traceID' => "session_CFG");
     $userKey;
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array($username));
     //----------------------------------------------------------
     if ($chk['bool']) {
         if (is_null(Constants::$mysqli)) {
             GenFun::hostConnect();
         }
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     session_start();
     $session_id = GenFun::encrypt(session_id() . self::SALT . $username);
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = MySQL::getTable(SessionLog_const::TBL, array("session_id" => $session_id, "userKey" => $_COOKIE['user']));
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     $userKey = $username . "-" . rand(0, 13000000);
     setcookie("user", $userKey);
     //----------------------------------------------------------
     if (sizeof($chk['result']) == 0) {
         $chk = InsertINTO::go(array("tableID" => SessionLog_const::TBL, "setArr" => array("userKey" => $userKey, "accounts_id" => $accounts_id, "session_id" => $session_id)));
     } else {
         $chk = Update::go(SessionLog_const::TBL, array("userKey" => $userKey), array("session_id" => $session_id));
         if ($chk['bool']) {
             $chk['message'] = "session for this user has already been established!!!";
         }
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #18
0
 public function codiad_CFG($hash)
 {
     $dir_relative = GlobalMas::$filesPath_relative . $hash . "/";
     $dir = GlobalMas::$filesPath_absolute . $hash . "/";
     //-----------------------------------------------------
     if (!file_exists($dir . "codiad")) {
         Archive::extract(GlobalMas::$filesPath_absolute . "/codiad.zip", $dir);
         //-----------------------------------------------------
         $config_contents = FileFolder::file_get_contents($dir . "codiad/config.php");
         $config_contents = str_replace("{BASE_PATH}", $dir . "codiad", $config_contents);
         $config_contents = str_replace("{BASE_URL}", GenFun::get_full_url($dir . "codiad"), $config_contents);
         FileFolder::file_put_contents($dir . "codiad/config.php", $config_contents);
         //---------------------------------------------------------
         exec("ln -s " . $dir . "compile " . $dir . "codiad/workspace/compile" . " 2>&1", $output);
         exec("ln -s " . $dir . " " . $dir . "codiad/workspace/root" . " 2>&1", $output);
         //---------------------------------------------------------
         if (strpos(join($output), "Errno::") !== false) {
             krumo($output);
             die;
         }
     }
 }
Example #19
0
function archive($folderPath = NULL)
{
    $folderPath = dirname(__FILE__) . "/files/new_files/";
    //----------------------------------------------------------
    //init var
    //----------------------------------------------------------
    $chk = array("bool" => true, "func" => "archive");
    $dirArray = array();
    $myDirectory;
    //----------------------------------------------------------
    //$this->move(dirname(__FILE__)."/files/videoOrganizer/thumb/",$folderPath.'thumb/');
    //$this->move(dirname(__FILE__)."/files/videoOrganizer/",$folderPath);
    //----------------------------------------------------------
    $myDirectory = opendir($folderPath);
    //----------------------------------------------------------
    $videoPath = GenFun::get_full_url(dirname(__FILE__)) . "files/videoOrganizer/";
    //----------------------------------------------------------
    $this->move($folderPath, $folderPath, " ", "_");
    //----------------------------------------------------------
    $this->move($folderPath . 'thumb/', $folderPath . 'thumb/', " ", "_");
    //----------------------------------------------------------
    while ($entryName = readdir($myDirectory)) {
        if (stristr($entryName, '.mp4')) {
            array_push($dirArray, array('title' => $entryName, 'orig_title' => $entryName, 'hash' => GenFun::encrypt($entryName), 'path' => $videoPath, 'mp4' => $entryName, 'thumbnail_url' => "thumb/" . GenFun::str_lreplace(".mp4", ".png", $entryName)));
        }
    }
    //----------------------------------------------------------
    $this->move($folderPath, $folderPath, "_", " ");
    //----------------------------------------------------------
    $this->move($folderPath . 'thumb/', $folderPath . 'thumb/', "_", " ");
    //----------------------------------------------------------
    $this->move($folderPath . 'thumb/', dirname(__FILE__) . "/files/videoOrganizer/thumb/");
    $this->move($folderPath, dirname(__FILE__) . "/files/videoOrganizer/");
    //----------------------------------------------------------
    $chk = $this->_insertContents($dirArray);
    return $chk;
}
Example #20
0
 public function sendLink($email, $message, $url)
 {
     Trace::output($this->traceID, "sendLink");
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "sendLink");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK($obj);
     //----------------------------------------------------------
     $emailObj = array("emailTo" => $email, 'link' => "http://awwthentic.com/Modules/DOM/uber_src/server/werm/services/Download.php?url={$url}", 'linkTxt' => "Click here to download file.", "message" => $message, "subject" => $subject = $obj['sender'] . " sent you a file!!!");
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = SendEmail_v0::sendDefault($emailObj);
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk['message'] = "Email was successfully sent to {$email}";
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #21
0
 public function changePassword($hash, $password)
 {
     Trace::output($this->traceID, "changePassword");
     //----------------------------------------------------------
     $chk = GenFun::error_chk(array($hash, $password));
     //----------------------------------------------------------
     $this->tblName = ForgotPwRequest_const::TBL;
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "changePassword");
     //----------------------------------------------------------
     $chk = $this->getAccountRow($hash);
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     if ($chk['result'][0]['confirmed'] == 1) {
         $chk['bool'] = false;
     }
     //----------------------------------------------------------
     if (sizeof($chk['result']) != 0 && $chk['bool']) {
         $chk = Update::go(Accounts_const::TBL, array("password" => GenFun::encrypt($password . $this->salt)), array("id" => $chk['result'][0]['accounts_id']));
         $chk = $this->confirm($hash, "forgotPwRequest");
     } else {
         $chk['bool'] = false;
         $chk['message'] = "This link has been disabled!!!";
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk['message'] = "Password Updated!!!";
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #22
0
 private function chk($obj, $params, $func)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $obj = GenFun::varChkAll($obj);
     //----------------------------------------------------------
     $params = SetPublicProp::go($params, $obj, false);
     //----------------------------------------------------------
     return call_user_func_array(array($this, $func), $params);
 }
Example #23
0
 public function uploadFile($replaceWhiteSpaceWith = NULL)
 {
     Trace::output(self::$traceID, "uploadFile", func_get_args());
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "uploadFile");
     //----------------------------------------------------------
     $upload = $this->uploadClass->post(false);
     //----------------------------------------------------------
     if (is_null($upload["files"][0]->error)) {
         $orig_path = urldecode(GenFun::get_local_url($upload['files'][0]->url));
         //----------------------------------------------------------
         $oldName = $upload["files"][0]->name;
         //----------------------------------------------------------
         $newName = is_null($replaceWhiteSpaceWith) ? $oldName : str_replace(' ', '_', $oldName);
         $arr = explode(".", $newName);
         $ext = $arr[sizeof($arr) - 1];
         $newName = stripslashes($arr[0]);
         //----------------------------------------------------------
         if (!is_null($replaceWhiteSpaceWith)) {
             $newName = preg_replace('/[^a-z_0-9-]*/i', '', $newName);
         }
         //----------------------------------------------------------
         $path = FileFolder::getPathFromFile($orig_path);
         //----------------------------------------------------------
         $path = $path . $newName . "." . $ext;
         //----------------------------------------------------------
         rename($orig_path, $path);
         //----------------------------------------------------------
         $local_url = $path;
         //----------------------------------------------------------
         //$hash = MySQL::getNextInsertID('files');
         //----------------------------------------------------------
         //if (is_object($hash)) return $hash;
         //----------------------------------------------------------
         //$new_local_url = FileFolder::moveToFolder($local_url, $hash."/");
         //----------------------------------------------------------
         //$upload['files'][0]->url = GenFun::get_full_url($new_local_url);
         //----------------------------------------------------------
         $chk = Upload::insertFile($newName . "." . $ext, json_encode($upload));
         //----------------------------------------------------------
         if ($chk['bool']) {
             $hash = $chk['row']['hash'];
             //----------------------------------------------------------
             if (is_object($hash)) {
                 return $hash;
             }
             //----------------------------------------------------------
             $this->url_local = FileFolder::moveToFolder($local_url, $this->appendToDir . $hash . "/");
             //----------------------------------------------------------
             $upload['hash'] = $hash;
             $chk['files'] = $upload['files'];
             $chk['value'] = $chk['insert_id'];
             $chk['hash'] = $hash;
             unset($chk['insert_id']);
             unset($chk['row']);
         }
     } else {
         $chk = $upload;
     }
     return $chk;
 }
Example #24
0
 public function updateMessages($updateArr, $approve, $close = FALSE)
 {
     Trace::output($this->traceID, "updateMessages");
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "updateMessages");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array($updateArr, $approve));
     //----------------------------------------------------------
     if ($chk[bool]) {
         $chk = $this->_updateMessages($updateArr, $approve, $close = FALSE);
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     return $chk;
 }
Example #25
0
 public static function chk($file, $include = true)
 {
     //-------------------------------------------
     //init var
     //-------------------------------------------
     $bool = true;
     //-------------------------------------------
     foreach (self::$filesLoaded as &$value) {
         if ($file == $value) {
             $bool = false;
         }
     }
     //-------------------------------------------
     if (!file_exists(GenFun::get_local_url($file))) {
         throw new Exception($file . " does not exist ");
     }
     //-------------------------------------------
     if ($bool) {
         array_push(self::$filesLoaded, $file);
         if ($include) {
             include_once $file;
         }
     }
     //-------------------------------------------
     return $bool;
 }
Example #26
0
 public function setCookies()
 {
     $cookie_content = file_get_contents($this->cookiePath);
     //---------------------------------------------------------
     unlink($this->cookiePath);
     //---------------------------------------------------------
     $cookie_content = str_replace("# Netscape HTTP Cookie File\n# http://curl.haxx.se/docs/http-cookies.html\n# This file was generated by libcurl! Edit at your own risk.", '', $cookie_content);
     $lines = explode("\n", $cookie_content);
     //---------------------------------------------------------
     foreach ($lines as $key => $value) {
         if ($value != "") {
             $newLines[] = $value;
         }
     }
     //---------------------------------------------------------
     $lines = $newLines;
     //---------------------------------------------------------
     foreach ($lines as $key => $value) {
         $line = preg_replace('/\\s+/', '{#}', $value);
         $line = explode("{#}", $line);
         $val = end($line);
         $cookieName = prev($line);
         setcookie($cookieName, $val, GenFun::getCookieTime());
     }
 }
Example #27
0
 public function insertINTO()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "insertINTO");
     $this->updateArr = array();
     //----------------------------------------------------------
     $chk = GenFun::errorKey_chk($this->setArr, NULL, true);
     //----------------------------------------------------------
     $this->setArr = $chk['valueArr'];
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $this->tableID = Constants::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $this->queryString = $this->insertType . " " . $this->tableID . " (";
     foreach ($this->setArr as $i => $value) {
         if (strrpos($value, "{hash}") === 0) {
             $this->updateArr[$i] = $value;
         } else {
             $this->queryString .= $i . ",";
         }
     }
     //----------------------------------------------------------
     foreach ($this->updateArr as $i => $value) {
         unset($this->setArr[$i]);
     }
     //----------------------------------------------------------
     $this->queryString = substr($this->queryString, 0, -1);
     $this->queryString .= ") ";
     //----------------------------------------------------------
     $keys = array_keys($this->setArr);
     $this->queryString .= "VALUES ";
     //----------------------------------------------------------
     $high = sizeof($this->setArr[$keys[0]]);
     for ($i = 1; $i < sizeof($this->setArr); $i++) {
         if (is_array($this->setArr[$keys[$i]])) {
             $cur = sizeof($this->setArr[$keys[$i]]);
             if ($high < $cur) {
                 $high = $cur;
             }
         }
     }
     //----------------------------------------------------------
     for ($i = 0; $i < 1; $i++) {
         $value = $this->setArr[$keys[$i]];
         $num = is_array($value) ? sizeof($value) : 1;
         for ($j = 0; $j < $high; $j++) {
             if (is_array($this->setArr[$keys[$i]])) {
                 $value = $this->setArr[$keys[$i]][$j];
             }
             if ($i == 0) {
                 $this->queryString .= "(";
             }
             if (strrpos($value, "(") !== false && strrpos($value, "(") == 0 && !$this->ignore) {
                 $this->queryString .= $value;
                 //$this->queryString .= ",";
             } else {
                 if ($value == "DEFAULT") {
                     $this->queryString .= $value;
                 } else {
                     $this->queryString .= "'" . Constants::$mysqli->escape_string($value) . "'";
                 }
             }
             //-------------------------------------------------
             for ($k = 0; $k < sizeof($this->setArr); $k++) {
                 if ($keys[$k] != $keys[$i]) {
                     $this->queryString .= ",";
                     if (is_array($this->setArr[$keys[$k]])) {
                         $v = $this->setArr[$keys[$k]][$j];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     } else {
                         $v = $this->setArr[$keys[$k]];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     }
                 }
             }
             //-------------------------------------------------
             //if ($i == sizeof($this->setArr)-1) {
             //$this->queryString = substr($this->queryString, 0, -1);
             $this->queryString .= ")";
             //}
             //-------------------------------------------------
             if ($j < $high - 1) {
                 $this->queryString .= ",";
             }
         }
     }
     //----------------------------------------------------------
     if (!is_null($this->onDuplicate)) {
         $this->queryString .= " ON DUPLICATE KEY UPDATE ";
         $this->queryString = MySQL::condition($this->tableID, $this->onDuplicate, NULL, $this->queryString);
     }
     //----------------------------------------------------------
     if (!$this->returnQuery) {
         $chk = $this->getResult();
         $insert_id = $chk['insert_id'];
         if ($chk['duplicate']) {
             $chk['duplicate'] = GetTable::go($this->tableID, $this->setArr);
         } else {
             if (sizeof($this->updateArr) > 0) {
                 foreach ($this->updateArr as $i => $value) {
                     if (strrpos($value, "{hash}") === 0) {
                         $value = strtr($value, array('{hash}' => ""));
                         /*if (!is_numeric($value)) {
                         			$chk['bool'] = false;
                         			$chk['messgae'] = "In order to use the alphaID() utility ".$value.' must be numeric!!!';
                         			return $chk;
                         		}*/
                         $this->updateArr[$i] = alphaID($insert_id . $value);
                     }
                 }
                 $this->setArr['id'] = $insert_id;
                 $chk = Update::go($this->tableID, $this->updateArr, $this->setArr);
             }
         }
         if (!$chk['bool']) {
             return $chk;
         }
         if ($this->returnRow) {
             $chk['row'] = GetTable::go($this->tableID, array("id" => $insert_id));
             if ($chk['row']['bool']) {
                 $chk['row'] = $chk['row']['result'][0];
             }
         }
         $chk['insert_id'] = $insert_id;
         return $chk;
     } else {
         return $this->queryString;
     }
 }
Example #28
0
 function __construct($conn = NULL, $database = NULL)
 {
     if (is_null($conn)) {
         $this->conn = GenFun::hostConnect($database);
     }
 }
Example #29
0
 public function file_exists_local($file)
 {
     if (strpos($file, "http://") !== false) {
         $file = GenFun::get_local_url($file);
     }
     //---------------------------------------------------------
     if (file_exists($file)) {
     } else {
         if (file_exists(Import::uber_src_path() . $file)) {
             $file = Import::uber_src_path() . $file;
         } else {
             if (file_exists(Import::getImportPath() . $file)) {
                 $file = Import::getImportPath() . $file;
             }
         }
     }
     return $file;
 }
Example #30
0
<?php

require_once dirname(__FILE__) . "/ProjectGlobal.php";
require_once Import::$uber_src_path . "/server/smarty/libs/Smarty.class.php";
//------------------------------------------------------------------------------------------------
function compile_CFG($prop)
{
    $smarty = new Smarty();
    $smarty->assign($prop);
    $string = $smarty->fetch(dirname(__FILE__) . '/compile.tpl');
    return $string;
}
//----------------------------------------
if (isset($_GET['compile']) && $_GET['compile'] == 1 && !isset($_COOKIE['compile_curl'])) {
    $compiler = new Compiler(ProjectGlobal::$compileObj);
    foreach ($compiler->compilers as $key => $compile) {
        $zipPath = rtrim(GenFun::get_full_url($compile->compilePath), "/") . ".zip";
        $prop = ["save_path" => $compile->save_path, "filesize" => number_format(FileFolder::getFileSize($zipPath)), "zipPath" => $zipPath, "fullPath" => GenFun::get_full_url($compile->compilePath), "width" => $_GET['width'], "height" => $_GET['height']];
        if ($key == 0) {
            $prop['style'] = true;
        }
        echo compile_CFG($prop);
    }
    //krumo($compiler);
}
//----------------------------------------