public static function MIME()
 {
     $link = AdminUtility::getDefaultDBConnection();
     $query = "select value from settings where name='MIME_ebooks'";
     $result = mysqli_query($link, $query);
     $row = mysqli_fetch_array($result);
     $value = $row['value'];
     return explode(',', $value);
 }
예제 #2
0
/**
 * Resets admin password, requires AdminUtility to be included 
 * @param type $id
 * @param type $newPassword
 */
function resetAdminPassword($id, $newPassword)
{
    //Check password
    $link = AdminUtility::getDefaultDBConnection();
    $pwd = crypt($newPassword);
    $query = "update admins set password='******' where username='******'";
    mysqli_query($link, $query);
    //Log error
    AdminUtility::logMySQLError($link);
}
 public static function MIME()
 {
     $array = array();
     $query = "select value from settings where name='MIME_ebooks' or name='MIME_videos'";
     $link = AdminUtility::getDefaultDBConnection();
     $result = mysqli_query($link, $query);
     while ($row = mysqli_fetch_array($result)) {
         $value = $row['value'];
         $array = array_merge($array, explode(',', $value));
     }
     return $array;
 }
예제 #4
0
 public function changeEmail($email)
 {
     if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $link = AdminUtility::getDefaultDBConnection();
         $query = "update admins set email='" . $email . "' where username='******'";
         mysqli_query($link, $query);
         //Log error
         AdminUtility::logMySQLError($link);
         //Reload data
         $this->adminInfo = $this->getAdminData();
     } else {
         throw new Exception("Invalid mail");
     }
 }
예제 #5
0
function getClassReps()
{
    $class_reps = array();
    $query = "select u.first_name, u.last_name, u.regno, u.level, m.user_id, m.units_used, m.units_assigned from admins a " . "join (users u, messenger_sms_biller m) on (u.regno = a.username and u.regno = m.user_id) " . "where a.type = '" . Admin::CLASS_REP . "' ";
    $link = AdminUtility::getDefaultDBConnection();
    $result = mysqli_query($link, $query);
    if ($result) {
        while ($row = mysqli_fetch_array($result)) {
            array_push($class_reps, $row);
        }
    }
    //Log error
    AdminUtility::logMySQLError($link);
    return $class_reps;
}
예제 #6
0
 function activateUsers(array $regno)
 {
     $link = AdminUtility::getDefaultDBConnection();
     mysqli_autocommit($link, false);
     foreach ($regno as $value) {
         $query = "update users set is_suspended = 0, is_deleted = 0  where regno = '{$value}'";
         $ok = mysqli_query($link, $query);
         if (!$ok) {
             //Log error
             AdminUtility::logMySQLError($link);
             return FALSE;
         }
     }
     return mysqli_commit($link);
 }
