예제 #1
0
/**
 * Action handler function
 *
 * @param	&vivvo_lite_site	$sm
 * @param	string				$action
 * @param	string				$command
 * @return	bool
 */
function schedule_service(&$sm, $action, $command)
{
    if ($action != 'schedule') {
        return false;
    }
    require_once VIVVO_FS_ROOT . 'lib/vivvo/service/Schedules.service.php';
    $service = new SchedulesService($sm);
    $dm = $sm->get_dump_manager();
    $um = $sm->get_url_manager();
    $lang = $sm->get_lang();
    switch ($command) {
        case 'add':
            $schedule_params = $um->get_param_regexp('/^schedule_/');
            if ($service->add_schedule($schedule_params)) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_SCHEDULE_ADD_SUCCESS'));
                header('X-Vivvo-Action-Status: 1');
                vivvo_hooks_manager::call('schedule_add_postaction');
                return true;
            }
            break;
        case 'edit':
            $schedule_params = $um->get_param_regexp('/^schedule_/');
            if ($service->edit_schedule($schedule_params)) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_SCHEDULE_EDIT_SUCCESS'));
                header('X-Vivvo-Action-Status: 1');
                vivvo_hooks_manager::call('schedule_edit_postaction');
                return true;
            }
            break;
        case 'delete':
            if ($service->delete_schedule($um->get_param('schedule_id'))) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_SCHEDULE_DELETE_SUCCESS'));
                header('X-Vivvo-Action-Status: 1');
                vivvo_hooks_manager::call('schedule_delete_postaction');
                return true;
            }
            break;
        case 'save_changes':
            $article_id = $um->get_param('article_id');
            foreach ($um->get_param('schedule') as $id => $mask) {
                if (!$service->edit_schedule(array('id' => $id, 'article_id' => $article_id, 'time_mask' => $mask))) {
                    break 2;
                }
            }
            foreach ($um->get_param('new_schedule') as $mask) {
                if (!$service->add_schedule(array('article_id' => $article_id, 'time_mask' => $mask))) {
                    break 2;
                }
            }
            header('X-Vivvo-Action-Status: 1');
            return true;
        default:
    }
    header('X-Vivvo-Action-Status: 0');
    header('X-Vivvo-Action-Error: ' . json_encode($service->get_error_info()));
    return false;
}
예제 #2
0
/**
 * Action handler function
 *
 * @param	&vivvo_lite_site	$sm
 * @param	string				$action
 * @param	string				$command
 * @return	bool
 */
