public static function insert($inputData = array())
 {
     // End addons
     $totalArgs = count($inputData);
     $addMultiAgrs = '';
     if (isset($inputData[0]['foldername'])) {
         foreach ($inputData as $theRow) {
             $keyNames = array_keys($theRow);
             $insertKeys = implode(',', $keyNames);
             $keyValues = array_values($theRow);
             $insertValues = "'" . implode("','", $keyValues) . "'";
             $addMultiAgrs .= "({$insertValues}), ";
         }
         $addMultiAgrs = substr($addMultiAgrs, 0, strlen($addMultiAgrs) - 2);
     } else {
         $keyNames = array_keys($inputData);
         $insertKeys = implode(',', $keyNames);
         $keyValues = array_values($inputData);
         $insertValues = "'" . implode("','", $keyValues) . "'";
         $addMultiAgrs = "({$insertValues})";
     }
     Database::query("insert into plugins_meta({$insertKeys}) values" . $addMultiAgrs);
     if (!($error = Database::hasError())) {
         $id = Database::insert_id();
         return $id;
     }
     return false;
 }
Example #2
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (isset($post['content'])) {
         // $post['content']=Shortcode::toBBCode($post['content']);
         $post['content'] = String::encode(strip_tags($post['content'], '<p><br>'));
     }
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "commentid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "comments set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/comment');
     DBCache::removeCache($listIDs, 'system/comment');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
Example #3
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (is_numeric($listID)) {
         $userid = $listID;
         unset($listID);
         $listID = array($userid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "userid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "address set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/address');
     DBCache::removeCache($listIDs, 'system/address');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (isset($post['groupdata']) && !is_array($post['groupdata'])) {
         $post['groupdata'] = self::lineToArray($post['groupdata']);
     }
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "groupid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     $prefix = '';
     $prefixall = Database::isPrefixAll();
     if ($prefixall != false || $prefixall == 'no') {
         $prefix = Database::getPrefix();
     }
     Database::query("update " . $prefix . "usergroups set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/usergroup');
     // DBCache::removeCache($listIDs,'system/usergroup');
     if (!($error = Database::hasError())) {
         $loadData = self::get(array('where' => "where groupid IN ({$listIDs})"));
         $total = count($loadData);
         for ($i = 0; $i < $total; $i++) {
             $loadData[$i]['groupdata'] = self::lineToArray($loadData[$i]['groupdata']);
             Cache::saveKey($prefix . 'userGroup_' . $loadData[$i]['groupid'], serialize($loadData[$i]));
         }
         return true;
     }
     return false;
 }
Example #5
0
 public static function update($listID, $post = array(), $whereQuery = '', $addWhere = '')
 {
     if (is_numeric($listID)) {
         $catid = $listID;
         unset($listID);
         $listID = array($catid);
     }
     $listIDs = "'" . implode("','", $listID) . "'";
     if (isset($post['title'])) {
         $postTitle = isset($post['addTitle']) ? $post['addTitle'] : $post['title'];
         $post['title'] = String::encode(strip_tags($post['title']));
         $post['friendly_url'] = String::makeFriendlyUrl(strip_tags($postTitle));
         $loadPost = self::get(array('where' => "where friendly_url='" . $post['friendly_url'] . "'"));
         if (isset($loadPost[0]['postid']) && (int) $loadPost[0]['postid'] != (int) $listID[0]) {
             return false;
         }
     }
     if (isset($post['content'])) {
         // $post['content']=Shortcode::toBBCode($post['content']);
         $post['content'] = String::encode($post['content']);
     }
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : "postid in ({$listIDs})";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update " . Database::getPrefix() . "post set {$setUpdates} where {$whereQuery} {$addWhere}");
     // DBCache::removeDir('system/post');
     // DBCache::removeCache($listIDs,'system/post');
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }
Example #6
0
 public static function insert($listFields = array())
 {
     $mainTable = self::$query['table'];
     $totalArgs = count($listFields);
     if ($totalArgs == 0) {
         return false;
     }
     $addMultiAgrs = '';
     if ($totalArgs > 1) {
         foreach ($listFields as $theRow) {
             $keyNames = array_keys($theRow);
             $insertKeys = implode(',', $keyNames);
             $keyValues = array_values($theRow);
             $insertValues = "'" . implode("','", $keyValues) . "'";
             $addMultiAgrs .= "({$insertValues}), ";
         }
         $addMultiAgrs = substr($addMultiAgrs, 0, strlen($addMultiAgrs) - 2);
     } else {
         $keyNames = array_keys($listFields);
         $insertKeys = implode(',', $keyNames);
         $keyValues = array_values($listFields);
         $insertValues = "'" . implode("','", $keyValues) . "'";
         $addMultiAgrs = "({$insertValues})";
     }
     // $whereQuery=$this->parseWhere();
     $resultData = "insert into {$mainTable}({$insertKeys}) values" . $addMultiAgrs;
     Database::query($resultData);
     if (!($error = Database::hasError())) {
         if (isset($this->query['getID'])) {
             $id = Database::insert_id();
             return $id;
         }
         return true;
     }
     return false;
 }
Example #7
0
 public static function update($id, $post = array(), $whereQuery = '', $addWhere = '')
 {
     $keyNames = array_keys($post);
     $total = count($post);
     $setUpdates = '';
     for ($i = 0; $i < $total; $i++) {
         $keyName = $keyNames[$i];
         $setUpdates .= "{$keyName}='{$post[$keyName]}', ";
     }
     $setUpdates = substr($setUpdates, 0, strlen($setUpdates) - 2);
     $whereQuery = isset($whereQuery[5]) ? $whereQuery : " cronid='{$id}'";
     $addWhere = isset($addWhere[5]) ? $addWhere : "";
     Database::query("update cronjobs set {$setUpdates} where {$whereQuery} {$addWhere}");
     if (!($error = Database::hasError())) {
         return true;
     }
     return false;
 }