예제 #7
0
function totalSmsSent($user_id)
{
    $query = "select sum(num_delivered) as num from messenger_log where user_id = '" . $user_id . "' and is_sent=1";
    $link = AdminUtility::getDefaultDBConnection();
    $result = mysqli_query($link, $query);
    if ($result) {
        $row = mysqli_fetch_array($result);
        return $row['num'];
    }
    //Log error
    AdminUtility::logMySQLError($link);
    return false;
}
예제 #8
0
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once 'class_lib.php';
require_once '../functions.php';
$id = filter_input(INPUT_GET, "id");
$code = filter_input(INPUT_GET, "c");
$link = AdminUtility::getDefaultDBConnection();
if (empty($code)) {
    //generate code, mail code to admin then redirect to cpanel/index.php to notify admin of "mail"
    //Get email
    $query = "select email from admins where username = '******'";
    $result = mysqli_query($link, $query);
    if ($result) {
        //Generate code
        $row = mysqli_fetch_array($result);
        $code = uniqid();
        $email = $row["email"];
        $query = "insert into password_reset set " . "username = '******', " . "code='{$code}' " . "on duplicate key update " . "code='{$code}', " . "time_of_request=now()";
        $result = mysqli_query($link, $query);
        if ($result) {
            //Mail
            $link = $_SERVER["HTTP_HOST"] . "/" . $_SERVER["PHP_SELF"] . "?c={$code}&id={$id}";
예제 #9
0
function getExecutivePosts()
{
    $posts = array();
    $query = "select * from posts";
    $link = AdminUtility::getDefaultDBConnection();
    $result = mysqli_query($link, $query);
    if ($result) {
        while ($row = mysqli_fetch_array($result)) {
            $posts[] = $row;
        }
    }
    //Log error
    AdminUtility::logMySQLError($link);
    return $posts;
}
예제 #10
0
 function removeExecutive($executiveID, $link = null)
 {
     $query = "delete from executives where id = '{$executiveID}'";
     if (empty($link)) {
         $link = AdminUtility::getDefaultDBConnection();
     }
     mysqli_query($link, $query);
     //Log error
     AdminUtility::logMySQLError($link);
 }
예제 #11
0
 public function updateSettingsTable(array $array)
 {
     if (count($array) > 0) {
         $link = AdminUtility::getDefaultDBConnection();
         mysqli_autocommit($link, false);
         $ok = true;
         foreach ($array as $key => $value) {
             /*            if (strcasecmp($key, "help_lines") === 0) {
                               validateNumbers($value);
                               }
             
                              */
             $query = "update settings set value = '{$value}' where name = '{$key}'";
             //$ok remains true if all statements was sucessfully executed
             $ok = $ok and mysqli_query($link, $query);
         }
         if ($ok) {
             mysqli_commit($link);
             //Log error
             AdminUtility::logMySQLError($link);
             return true;
         } else {
             throw new Exception("Error occured while updating settings table");
         }
     } else {
         throw new Exception("No parameter was set");
     }
 }
예제 #12
0
function deleteLibraryItems(array $IDs)
{
    $link = AdminUtility::getDefaultDBConnection();
    mysqli_autocommit($link, false);
    foreach ($IDs as $value) {
        $query = "select * from library where id={$value}";
        $res = mysqli_query($link, $query);
        if ($res) {
            $row = mysqli_fetch_array($res);
            $query = "delete from library where id={$value}";
            $ok = mysqli_query($link, $query);
            if ($ok && $row['file_type'] !== "link") {
                //delete file from local server
                $ok = unlink(ROOT . $row['link']);
                if (!$ok) {
                    mysqli_rollback($link);
                    throw new Exception("File could not be deleted");
                }
            } elseif (!$ok) {
                //Log error
                AdminUtility::logMySQLError($link);
                throw new Exception("Oops! Something went wrong. Database didn't respond very well");
            }
        }
    }
    return mysqli_commit($link);
}
예제 #13
0
 /**
  * 
  * @param type $search_query
  * @param type $sort_type
  * @param type $sort_order
  * @return array
  */
 public static function searchUsers($search_query, $is_deleted = false, $is_suspended = false, $sort_type = null, $sort_order = null)
 {
     $users = array();
     $link = AdminUtility::getDefaultDBConnection();
     //process query
     $fields = explode(" ", $search_query);
     $query = "select * from users where (is_deleted = " . ($is_deleted ? "1" : "0") . " and " . "is_suspended = " . ($is_suspended ? "1" : "0") . ") and " . "(";
     for ($count = 0; $count < count($fields); $count++) {
         $query .= "regno = '{$fields[$count]}' or " . "last_name like '%{$fields[$count]}%' or " . "level = '{$fields[$count]}' or " . "first_name like '%{$fields[$count]}%'";
         if ($count !== count($fields) - 1) {
             $query .= " or ";
         } else {
             $query .= ")";
         }
     }
     //Search
     $result = mysqli_query($link, $query);
     if ($result) {
         while ($row = mysqli_fetch_array($result)) {
             array_push($users, $row);
         }
     }
     AdminUtility::sortUser($users, $sort_type, $sort_order);
     //Log error
     AdminUtility::logMySQLError($link);
     return $users;
 }
예제 #14
0
 public function download()
 {
     $link = AdminUtility::getDefaultDBConnection();
     ///
 }
예제 #15
0
 public function changeSenderID($new_id)
 {
     $link = AdminUtility::getDefaultDBConnection();
     $query = "update messenger_sms_biller set default_sender_id='" . $new_id . "' where user_id='" . $this->getAdminID() . "'";
     if (mysqli_query($link, $query)) {
         return true;
     }
     //Log error
     AdminUtility::logMySQLError($link);
     return false;
 }