function feed_service($sm, $action, $command)
{
    if ($action != 'feed') {
        return false;
    }
    require_once dirname(__FILE__) . '/feed.service.php';
    $service = new feed_service($sm);
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $lang = vivvo_lang::get_instance();
    if ($command == 'edit') {
        $feed_id = $um->get_param('PLUGIN_FEED_id');
        $in_feed = $um->get_param_regexp('/^PLUGIN_FEED_/');
        if ($service->edit_feed($feed_id, $in_feed)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PLUGIN_FEED_EDIT_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('feed_edit_postaction');
            return true;
        }
    } elseif ($command == 'preferences') {
        if (is_array($um->list) and !empty($um->list)) {
            foreach ($um->list as $key => $value) {
                if (preg_match('/^(VIVVO_PLUGIN_FEED_IMPORTER_)/', $key)) {
                    if (!($response = $service->preferences_feed($key, $um->list[$key]))) {
                        break;
                    }
                }
            }
        }
        if (!empty($response)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PLUGIN_FEED_PREFERENCES_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('feed_preferences_postaction');
            return true;
        }
    }
    header('X-Vivvo-Action-Status: 0');
    header('X-Vivvo-Action-Error: ' . json_encode($service->get_error_info()));
    return false;
}
예제 #3
0
function UserFilters_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/UserFilters.service.php';
    $UserFilters_service =& new UserFilters_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    if ($command == 'add') {
        $filter_name = $um->get_param('FILTER_name');
        $filter_section = $um->get_param('FILTER_section');
        $filter_data = $um->get_param('FILTER_data');
        $response = $UserFilters_service->add_UserFilters($filter_name, $filter_section, $filter_data);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_FILTER_ADD_SUCCESS'));
            vivvo_hooks_manager::call('userFilter_add_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($UserFilters_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        $filter_id = $um->get_param('FILTER_id');
        $response = $UserFilters_service->delete_UserFilters($filter_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_FILTER_DELETE_SUCCESS'));
            vivvo_hooks_manager::call('userFilter_delete_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($UserFilters_service->get_error_info()));
            return false;
        }
    }
}
예제 #4
0
 /**
  * Delete article schedule
  *
  * @param	array	$schedule_params
  * @return	bool
  */
 public function delete_schedule($schedule_params)
 {
     if (!vivvo_hooks_manager::call('schedule_delete', array(&$schedule_params))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = $this->get_site_manager();
     if ($sm->user && $sm->user->can('MANAGE_SCHEDULES')) {
         $schedule_list = new ArticlesSchedule_list($sm);
         $schedule = $schedule_list->get_schedule_by_id((int) $schedule_params['id']);
         if ($schedule) {
             $schedule->sql_delete();
             return true;
         } else {
             $this->set_error_code(2805);
         }
     } else {
         $this->set_error_code(2803);
     }
     return false;
 }
예제 #5
0
/**
 * Box def move service function
 *
 * @param vivvo_lite_site $sm
 * @return xmlrpcresp
 */
function vivvo_core_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/vivvo_core.service.php';
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $lang = $sm->get_lang();
    $vivvo_core_service = new vivvo_core_service($sm);
    if ($command == 'preferences') {
        $success = true;
        if (is_array($um->list) && !empty($um->list)) {
            foreach ($um->list as $key => $value) {
                if (preg_match('/^(VIVVO_|PLUGIN_)/', $key)) {
                    if (is_array($um->list[$key])) {
                        $value = implode(',', $um->list[$key]);
                        $response = $vivvo_core_service->edit_preferences($key, $value);
                        if (!$response) {
                            $success = false;
                        }
                    } else {
                        $response = $vivvo_core_service->edit_preferences($key, $um->list[$key]);
                        if (!$response) {
                            $success = false;
                        }
                    }
                }
            }
        }
        if ($success) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PREFERENCES_SAVE_SUCCESS'));
            vivvo_hooks_manager::call('vivvoCore_preferences_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($vivvo_core_service->get_error_info()));
            return false;
        }
    } else {
        if ($command == 'cronTask') {
            $success = true;
            if (is_array($um->list) && !empty($um->list)) {
                foreach ($um->list as $key => $value) {
                    if (preg_match('/^(VIVVO_|PLUGIN_)/', $key)) {
                        if (is_array($um->list[$key])) {
                            $value = implode(',', $um->list[$key]);
                            $response = $vivvo_core_service->edit_preferences($key, $value);
                            if (!$response) {
                                $success = false;
                            }
                        } else {
                            $response = $vivvo_core_service->edit_preferences($key, $um->list[$key]);
                            if (!$response) {
                                $success = false;
                            }
                        }
                    }
                }
            }
            $in_task = $um->get_param_regexp('/^TASK_/');
            $success = $success && $vivvo_core_service->edit_cron_task($in_task);
            if ($success) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TASK_SAVE_SUCCESS'));
                vivvo_hooks_manager::call('vivvoCore_cronTask_postaction');
                header('X-Vivvo-Action-Status: 1');
                return true;
            } else {
                header('X-Vivvo-Action-Status: 0');
                header('X-Vivvo-Action-Error: ' . json_encode($vivvo_core_service->get_error_info()));
                return false;
            }
        } else {
            if ($command == 'groupAdd') {
                $in_group = $um->get_param_regexp('/^GROUP_/');
                $success = $vivvo_core_service->group_add($in_group);
                if ($success) {
                    $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_GROUP_SAVE_SUCCESS'));
                    vivvo_hooks_manager::call('vivvoCore_groupAdd_postaction');
                    header('X-Vivvo-Action-Status: 1');
                    return true;
                } else {
                    header('X-Vivvo-Action-Status: 0');
                    header('X-Vivvo-Action-Error: ' . json_encode($vivvo_core_service->get_error_info()));
                    return false;
                }
            } else {
                if ($command == 'groupEdit') {
                    $group_id = $um->get_param('GROUP_id');
                    $in_group = $um->get_param_regexp('/^GROUP_/');
                    $success = $vivvo_core_service->group_edit($group_id, $in_group);
                    if ($success) {
                        $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_GROUP_EDIT_SUCCESS'));
                        vivvo_hooks_manager::call('vivvoCore_groupEdit_postaction');
                        header('X-Vivvo-Action-Status: 1');
                        return true;
                    } else {
                        header('X-Vivvo-Action-Status: 0');
                        header('X-Vivvo-Action-Error: ' . json_encode($vivvo_core_service->get_error_info()));
                        return false;
                    }
                } else {
                    if ($command == 'groupDelete') {
                        $group_id = $um->get_param('GROUP_id');
                        $success = $vivvo_core_service->group_delete($group_id);
                        if ($success) {
                            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_GROUP_DELETE_SUCCESS'));
                            vivvo_hooks_manager::call('vivvoCore_groupDelete_postaction');
                            header('X-Vivvo-Action-Status: 1');
                            return true;
                        } else {
                            header('X-Vivvo-Action-Status: 0');
                            header('X-Vivvo-Action-Error: ' . json_encode($vivvo_core_service->get_error_info()));
                            return false;
                        }
                    }
                }
            }
        }
    }
}
예제 #6
0
function user_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/Users.service.php';
    $user_service =& new user_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    if ($command == 'add') {
        $in_user = $um->get_param_regexp('/^USER_/');
        $response = $user_service->add_user($in_user);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_ADD_SUCCESS'));
            vivvo_hooks_manager::call('user_add_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        if (is_array($um->get_param('ids'))) {
            $user_id = $um->get_param('ids');
        } else {
            $user_id = array($um->get_param('USER_id'));
        }
        $all_matching = $um->get_param('all_matching');
        $response = $user_service->delete_user($user_id, $all_matching);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_DELETE_SUCCESS'));
            vivvo_hooks_manager::call('user_delete_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'edit') {
        $user_id = $um->get_param('USER_id');
        $in_user = $um->get_param_regexp('/^USER_/');
        $response = $user_service->edit_user($user_id, $in_user);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_EDIT_SUCCESS'));
            vivvo_hooks_manager::call('user_edit_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'setField') {
        $users_ids = $um->get_param('ids');
        $field_name = $um->get_param('field_name');
        $filed_value = $um->get_param('field_value');
        $all_matching = $um->get_param('all_matching');
        $response = $user_service->set_field($users_ids, $field_name, $filed_value, $all_matching);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_SET_FIELD_SUCCESS'));
            vivvo_hooks_manager::call('user_setField_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'addToGroup') {
        $users_ids = $um->get_param('ids');
        $group_id = $um->get_param('USER_group');
        $response = $user_service->add_to_group($group_id, $users_ids);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_SET_FIELD_SUCCESS'));
            vivvo_hooks_manager::call('user_addToGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'removeFromGroup') {
        $users_ids = $um->get_param('ids');
        $group_id = $um->get_param('USER_group');
        $response = $user_service->remove_from_group($group_id, $users_ids);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_SET_FIELD_SUCCESS'));
            vivvo_hooks_manager::call('user_removeFromGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'deleteImage') {
        $user_id = $um->get_param('USER_id');
        $response = $user_service->delete_image($user_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_DELETE_IMAGE_SUCCESS'));
            vivvo_hooks_manager::call('user_deleteImage_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'checkUsername') {
        $username = $um->get_param('USER_username');
        $response = $user_service->check_username($username);
        if ($response) {
            vivvo_hooks_manager::call('user_checkUsername_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'checkEmail') {
        $email = $um->get_param('USER_email');
        $response = $user_service->check_email($email);
        if ($response) {
            vivvo_hooks_manager::call('user_checkEmail_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'report404') {
        $url = $um->get_param('url');
        $referrer = $um->get_param('referrer');
        $response = $user_service->report_404($url, $referrer);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_REPORTED_404_SUCCESS'));
            vivvo_hooks_manager::call('user_report404_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($user_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #7
0
/**
 * file service function
 *
 * @param xmlrpcmsg $m
 * @return xmlrpcresp
 */
function file_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/file.service.php';
    $file_service =& new file_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    if ($command == 'revert') {
        $filename = $um->get_param('FILE_filename');
        $response = $file_service->revert($filename);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_REVERT_SUCCESS'));
            vivvo_hooks_manager::call('file_revert_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'save') {
        $filename = $um->get_param('FILE_filename');
        $content = $um->get_param('FILE_content');
        $response = $file_service->save($filename, $content);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_SAVE_SUCCESS'));
            vivvo_hooks_manager::call('file_save_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'duplicate') {
        $filename = $um->get_param('FILE_filename');
        $new_name = $um->get_param('FILE_new_filename');
        $response = $file_service->duplicate($filename, $new_name);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_DUPLICATE_SUCCESS'));
            vivvo_hooks_manager::call('file_duplicate_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        $filename = $um->get_param('FILE_filename');
        if (is_array($filename)) {
            $response = true;
            foreach ($filename as $file) {
                $response = $response && $file_service->delete($file);
            }
        } else {
            $response = $file_service->delete($filename);
        }
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_DELETE_SUCCESS'));
            vivvo_hooks_manager::call('file_delete_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'move') {
        $filename = $um->get_param('FILE_filename');
        $destination = $um->get_param('FILE_destination');
        if (is_array($filename)) {
            $response = true;
            foreach ($filename as $file) {
                $response = $response && $file_service->move($file, $destination);
            }
        } else {
            $response = $file_service->move($filename, $destination);
        }
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_MOVED_SUCCESS'));
            vivvo_hooks_manager::call('file_move_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'upload') {
        if ($um->get_param('UPLOAD_destination')) {
            $response = $file_service->upload('UPLOAD_file', $um->get_param('UPLOAD_destination'));
        } else {
            $response = $file_service->upload('UPLOAD_file');
        }
        if ($response) {
            $sm->action_response = $response;
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_UPLOAD_SUCCESS'));
            vivvo_hooks_manager::call('file_upload_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($file_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #8
0
 /**
  * Remove tag from tag group
  *
  * @param	int		$tag_id
  * @param	int		$group_id
  */
 public function remove_tag_from_group($tag_id, $group_id)
 {
     if (!vivvo_hooks_manager::call('tag_removeTagFromGroup', array(&$tag_id, &$group_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $user = vivvo_lite_site::get_instance()->user;
     if ($user && $user->can('MANAGE_TAGS')) {
         $tag_group_rel = new TagsToTagsGroups_list();
         $tag_group_rel->get_rel($tag_id, $group_id);
         if ($tag_group_rel->sql_delete_list($this->_post_master)) {
             return true;
         }
         $this->set_error_code(2416);
         return false;
     }
     $this->set_error_code(2410);
     return false;
 }
예제 #9
0
 /**
  * Delete user filter
  *
  * @param	integer	$filter_id
  * @return	boolean	true on success or false on fail
  */
 function delete_UserFilters($filter_id)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('UserFilter_delete', array(&$filter_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         $filter_list = new UserFilters_list();
         $filter_list->get_UserFilter_by_id($filter_id);
         if ($filter_list->sql_delete_list($this->_post_master)) {
             admin_log($sm->user->get_username(), 'Deleted user filter #' . $filter_id);
             return true;
         } else {
             $this->set_error_code(2503);
             return false;
         }
     } else {
         $this->set_error_code(2504);
         return false;
     }
 }
예제 #10
0
 /**
  * Delete category image
  *
  * @param	integer	$category_id
  * @return	boolean	true on success or false on fail
  */
 function delete_image($category_id)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('category_deleteImage', array(&$category_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         if ($sm->user->is_admin()) {
             $category_list = new Categories_list();
             $category = $category_list->get_category($category_id);
             if ($category !== false) {
                 $fm = $sm->get_file_manager();
                 if ($category->image != '') {
                     if ($fm->delete_fs(VIVVO_FS_ROOT . VIVVO_FS_FILES_DIR . $category->image)) {
                         $category->set_image('');
                         $this->_post_master->set_data_object($category);
                         if ($this->_post_master->sql_update()) {
                             admin_log($sm->user->get_username(), 'Edited category #' . $category_id);
                             return true;
                         } else {
                             $this->set_error_code(2117);
                             return false;
                         }
                     }
                 }
             } else {
                 $this->set_error_code(2118);
                 return false;
             }
         } else {
             $this->set_error_code(2119);
             return false;
         }
     } else {
         $this->set_error_code(2120);
         return false;
     }
 }
예제 #11
0
 function email_to_a_friend($article_id, $to, $bcc, $your_email, $message)
 {
     require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php';
     if (!vivvo_hooks_manager::call('article_mail', array(&$article_id, &$to, &$bcc, &$your_email, &$message))) {
         return vivvo_hooks_manager::get_status();
     }
     if (VIVVO_EMAIL_ENABLE == 1) {
         if (isset($_SESSION['vivvo']['email_to_friend_time']) && $_SESSION['vivvo']['email_to_friend_time'] + VIVVO_EMAIL_FLOOD_CHECK > VIVVO_START_TIME) {
             $this->set_error_code(2202);
             return false;
         }
         $article_list = new Articles_list();
         $article = $article_list->get_article_by_id($article_id);
         $lang = vivvo_lang::get_instance();
         if ($article !== false) {
             $to = strip_tags($to);
             $bcc = strip_tags($bcc);
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $your_email)) {
                 $this->set_error_code(2032);
                 return false;
             }
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $bcc)) {
                 $bcc = '';
             }
             if (VIVVO_EMAIL_SEND_BCC) {
                 if ($bcc) {
                     $bcc .= ', ' . VIVVO_EMAIL_SEND_BCC;
                 } else {
                     $bcc = VIVVO_EMAIL_SEND_BCC;
                 }
             }
             if (VIVVO_EMAIL_SEND_CC) {
                 $headers['Cc'] = VIVVO_EMAIL_SEND_CC;
             }
             if (preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $to)) {
                 $body_template = new template();
                 $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_TO_A_FRIEND_BODY);
                 $body_template->set_string_template($template_sting);
                 $body_template->assign('article', $article);
                 $body_template->assign('user_email_address', $your_email);
                 $body_template->assign('message', $message);
                 $body = $body_template->get_output() . "\n\n";
                 $headers['From'] = $your_email;
                 $recipients = array();
                 $recipients[] = $to;
                 if ($bcc != '') {
                     $headers['Bcc'] = $bcc;
                 }
                 $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_TO_A_FRIEND_SUBJECT) . "?=";
                 $headers['Content-Type'] = "text/plain; charset=UTF-8;";
                 if (VIVVO_EMAIL_SMTP_PHP == 1) {
                     $mail_object = new Mail();
                     $mail_object->send($to, $headers, $body);
                 } else {
                     $mail_options['driver'] = 'smtp';
                     $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                     $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                     $mail_options['localhost'] = 'localhost';
                     if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                         $mail_options['auth'] = true;
                         $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                         $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                     } else {
                         $mail_options['auth'] = false;
                         $mail_options['username'] = '';
                         $mail_options['password'] = '';
                     }
                     $mail_object = Mail::factory('smtp', $mail_options);
                     $mail_object->send($to, $headers, $body);
                 }
                 $article->set_emailed($article->emailed + 1);
                 $this->_post_master->set_data_object($article);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['email_to_friend_time'] = time();
                     return true;
                 } else {
                     $this->set_error_code(2033);
                     return false;
                 }
             } else {
                 $this->set_error_code(2034);
                 return false;
             }
         } else {
             $this->set_error_code(2035);
             return false;
         }
     }
 }
예제 #12
0
 function move($filename, $destination)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('file_move', array(&$filename, &$destination))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         if ($sm->user->is('ASSET_MANAGER') || $sm->user->can('MANAGE_FILES')) {
             if (file_exists(VIVVO_FS_ROOT . $filename)) {
                 if (file_exists(VIVVO_FS_ROOT . $destination) && is_dir(VIVVO_FS_ROOT . $destination)) {
                     if (substr(VIVVO_FS_ROOT . $destination, -1, 1) != '/' && substr(VIVVO_FS_ROOT . $destination, -1, 1) != '\\') {
                         $destination .= '/';
                     }
                     $file = basename(VIVVO_FS_ROOT . $filename);
                     if (@rename(VIVVO_FS_ROOT . $filename, VIVVO_FS_ROOT . $destination . $file)) {
                         admin_log($sm->user->get_username(), 'Moved file ' . $filename . ' to ' . $destination);
                         return true;
                     } else {
                         $this->set_error_code(2823);
                         return false;
                     }
                 } else {
                     $this->set_error_code(2824);
                     return false;
                 }
             } else {
                 $this->set_error_code(2825);
                 return false;
             }
         } else {
             $this->set_error_code(2826);
             return false;
         }
     } else {
         $this->set_error_code(2827);
         return false;
     }
 }
예제 #13
0
function comment_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/Comments.service.php';
    $comment_service =& new comment_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    if ($command == 'add') {
        $in_comment = $um->get_param_regexp('/^COMMENT_/');
        $captcha = $um->get_param('COMMENT_captcha');
        $response = $comment_service->add_comment($in_comment, $captcha);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_COMMENT_ADD_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_add_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        if (is_array($um->get_param('ids'))) {
            $comment_id = $um->get_param('ids');
        } else {
            $comment_id = array($um->get_param('COMMENT_id'));
        }
        $all_matching = $um->get_param('all_matching');
        $response = $comment_service->delete_comment($comment_id, $all_matching);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_COMMENT_DELETE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_delete_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'edit') {
        $comment_id = $um->get_param('COMMENT_id');
        $in_comment = $um->get_param_regexp('/^COMMENT_/');
        $response = $comment_service->edit_comment($comment_id, $in_comment);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_COMMENT_EDIT_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_edit_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'setField') {
        $comments_ids = $um->get_param('ids');
        $all_matching = $um->get_param('all_matching');
        $field_name = $um->get_param('field_name');
        $field_value = $um->get_param('field_value');
        $response = $comment_service->set_field($comments_ids, $field_name, $field_value, $all_matching);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_COMMENT_SET_FIELD_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_setField_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'reportInappropriateContent') {
        $comment_id = $um->get_param('COMMENT_id');
        $response = $comment_service->report_inappropriate_content($comment_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_COMMENT_REPORTING_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_reportContent_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'vote') {
        $comment_id = $um->get_param('COMMENT_id');
        $vote = $um->get_param('COMMENT_vote');
        $response = $comment_service->vote($comment_id, $vote);
        if ($response) {
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('comment_vote_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($comment_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'proxy') {
        class _fakeArticle__
        {
            public $get_id;
            public function __get($name)
            {
                return $this->get_id;
            }
        }
        $fake_article = new _fakeArticle__();
        $fake_article->get_id = $um->get_param('article_id');
        $sm->get_template()->assign('pg', $um->get_param('pg'));
        $sm->get_template()->assign('CURRENT_URL', $um->get_param('CURRENT_URL'));
        $sm->get_template()->assign('article', $fake_article);
        $sm->get_template()->assign('ajax_output', intval(1));
        vivvo_hooks_manager::call('comment_proxy_postaction');
    }
    return true;
}
예제 #14
0
/**
 * file service function
 *
 * @param xmlrpcmsg $m
 * @return xmlrpcresp
 */
function assets_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/assets.service.php';
    $assets_service =& new assets_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    if ($command == 'delete') {
        $filename = $um->get_param('FILE_filename');
        if (is_array($filename)) {
            $response = true;
            foreach ($filename as $file) {
                $response = $response && $assets_service->delete($file);
            }
        } else {
            $response = $assets_service->delete($filename);
        }
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_DELETE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_delete_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'move') {
        $filename = $um->get_param('FILE_filename');
        $destination = $um->get_param('FILE_destination');
        if (is_array($filename)) {
            $response = true;
            foreach ($filename as $file) {
                $response = $response && $assets_service->move($file, $destination);
            }
        } else {
            $response = $assets_service->move($filename, $destination);
        }
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_MOVED_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_move_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'rename') {
        $filename = $um->get_param('FILE_filename');
        $newname = $um->get_param('FILE_newname');
        if (is_array($filename)) {
            $response = $assets_service->rename($filename[0], $newname);
        } else {
            $response = $assets_service->rename($filename, $newname);
        }
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_RENAMED_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_rename_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'upload') {
        if ($um->get_param('UPLOAD_destination')) {
            $response = $assets_service->upload('UPLOAD_file', $um->get_param('UPLOAD_destination'));
        } else {
            $response = $assets_service->upload('UPLOAD_file');
        }
        if ($response) {
            $sm->action_response = $response;
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_UPLOAD_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_upload_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'edit') {
        $asset_id = $um->get_param('ASSET_id');
        $data = $um->get_param_regexp('/^ASSET_/');
        $response = $assets_service->edit($asset_id, $data);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_EDIT_DATA_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_edit_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'scan_dir') {
        $response = $assets_service->scan_dir($um->get_param('FILE_dir'));
        if ($response) {
            $sm->action_response = $response;
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_DIRSCAN_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_scanDir_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'new_dir') {
        $current = $um->get_param('FILE_current');
        $newdir = $um->get_param('FILE_newdir');
        $response = $assets_service->new_dir($current, $newdir);
        if ($response) {
            $sm->action_response = $response;
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_ADD_DIR_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_newDir_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
        //----------------------------------------------------------
    } elseif ($command == 'delete_dir') {
        $response = $assets_service->rm_dir($um->get_param('FILE_rmdir'));
        if ($response) {
            $sm->action_response = $response;
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FILE_DELETE_DIR_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('asset_deleteDir_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($assets_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #15
0
 /**
  * Edit plugin preferences.
  *
  * @param	string	$variable_name
  * @param	int		$variable_value
  * @return	bool	true on succes or false on failure
  */
 public function preferences_feed($variable_name, $variable_value)
 {
     if (!$this->check_token()) {
         return false;
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user and $sm->user->can('MANAGE_PLUGIN', 'feed_importer')) {
         if (!vivvo_hooks_manager::call('feed_preferences', array(&$variable_name, &$variable_value))) {
             return vivvo_hooks_manager::get_status();
         }
         require_once VIVVO_FS_FRAMEWORK . 'vivvo_preference.php';
         $preferences_list = new preferences_list();
         $preferences = $preferences_list->get_preference_by_variable_name($variable_name);
         if ($preferences != false) {
             if ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_USER_ID' and $variable_value < 0) {
                 $variable_value = 1;
             } elseif ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_STATUS' and $variable_value != 1) {
                 $variable_value = 0;
             } elseif ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_AUTO_ARCHIVE' and $variable_value <= 0) {
                 $variable_value = 0;
             } elseif ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_AUTO_DELETE' and $variable_value <= 0) {
                 $variable_value = 0;
             } elseif ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_PERIOD' and ($variable_value = (int) $variable_value) <= 0) {
                 $variable_value = 1;
             }
             $preferences->set_variable_value($variable_value);
             $this->_post_master->set_data_object($preferences);
             if ($this->_post_master->sql_update()) {
                 if ($variable_name == 'VIVVO_PLUGIN_FEED_IMPORTER_PERIOD') {
                     $pm = $sm->get_plugin_manager();
                     $cm = $sm->get_cron_manager();
                     if ($variable_value == 1) {
                         $variable_value = '*';
                     } else {
                         $variable_value = '*/' . $variable_value;
                     }
                     $cm->cron_job("19 {$variable_value} * * *", $pm->plugins['feed_importer']['root_dir'] . 'tasks/auto_import_feeds.php', null, 'auto_import_feeds');
                 }
                 return true;
             } else {
                 $this->set_error_code(10101);
                 // can't update plugin preferences
                 return false;
             }
         } else {
             $this->set_error_code(10102);
             // preference does not exists
             return false;
         }
     } else {
         $this->set_error_code(10103);
         // you don't have sufficient privileges for this action
         return false;
     }
 }
예제 #16
0
 /**
  * Report 404 error via e-mail
  *
  * @param	integer		$comment_id
  * @return	boolean		true on succes, or false on fail
  */
 function report_404($url, $referrer = '')
 {
     if (!vivvo_hooks_manager::call('user_report404', array(&$url))) {
         return vivvo_hooks_manager::get_status();
     }
     require_once dirname(__FILE__) . '/../../../lib/vivvo/framework/PEAR/Mail.php';
     $url = htmlspecialchars($url);
     $referrer = htmlspecialchars($referrer);
     if (VIVVO_EMAIL_ENABLE == 1) {
         $lang = vivvo_lang::get_instance();
         $body .= $lang->get_value('LNG_REPORT_404_BODY') . "\n";
         $body .= 'URL : ' . $url . "\n";
         $body .= 'Referrer : ' . $referrer . "\n\n";
         $to = VIVVO_ADMINISTRATORS_EMAIL;
         $headers['From'] = VIVVO_ADMINISTRATORS_EMAIL;
         $headers['To'] = VIVVO_ADMINISTRATORS_EMAIL;
         $subject = str_replace('<WEBSITE_TITLE>', VIVVO_WEBSITE_TITLE, $lang->get_value('LNG_REPORT_404_MAIL_SUBJECT'));
         $headers['Subject'] = "=?UTF-8?B?" . base64_encode($subject) . "?=";
         $headers['Content-Type'] = "text/plain; charset=UTF-8;";
         if (VIVVO_EMAIL_SMTP_PHP == 1) {
             $mail_object = new Mail();
             $mail_object->send($to, $headers, $body);
         } else {
             $mail_options['driver'] = 'smtp';
             $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
             $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
             $mail_options['localhost'] = 'localhost';
             if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                 $mail_options['auth'] = true;
                 $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                 $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
             } else {
                 $mail_options['auth'] = false;
                 $mail_options['username'] = '';
                 $mail_options['password'] = '';
             }
             $mail_object =& Mail::factory('smtp', $mail_options);
             $mail_object->send($to, $headers, $body);
         }
         return true;
     }
 }
예제 #17
0
function category_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/Categories.service.php';
    $category_service = new category_service($sm);
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $lang = $sm->get_lang();
    $category_id = $um->get_param('CATEGORY_id');
    if ($command == 'add') {
        $in_category = $um->get_param_regexp('/^CATEGORY_/');
        $response = $category_service->add_category($in_category);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value($um->get_param('CATEGORY_redirect') ? 'LNG_INFO_LINK_ADD_SUCCESS' : 'LNG_INFO_CATEGORY_ADD_SUCCESS'));
            vivvo_cache::get_instance()->delete('categories');
            vivvo_hooks_manager::call('category_add_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($category_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        $response = $category_service->delete_category($category_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value($um->get_param('CATEGORY_redirect') ? 'LNG_INFO_LINK_DELETE_SUCCESS' : 'LNG_INFO_CATEGORY_DELETE_SUCCESS'));
            vivvo_cache::get_instance()->delete('categories');
            vivvo_hooks_manager::call('category_delete_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($category_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'edit') {
        $category_id = $um->get_param('CATEGORY_id');
        $in_category = $um->get_param_regexp('/^CATEGORY_/');
        $response = $category_service->edit_category($category_id, $in_category);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value($um->get_param('CATEGORY_redirect') ? 'LNG_INFO_LINK_EDIT_SUCCESS' : 'LNG_INFO_CATEGORY_EDIT_SUCCESS'));
            vivvo_cache::get_instance()->delete('categories');
            vivvo_hooks_manager::call('category_edit_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($category_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'reorder') {
        $in_category = $um->get_param('category_list');
        $in_category = json_decode($in_category, true);
        $response = $category_service->reorder_category(0, $in_category);
        if ($response !== false) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_CATEGORY_REORDER_SUCCESS'));
            vivvo_cache::get_instance()->delete('categories');
            vivvo_hooks_manager::call('category_reorder_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($category_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'deleteImage') {
        $category_id = $um->get_param('CATEGORY_id');
        $response = $category_service->delete_image($category_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_CATEGORY_DELETE_IMAGE_SUCCESS'));
            vivvo_cache::get_instance()->delete('categories');
            vivvo_hooks_manager::call('category_deleteImage_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($category_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #18
0
/**
 * Form builder manager service
 *
 * @param	site_manager	$sm
 * @param	string			$action
 * @param	string			$command
 * @return	boolean			true on succes, or false on fail
 */
function form_builder_service($sm, $action, $command)
{
    require_once dirname(__FILE__) . '/form_builder.service.php';
    $form_builder_service = new form_builder_service($sm);
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $lang = $sm->get_lang();
    $pm = $sm->get_plugin_manager();
    $lang->load_lang(VIVVO_ADMIN_LANG, $pm->plugins['form_builder']['root_dir'] . 'admin/lang/');
    if ($command == 'add') {
        $in_form = $um->get_param_regexp('/^PLUGIN_FORM_BUILDER_/');
        unset($in_form['elements']);
        $in_form_elemnet = $um->get_param('PLUGIN_FORM_BUILDER_elements');
        $response = $form_builder_service->add($in_form, $in_form_elemnet);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PLUGIN_FORM_BUILDER_FORM_ADD_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('form_builder_add_postaction');
            return true;
        } else {
            return false;
        }
    } elseif ($command == 'edit') {
        $form_id = $um->get_param('PLUGIN_FORM_BUILDER_id');
        $in_form = $um->get_param_regexp('/^PLUGIN_FORM_BUILDER_/');
        unset($in_form['elements']);
        $in_form_elemnet = $um->get_param('PLUGIN_FORM_BUILDER_elements');
        $response = $form_builder_service->edit($form_id, $in_form, $in_form_elemnet);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PLUGIN_FORM_BUILDER_FORM_EDIT_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('form_builder_edit_postaction');
            return true;
        } else {
            return false;
        }
    } elseif ($command == 'delete') {
        $form_id = $um->get_param('PLUGIN_FORM_BUILDER_id');
        $response = $form_builder_service->delete($form_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_PLUGIN_FORM_BUILDER_FORM_DELETE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('form_builder_delete_postaction');
            return true;
        } else {
            return false;
        }
    } elseif ($command == 'mail') {
        $form_id = $um->get_param('PFB_form_id');
        $in_form = $um->get_param_regexp('/^PFB_/');
        $response = $form_builder_service->mail($form_id, $in_form);
        if ($response !== false) {
            $dm->add_dump('info', 0, $response);
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('form_builder_mail_postaction');
            return true;
        } else {
            return false;
        }
    } elseif ($command == 'my_action') {
        $form_id = $um->get_param('PFB_form_id');
        $in_form = $um->get_param_regexp('/^PFB_/');
        $response = $form_builder_service->my_action($form_id, $in_form);
        if ($response !== false) {
            $dm->add_dump('info', 0, $response);
            return true;
        } else {
            return false;
        }
    }
    header('X-Vivvo-Action-Status: 0');
    header('X-Vivvo-Action-Error: ' . json_encode($form_builder_service->get_error_info()));
    return false;
}
예제 #19
0
function article_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/Articles.service.php';
    $article_service = new articles_service($sm);
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $lang = $sm->get_lang();
    $article_id = $um->get_param('article_id');
    if ($command == 'add') {
        $in_article = $um->get_param_regexp('/^ARTICLE_/');
        if ($um->get_param('publish') == 1 && intval($in_article['status']) < 1) {
            $in_article['status'] = 1;
        }
        $response = $article_service->add_article($in_article);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_ADD_SUCCESS') . ' <a href="' . VIVVO_URL . 'index.php?news=' . $um->get_param('ARTICLE_id') . '" target="_blank">' . $lang->get_value('LNG_ADMIN_PREVIEW') . '</a>');
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_add_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'delete') {
        if (is_array($um->get_param('ids'))) {
            $article_id = $um->get_param('ids');
        } else {
            $article_id = array($um->get_param('ARTICLE_id'));
        }
        $all_matching = $um->get_param('all_matching');
        $response = $article_service->delete_article($article_id, $all_matching);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_DELETE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_delete_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'edit') {
        $article_id = $um->get_param('ARTICLE_id');
        $in_article = $um->get_param_regexp('/^ARTICLE_/');
        if ($um->get_param('publish') == 1 && intval($in_article['status']) < 1) {
            $in_article['status'] = 1;
        }
        $response = $article_service->edit_article($article_id, $in_article);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_EDIT_SUCCESS') . ' <a href="' . VIVVO_URL . 'index.php?news=' . $article_id . '" target="_blank">' . $lang->get_value('LNG_ADMIN_PREVIEW') . '</a>');
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_edit_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'reorder') {
        $in_article = $um->get_param('article_list');
        $response = $article_service->reorder_article($in_article);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_REORDER_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_reorder_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'normalize_order') {
        $response = $article_service->normalize_order();
        if ($response) {
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_normalizeOrder_postaction');
            return true;
        } else {
            return false;
        }
    } elseif ($command == 'setField') {
        $articles_ids = $um->get_param('ids');
        $field_name = $um->get_param('field_name');
        $filed_value = $um->get_param('field_value');
        $all_matching = $um->get_param('all_matching');
        $response = $article_service->set_field($articles_ids, $field_name, $filed_value, $all_matching);
        if ($response) {
            if ($field_name == 'status' and $filed_value == -2) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_TRASH_SUCCESS'));
            } else {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_SET_FIELD_SUCCESS'));
            }
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_setField_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'deleteImage') {
        $article_id = $um->get_param('ARTICLE_id');
        $response = $article_service->delete_image($article_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_DELETE_IMAGE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_deleteImage_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'deleteDocument') {
        $article_id = $um->get_param('ARTICLE_id');
        $response = $article_service->delete_document($article_id);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_DELETE_DOCUMENT_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_deleteDocument_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'vote') {
        $article_id = $um->get_param('ARTICLE_id');
        $vote = $um->get_param('ARTICLE_vote');
        $response = $article_service->vote($article_id, $vote);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_ARTICLE_VOTE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_vote_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'mail') {
        $article_id = $um->get_param('ARTICLE_id');
        $article_to = $um->get_param('ARTICLE_to');
        $article_bcc = $um->get_param('ARTICLE_bcc');
        $article_your_email = $um->get_param('ARTICLE_your_email');
        $article_message = $um->get_param('ARTICLE_message');
        $response = $article_service->email_to_a_friend($article_id, $article_to, $article_bcc, $article_your_email, $article_message);
        if ($response) {
            $mail_sent = str_replace('<MAIL_TO>', $article_to, $lang->get_value('LNG_INFO_ARTICLE_E_MAIL_TO_A_FRIEND_SENT_SUCCESS'));
            $dm->add_dump('info', 0, $mail_sent);
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_mail_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'purge_trashbin') {
        $response = $article_service->purge_trashbin();
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TRASHBIN_DELETE_SUCCESS'));
            header('X-Vivvo-Action-Status: 1');
            vivvo_hooks_manager::call('article_delete_postaction');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($article_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #20
0
 /**
  * Change password procedure
  *
  * @param	array	$user_data
  * @return	boolean	true on success or false on fail
  */
 function change_password($user_data)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('login_changePassword', array(&$user_data))) {
         return vivvo_hooks_manager::get_status();
     }
     $key = $user_data['key'];
     $user_list = new Users_list();
     $user = $user_list->get_user_by_forgot_md5($key);
     if ($user === false) {
         $this->set_error_code(2713);
         return false;
     } else {
         if (strlen($user_data['password']) < 6) {
             $this->set_error_code(2706);
             return false;
         }
         if ($user_data['password'] != $user_data['retype_password']) {
             $this->set_error_code(2707);
             return false;
         }
         $user_data['password'] = md5($user_data['password']);
         $user->set_password($user_data['password']);
         $this->_post_master->set_data_object($user);
         if ($this->_post_master->sql_update()) {
             admin_log($user->get_username(), ' Changed password');
             return true;
         } else {
             $this->set_error_code(2711);
             return false;
         }
     }
 }
예제 #21
0
 function parse_url($force = false)
 {
     //TODO srediti non friendly urls
     if (vivvo_hooks_manager::call('url_parse_pre', array(&$this, &$force)) == false) {
         return;
     }
     if (!$force && (defined('VIVVO_ADMIN_MODE') || defined('VIVVO_SKIP_URL_PARSING'))) {
         return;
     }
     $sm = vivvo_lite_site::get_instance();
     $pm = $sm->get_plugin_manager();
     $user = $sm->user;
     empty($this->_url_array) and $this->_url_array[0] = 'index.php';
     // default is index
     // Fix for #594 (plain text version on article preview)
     if ($user and $user->can('ACCESS_ADMIN') and count($this->_url_array) == 1 and $this->_url_array[0] == 'index.php' and !empty($_GET['news']) and !empty($this->list['output_type']) and $this->list['output_type'] != 'php') {
         $this->_url_array = array('feed', 'index.' . $this->list['output_type']);
     }
     if (preg_match('/[a-zA-Z0-9_]*\\.php/', $this->_url_array[0])) {
         return;
     } elseif (strtolower($this->_url_array[0]) == '404.html') {
         $this->list['404'] = true;
     } elseif ($sm->is_registered_url($this->_url_array[0] . $this->list['output_type'])) {
         if (vivvo_hooks_manager::call('url_parse_handler_pre', array(&$this, $this->_url_array[0] . $this->list['output_type']))) {
             $res = $sm->call_url_handler($this->_url_array[0] . $this->list['output_type'], $this->_url_array);
             vivvo_hooks_manager::call('url_parse_handler_post', array(&$this, $this->_url_array[0] . $this->list['output_type'], &$res));
             if ($res === false) {
                 go_404();
             } else {
                 if (is_array($res) && !empty($res)) {
                     $this->list = array_merge($this->list, $res);
                 }
             }
         }
         return;
     } elseif ($sm->is_registered_url($this->_url_array[0])) {
         if (vivvo_hooks_manager::call('url_parse_handler_pre', array(&$this, $this->_url_array[0]))) {
             $res = $sm->call_url_handler($this->_url_array[0], $this->_url_array);
             vivvo_hooks_manager::call('url_parse_handler_post', array(&$this, $this->_url_array[0], &$res));
             if ($res === false) {
                 go_404();
             } else {
                 if (is_array($res) && !empty($res)) {
                     $this->list = array_merge($this->list, $res);
                 }
             }
         }
         return;
     } elseif (strtolower($this->_url_array[0]) == 'app') {
         if (isset($this->_url_array[1])) {
             $this->list['plugin'] = $this->_url_array[1];
             $plagin_name = $this->_url_array[1];
             array_shift($this->_url_array);
             array_shift($this->_url_array);
             $parsed_url = $pm->url_handler($plagin_name, $this->_url_array);
             if (is_array($parsed_url) && !empty($parsed_url)) {
                 foreach ($parsed_url as $k => $v) {
                     $this->list[$k] = $v;
                 }
             }
         }
     } elseif (count($this->_url_array) > 0) {
         $last_chunk = end($this->_url_array);
         $url_count = count($this->_url_array);
         if ($url_count == 1) {
             //all news
             if (preg_match('/^index\\.(\\d+)?.*' . $this->list['output_type'] . '?$/i', $last_chunk, $filename)) {
                 if (!empty($filename[1])) {
                     $this->list['pg'] = $filename[1];
                 }
                 array_pop($this->_url_array);
             } else {
                 if (vivvo_hooks_manager::call('url_parse_default_pre', array(&$this))) {
                     $res = $sm->call_url_handler('category', $this->_url_array);
                     if ($res === false) {
                         go_404();
                     } else {
                         if (is_array($res) && !empty($res)) {
                             $this->list = array_merge($this->list, $res);
                         }
                         vivvo_hooks_manager::call('url_parse_default_post');
                     }
                 }
             }
         } else {
             if (vivvo_hooks_manager::call('url_parse_default_pre', array(&$this))) {
                 $res = $sm->call_url_handler('category', $this->_url_array);
                 if ($res === false) {
                     go_404();
                 } else {
                     if (is_array($res) && !empty($res)) {
                         $this->list = array_merge($this->list, $res);
                     }
                 }
                 //article URL
                 if (!empty($this->list['output_type'])) {
                     if (isset($this->list['search_cid']) && !preg_match('/^index\\.(\\d+)?.*' . $this->list['output_type'] . '?$/i', $last_chunk)) {
                         if (VIVVO_URL_FORMAT != 0 && $sm->is_registered_url('article' . VIVVO_URL_FORMAT)) {
                             $res = $sm->call_url_handler('article' . VIVVO_URL_FORMAT, $this->_url_array);
                         } else {
                             $res = $sm->call_url_handler('article', $this->_url_array);
                         }
                         if ($res === false) {
                             go_404();
                         } else {
                             if (is_array($res) && !empty($res)) {
                                 $this->list = array_merge($this->list, $res);
                             }
                         }
                     }
                 }
                 vivvo_hooks_manager::call('url_parse_default_post');
             }
         }
     }
 }
예제 #22
0
function tag_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/Tags.service.php';
    $tag_service = new tag_service($sm);
    $dm = $sm->get_dump_manager();
    $um = $sm->get_url_manager();
    $lang = $sm->get_lang();
    if ($command == 'add') {
        $name = $um->get_param('TAG_name');
        $sefriendly = $um->get_param('TAG_sefriendly');
        if ($tag_service->add_tag($name, $sefriendly)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_ADD_SUCCESS'));
            vivvo_hooks_manager::call('tag_add_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'addGroup') {
        $name = $um->get_param('TAG_GROUP_name');
        $url = $um->get_param('TAG_GROUP_url');
        $template = $um->get_param('TAG_GROUP_template');
        $tag_template = $um->get_param('TAG_GROUP_tag_template');
        $metadata = $um->get_param_regexp('/^TAG_GROUP_META_/');
        $via_ajax = $um->isset_param('json_output');
        $new_tags = $um->get_param('TAG_GROUP_new_tags');
        if ($group_id = $tag_service->add_tag_group($name, $url, $template, $tag_template, $metadata, $via_ajax, $new_tags)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_ADD_SUCCESS'));
            vivvo_hooks_manager::call('tag_addGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            if ($via_ajax) {
                exit('{"new_tags_group_id":"' . $group_id . '"}');
            }
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'edit') {
        $id = $um->get_param('TAG_id');
        $name = $um->get_param('TAG_name');
        $sefriendly = $um->get_param('TAG_sefriendly');
        if ($tag_service->edit_tag($id, $name, $sefriendly)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_EDIT_SUCCESS'));
            vivvo_hooks_manager::call('tag_edit_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'editGroup') {
        $id = $um->get_param('TAG_GROUP_id');
        $name = $um->get_param('TAG_GROUP_name');
        $url = $um->get_param('TAG_GROUP_url');
        $template = $um->get_param('TAG_GROUP_template');
        $tag_template = $um->get_param('TAG_GROUP_tag_template');
        $metadata = $um->get_param_regexp('/^TAG_GROUP_META_/');
        $new_tags = $um->get_param('TAG_GROUP_new_tags');
        if ($tag_service->edit_tag_group($id, $name, $url, $template, $tag_template, $metadata, $new_tags)) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_EDIT_SUCCESS'));
            vivvo_hooks_manager::call('tag_editGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'delete') {
        if ($tag_service->delete_tag($um->get_param('TAG_id'), $um->get_param('all_matching'))) {
            $dm->_dump_pool = array();
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_DELETE_SUCCESS'));
            vivvo_hooks_manager::call('tag_delete_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'deleteGroup') {
        if ($tag_service->delete_tag_group($um->get_param('TAG_GROUP_id'))) {
            $dm->_dump_pool = array();
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_DELETE_SUCCESS'));
            vivvo_hooks_manager::call('tag_deleteGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } elseif ($command == 'addTagToGroup') {
        $tag_id = $um->get_param('TAG_id');
        $group_id = $um->get_param('TAG_GROUP_id');
        if ($tag_service->add_tag_to_group($tag_id, $group_id)) {
            $dm->_dump_pool = array();
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_LINK_SUCCESS'));
            vivvo_hooks_manager::call('tag_addTagToGroup_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        }
        header('X-Vivvo-Action-Status: 0');
        header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
        return false;
    } else {
        if ($command == 'addTagsToTopic') {
            $tag_names = $um->get_param('TAG_names');
            $topic_id = $um->get_param('TAG_topic_id');
            if ($tag_service->add_tag_names_to_topic($tag_names, $topic_id)) {
                $dm->_dump_pool = array();
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_LINK_SUCCESS'));
                vivvo_hooks_manager::call('tag_addTagsToTopic_postaction');
                header('X-Vivvo-Action-Status: 1');
                return true;
            }
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
            return false;
        } elseif ($command == 'removeTagFromGroup') {
            $tag_id = $um->get_param('TAG_id');
            $group_id = $um->get_param('TAG_GROUP_id');
            if ($tag_service->remove_tag_from_group($tag_id, $group_id)) {
                $dm->_dump_pool = array();
                $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_TAG_GROUP_UNLINK_SUCCESS'));
                vivvo_hooks_manager::call('tag_removeTagFromGroup_postaction');
                header('X-Vivvo-Action-Status: 1');
                return true;
            }
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
            return false;
        } elseif ($command == 'deleteLink') {
            $tag_id = $um->get_param('TAG_link_id');
            if ($tag_service->delete_tag_link($tag_id)) {
                vivvo_hooks_manager::call('tag_deleteLink_postaction');
                header('X-Vivvo-Action-Status: 1');
                return true;
            }
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
            return false;
        } elseif ($command == 'addLink') {
            $article_id = $um->get_param('TAG_article_id');
            $name = $um->get_param('TAG_name');
            if ($tag_service->add_tag_link($article_id, $name)) {
                vivvo_hooks_manager::call('tag_addLink_postaction');
                header('X-Vivvo-Action-Status: 1');
                return true;
            }
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($tag_service->get_error_info()));
            return false;
        }
    }
}
예제 #23
0
function login_service(&$sm, $action, $command)
{
    require_once dirname(__FILE__) . '/login.service.php';
    $login_service =& new login_service($sm);
    $um =& $sm->get_url_manager();
    $dm =& $sm->get_dump_manager();
    $lang =& $sm->get_lang();
    // check
    if ($command == 'check') {
        $response = $login_service->is_logedin();
        if ($response) {
            vivvo_hooks_manager::call('login_check_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'logout') {
        $response = $login_service->logout();
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_LOGIN_LOGUOUT_SUCCESS'));
            vivvo_hooks_manager::call('login_logout_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'login') {
        $username = $um->get_param('LOGIN_username');
        $password = $um->get_param('LOGIN_password');
        $remeber = $um->get_param('LOGIN_remember');
        $response = $login_service->login($username, $password, $remeber);
        if ($response) {
            vivvo_hooks_manager::call('login_login_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'register') {
        $in_user = $um->get_param_regexp('/^USER_/');
        $captcha = $um->get_param('USER_captcha');
        $response = $login_service->register($in_user, $captcha);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_REGISTER_SUCCESS'));
            vivvo_hooks_manager::call('login_register_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'forgotMail') {
        $username = $um->get_param('LOGIN_username');
        $email = $um->get_param('LOGIN_email');
        $response = $login_service->forgot_mail($username, $email);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FORGOT_PASSWORD_NOTICE'));
            vivvo_hooks_manager::call('login_forgotMail_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'changePassword') {
        $in_user = $um->get_param_regexp('/^USER_/');
        $response = $login_service->change_password($in_user);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_FORGOT_PASSWORD__HAS_BEEN_SUCCESSFULLY_CHANGED'));
            vivvo_hooks_manager::call('login_changePassword_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'checkUser') {
        $in_user = $um->get_param_regexp('/^USER_/');
        $response = $login_service->check_user($in_user);
        if ($response) {
            vivvo_hooks_manager::call('login_checkUser_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    } elseif ($command == 'confirm') {
        $activation_code = $um->get_param('ack');
        $response = $login_service->confirm($activation_code);
        if ($response) {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INFO_USER_CONFIRM_SUCCESS'));
            vivvo_hooks_manager::call('login_confirm_postaction');
            header('X-Vivvo-Action-Status: 1');
            return true;
        } else {
            header('X-Vivvo-Action-Status: 0');
            header('X-Vivvo-Action-Error: ' . json_encode($login_service->get_error_info()));
            return false;
        }
    }
    return true;
}
예제 #24
0
 /**
  * Edit comment
  *
  * @param	integer		$comment_id
  * @param	array		$data
  * @return	boolean		true on succes, or false on fail
  */
 function vote($comment_id, $vote)
 {
     if (!vivvo_hooks_manager::call('comment_vote', array(&$comment_id, &$vote))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     $dm = $sm->get_dump_manager();
     if (!$sm->user && $sm->guest_group && $sm->guest_group->group_privileges['ARTICLE_COMMENT'] > 0 || $sm->user && $sm->user->privileges['ARTICLE_COMMENT'] > 0) {
         if (!isset($_SESSION['vivvo']['comment'])) {
             $_SESSION['vivvo']['comment'] = array();
         }
         if (in_array($comment_id, $_SESSION['vivvo']['comment'])) {
             $this->set_error_code(2222);
             return false;
         } else {
             if ($vote != 1 and $vote != -1) {
                 $this->set_error_code(2223);
                 return false;
             }
             $comment_list = new Comments_list();
             $comment = $comment_list->get_comments_by_id($comment_id);
             if ($comment !== false) {
                 $vote += $comment->get_vote();
                 $comment->set_vote($vote);
                 $this->_post_master->set_data_object($comment);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['comment'][] = $comment->id;
                     $dm->add_dump('info', 0, $vote);
                     return true;
                 } else {
                     $this->set_error_code(2224);
                     return false;
                 }
             } else {
                 $this->set_error_code(2225);
                 return false;
             }
         }
     } else {
         $this->set_error_code(2226);
         return false;
     }
 }
예제 #25
0
 function sql_delete_list($sql_table, $where, $from = false, $commit = true)
 {
     if ($from) {
         $sql = 'DELETE FROM ' . $from . ' WHERE ' . $where;
         $sql_table = preg_replace('/^' . VIVVO_DB_PREFIX . '/', '', $from);
     } else {
         $sql = 'DELETE FROM `' . VIVVO_DB_PREFIX . $sql_table . '` WHERE ' . $where;
     }
     $db = vivvo_lite_site::get_instance()->get_db();
     if ($commit == true || !$db->supports('transactions')) {
         $hook = 'db_' . $sql_table . '_delete_list';
         if (vivvo_hooks_manager::call($hook . '_pre', array(&$this)) !== false) {
             $res = $db->query($sql);
             if (PEAR::isError($res)) {
                 vivvo_lite_site::get_instance()->debug_push("sql:", $res->getMessage(), 1);
                 return false;
             }
             vivvo_hooks_manager::call($hook . '_post', array(&$this));
         } elseif (!vivvo_hooks_manager::get_status()) {
             return false;
         }
     } else {
         $this->stack[] = $sql;
     }
     vivvo_cache::get_instance()->cleanup();
     return true;
 }
예제 #26
0
 function group_edit($group_id, $in_group)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('vivvoCore_groupEdit', array(&$group_id, &$in_group))) {
         return vivvo_hooks_manager::get_status();
     }
     if ($this->_user && $this->_user->is_admin()) {
         $sm = vivvo_lite_site::get_instance();
         $user_manager = $sm->get_user_manager();
         $group = $user_manager->get_group_by_id($group_id);
         if ($group) {
             if (VIVVO_USER_SOURCE == 'vivvo@localhost') {
                 $group->name = $in_group['name'];
                 $this->_post_master->set_data_object($group);
                 if (!$this->_post_master->sql_update()) {
                     $this->set_error_code(5115);
                     return false;
                 }
             }
             if ($user_manager->save_group_privileges($group, $in_group['privileges'])) {
                 admin_log($sm->user->get_username(), 'Edited group #' . $group_id);
                 return true;
             } else {
                 $this->set_error_code(5116);
                 return false;
             }
         } else {
             $this->set_error_code(5117);
             return false;
         }
     } else {
         $this->set_error_code(5118);
         return false;
     }
 }
예제 #27
0
 function rm_dir($dir)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('asset_delete_dir', array(&$dir))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         if ($sm->user->is('ASSET_MANAGER') or $sm->user->can('MANAGE_FILES')) {
             $fulldir = VIVVO_FS_ROOT . $dir;
             if (substr($fulldir, -1) != '/') {
                 $fulldir .= '/';
             }
             if (file_exists($fulldir) and is_dir($fulldir) and $files = @scandir($fulldir)) {
                 //quick check if not empty
                 if (count($files) > 3) {
                     $this->set_error_code(2832);
                     return false;
                 }
                 foreach ($files as $f) {
                     //check if any files inthere
                     if ($f != '.' and $f != '..' and $f != '.htstampdir') {
                         $this->set_error_code(2832);
                         return false;
                     }
                 }
                 //remove flagfile, if any
                 @unlink($fulldir . '.htstampdir');
                 // try to delete
                 if (@rmdir($fulldir)) {
                     admin_log($sm->user->get_username(), 'Removed directory ' . $fulldir);
                     $parts = explode('/', $dir);
                     $name = secure_sql(end($parts));
                     array_pop($parts);
                     $path = md5(implode('/', $parts) . '/');
                     $sm->get_db()->exec('DELETE FROM ' . VIVVO_DB_PREFIX . "asset_files WHERE path_md5 = '{$path}' AND name = '{$name}'");
                     return true;
                 } else {
                     $this->set_error_code(2831);
                     return false;
                 }
             } else {
                 $this->set_error_code(2836);
                 return false;
             }
         } else {
             $this->set_error_code(2826);
             return false;
         }
     } else {
         $this->set_error_code(2827);
         return false;
     }
 }
예제 #28
0
 /**
  * Mail form
  *
  * @param	integer	$form_id
  * @param	array	$data
  * @return	boolean	true on succes, or false on fail
  */
 function mail($form_id, $data)
 {
     $sm = vivvo_lite_site::get_instance();
     if (!vivvo_hooks_manager::call('form_builder_mail', array(&$form_id, &$delete))) {
         return vivvo_hooks_manager::get_status();
     }
     require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php';
     $form_list = new FormBuilderForms_list();
     $form = $form_list->get_form_by_id($form_id);
     $data = array_map('urldecode', $data);
     $attachments = array();
     if ($form !== false) {
         $form_element_list = new FormBuilderFields_list($this->_site_manager);
         $form_element_list->get_elements_by_form_id($form->id);
         $message = '';
         foreach ($form_element_list->list as $field) {
             if ($field->required && !key_exists($field->name, $data) && $data[$field->name] !== '' && $field->type != 'file_upload') {
                 $this->set_error_code(10712);
                 return false;
             } else {
                 if ($field->required && $field->type == 'file_upload' && empty($_FILES['PFB_' . $field->name]['name'])) {
                     $this->set_error_code(10712);
                     return false;
                 }
             }
             if (key_exists($field->name, $data)) {
                 if ($field->reg_exp) {
                     if (!preg_match('/^' . $field->reg_exp . '$/', $data[$field->name])) {
                         $this->set_error_code(10713);
                         return false;
                     }
                 }
                 if ($field->type != 'submit') {
                     if ($field->label != '') {
                         $message .= $field->label . ': ' . $data[$field->name] . "\n";
                     } else {
                         $message .= $field->name . ': ' . $data[$field->name] . "\n";
                     }
                 }
             }
             if ($field->type == 'file_upload' && isset($_FILES['PFB_' . $field->name])) {
                 $attachments[] = 'PFB_' . $field->name;
             }
         }
         if ($form->email) {
             $files = array();
             if (count($attachments)) {
                 foreach ($attachments as $attachment) {
                     if ($_FILES[$attachment]['error'] == 0 && $_FILES[$attachment]['size'] > 0 && $_FILES[$attachment]['size'] <= 2 * 1024 * 1024 && in_array(substr($_FILES[$attachment]['name'], strrpos($_FILES[$attachment]['name'], '.') + 1), array_map('trim', explode(',', VIVVO_ALLOWED_EXTENSIONS))) && is_uploaded_file($_FILES[$attachment]['tmp_name'])) {
                         $filename = VIVVO_FS_INSTALL_ROOT . 'cache/' . md5(uniqid(mt_rand(), true)) . basename($_FILES[$attachment]['name']);
                         if (move_uploaded_file($_FILES[$attachment]['tmp_name'], $filename)) {
                             $files[] = array($filename, basename($_FILES[$attachment]['name']));
                         }
                     }
                 }
             }
             $headers['From'] = VIVVO_ADMINISTRATORS_EMAIL;
             $headers['Subject'] = "=?UTF-8?B?" . base64_encode($form->title) . "?=";
             if (!count($files)) {
                 $headers['Content-Type'] = "text/plain; charset=UTF-8;";
             } else {
                 require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/framework/PEAR/Mail/mime.php';
                 $mime = new Mail_mime();
                 $mime->setTXTBody($message);
                 foreach ($files as $file) {
                     $mime->addAttachment($file[0], 'application/octet-stream', $file[1]);
                 }
                 $message = $mime->get();
                 $headers = $mime->headers($headers);
                 foreach ($files as $file) {
                     @unlink($file[0]);
                 }
             }
             if (VIVVO_EMAIL_SMTP_PHP == 1) {
                 $mail_object = new Mail();
                 $mail_object->send($form->email, $headers, $message);
             } else {
                 $mail_options['driver'] = 'smtp';
                 $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                 $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                 $mail_options['localhost'] = 'localhost';
                 if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                     $mail_options['auth'] = true;
                     $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                     $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                 } else {
                     $mail_options['auth'] = false;
                     $mail_options['username'] = '';
                     $mail_options['password'] = '';
                 }
                 $mail_object = Mail::factory('smtp', $mail_options);
                 $mail_object->send($form->email, $headers, $message);
             }
         }
         if ($form->message) {
             return $form->message;
         } else {
             return ' ';
         }
     }
 }
예제 #29
0
 /**
  * Call this inside callback function to stop other registered callbacks from being called after
  * this one. If priority is given than only callbacks of that priority or less will be skipped.
  *
  * @param integer $priority - Priority (optional)
  * @return void
  */
 public static function stop_propagation($priority = 0)
 {
     self::$propagate_limit = $priority ? $priority : self::get_current_priority();
 }